Page 1 of 36

[RC1] Prime Birthdate - Require on Registration

Posted: Mon Jul 16, 2007 5:52 pm
by primehalo
MOD Title: Prime Birthdate
MOD Description: 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.
MOD Version: View the Installation Instructions for latest version number
MOD Download: Main Download Site
Demo Board: http://www.absoluteanime.com/forum/
Demo Username: Not Required
Demo Password: Not Required

For the release history, please view the Installation Instructions.

For the MOD DB approved version, please view this thread.

Screenshot
Image

Re: [BETA] Require Birth Date on Registration

Posted: Mon Jul 16, 2007 5:55 pm
by primehalo
This is one feature I really wanted to see in phpbb3. I've only tested it out on my localhost, as I've been having trouble accessing my online test forum. If you try it out, please alert me to anything you find wrong with it. Thanks.

Re: [BETA] Require Birth Date on Registration (version 0.0.0)

Posted: Sat Jul 21, 2007 12:47 am
by ukrob12
Yeah, I got a problem lol.. there is two March's and no October! Great mod other than that though :)

If you could patch the date problem as soon as you can cause I'm running this mod (I really do require it for my forum). .. and I can't find where the months are in the mod!

Re: [BETA] Require Birth Date on Registration (version 0.0.0)

Posted: Sat Jul 21, 2007 1:06 am
by primehalo
Can you post a link to your board? I pull the short month names right from the "common.php" language file. The part where I build the month dropdown listbox is in "./includes/ucp/ucp_register.php", search for the variable "$s_birthday_month_options". If you could post the code in the general area of that variable, I can check and see if something got messed up.

Here is what mine looks like: http://www.absoluteanime.com/phpbb3/ucp ... e=register

Re: [BETA] Require Birth Date on Registration (version 0.0.1)

Posted: Sat Jul 21, 2007 2:20 pm
by playerfr
Have to install this one :D for next version will you provide Update files ? or is it better that i wait for a stable version :?

Re: [BETA] Require Birth Date on Registration (version 0.0.1)

Posted: Sat Jul 21, 2007 4:57 pm
by primehalo
To update from version 0.0.0 to 0.0.1:

File copy
  1. Copy: ./root/language/en/mods/require_birth_date.php
    To: ./language/en/mods/require_birth_date.php
  2. Copy: ./root/includes/functions_birthdate.php
    To: ./includes/functions_birthdate.php
Open: includes/ucp/ucp_profile.php
Find:

Code: Select all

*/
Add after:

Code: Select all

//mod: Require Birth Date on Registration -----------------------------------//
/**
* This contains functions for verifying and displaying the birth date.
*/
include($phpbb_root_path . 'includes/functions_birthdate.' . $phpEx);
//end: Require Birth Date on Registration -----------------------------------//


Find:

Code: Select all

// validate custom profile fields
Add before:

Code: Select all

//mod: Require Birth Date on Registration -----------------------------------//
					if (($result = validate_birth_date($data['bday_day'] . '-' . $data['bday_month'] . '-' . $data['bday_year'])) !== false)
					{
						$user->add_lang('mods/require_birth_date');
						if ($result == 'NO_BIRTH_DATE')
						{
							$result = 'INVALID_BIRTH_DATE';
						}
						$error[] = $result;
					}
//end: Require Birth Date on Registration -----------------------------------//


Open: includes/ucp/ucp_register.php

Find:

Code: Select all

//mod: Require Birth Date on Registration -----------------------------------//
//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  //
//This function will return a person's current age. It accepts the date in   //
//the form of a string, in the format "day-month-year".                      //
//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  //
function get_age($date_of_birth) //day-month-year
{ 
	$birth = explode("-", $date_of_birth);
	$age = date("Y") - $birth[2];
	if (($birth[1] > date("m")) || ($birth[1] == date("m") && date("d") < $birth[0]))
	{
		$age -= 1;
	}
	return $age;
} 

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  //
//This function will validate a birth date. It accepts the date in the form  //
//of a string, in the format "day-month-year".                               //
//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  //
function validate_birth_date($date_of_birth) //day-month-year
{
	$minimum_age = 4;
	$birth = explode("-", $date_of_birth);
	if ((!$birth[0] || !$birth[1] || !$birth[2]))
	{
		return 'NO_BIRTH_DATE';
	}
	if ($birth[0] < 0 || $birth[0] > 31 || $birth[1] < 0 || $birth[1] > 12 || ($birth[2] < 1901 && $birth[2] > 0) || $birth[2] > gmdate('Y', time()))
	{
		return 'INVALID_BIRTH_DATE';
	}
	if (checkdate($birth[1], $birth[0], $birth[2]) === false)
	{
		return 'INVALID_BIRTH_DATE';
	}
	if (get_age($date_of_birth) < $minimum_age)
	{
		return 'TOO_YOUNG';
	}
	return(false);
}
//end: Require Birth Date on Registration -----------------------------------//


Replace with:

Code: Select all

//mod: Require Birth Date on Registration -----------------------------------//
/**
* This contains functions for verifying and displaying the birth date.
*/
include($phpbb_root_path . 'includes/functions_birthdate.' . $phpEx);
//end: Require Birth Date on Registration -----------------------------------//


Find:

Code: Select all

//mod: Require Birth Date on Registration -----------------------------------//
//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  //
//Here we grab submitted birth date information, or initialize it if none    //
//exists. Then we create the birth date form fields for display in the       //
//templates (much of that code is copied from ucp_profile.php).              //
//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  //
		$bday['month']	= request_var('bday_month', 0);
		$bday['day']	= request_var('bday_day', 0);
		$bday['year']	= request_var('bday_year', 0);
		$bday['date']	= sprintf('%2d-%2d-%4d', $bday['day'], $bday['month'], $bday['year']);

		$s_birthday_day_options = '<option value="0"' . ((!$bday['day']) ? ' selected="selected"' : '') . '>' . $user->lang['DAY'] . '</option>';
		for ($i = 1; $i < 32; $i++)
		{
			$selected = ($i == $bday['day']) ? ' selected="selected"' : '';
			$s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>";
		}
	
		$s_birthday_month_options = '<option value="0"' . ((!$bday['month']) ? ' selected="selected"' : '') . '>' . $user->lang['MONTH'] . '</option>';
		for ($i = 1, $lang_dates = $user->lang['datetime']; $i < 13; $i++)
		{
			$display_month = strtr(@gmdate('M', strtotime("2000-{$i}-01")), $lang_dates);
			$selected = ($i == $bday['month']) ? ' selected="selected"' : '';
			$s_birthday_month_options .= "<option value=\"$i\"$selected>{$display_month}</option>";
		}
		$s_birthday_year_options = '';
	
		$now = getdate();
		$s_birthday_year_options = '<option value="0"' . ((!$bday['year']) ? ' selected="selected"' : '') . '>' . $user->lang['YEAR'] . '</option>';
		for ($i = $now['year'] - 100; $i < $now['year']; $i++)
		{
			$selected = ($i == $bday['year']) ? ' selected="selected"' : '';
			$s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>";
		}
		unset($now);
	
		$template->assign_vars(array(
			'S_BIRTHDAY_DAY_OPTIONS'	=> $s_birthday_day_options,
			'S_BIRTHDAY_MONTH_OPTIONS'	=> $s_birthday_month_options,
			'S_BIRTHDAY_YEAR_OPTIONS'	=> $s_birthday_year_options,)
		);
//end: Require Birth Date on Registration -----------------------------------//

Replace with:

Code: Select all

//mod: Require Birth Date on Registration -----------------------------------//
//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  //
//We grab submitted birth date information, or initialize it if none exists. //
//Then we create the birth date form fields for display in the templates.    //
//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  //
		$bday['month'] = request_var('bday_month', 0);
		$bday['day']   = request_var('bday_day', 0);
		$bday['year']  = request_var('bday_year', 0);
		$bday['date']  = sprintf('%2d-%2d-%4d', $bday['day'], $bday['month'], $bday['year']);

		$bday_options = get_birth_date_options($bday['date']);
		$template->assign_vars(array(
			'S_BIRTHDAY_DAY_OPTIONS'	=> $bday_options[0],
			'S_BIRTHDAY_MONTH_OPTIONS'	=> $bday_options[1],
			'S_BIRTHDAY_YEAR_OPTIONS'	=> $bday_options[2],
		));
