<?php

if ($vbulletin->userinfo['userid'] AND $vbulletin->options['dbtech_vbshop_enablepoints'])
{
	foreach ((array)VBSHOP::$cache['currency'] as $currencyid => $currency)
	{
		// Shorthand
		$var = 'per' . $type;
		
		if (!$currency[$var])
		{
			continue;
		}
		
		// Update the points table
		$vbulletin->db->query_write("
			UPDATE " . TABLE_PREFIX . $currency['pointstable'] . "
			SET " . $currency['pointscolumn'] . " = " . $currency['pointscolumn'] . " + '" . doubleval($currency[$var]) . "'
			WHERE userid = " . $vbulletin->db->sql_prepare($vbulletin->userinfo['userid'])
		);
		
		$info = array(
			'currencyid' 	=> $currencyid,
			'amount' 		=> doubleval($currency[$var]),
		);
		
		switch ($var)
		{
			case 'perthread':
				$info['threadid'] = $threadinfo['threadid'];
				break;
				
			case 'perreply':
				$info['postid'] = $post['postid'];
				break;
		}
		
		// init data manager
		$dm =& VBSHOP::initDataManager('Transactionlog', $vbulletin, ERRTYPE_ARRAY);
			$dm->set('userid', 		$vbulletin->userinfo['userid']);
			$dm->set('recipient', 	$vbulletin->userinfo['userid']);
			$dm->set('ipaddress', 	IPADDRESS);
			$dm->set('action', 		$var);
			$dm->set('info', 		$info);
		$dm->save();
		unset($dm);		
	}
}
?>