Would you like your moderators to be notified of newly posted messages awaiting validation in forums for which they are responsible? Here's the add-on you need!
Code: Select all
#
#-----[ OPEN ]---------------------------------------------
#
ROOT/includes/functions_post.php
#
#-----[ FIND ]---------------------------------------------
#
if ($mode != 'editpost')
{
$post_id = $db->sql_nextid();
#
#-----[ AFTER, ADD ]-----
#
//the following code was added by brett (aka: minorgod) to improve the post control mod and alert moderators that a new post needs moderating
if ( $userdata['user_id'] == ANONYMOUS || $board_config['post_control_users'] == "1" && $userdata['user_level'] == USER || $board_config['post_control_edited'] == "1" && $userdata['user_level'] == USER )
{
//see if we're logged into an admin session and if so, skip the notification completely
if(!$userdata['session_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);
}
// Now grab the admin addresses to see if our current poster is in the list of admin recipients.
// I couldn't figure out a quicker way to do this using the PHPbb DB abstraction functions. If
// we were using PEAR DB (which we really SHOULD be), then I could have just said
// $admin_email_address_list = $db->getAll($query); but since we're not using PEAR and PHPbb has
// no equivalent function, we must get the records and loop through them old-school style. LAME.
$sql = "SELECT user_email
FROM " . USERS_TABLE . "
WHERE user_level = " . ADMIN;
$admin_email_addresses = $db->sql_query($sql);
while($address_row = $db->sql_fetchrow($admin_email_addresses)){
$admin_email_address_list[] = $address_row['user_email'];
}
$db->sql_freeresult($admin_email_addresses);
//now do the emailing only if the user is not in the admin address list
if( empty($userdata['user_email']) || !in_array($userdata['user_email'],$admin_email_address_list)){
while ($row = $db->sql_fetchrow($result)){
include_once($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
$script_name = ($script_name != '') ? $script_name . '/viewtopic.'.$phpEx : 'viewtopic.'.$phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
$server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) . '/' : '/';
$post_control_subject = str_replace("''", "'", $post_subject);
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
$emailer->email_address(trim($row['user_email']));
$emailer->use_template("post_control_notify", $row['user_lang']);
$emailer->set_subject("New Post Requires Authorization");
$emailer->assign_vars(array(
'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
'SITENAME' => $board_config['sitename'],
'SUBJECT' => (!empty($post_control_subject)) ? '- ' . $post_control_subject : '',
'TOPIC_TITLE' => (!empty($post_control_subject)) ? '(' . $post_control_subject . ') ' : '',
'U_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_POST_URL . "=$post_id#$post_id"
)
);
$emailer->send();
$emailer->reset();
}//end while ($row = $db->sql_fetchrow($result)){
}//end if( empty($userdata['user_email']) || !in_array($userdata['user_email'],$admin_email_address_list))
$db->sql_freeresult($result);
}
}
//end code added by brett (aka: minorgod) to improve the post control mod and alert moderators that a new post needs moderating
#
#-----[ CREATE ]---------------------------------------------
#
ROOT/language/lang_english/email/post_control_notify.tpl
#
#-----[ PASTE THE FOLLOWING ]---------------------------------------------
#
Subject: New Post Requiring Approval {SUBJECT}
Charset: iso-8859-1
Hello,
You are receiving this email because a new post {TOPIC_TITLE}is requiring approval on {SITENAME}.
You can use the following link to validate or invalidate this post:
{U_TOPIC}
{EMAIL_SIG}
#
#-----[ CREER ]---------------------------------------------
#
ROOT/language/lang_french/email/post_control_notify.tpl
#
#-----[ COPIER LE TEXTE SUIVANT ]---------------------------------------------
#
Subject: Message en attente de validation {SUBJECT}
Charset: iso-8859-1
Bonjour,
Vous recevez ce courriel parce qu'un nouveau message {TOPIC_TITLE}est en attente de validation sur {SITENAME}.
Vous pouvez utiliser le lien suivant pour valider ou invalider le message:
{U_TOPIC}
{EMAIL_SIG}
Happy new year!