<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="kirky_dobrestrict" active="1">
	<title>Birthdate Forum Restrictions</title>
	<description />
	<version>1.0.1</version>
	<url />
	<versioncheckurl />
	<dependencies>
	</dependencies>
	<codes>
		<code version="1.00">
			<installcode><![CDATA[$db->hide_errors();
$db->query_write("ALTER TABLE " . TABLE_PREFIX . "forum ADD bfr_age SMALLINT( 3 ) UNSIGNED NOT NULL DEFAULT '0'");
$db->show_errors();]]></installcode>
			<uninstallcode><![CDATA[$db->hide_errors();
$db->query_write("ALTER TABLE " . TABLE_PREFIX . "forum DROP bfr_age");
$db->show_errors();]]></uninstallcode>
		</code>
	</codes>
	<templates>
	</templates>
	<plugins>
		<plugin active="1" executionorder="5">
			<title>Add Option to Forum Manager</title>
			<hookname>forumadmin_edit_form</hookname>
			<phpcode><![CDATA[print_table_header("Birthdate Forum Restriction");
print_input_row($vbphrase['bfr_minimum_age'], 'forum[bfr_age]', $forum['bfr_age']);]]></phpcode>
		</plugin>
		<plugin active="1" executionorder="5">
			<title>Add to Validfields</title>
			<hookname>forumdata_start</hookname>
			<phpcode><![CDATA[$this->validfields['bfr_age'] = array(TYPE_UINT, REQ_NO);]]></phpcode>
		</plugin>
		<plugin active="1" executionorder="5">
			<title>Init Function and Age Checking</title>
			<hookname>global_setup_complete</hookname>
			<phpcode><![CDATA[function bfrMin($foo, $bar)
{
	$foo = $foo == '' ? '00-00-0000' : $foo;
	$bday = explode('-', $foo);	
	$year = vbdate('Y', TIMENOW, false, false);
	$month = vbdate('n', TIMENOW, false, false);
	$day = vbdate('j', TIMENOW, false, false);
	if ($year > $bday[2] AND $bday[2] != '0000')
	{
		$age = $year - $bday[2];
		if ($month < $bday[0] OR ($month == $bday[0] AND $day < $bday[1]))
		{
			$age--;
		}
	}else{
		return 0;
	}
	return $age >= $bar ? 2 : 1;
}

if (in_array(THIS_SCRIPT, array('newthread', 'newreply')) AND $foruminfo['bfr_age'] > 0)
{
	switch (bfrMin($vbulletin->userinfo['birthday'], $foruminfo['bfr_age'])){
		case 0:
			eval(standard_error(fetch_error('bfr_no_birth_year', $foruminfo['title_clean'])));
			break;
		case 1:
			eval(standard_error(fetch_error('bfr_not_old_enough', $foruminfo['bfr_age'], $foruminfo['title_clean'])));
			break;
		case 2:
			continue;
			break;					
	}
}]]></phpcode>
		</plugin>
	</plugins>
	<phrases>
		<phrasetype name="Error Messages" fieldname="error">
			<phrase name="bfr_no_birth_year" date="1206247395" username="admin" version="1.00"><![CDATA[You must specify a Date of Birth in your Profile to participate in discussions in {1}.]]></phrase>
			<phrase name="bfr_not_old_enough" date="1206247374" username="admin" version="1.00"><![CDATA[Sorry. You may not participate in discussions in {2} until you are {1} years of age.]]></phrase>
		</phrasetype>
		<phrasetype name="Forum-Related" fieldname="forum">
			<phrase name="bfr_minimum_age" date="1206155986" username="admin" version="1.00"><![CDATA[Enter the Minimum Age required for each User to be granted permission to post replies/new threads.
<br /><dfn>(Leave blank for no age restrictions)</dfn>]]></phrase>
		</phrasetype>
	</phrases>
	<options>
	</options>
	<helptopics>
	</helptopics>
	<cronentries>
	</cronentries>
	<faqentries>
	</faqentries>
</product>
