<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="./contrib/xsl/modx.prosilver.en.xsl"?>
<!-- 
	NOTICE: Please open this file in your web browser. If presented with a security warning, you may safely tell it to allow the blocked content.
-->
<!--For security purposes, please check: http://www.phpbb.com/mods/ for the latest version of this MOD. Although MODs are checked before being allowed in the MODs Database there is no guarantee that there are no security problems within the MOD. No support will be given for MODs not found within the MODs Database which can be found at http://www.phpbb.com/mods/-->
<mod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.phpbb.com/mods/xml/modx-1.2.1.xsd">
	<header>
		<license>http://opensource.org/licenses/gpl-license.php GNU General Public License v2</license>
		<title lang="en">Prime Birthdate</title>
		<description lang="en">Provides the ability to make the birth date a required field. A birth date form field will be added to the registration pages, and if the forum is set to use COPPA then the entered birth date will be used to determine the user's age (instead using of the current link-selection method). Additionally, you will have the option to set a minimum age requirement for registration, and users will have the option to choose whether or not they want their age publicly viewable.</description>
		<author-notes lang="en">The setting to make the birth date required can be found in the "Board Features" section of the "Administration Control Panel". The minimum and maximum age settings can be found in the "User registration settings" section.

The SQL statements that you will be instructed to execute later will initialize the "Display Age" and "Display Congrats" settings to "No". For a different default, change the zero (0) to a one (1) BEFORE you execute the SQL statement. If you want to change the default AFTER you have already executed the SQL statement, then execute the SQL statement again but change the "ADD COLUMN" to "MODIFY". This will not affect current users. To change the setting for everyone, use this SQL:

	UPDATE phpbb_users SET user_show_age=0, user_congrats=0;

Support is given for both prosilver and subsilver2 templates. If you are using other templates then you will need to modify the template instructions to fit your templates.

