<?php
$currencydata = array(
	'fields' => array(),
	'tables' => array(),
	'lookup' => array()
);

$currencies = (array)(class_exists('VBSHOP') ? VBSHOP::$cache['currency'] : $vbulletin->dbtech_vbshop_currency);
foreach ($currencies as $currencyid => $currency)
{
	if (!$currency['active'])
	{
		// Inactive currency
		continue;
	}
	
	if ($currency['pointstable'] == 'user')
	{
		// Should already be included
		continue;
	}
			
	// Setup the fields and tables
	$currencydata['fields'][] = 'vbshop_pointstable_' . $currencyid . '.' . $currency['pointscolumn'];
	$currencydata['tables'][] = 'LEFT JOIN ' . TABLE_PREFIX . $currency['pointstable'] . ' AS vbshop_pointstable_' . $currencyid . ' ON(vbshop_pointstable_' . $currencyid . '.userid = user.userid)';
}

if (count($currencydata['fields']))
{
	$hook_query_fields .= ' , ' . implode(' , ', $currencydata['fields']);
	$hook_query_joins .= ' ' . implode(' ', $currencydata['tables']);
}
?>