<?php
// How to manually manipulate ibEconomy, and properly log a transaction while doing so
// (C) Zefie Networks - Unlicensed - You are free to do as you wish with this code.
class custom_actions_premiumsub {
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
function __construct(){
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
if( !isset($this->registry->mysql_ibEconomy) )
{
require_once( IPSLib::getAppDir( 'ibEconomy' ) . '/sql/mysql_ibEconomy.php' );
$this->registry->mysql_ibEconomy = new ibEconomyMySQL( $this->registry );
}
if( !isset($this->registry->ecoclass) )
{
require_once( IPSLib::getAppDir( 'ibEconomy' ) . '/sources/ecoclass.php' );
$this->registry->ecoclass = new class_ibEconomy( $this->registry );
}
}
public function onPaid ($member, $package, $invoice) {
$points2Add = 50;
# Add points
$this->registry->mysql_ibEconomy->updateMemberPts( $member['member_id'], $points2Add, '+', TRUE );
# Log in transaction logs
// 'subreward' is read from ibEconomy/public_ibEconomy lang pack
$this->registry->ecoclass->addLog( 'subreward', $points2Add, $member['member_id'], 'subscription', 'Premium Subscription Reward' );
}
}
Comments