Advertisement
zefie

How to manually manipulate ibEconomy, and properly log tx

Jan 24th, 2013
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.24 KB | None | 0 0
  1. <?php
  2. // How to manually manipulate ibEconomy, and properly log a transaction while doing so
  3. // (C) Zefie Networks - Unlicensed - You are free to do as you wish with this code.
  4.  
  5. class custom_actions_premiumsub {
  6.         protected $registry;
  7.         protected $DB;
  8.         protected $settings;
  9.         protected $request;
  10.         protected $lang;
  11.         protected $member;
  12.         protected $memberData;
  13.         protected $cache;
  14.         protected $caches;
  15.  
  16.         function __construct(){
  17.                 $this->registry = ipsRegistry::instance();
  18.                 $this->DB           =  $this->registry->DB();
  19.                 $this->settings     =& $this->registry->fetchSettings();
  20.                 $this->request      =& $this->registry->fetchRequest();
  21.                 $this->lang         =  $this->registry->getClass('class_localization');
  22.                 $this->member       =  $this->registry->member();
  23.                 $this->memberData       =& $this->registry->member()->fetchMemberData();
  24.                 $this->cache        =  $this->registry->cache();
  25.                 $this->caches       =& $this->registry->cache()->fetchCaches();
  26.                 if( !isset($this->registry->mysql_ibEconomy) )
  27.                 {
  28.                         require_once( IPSLib::getAppDir( 'ibEconomy' ) . '/sql/mysql_ibEconomy.php' );
  29.                         $this->registry->mysql_ibEconomy = new ibEconomyMySQL( $this->registry );
  30.                 }
  31.                 if( !isset($this->registry->ecoclass) )
  32.                 {
  33.                         require_once( IPSLib::getAppDir( 'ibEconomy' ) . '/sources/ecoclass.php' );
  34.                         $this->registry->ecoclass = new class_ibEconomy( $this->registry );
  35.                 }
  36.         }
  37.  
  38.         public function onPaid ($member, $package, $invoice) {
  39.                 $points2Add = 50;
  40.                 # Add points
  41.                $this->registry->mysql_ibEconomy->updateMemberPts( $member['member_id'], $points2Add, '+', TRUE );
  42.                 # Log in transaction logs
  43.         // 'subreward' is read from ibEconomy/public_ibEconomy lang pack
  44.                 $this->registry->ecoclass->addLog( 'subreward', $points2Add, $member['member_id'], 'subscription', 'Premium Subscription Reward' );
  45.         }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement