<?php
$vbulletin->options['dbtech_vbshop_override_cancustomavatar_exempt'] = @unserialize($vbulletin->options['dbtech_vbshop_override_cancustomavatar_exempt']);
if (
	($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canuseavatar']) AND 
	$vbulletin->options['dbtech_vbshop_override_cancustomavatar'] AND 
	!is_member_of($vbulletin->userinfo, (array)$vbulletin->options['dbtech_vbshop_override_cancustomavatar_exempt'])
)
{
	// Verify purchases
	VBSHOP::verify_purchases($vbulletin->userinfo);
	
	$override = true;
	foreach ($vbulletin->userinfo['dbtech_vbshop_purchase'] as $purchaseid => $purchase)
	{
		if ($purchase['feature'] != 'item' OR $purchase['userid'] != $vbulletin->userinfo['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;
		}

		if ($item['itemtypeid'] != 'avatarchange')
		{
			// Skip this
			continue;
		}

		// We're not overriding permissions
		$override = false;
		break;
	}

	if ($override)
	{
		// Fake no permissions
		$permissions['genericpermissions'] -= $vbulletin->bf_ugp_genericpermissions['canuseavatar'];
	}
}
?>