############################################################## 
## MOD Title:          Birthday Mail Extention
## MOD Author:         Tuxman < tuxman@sumpfkuh.de >
## MOD Description:    This mod will extend the Birthday Mod
##                     ( http://www.phpbbhacks.com/viewhack.php?id=187 )
##                     to send an eMail if the user's birthday has
##                     come...
## MOD Version:        1.01
## Compatibility:      2.0.x
##
## Changes since 1.0:  * Now using phpBB's mailer function
##                     * Now using Mail Templates
##                     * Now "replacing" the old popup window
## 
## Installation Level: Simple
## Installation Time:  10 Minutes
##
## Files To Edit:      2
##      includes/page_header.php
##      language/lang_english/lang_main.php
##
## Included Files:     1
##      language/lang_english/email/birthday.tpl
##
############################################################## 

#
#-----[ COPY ]------------------------------------------------
#

language/lang_english/email/birthday.tpl

#
#-----[ OPEN ]------------------------------------------------
#

includes/page_header.php

#
#-----[ FIND ]------------------------------------------------
#

		$template->assign_var("GREETING_POPUP",
			"<script language=\"Javascript\" type=\"text/javascript\"><!--
			window.open('".append_sid('birthday_popup.'.$phpEx)."', '_phpbbprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');
			//-->
			</script>");

#
#-----[ REPLACE BY ]------------------------------------------
#

// START Birthday Mail Extension
	$sql = "SELECT * FROM " . USERS_TABLE . " WHERE user_id = " . $userdata['user_id'];
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, $lang['bd_sqlerror']);
	}
	
	while( $row = $db->sql_fetchrow($result) )
	{
		$bd_mail = intval($row['user_email']);
	}

	$sql = "SELECT * FROM " . USERS_TABLE . " WHERE user_id = $user_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, $lang['bd_sqlerror']);
	}
	while ($row = $db->sql_fetchrow($result))
		$emailer->from($board_config['board_email']); 
		$emailer->replyto($board_config['board_email']); 
	
		$emailer->email_address(trim($row['user_email'])); 
		$emailer->use_template("birthday", $row['user_lang']);
		$emailer->set_subject($lang['bd_subject']);

		$emailer->assign_vars(array(
			'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $row['username']), 0, 25)),
			'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']),
			'BOARDNAME' => str_replace('<br />', "\n", "-- \n" . $board_config['sitename'])
		);
		$emailer->send();
		$emailer->reset();
	}
// END Birthday Mail Extension

#
#-----[ OPEN ]------------------------------------------------
#

language/lang_english/lang_main.php

#
#-----[ FIND ]------------------------------------------------
#

//
// That's all, Folks!

#
#-----[ BEFORE, ADD ]------------------------------------------
#

$lang['bd_smtperror'] = 'You must <b>not</b> use an external mail server to send this mail!';
$lang['bd_sqlerror'] = 'Error reading SQL';
$lang['bd_subject'] = 'Gratulations!';

#
#-----[ END OF MOD ]-------------------------------------------