Jump to content


Photo

custom package action.php demo/docs?


  • Please log in to reply
12 replies to this topic

#1 KiltsRock.com

KiltsRock.com

    IPB Full Member

  • +Clients
  • 125 posts

Posted 12 February 2011 - 11:10 AM

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.inv...ions/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 )
KT
Founder
The Brotherhood of the Kilt
http://www.kiltsrock.com

#2 DawPi

DawPi

    Needs Hobby

  • +Clients
  • 4,779 posts

Posted 22 January 2012 - 09:24 AM

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?

Dawid Pieron
intermedia - owner, developer and ip.board modder
buy ips community suite | mail | developer's profile
Do you need convert custom script to IP.Board or his applications? I'm Conversion Specialist.

 

GREAT discount for all my most popular mods. Check them!


#3 Michael

Michael

    Meet Jay

  • +Clients
  • 19,587 posts

Posted 22 January 2012 - 09:58 AM

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

Contact Me: Email · Facebook · Twitter · Google+


#4 DawPi

DawPi

    Needs Hobby

  • +Clients
  • 4,779 posts

Posted 22 January 2012 - 10:22 AM

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

Dawid Pieron
intermedia - owner, developer and ip.board modder
buy ips community suite | mail | developer's profile
Do you need convert custom script to IP.Board or his applications? I'm Conversion Specialist.

 

GREAT discount for all my most popular mods. Check them!


#5 DawPi

DawPi

    Needs Hobby

  • +Clients
  • 4,779 posts

Posted 22 January 2012 - 10:35 AM

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

File: admin\applications_addon\other\secgroupchange\extensions\nexus\actions.php
<?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 );
        }        
    }
}

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

Dawid Pieron
intermedia - owner, developer and ip.board modder
buy ips community suite | mail | developer's profile
Do you need convert custom script to IP.Board or his applications? I'm Conversion Specialist.

 

GREAT discount for all my most popular mods. Check them!


#6 DawPi

DawPi

    Needs Hobby

  • +Clients
  • 4,779 posts

Posted 24 January 2012 - 07:55 AM

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

Dawid Pieron
intermedia - owner, developer and ip.board modder
buy ips community suite | mail | developer's profile
Do you need convert custom script to IP.Board or his applications? I'm Conversion Specialist.

 

GREAT discount for all my most popular mods. Check them!


#7 Mark

Mark

    I dropped the "iggy"

  • IPS Staff
  • 8,384 posts

Posted 24 January 2012 - 09:25 AM

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.

Mark Wade
Developer

zce-php5-3-logo.gif php5-zce-logo-new.gif


#8 DawPi

DawPi

    Needs Hobby

  • +Clients
  • 4,779 posts

Posted 25 January 2012 - 02:42 PM

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

Code for tests:
<?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

Situation: package 'Widgets'. Cost: 1.

Video:
Attached File  2012-01-25 20-41-55.zip   869.8KB   2 downloads

Am I doing something wrong?

Dawid Pieron
intermedia - owner, developer and ip.board modder
buy ips community suite | mail | developer's profile
Do you need convert custom script to IP.Board or his applications? I'm Conversion Specialist.

 

GREAT discount for all my most popular mods. Check them!


#9 Mark

Mark

    I dropped the "iggy"

  • IPS Staff
  • 8,384 posts

Posted 26 January 2012 - 06:19 AM

What's the path to that file?

Mark Wade
Developer

zce-php5-3-logo.gif php5-zce-logo-new.gif


#10 DawPi

DawPi

    Needs Hobby

  • +Clients
  • 4,779 posts

Posted 26 January 2012 - 07:00 AM

As above: : admin\applications_addon\other\secgroupchange\extensions\nexus\actions.php

Dawid Pieron
intermedia - owner, developer and ip.board modder
buy ips community suite | mail | developer's profile
Do you need convert custom script to IP.Board or his applications? I'm Conversion Specialist.

 

GREAT discount for all my most popular mods. Check them!


#11 DawPi

DawPi

    Needs Hobby

  • +Clients
  • 4,779 posts

Posted 27 January 2012 - 06:20 AM

Any advice, Mark?

Dawid Pieron
intermedia - owner, developer and ip.board modder
buy ips community suite | mail | developer's profile
Do you need convert custom script to IP.Board or his applications? I'm Conversion Specialist.

 

GREAT discount for all my most popular mods. Check them!


#12 Mark

Mark

    I dropped the "iggy"

  • IPS Staff
  • 8,384 posts

Posted 27 January 2012 - 08:42 AM

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.

Mark Wade
Developer

zce-php5-3-logo.gif php5-zce-logo-new.gif


#13 DawPi

DawPi

    Needs Hobby

  • +Clients
  • 4,779 posts

Posted 27 January 2012 - 11:00 AM

Great.. :) Will do.

Dawid Pieron
intermedia - owner, developer and ip.board modder
buy ips community suite | mail | developer's profile
Do you need convert custom script to IP.Board or his applications? I'm Conversion Specialist.

 

GREAT discount for all my most popular mods. Check them!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users