<?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.					  * >>
<< * ---------------------------------------------------------------- * >>
<< ******************************************************************** >>
\*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

do
{
	if (THIS_SCRIPT != 'private')
	{
		// Do nothing during registration so we don't break the process
		break;
	}
	
	if (is_member_of($vbulletin->userinfo, explode(',', $vbulletin->options['dbtech_vbsuper_pm_min_post_excluded'])))
	{
		// We're excluded from these restrictions
		break;
	}

	if (in_array($vbulletin->userinfo['userid'], explode(',', $vbulletin->options['dbtech_vbsuper_pm_min_post_excluded_ids'])))
	{
		// Second chance for exclusion
		break;
	}

	if (!$vbulletin->options['dbtech_vbsuper_pm_min_post_enabled'] OR $vbulletin->userinfo['posts'] >= $vbulletin->options['dbtech_vbsuper_pm_min_post_qty'])
	{
		// Post restrictions aren't enabled or we have enough posts
		break;
	}

	foreach ($pmdm->info['recipients'] AS $staff_member)
	{
		if (is_member_of($staff_member, explode(',', $vbulletin->options['dbtech_vbsuper_pm_min_post_staff'])))
		{
			// We're a staffer or something
			continue;
		}

		if ($vbulletin->options['dbtech_vbsuper_pm_min_post_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_min_post_error_popup', $vbulletin->userinfo['username'], $vbulletin->options['dbtech_vbsuper_pm_min_post_qty'], $vbulletin->userinfo['posts'])));
		}
		else
		{
			// DM error message

			// Switch error message
			$vbphrase['errors'] = $vbphrase['dbtech_vbsuper_pm_min_posts_error_title'];
			
			// Switch subheader message
			$vbphrase['errors_occured_when_submitted'] = $vbphrase['dbtech_vbsuper_pm_blocked_error_occured'];
			
			// Show error
			$pmdm->error('dbtech_vbsuper_pm_min_post_error', $vbulletin->userinfo['username'], $vbulletin->options['dbtech_vbsuper_pm_min_post_qty'], $vbulletin->userinfo['posts']);
		}
	}

}
while (false);

/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*\
<< ********************************************************************* >>
<< * Created: 09:30, Fri June 8th 2012                                 * >>
<< * VER: 1.0.0                                                        * >>
<< ********************************************************************* >>
\*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
?>