//end: Require Birth Date on Registration -----------------------------------//


Re: [BETA] Require Birth Date on Registration (version 0.0.1)

Posted: Tue Jul 24, 2007 10:24 am
by hsiehstanley83
Great mod of yours!
I LOVE IT! :)

*EDIT* I wonder why you can read my mind ;)

Re: [BETA] Require Birth Date on Registration (version 0.0.1)

Posted: Wed Jul 25, 2007 5:50 am
by primehalo
How long did it take you to install it? Was 10 minutes a descent estimate?

Re: [BETA] Require Birth Date on Registration (version 0.0.1)

Posted: Wed Jul 25, 2007 5:16 pm
by ukrob12
If I remember right then probably, yeah. Maybe slightly less..

Re: [BETA] Prime Birthdate (0.0.2) Require on Registration

Posted: Wed Aug 08, 2007 7:53 am
by Sylwia
Hi, I installed this mod, but the registration page is blank now, I also can't logout when I'm logged in. Any idea what might have gone wrong?

I checked and rechecked everything, and am not sure what else I might do. Any help will be appreciated.

http://scotch-and-sirens.waw.pl/phpBB3/index.php

Sylwia

Re: [BETA] Prime Birthdate (0.0.2) Require on Registration

Posted: Wed Aug 08, 2007 7:59 am
by primehalo
Sylwia wrote:Hi, I installed this mod, but the registration page is blank now, I also can't logout when I'm logged in. Any idea what might have gone wrong?

I checked and rechecked everything, and am not sure what else I might do. Any help will be appreciated.

http://scotch-and-sirens.waw.pl/phpBB3/index.php

Sylwia
Hard to tell without any error messages. Can you send me the files that you modified so I can take a look? Do you have access to your server's error logs?

Re: [BETA] Prime Birthdate (0.0.2) Require on Registration

Posted: Wed Aug 08, 2007 8:25 am
by Sylwia
Sure, just tell me how to send them or email me.

I don't have access to my server's error logs, but I wrote to my provider, so hopefully they'll answer back.

Also, I returned to my previous settings and it's still not working.

Sylwia

Re: [BETA] Prime Birthdate (0.0.2) Require on Registration

Posted: Wed Aug 08, 2007 9:27 am
by primehalo
Sylwia wrote:Sure, just tell me how to send them or email me.

I don't have access to my server's error logs, but I wrote to my provider, so hopefully they'll answer back.

Also, I returned to my previous settings and it's still not working.

Sylwia
I looked over the files you sent and didn't see anything wrong. If you removed all of the changes and it still doesn't work, then maybe you accidentally added in a typo somewhere when originally installing it. I know I've done that a few times, accidentally deleting a semicolon or an ending brace. Getting ahold of those error logs would really help. And if you haven't installed many MODs, perhaps you could copy over a fresh version of the phpbb3 files (minus the config.php of course).

Do you know what version of PHP you're running? I think my code is compatible with version 4.3.3 and higher, but I'm running 5.2.3 so I can't test that.

Re: [BETA] Prime Birthdate (0.0.2) Require on Registration

Posted: Wed Aug 08, 2007 12:32 pm
by .:: Chico ::.
great mod. Thank you, Prime.

I'm gonna test him on RC4.

Just a Sugestion: a Pack of require option sounds good like localization require, what do you think :?:

Regards,
Chico.

Re: [BETA] Prime Birthdate (0.0.2) Require on Registration

Posted: Wed Aug 08, 2007 2:30 pm
by Sylwia
Thanks, I found the mistake. I replaced with the ucp.php file the one in the main folder instead of the one in the language/en folder. They're both called the same, but apparently are not the same. ;) Your mod works great!

I have another question though. Would it be possible to use the age option in such a way that people younger than 18 would automatically register to another group. I just need to give different permissions to adults and minors. At this moment I changed the requirements of COPPA, so everyone who is younger than 18 is registered as a COPPA user, but that requires my manual activating of each of them. Would is be possible to change it in such a way that they would register themselves but stay in the COPPA group or some other group defined for them?

Also, would it be then possible for them to automatically leave the restricted group as soon as they're 18?

I'm not even sure it's a good place to ask the question, but I'm very new to php. So if I should ask it elsewhere pls just redirect me.