From 202a96cb908b03379f311b5ec893b20addbbf020 Mon Sep 17 00:00:00 2001 From: Graham Eames Date: Fri, 23 Sep 2005 18:46:18 +0000 Subject: [PATCH] Change handling of re-activation emails If account activation is set to admin, these are now sent to the administrator and not the user. This is a slight change in behaviour but brings the code into line with the messages displayed to the user and the email which is sent and is required because only an administrator is able to re-activate an account with that account activation setting. [Bug #145] git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@5225 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/usercp_register.php | 66 ++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/phpBB/includes/usercp_register.php b/phpBB/includes/usercp_register.php index 05495a3760..3171264405 100644 --- a/phpBB/includes/usercp_register.php +++ b/phpBB/includes/usercp_register.php @@ -532,22 +532,56 @@ if ( isset($HTTP_POST_VARS['submit']) ) include($phpbb_root_path . 'includes/emailer.'.$phpEx); $emailer = new emailer($board_config['smtp_delivery']); - $emailer->from($board_config['board_email']); - $emailer->replyto($board_config['board_email']); - - $emailer->use_template('user_activate', stripslashes($user_lang)); - $emailer->email_address($email); - $emailer->set_subject($lang['Reactivate']); - - $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' => (!empty($board_config['board_email_sig'])) ? str_replace('
', "\n", "-- \n" . $board_config['board_email_sig']) : '', - - 'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey) - ); - $emailer->send(); - $emailer->reset(); + if ( $board_config['require_activation'] != USER_ACTIVATION_ADMIN ) + { + $emailer->from($board_config['board_email']); + $emailer->replyto($board_config['board_email']); + + $emailer->use_template('user_activate', stripslashes($user_lang)); + $emailer->email_address($email); + $emailer->set_subject($lang['Reactivate']); + + $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' => (!empty($board_config['board_email_sig'])) ? str_replace('
', "\n", "-- \n" . $board_config['board_email_sig']) : '', + + 'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey) + ); + $emailer->send(); + $emailer->reset(); + } + else if ( $board_config['require_activation'] == USER_ACTIVATION_ADMIN ) + { + $sql = 'SELECT user_email, user_lang + FROM ' . USERS_TABLE . ' + WHERE user_level = ' . 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_activate", $row['user_lang']); + $emailer->set_subject($lang['Reactivate']); + + $emailer->assign_vars(array( + 'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)), + 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . $board_config['board_email_sig']), + + 'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey) + ); + $emailer->send(); + $emailer->reset(); + } + $db->sql_freeresult($result); + } $message = $lang['Profile_updated_inactive'] . '

' . sprintf($lang['Click_return_index'], '', ''); }