Sign in to follow this  
Followers 0

custom package action.php demo/docs?

13 posts in this topic

Posted

Are there any docs which identify all the data sent to and from the nexus api which can be consumed using the custom actions tool?

this doc provides the basics, but no info on how the data is constructed.

http://community.invisionpower.com/resources/documentation/index.html/_/developer-resources/custom-applications/nexus-r367

any assistance or direction would be helpful.

( my intent is to write an action for onPaid to run some custom php I am trying to convert from an old shop system I had )

Share this post


Link to post
Share on other sites

Posted

Any update? I've sources/actions/dp3_sogc.php file, but DOES not work.. I think it isn't even called..

Could someone give us updated interface for these actions?

Share this post


Link to post
Share on other sites

Posted

The files need to actually be called actions.php or items.php, and they go in the /extensions/nexus/ folder for an existing or new application. I wrote a custom actions.php file for my site which promotes members to a Premium group when they've paid, it looks like this:

<?php


if ( !defined( 'IN_IPB' ) )

{

    print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";

    exit();

}


class actions_downloads

{

    /**

     * Package Purchased

     *

     * @param    array    The member purchasing

     * @param    array    Item data

     * @return    mixed    Will be serialized and saved in nexus_purchases.ps_extra

     */

    public function onPaid( $member, $item )

    {

        /* Purchased a file? */

        if ( $item['type'] == 'file' )

        {

            /* Regular member?  Promote to Premium */

            if ( $member['member_group_id'] == ipsRegistry::$settings['member_group'] )

            {

                $save['member_group_id'] = 7;

            }


            /* Resource Author?  Add Premium as secondary if necessary */

            else if ( $member['member_group_id'] == 8 )

            {

                $current_secondary = $member['mgroup_others'] ? explode( ',', $member['mgroup_others'] ) : array();


                if ( !in_array( 7, $current_secondary ) )

                {

                    $current_secondary[] = 7;

                    $save['mgroup_others'] = implode( ',', $current_secondary );

                }

            }


            /* Save and return */

            if ( !empty( $save ) )

            {

                ipsRegistry::DB()->update( 'members', $save, "member_id={$member['member_id']}" );

            }

        }

    }


    /**

     * Package Renewed, but was still active anyway

     *

     * @param    array    The member renewing

     * @param    array    The row from nexus_purchases

     * @return    void

     */

    public function onRenew( $member, $purchase ) { }


    /**

     * Package Reactivated (for example, renewing after had expired)

     *

     * @param    array    The member renewing

     * @param    array    The row from nexus_purchases

     * @return    void

     */

    public function onReactivate( $member, $purchase ) { }


    /**

     * Package Expired

     *

     * @param    array    The row from nexus_purchases

     * @return    void

     */

    public function onExpire( $purchase ) { }


    /**

     * Package Cancelled or Deleted

     *

     * @param    array    The row from nexus_purchases

     * @return    void

     */

    public function onCancel( $purchase ) { }

}
DawPi likes this

Share this post


Link to post
Share on other sites

Posted

Hello,
oh, so it must be as file for the application. Thanks a lot! Will check it.

Share this post


Link to post
Share on other sites

Posted

One more question: how to change it these methods are called? I'm using print with die function but doesn't work..

File: adminapplications_addonothersecgroupchangeextensionsnexusactions.php


I know there is additional IPSMember:load method, but don't mind with that for now.


<?php


if ( ! defined( 'IN_IPB' ) )

{

	    print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";

	    exit();

}


class actions_secgroupchange

{

    /**

	 * Package Purchased

	 *

	 * @param    array    The member purchasing

	 * @param    array    Item data

	 * @return    mixed    Will be serialized and saved in nexus_purchases.ps_extra

	 */

    public function onPaid( $member, $item )

    {

        /* Load library */


        require_once( IPSLib::getAppDir( 'secgroupchange' ) . '/sources/library.php' );

        $lib               =  new secgroupchangeLib( ipsRegistry::instance() );


        /* Load new secondary groups */


        $member         = IPSMember::load( $member['member_id'], 'core', 'id' );


        $newSecGroups     = IPSText::cleanPermString( $member['mgroup_others'] );


        /* Load old secondary groups */


        $oldSecGroups     = IPSText::cleanPermString( $item['p_secondary_group'] );


        /* Check if secondary groups were changed */


        if( $oldSecGroups != $newSecGroups )

        {

            /* Send message */


            $lib->sendMsg( $member['member_id'], $oldSecGroups, $newSecGroups, TRUE );

        }        

    }

}

Share this post


Link to post
Share on other sites

Posted

Any help? I'm stuck with this. :|

Share this post


Link to post
Share on other sites

Posted

That code looks fine to me. onPaid is called when a product is purchased and the transaction is actually approved - use the "Check" method and then mark the transaction paid in the ACP - that is when onPaid will be called. Putting die("Hello, World!"); in there should indicate if it's being executed correctly.

Share this post


Link to post
Share on other sites

Posted

Gosh.. Any of them weren't run.. :|

Code for tests:


Situation: package 'Widgets'. Cost: 1.

Video:
2012-01-25 20-41-55.zip

Am I doing something wrong?

<?php


if ( ! defined( 'IN_IPB' ) )

{

		print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";

		exit();

}


class actions_secgroupchange

{

	/**

	 * Package Purchased

	 *

	 * @param	array	The member purchasing

	 * @param	array	Item data

	 * @return	mixed	Will be serialized and saved in nexus_purchases.ps_extra

	 */

	public function onPaid( $member, $item )

	{

		die("Hello, World! - 1");				

	}


	/**

	 * Package Expired

	 *

	 * @param	array	The row from nexus_purchases

	 * @return	void

	 */

	public function onExpire( $purchase )

	{

		die("Hello, World! - 2");		

	}


	/**

	 * Package Cancelled or Deleted

	 *

	 * @param	array	The row from nexus_purchases

	 * @return	void

	 */

	public function onCancel( $purchase )

	{

		die("Hello, World! - 3");

	}


	/**

	 * Package Renewed, but was still active anyway

	 *

	 * @param	array	The member renewing

	 * @param	array	The row from nexus_purchases

	 * @return	void

	 */

	public function onRenew( $member, $purchase ) { }


	/**

	 * Package Reactivated (for example, renewing after had expired)

	 *

	 * @param	array	The member renewing

	 * @param	array	The row from nexus_purchases

	 * @return	void

	 */

	public function onReactivate( $member, $purchase ) { }	  

}//End of class

Share this post


Link to post
Share on other sites

Posted

What's the path to that file?

Share this post


Link to post
Share on other sites

Posted

As above: : adminapplications_addonothersecgroupchangeextensionsnexusactions.php

Share this post


Link to post
Share on other sites

Posted

Any advice, Mark?

Share this post


Link to post
Share on other sites

Posted

Honestly, I have no idea. That looks fine to me.

If you shoot me a PM with details to access the installation I'll be happy to take a look on Monday.

Share this post


Link to post
Share on other sites

Posted

Great.. :) Will do.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Who's Browsing   0 members

    No registered users viewing this page.