##############################################################
## MOD Title: Admin Registration Notify [2.0.8]
## MOD Author: 	mosymuis < mods@mosymuis.nl > (Rens van Dongen) http://mods.mosymuis.nl
##
## MOD Description: This mod will send a notification email to
##		all admins when a new user has joined the forum.
##		This can be turned off in the admincp.
##
## MOD Version: 1.0.0
##
## Installation Level: (Easy)
## Installation Time: 5 Minutes
## Files To Edit: (8)
##		- admin/admin_board.php 
##		- includes/constants.php
##		- includes/usercp_register.php
##		- templates/subSilver/admin/board_config_body.tpl
##		- language/lang_english/lang_main.php
##		- language/lang_english/lang_admin.php
## Included Files: (3)
##		- db_update.php
##		- phpbb_root_path/language/lang_english/email/admin_new_user.tpl
##############################################################
## Author Notes: Made for a request from Marcy at phpbbhacks.com.
##############################################################
## MOD History:
##
##   2004/03/14 - Version 1.0.0
##      - Initial BETA Release
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ COPY ]------------------------------------------
#
copy phpbb_root_path/language/lang_english/email/admin_new_user.tpl to language/lang_english/email/admin_new_user.tpl

# 
#-----[ SQL ]------------------------------------------ 
# or run the included db_update.php
# change phpbb_ to the database prefix you use
#
INSERT INTO phpbb_config VALUES ('registration_notify', 1);

# 
#-----[ OPEN ]------------------------------------------ 
# 
admin/admin_board.php

# 
#-----[ FIND ]------------------------------------------ 
# 
$activation_admin = ( $new['require_activation'] == USER_ACTIVATION_ADMIN ) ? "checked=\"checked\"" : "";

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
$registration_notify_none = ( $new['registration_notify'] == USER_REGISTRATION_NOTIFY_NONE ) ? "checked=\"checked\"" : "";
$registration_notify_mod = ( $new['registration_notify'] == USER_REGISTRATION_NOTIFY_MOD ) ? "checked=\"checked\"" : "";
$registration_notify_admin = ( $new['registration_notify'] == USER_REGISTRATION_NOTIFY_ADMIN ) ? "checked=\"checked\"" : "";

# 
#-----[ FIND ]------------------------------------------ 
# 
	"L_ACCT_ACTIVATION" => $lang['Acct_activation'],

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
	"L_REGISTRATION_NOTIFY" => $lang['Registration_notify'],
	"L_MOD" => $lang['Moderator'],

# 
#-----[ FIND ]------------------------------------------ 
# 
	"ACTIVATION_ADMIN_CHECKED" => $activation_admin,

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
	"REGISTRATION_NOTIFY_NONE" => USER_REGISTRATION_NOTIFY_NONE,
	"REGISTRATION_NOTIFY_NONE_CHECKED" => $registration_notify_none,
	"REGISTRATION_NOTIFY_MOD" => USER_REGISTRATION_NOTIFY_MOD,
	"REGISTRATION_NOTIFY_MOD_CHECKED" => $registration_notify_mod,
	"REGISTRATION_NOTIFY_ADMIN" => USER_REGISTRATION_NOTIFY_ADMIN,
	"REGISTRATION_NOTIFY_ADMIN_CHECKED" => $registration_notify_admin,

# 
#-----[ OPEN ]------------------------------------------ 
# 
includes/constants.php

# 
#-----[ FIND ]------------------------------------------ 
# 
define('USER_ACTIVATION_ADMIN', 2);

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
define('USER_REGISTRATION_NOTIFY_NONE', 0);
define('USER_REGISTRATION_NOTIFY_MOD', 2);
define('USER_REGISTRATION_NOTIFY_ADMIN', 1);

#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_register.php

#
#-----[ FIND ]------------------------------------------
#
			$emailer = new emailer($board_config['smtp_delivery']);

#
#-----[ AFTER, ADD ]------------------------------------------
#
			if ( $board_config['registration_notify'] )
			{
				$sql = "SELECT user_email, user_lang
					FROM " . USERS_TABLE . "
					WHERE user_level" . (($board_config['registration_notify'] == USER_REGISTRATION_NOTIFY_ADMIN) ? " = " : " >= ") . ADMIN;

				if ( !($result = $db->sql_query($sql)) )
				{
					message_die(GENERAL_ERROR, 'Could not select Administrators', '', __LINE__, __FILE__, $sql);
				}

				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("admin_new_user", $row['user_lang']);
					$emailer->set_subject($lang['New_user_registration']);

					$emailer->assign_vars(array(
						'SITENAME' => $board_config['sitename'],
						'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
						'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']),

						'U_PROFILE' => $server_url . '?mode=viewprofile&' . POST_USERS_URL . '=' . $user_id)
					);
					$emailer->send();
					$emailer->reset();
				}
				$db->sql_freeresult($result);
			}

# 
#-----[ OPEN ]------------------------------------------ 
# Make sure to edit this file for every theme you use!
#
templates/subSilver/admin/board_config_body.tpl 

# 
#-----[ FIND ]------------------------------------------ 
# 
		<td class="row2"><input type="radio" name="require_activation" value="{ACTIVATION_NONE}" {ACTIVATION_NONE_CHECKED} />{L_NONE}&nbsp; &nbsp;<input type="radio" name="require_activation" value="{ACTIVATION_USER}" {ACTIVATION_USER_CHECKED} />{L_USER}&nbsp; &nbsp;<input type="radio" name="require_activation" value="{ACTIVATION_ADMIN}" {ACTIVATION_ADMIN_CHECKED} />{L_ADMIN}</td>
	</tr>

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
	<tr>
		<td class="row1">{L_REGISTRATION_NOTIFY}</td>
		<td class="row2"><input type="radio" name="registration_notify" value="{REGISTRATION_NOTIFY_NONE}" {REGISTRATION_NOTIFY_NONE_CHECKED} />{L_NONE}&nbsp; &nbsp;<input type="radio" name="registration_notify" value="{REGISTRATION_NOTIFY_MOD}" {REGISTRATION_NOTIFY_MOD_CHECKED} />{L_MOD}&nbsp; &nbsp;<input type="radio" name="registration_notify" value="{REGISTRATION_NOTIFY_ADMIN}" {REGISTRATION_NOTIFY_ADMIN_CHECKED} />{L_ADMIN}</td>
	</tr>

#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php

#
#-----[ FIND ]------------------------------------------
#
//
// That's all, Folks!
// -------------------------------------------------

#
#-----[ BEFORE, ADD ]------------------------------------------
#
// Admin Registration Notify mod
$lang['New_user_registration'] = 'New user registration';

#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_admin.php

#
#-----[ FIND ]------------------------------------------
#
//
// That's all Folks!
// -------------------------------------------------

#
#-----[ BEFORE, ADD ]------------------------------------------
#
// Admin Registration Notify mod
$lang['Registration_notify'] = 'Send notify email on new user registrations';


#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM