Code:
<?xml version="1.0" encoding="UTF-8"?>
<plugin name="VIP Custom Actions" version_long="10000" version_human="1.0.0" author="Argyros" website="" update_check=""><hooks><hook type="C" class="\IPS\nexus\Package" filename="5b3c925ad8b583cc3f6c0777e6c6c753"><![CDATA[//<?php
class hook14 extends _HOOK_CLASS_
{
public function onPurchaseGenerated( \IPS\nexus\Purchase $purchase, \IPS\nexus\Invoice $invoice)
{
try
{
if ( in_array( $this->id, array( 1 ) ) )
{
$memberid = $purchase->member->member_id;
$sql = "SELECT field_2 FROM core_pfields_content WHERE member_id=$memberid";
$sql2 = "SELECT name FROM core_members WHERE member_id=$memberid";
$ingame = \IPS\Db::i()->query($sql);
$member = \IPS\Db::i()->query($sql2);
while ($row = $ingame ->fetch_assoc()) {
while ($row2 = $member ->fetch_assoc()) {
}
\IPS\Db::i()->insert( 'vips', array(
'username' => $row["field_2"],
'member' => $memberid,
'name' => $row2["name"],
'level' => "1"
) );
}
}
}
}
}
return parent::onPurchaseGenerated( $purchase, $invoice );
}
catch ( \RuntimeException $e )
{
if ( method_exists( get_parent_class(), __FUNCTION__ ) )
{
return call_user_func_array( 'parent::' . __FUNCTION__, func_get_args() );
}
else
{
throw $e;
}
}
}
public function onExpire( \IPS\nexus\Purchase $purchase )
{
try
{
if ( in_array( $this->id, array( 1 ) ) )
{
$memberid = $purchase->member->member_id;
$sql = "UPDATE vips SET level = 0 WHERE member=$memberid";
\IPS\Db::i()->query($sql);
}
}
catch ( \RuntimeException $e )
{
if ( method_exists( get_parent_class(), __FUNCTION__ ) )
{
return call_user_func_array( 'parent::' . __FUNCTION__, func_get_args() );
}
else
{
throw $e;
}
}
}
public function onCancel( \IPS\nexus\Purchase $purchase )
{
try
{
if ( in_array( $this->id, array( 1 ) ) )
{
$memberid = $purchase->member->member_id;
$sql = "UPDATE vips SET level = 0 WHERE member=$memberid";
\IPS\Db::i()->query($sql);
}
}
catch ( \RuntimeException $e )
{
if ( method_exists( get_parent_class(), __FUNCTION__ ) )
{
return call_user_func_array( 'parent::' . __FUNCTION__, func_get_args() );
}
else
{
throw $e;
}
}
}
public function onRenew( \IPS\nexus\Purchase $purchase, $cycles )
{
try
{
if ( in_array( $this->id, array( 1 ) ) )
{
$memberid = $purchase->member->member_id;
$sql = "UPDATE vips SET level = 1 WHERE member=$memberid";
\IPS\Db::i()->query($sql);
}
}
catch ( \RuntimeException $e )
{
if ( method_exists( get_parent_class(), __FUNCTION__ ) )
{
return call_user_func_array( 'parent::' . __FUNCTION__, func_get_args() );
}
else
{
throw $e;
}
}
}
/**
* On Purchase Reactivated (renewed after being expired or reactivated after being canceled)
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return void
*/
public function onReactivate( \IPS\nexus\Purchase $purchase )
{
try
{
if ( in_array( $this->id, array( 1 ) ) )
{
$memberid = $purchase->member->member_id;
$sql = "UPDATE vips SET level = 1 WHERE member=$memberid";
\IPS\Db::i()->query($sql);
}
}
catch ( \RuntimeException $e )
{
if ( method_exists( get_parent_class(), __FUNCTION__ ) )
{
return call_user_func_array( 'parent::' . __FUNCTION__, func_get_args() );
}
else
{
throw $e;
}
}
}
}]]></hook></hooks><tasks/><widgets/><htmlFiles/><cssFiles/><jsFiles/><resourcesFiles/><lang/><versions><version long="10000" human="1.0.0"><![CDATA[//<?php
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Install Code
*/
class ips_plugins_setup_install
{
/**
* ...
*
* @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
*/
public function step1()
{
return TRUE;
}
// You can create as many additional methods (step2, step3, etc.) as is necessary.
// Each step will be executed in a new HTTP request
}]]></version><version long="10001" human="1.0.1"><![CDATA[//<?php
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* 1.0.1 Upgrade Code
*/
class ips_plugins_setup_upg_10001
{
/**
* ...
*
* @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
*/
public function step1()
{
return TRUE;
}
// You can create as many additional methods (step2, step3, etc.) as is necessary.
// Each step will be executed in a new HTTP request
}]]></version></versions></plugin>