Creating, maintaining, and updating MODs requires a lot of time and effort, so if you like this MOD and have the desire to express your thanks through a donation, that would be greatly appreciated. My Paypal ID is primehalo@gmail.com, or contact me for my mailing address. The suggested donation amount for this MOD is $5.00 (but any amount will help).</author-notes>
		<author-group>
			<author>
				<realname>Ken F. Innes IV</realname>
				<email>primehalo@gmail.com</email>
				<username>primehalo</username>
				<homepage><![CDATA[http://www.absoluteanime.com/admin/mods.htm#birthdate]]></homepage>
			</author>
		</author-group>
		<mod-version>1.2.2</mod-version>
		<installation>
			<level>easy</level>
			<time>600</time>
			<target-version>3.0.2</target-version>
		</installation>
		<history>
			<entry>
				<date>2007-09-20</date>
				<rev-version>1.0.0</rev-version>
				<changelog lang="en">
					<change>Removed an unnecessary SQL query.</change>
					<change>Merged the two included files into one file.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-09-21</date>
				<rev-version>1.0.1</rev-version>
				<changelog lang="en">
					<change>Fixed: On the registration page, an asterisk indicating that the birthday was a required field would always show up, even if the birthday wasn't required.</change>
					<change>Fixed: On the UCP Profile page, an asterisk indicating that the birthday was a required field would never show up, even if the birthday was required.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-10-01</date>
				<rev-version>1.0.1a</rev-version>
				<changelog lang="en">
					<change>Repackaged to comply with MOD Team Leader wGEric's specifications for proper packaging.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-10-22</date>
				<rev-version>1.0.2</rev-version>
				<changelog lang="en">
					<change>Updated for compatibility with phpBB3.0.RC7.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-10-25</date>
				<rev-version>1.0.3</rev-version>
				<changelog lang="en">
					<change>Fixed an include statement that was pointing to a file in the wrong directory.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-10-26</date>
				<rev-version>1.0.3a</rev-version>
				<changelog lang="en">
					<change>Added a check for IN_PHPBB to the language file, as per RC7.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-12-08</date>
				<rev-version>1.0.4</rev-version>
				<changelog lang="en">
					<change>Updated for phpBB3 RC8.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-12-11</date>
				<rev-version>1.0.5</rev-version>
				<changelog lang="en">
					<change>Replaced some hard-coded in-line comparisons with function calls to help compatibility with another MOD.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-12-17</date>
				<rev-version>1.0.6</rev-version>
				<changelog lang="en">
					<change>Fixed an issue where someone who had never before entered a birthdate would be unable to do so if the option was set to be required.</change>
					<change>Fixed a minor styling issue with the subsilver2 template style.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-12-27</date>
				<rev-version>1.0.7</rev-version>
				<changelog lang="en">
					<change>Changed magic numbers into defines.</change>
					<change>Changed the 'user_show_age' database column from a tinyint(1) to a tinyint(4).</change>
					<change>Modified the database update file to handle all supported databases instead of just mySQL.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-12-27</date>
				<rev-version>1.0.7a</rev-version>
				<changelog lang="en">
					<change>Fixed typo in the optional "db_install.php" file.</change>
					<change>Removed the keyword "UNSIGNED" from the manually executable SQL statement since phpBB3 doesn't seem to use UNSIGNED tinyint types that aren't 1-bit booleans.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-01-02</date>
				<rev-version>1.0.7b</rev-version>
				<changelog lang="en">
					<change>Removed an entire duplicate folder of this MOD that somehow got included into the ZIP package.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-01-04</date>
				<rev-version>1.0.7c</rev-version>
				<changelog lang="en">
					<change>Fixed a minor mistake in the subsilver2 installation instructions.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-01-28</date>
				<rev-version>1.0.8</rev-version>
				<changelog lang="en">
					<change>Minor code changes/additions to satisfy requirements for entry into the www.phpbb.com MOD database.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-02-18</date>
				<rev-version>1.0.8a</rev-version>
				<changelog lang="en">
					<change>Added a Turkish translation.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-02-20</date>
				<rev-version>1.0.9</rev-version>
				<changelog lang="en">
					<change>Added a Hebrew translation.</change>
					<change>In the Administration Control Panel, display a user's age next to their birthdate.</change>
					<change>Fixed: The function which returns a users age would incorrectly return the current year if a user did not have the year of their birthdate set.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-04-07</date>
				<rev-version>1.0.9a</rev-version>
				<changelog lang="en">
					<change>Updated the instructions for phpBB 3.0.1.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-04-18</date>
				<rev-version>1.0.9b</rev-version>
				<changelog lang="en">
					<change>Added a Spanish translation.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-04-18</date>
				<rev-version>1.0.9c</rev-version>
				<changelog lang="en">
					<change>Repackaged for MODX 1.2.0.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-07-20</date>
				<rev-version>1.0.10</rev-version>
				<changelog lang="en">
					<change>Changed the &amp; to &amp;amp; in the language files.</change>
					<change>Repackaged to fix the Firefox 3 restricted parent directory issue.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-07-25</date>
				<rev-version>1.2.0</rev-version>
				<changelog lang="en">
					<change>When inputting an improper date, you will no longer be presented with two different error messages telling you so.</change>
					<change>Moved most of the code inside of a class structure within a separate file. This should make updating easier in the future.</change>
					<change>Added a maximum age setting.</change>
					<change>Split the user_show_age database column into two columns, user_show_age and user_congrats.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-08-03</date>
				<rev-version>1.2.1</rev-version>
				<changelog lang="en">
					<change>Fixed a minor bug dealing with date validation that could occur on certain setups.</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-09-16</date>
				<rev-version>1.2.2</rev-version>
				<changelog lang="en">
					<change>Fixed some checks so they won't produce warning messages (if warnings messages are enabled).</change>
					<change>Fixed the SQL mentioned in the Author Notes section.</change>
				</changelog>
			</entry>
		</history>
		<link-group>
			<link type="template" href="contrib/template - subsilver2.xml" lang="en">subsilver2</link>
			<link type="language" href="contrib/language - es.xml" lang="en">Spanish</link>
			<link type="language" href="contrib/language - fr.xml" lang="en">French</link>
			<link type="language" href="contrib/language - he.xml" lang="en">Hebrew</link>
			<link type="language" href="contrib/language - tr.xml" lang="en">Turkish</link>
		</link-group>
	</header>
	<action-group>
		<sql><![CDATA[ALTER TABLE phpbb_users ADD COLUMN user_show_age tinyint(1) DEFAULT 0 NOT NULL;
ALTER TABLE phpbb_users ADD COLUMN user_congrats tinyint(1) DEFAULT 0 NOT NULL;]]></sql>
		<copy>
			<file from="root/adm/style/prime_birthdate.html" to="adm/style/prime_birthdate.html" />
			<file from="root/includes/prime_birthdate.php" to="includes/prime_birthdate.php" />
			<file from="root/language/en/mods/prime_birthdate.php" to="language/en/mods/prime_birthdate.php" />
			<file from="root/styles/prosilver/template/prime_birthdate.html" to="styles/prosilver/template/prime_birthdate.html" />
		</copy>

		<open src="adm/style/acp_users_profile.html">
			<edit>
				<find><![CDATA[	<dl> 
		<dt><label for="birthday">{L_BIRTHDAY}:</label><br /><span>{L_BIRTHDAY_EXPLAIN}</span></dt>
		<dd>{L_DAY}: <select id="birthday" name="bday_day">{S_BIRTHDAY_DAY_OPTIONS}</select> {L_MONTH}: <select name="bday_month">{S_BIRTHDAY_MONTH_OPTIONS}</select> {L_YEAR}: <select name="bday_year">{S_BIRTHDAY_YEAR_OPTIONS}</select></dd>
	</dl>]]></find>
				<action type="replace-with"><![CDATA[	<!-- IF PRIME_BIRTHDATE -->
		<!-- INCLUDE prime_birthdate.html -->
	<!-- ELSE -->
	<dl> 
		<dt><label for="birthday">{L_BIRTHDAY}:</label><br /><span>{L_BIRTHDAY_EXPLAIN}</span></dt>
		<dd>{L_DAY}: <select id="birthday" name="bday_day">{S_BIRTHDAY_DAY_OPTIONS}</select> {L_MONTH}: <select name="bday_month">{S_BIRTHDAY_MONTH_OPTIONS}</select> {L_YEAR}: <select name="bday_year">{S_BIRTHDAY_YEAR_OPTIONS}</select></dd>
	</dl>
	<!-- ENDIF -->]]></action>
			</edit>
		</open>

		<open src="includes/acp/acp_board.php">
			<edit>
				<find><![CDATA[		if (isset($display_vars['lang']))]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
		include($phpbb_root_path . 'includes/prime_birthdate.' . $phpEx);
		$prime_birthdate->display_acp_options($display_vars, $mode);
//-- end: Prime Birthdate ---------------------------------------------------//
]]></action>
			</edit>
		</open>

		<open src="includes/acp/acp_users.php">
			<edit>
				<find><![CDATA[				$data['user_birthday']	= sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
				include($phpbb_root_path . 'includes/prime_birthdate.' . $phpEx);
				$prime_birthdate->acp_users_get_vars($data, $user_row);
//-- end: Prime Birthdate ---------------------------------------------------//]]></action>
			</edit>

			<edit>
				<find><![CDATA[							'user_birthday'	=> $data['user_birthday'],
						);]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
						$prime_birthdate->acp_users_inject_sql($sql_ary, $data);
//-- end: Prime Birthdate ---------------------------------------------------//]]></action>
			</edit>

			<edit>
				<find>				unset($now);</find>
				<action type="after-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
				$prime_birthdate->acp_users_format_fields($data, $s_birthday_day_options, $s_birthday_month_options, $s_birthday_year_options);
//-- end: Prime Birthdate ---------------------------------------------------//]]></action>
			</edit>
		</open>

		<open src="includes/ucp/ucp_profile.php">
			<edit>
				<find><![CDATA[				add_form_key('ucp_profile_info');]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
				include($phpbb_root_path . 'includes/prime_birthdate.' . $phpEx);
				$prime_birthdate->ucp_profile_get_vars($data);
//-- end: Prime Birthdate ---------------------------------------------------//]]></action>
			</edit>

			<edit>
				<find><![CDATA[					$error = validate_data($data, $validate_array);]]></find>
				<action type="after-add"><![CDATA[
//-- mod: Prime Birthdate ---------------------------------------------------//
					$prime_birthdate->ucp_profile_error_checking($data, $error);
//-- end: Prime Birthdate ---------------------------------------------------//
]]></action>
			</edit>

			<edit>
				<find><![CDATA[							$sql_ary['user_birthday'] = $data['user_birthday'];]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
							$prime_birthdate->ucp_profile_insert_sql($sql_ary, $data);
//-- end: Prime Birthdate ---------------------------------------------------//]]></action>
			</edit>

			<edit>
				<find><![CDATA[					unset($now);]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
					$prime_birthdate->ucp_profile_format_fields($data, $s_birthday_day_options, $s_birthday_month_options, $s_birthday_year_options, $error);
//-- end: Prime Birthdate ---------------------------------------------------//]]></action>
			</edit>
		</open>


		<open src="includes/ucp/ucp_register.php">
			<edit>
				<find><![CDATA[		$user_lang		= request_var('lang', $user->lang_name);]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
		include($phpbb_root_path . 'includes/prime_birthdate.' . $phpEx);
		$birthdate = $prime_birthdate->ucp_register_init($coppa, $agreed, $change_lang);
//-- end: Prime Birthdate ---------------------------------------------------//]]></action>
			</edit>

			<edit>
				<find>			$add_coppa =</find>
				<action type="after-add">//-- mod: Prime Birthdate ---------------------------------------------------//
			$add_coppa = '';
//-- end: Prime Birthdate ---------------------------------------------------//</action>
			</edit>

			<edit>
				<find>			// DNSBL check</find>
				<action type="before-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
			$prime_birthdate->ucp_register_error_checking($error, $coppa, $birthdate);
//-- end: Prime Birthdate ---------------------------------------------------//
]]></action>
			</edit>

			<edit>
				<find>				// Register user...</find>
				<action type="before-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
				$prime_birthdate->ucp_register_update_user_row($user_row, $birthdate);
//-- end: Prime Birthdate ---------------------------------------------------//
]]></action>
			</edit>
		</open>

		<open src="includes/session.php">
			<edit>
				<find><![CDATA[				redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&amp;mode=reg_details'));
			}
		}]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
		include($phpbb_root_path . 'includes/prime_birthdate.' . $phpEx);
		$prime_birthdate->enforce_birthdate($this);
//-- end: Prime Birthdate ---------------------------------------------------//]]></action>
			</edit>
		</open>

		<open src="index.php">
			<edit>
				<find><![CDATA[			AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
	include($phpbb_root_path . 'includes/prime_birthdate.' . $phpEx);
	$prime_birthdate->index_inject_sql($sql);
//-- end: Prime Birthdate ---------------------------------------------------//]]></action>
			</edit>

			<edit>
				<find><![CDATA[		$birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
		$prime_birthdate->index_alter_birthday_list($row);
//-- end: Prime Birthdate ---------------------------------------------------//]]></action>
			</edit>
		</open>

		<open src="memberlist.php">
			<edit>
				<find>			$age = (int) ($now['year'] - $bday_year - $diff);</find>
				<action type="after-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
			include($phpbb_root_path . 'includes/prime_birthdate.' . $phpEx);
			$prime_birthdate->memberlist_show_age($data, $age);
//-- end: Prime Birthdate ---------------------------------------------------//]]></action>
			</edit>
		</open>

		<open src="viewtopic.php">
			<edit>
				<find>					$user_cache[$poster_id]['age'] = (int) ($now['year'] - $bday_year - $diff);</find>
				<action type="after-add"><![CDATA[//-- mod: Prime Birthdate ---------------------------------------------------//
					include($phpbb_root_path . 'includes/prime_birthdate.' . $phpEx);
					$prime_birthdate->alter_user_cache($user_cache, $row);
//-- end: Prime Birthdate ---------------------------------------------------//]]></action>
			</edit>
		</open>

		<open src="styles/prosilver/template/ucp_agreement.html">
			<edit>
				<find><![CDATA[			<input type="submit" name="agreed" id="agreed" value="{L_AGREE}" class="button1" />&nbsp;]]></find>
				<action type="before-add"><![CDATA[			<!-- INCLUDE prime_birthdate.html -->]]></action>
			</edit>
		</open>

		<open src="styles/prosilver/template/ucp_profile_profile_info.html">
			<edit>
				<find><![CDATA[	<!-- IF S_BIRTHDAYS_ENABLED -->]]></find>
				<action type="after-add"><![CDATA[		<!-- INCLUDE prime_birthdate.html -->
	<!-- ELSEIF FALSE -->]]></action>
			</edit>
		</open>

		<open src="styles/prosilver/template/ucp_register.html">
			<edit>
				<find><![CDATA[	<!-- BEGIN profile_fields -->]]></find>
				<action type="before-add"><![CDATA[	<!-- INCLUDE prime_birthdate.html -->]]></action>
			</edit>

			<edit>
				<find><![CDATA[<!-- IF S_COPPA -->]]></find>
				<action type="replace-with"><![CDATA[<!-- IF S_COPPA or S_COPPA === 0 -->]]></action>
			</edit>

			<edit>
				<find><![CDATA[<div class="panel">]]></find>
				<action type="replace-with"><![CDATA[<div class="panel" id="coppa_area"<!-- IF not S_COPPA --> style="display:none"<!-- ENDIF -->>]]></action>
			</edit>
		</open>

		<diy-instructions lang="en">As an alternative to manually executing the SQL statements, you can use the included 
"db_install.php" (located in the contrib directory). Simply copy the file to the root
directory of your phpbb3 install, and point your web browser to the address. Make 
sure you are logged in as an administrator before you do this, and make sure to
delete the file once you're done.</diy-instructions>
	</action-group>
</mod>