############################################################## 
## MOD Title: [Birthdays 2.0.1] phpBB 2 Calendar Add-on
## MOD Author: TerraFrost < terrafrost@phpbb.com > (Jim Wigginton) http://www.frostjedi.com/terra/wordpress/
## MOD Description: Adds a Birthday field to the memberlist.
## MOD Version: 1.0.0
##
## Installation Level: Easy
## Installation Time: 7 Minutes
##
## Files To Edit: 4
##      language/lang_english/lang_calendar.php
##      admin/admin_calendar.php
##      templates/subSilver/admin/calendar_config_body.tpl
##      cal_lite.php
##
## Included Files: 0
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## 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/
##############################################################
## Author Notes:
##
## Intended for 1.4.7:
## http://www.snailsource.com/forum/viewtopic.php?t=3305
##
############################################################## 
## MOD History: 
##
##   2006-04-20 - Version 1.0.0
##      - initial release
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################

#
#-----[ SQL ]-------------------------------------------
#
INSERT INTO phpbb_cal_config (config_name, config_value) VALUES ('show_birthdays',1);
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_calendar.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]-----------------------------------
#
$lang['show_birthday'] = "Show Birthdays";

#
#-----[ OPEN ]------------------------------------------
#
admin/admin_calendar.php
#
#-----[ FIND ]------------------------------------------
#
$show_headers_yes = ( $new['show_headers'] ) ? "checked=\"checked\"" : "";
$show_headers_no = ( !$new['show_headers'] ) ? "checked=\"checked\"" : "";
#
#-----[ AFTER, ADD ]------------------------------------
#

$show_birthdays_yes = ( $new['show_birthdays'] ) ? "checked=\"checked\"" : "";
$show_birthdays_no = ( !$new['show_birthdays'] ) ? "checked=\"checked\"" : "";
#
#-----[ FIND ]------------------------------------------
#
	"L_DATE_FORMAT_EXPLAIN" => $lang['cal_date_explain'],
#
#-----[ AFTER, ADD ]------------------------------------
#
	"L_SHOW_BIRTHDAYS" => $lang['show_birthday'],
#
#-----[ FIND ]------------------------------------------
#
	"S_SHOW_HEADERS_NO" => $show_headers_no,
#
#-----[ AFTER, ADD ]------------------------------------
#
	"S_SHOW_BIRTHDAYS_YES" => $show_birthdays_yes,
	"S_SHOW_BIRTHDAYS_NO" => $show_birthdays_no,
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/admin/calendar_config_body.tpl
#
#-----[ FIND ]------------------------------------------
#
    <tr> 
      <td class="row1">{L_SHOW_HEADERS}</td>
      <td class="row2"><input type="radio" name="show_headers" value="1" {S_SHOW_HEADERS_YES} />
        {L_YES}&nbsp;&nbsp; <input type="radio" name="show_headers" value="0" {S_SHOW_HEADERS_NO} />
        {L_NO}</td>
    </tr>
#
#-----[ AFTER, ADD ]------------------------------------
#
    <tr> 
      <td class="row1">{L_SHOW_BIRTHDAYS}</td>
      <td class="row2"><input type="radio" name="show_headers" value="1" {S_SHOW_BIRTHDAYS_YES} />
        {L_YES}&nbsp;&nbsp; <input type="radio" name="show_headers" value="0" {S_SHOW_BIRTHDAYS_NO} />
        {L_NO}</td>
    </tr>
#
#-----[ OPEN ]------------------------------------------
#
cal_lite.php
#
#-----[ FIND ]------------------------------------------
# this is a partial match
#
function defaultview()
{
	global $thisscript
		$board_config
		$cl_ed
#
#-----[ AFTER, ADD ]------------------------------------
#

	if ( $cal_config['show_birthdays'] )
	{
		$start = $cl_m.'000000';
		$end = $cl_m.'999999';
		$sql = "SELECT username, user_id, user_birthday 
			FROM ".USERS_TABLE." 
			WHERE user_birthday >= $start 
				AND user_birthday <= $end 
			ORDER BY user_birthday";
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not query birthday information for the specified month', '', __LINE__, __FILE__, $sql);
		}
		$birthdays = array();
		while ( $row = $db->sql_fetchrow($result) )
		{
			preg_match('/(..)(..)(....)/', sprintf('%08d',$row['user_birthday']), $bday_parts);
			$bday_month = $bday_parts[1];
			$bday_day = $bday_parts[2];
			$bday_year = $bday_parts[3];

			$birthdays[(int) $bday_day][] = array(
				'user_id' => $row['user_id'],
				'username' => $row['username'],
				'age' => ( $bday_year != 0 ) ? $cl_y - $bday_year : -1
			);
		}		
	}
#
#-----[ FIND ]------------------------------------------
#
		$event_list = '';
		$correction = 0;
#
#-----[ AFTER, ADD ]------------------------------------
#
		if ( $cal_config['show_birthdays'] && $cl_m == $today_month )
		{
			while (list(, $birthday) = @each($birthdays[(int) $today_day]))
			{
				$correction--;
				$age = ( $birthday['age'] != -1 ) ? ' ('.$birthday['age'].')' : '';
				$event_list.= '<span class="gensmall">-> <a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $birthday['user_id']) . '">' . $birthday['username'] . '</a>' . $age . '</span><br />';
			}
		}
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------
#
# EoM