<?php
if (/*$user['userid'] == $vbulletin->userinfo['userid'] AND THIS_SCRIPT != 'ajax' AND */isset($user['dbtech_vbshop_purchase']) AND class_exists('VBSHOP'))
{
	// Verify purchases
	VBSHOP::verify_purchases($user);
	
	$reload = false;
	foreach ($user['dbtech_vbshop_purchase'] as $purchaseid => $purchase)
	{
		if ($purchase['feature'] != 'item' OR $purchase['userid'] != $user['userid'])
		{
			// Skip the feature
			continue;
		}
		
		if (!$purchase['active'])
		{
			// Skip the feature
			continue;
		}
		
		if (!$item = VBSHOP::$cache[$purchase['feature']][$purchase['featureid']])
		{
			// Skip this
			continue;
		}

		if (!$item['active'])
		{
			// Skip this
			continue;
		}
		
		// Init item
		$itemobj = VBSHOP::init_item(array_merge($item, $purchase));
		
		if (method_exists($itemobj, 'cache_permissions'))
		{
			// Override permissions caching
			$itemobj->cache_permissions($user);
			
			// We're reloading permissions
			$reload = true;
		}
	}
	
	if ($reload)
	{
		// Ensure this thing is proper
		VBSHOP::_getPermissions();
	}
}