<?php
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*\
<< ******************************************************************** >>
<< * ---------------------------------------------------------------- * >>
<< * Copyright ©2011-2012 Ozzy47                                      * >>
<< * All Rights Reserved. 											  * >>
<< * This file may not be redistributed in whole or significant part. * >>
<< * ---------------------------------------------------------------- * >>
<< * You are not allowed to use this on your server unless the files  * >>
<< * you downloaded were done so with permission.					  * >>
<< * ---------------------------------------------------------------- * >>
<< ******************************************************************** >>
\*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/

// #################### DEFINE IMPORTANT CONSTANTS #######################
$excluded_groups = explode(",", $vbulletin->options['dbtech_vbsuper_pm_days_registered_excluded_groups']);
$joindate = floor((TIMENOW - $vbulletin->userinfo['joindate']) / 86400);
        
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

if (empty($pmdm->errors) AND $vbulletin->options['dbtech_vbsuper_pm_system_enabled'] AND $vbulletin->options['dbtech_vbsuper_pm_throttle_active'])	
{	
do
{
	if (is_member_of($vbulletin->userinfo, $excluded_groups))
	{
		// Usergroups excluded from these restrictions
		break;
	}
	
	if (in_array($vbulletin->userinfo['userid'], explode(',', $vbulletin->options['dbtech_vbsuper_pm_days_registered_excluded_id'])))
	{
		// User ID's excluded from these restrictions
		break;
	}	

	foreach ((array)$pmdm->info['recipients'] AS $staff_member)
	{
		if (!is_member_of($staff_member, explode(',', $vbulletin->options['dbtech_vbsuper_pm_days_registered_staff'])))
		{
			if ($vbulletin->options['dbtech_vbsuper_pm_days_registered_active'] AND $joindate < $vbulletin->options['dbtech_vbsuper_pm_min_days_registered'])
			{
				if ($vbulletin->options['dbtech_vbsuper_pm_registered_error_type'] == 1) //Popup Message
				{
					//Switch vBulletin Message header
					$vbulletin->templatecache['STANDARD_ERROR'] = str_replace(
						'\' . vB_Template_Runtime::parsePhrase("vbulletin_message") . \'',
						'\' . vB_Template_Runtime::parsePhrase("dbtech_vbsuper_pm_blocked_error_occured") . \'',
						$vbulletin->templatecache['STANDARD_ERROR']
					);
					//Error message block
					eval(standard_error(fetch_error('dbtech_vbsuper_pm_days_registered_error_popup', $vbulletin->userinfo['username'], $vbulletin->options['dbtech_vbsuper_pm_min_days_registered'], $joindate)));
				}
				else
				{         		
	 				//Switch error message
	  				$vbphrase['errors'] = $vbphrase['dbtech_vbsuper_pm_registered_title'];
	   				//Switch subheader message
	    			$vbphrase['errors_occured_when_submitted'] = $vbphrase['dbtech_vbsuper_pm_blocked_error_occured'];
	    			$pmdm->error('dbtech_vbsuper_pm_registered_error', $vbulletin->userinfo['username'], $vbulletin->options['dbtech_vbsuper_pm_min_days_registered'], $joindate);
 				}
		 	}	
		}
	}

}
while (false);	
}
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*\
<< ********************************************************************* >>
<< * Created: 09:30, Fri June 8th 2012                                 * >>
<< * VER: 1.0.0                                                        * >>
<< ********************************************************************* >>
\*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
?>