예제 #1
0
/**
 * Send a new forum message notification by mail to subscribed users.
 *
 * @param array $message
 *     An array containing the data for a forum message.
 */
function phorum_api_mail_message_notify($message)
{
    // Not "global $PHORUM", because we do not want the loading of language
    // files to override our already loaded language file.
    $PHORUM = $GLOBALS['PHORUM'];
    // Check if email notifications are allowed for the current forum.
    if (empty($PHORUM['allow_email_notify'])) {
        return;
    }
    $recipients = phorum_api_user_list_subscribers($PHORUM['forum_id'], $message['thread'], PHORUM_SUBSCRIPTION_MESSAGE);
    // No subscribers? Then we are done.
    if (empty($recipients)) {
        return;
    }
    $mail_data = array('forumname' => strip_tags($PHORUM['DATA']['NAME']), 'forum_id' => $message['forum_id'], "thread_id" => $message['thread'], 'message_id' => $message['message_id'], 'author' => phorum_api_user_get_display_name($message['user_id'], $message['author'], PHORUM_FLAG_PLAINTEXT), 'subject' => $message['subject'], 'fully_body' => $message['body'], 'plain_body' => wordwrap(phorum_api_format_strip($message['body']), 72), 'read_url' => phorum_api_url_no_uri_auth(PHORUM_READ_URL, $message['thread'], $message['message_id']), 'remove_url' => phorum_api_url_no_uri_auth(PHORUM_FOLLOW_URL, $message['thread'], 'stop=1'), 'noemail_url' => phorum_api_url_no_uri_auth(PHORUM_FOLLOW_URL, $message['thread'], 'noemail=1'), 'followed_threads_url' => phorum_api_url_no_uri_auth(PHORUM_CONTROLCENTER_URL, 'panel=' . PHORUM_CC_SUBSCRIPTION_THREADS), 'msgid' => $message['msgid'], 'mailmessagetpl' => 'NewReplyMessage', 'mailsubjecttpl' => 'NewReplySubject');
    foreach ($recipients as $language => $addresses) {
        $language = basename($language);
        if (file_exists(PHORUM_PATH . "/include/lang/{$language}.php")) {
            $mail_data['language'] = $language;
            include PHORUM_PATH . "/include/lang/{$language}.php";
        } else {
            $mail_data['language'] = $PHORUM['language'];
            include PHORUM_PATH . "/include/lang/{$PHORUM['language']}.php";
        }
        $mail_data['mailmessage'] = $PHORUM['DATA']['LANG']['NewReplyMessage'];
        $mail_data['mailsubject'] = $PHORUM['DATA']['LANG']['NewReplySubject'];
        phorum_api_mail($addresses, $mail_data);
    }
}
예제 #2
0
function phorum_email_notice($message)
{
    $PHORUM = $GLOBALS["PHORUM"];
    // do we allow email-notification for that forum?
    if (!$PHORUM['allow_email_notify']) {
        return;
    }
    include_once "./include/format_functions.php";
    $mail_users_full = phorum_api_user_list_subscribers($PHORUM['forum_id'], $message['thread'], PHORUM_SUBSCRIPTION_MESSAGE);
    if (count($mail_users_full)) {
        $mail_data = array("forumname" => strip_tags($PHORUM["DATA"]["NAME"]), "forum_id" => $PHORUM['forum_id'], "message_id" => $message['message_id'], "author" => phorum_api_user_get_display_name($message["user_id"], $message["author"], PHORUM_FLAG_PLAINTEXT), "subject" => $message['subject'], "full_body" => $message['body'], "plain_body" => phorum_strip_body($message['body']), "read_url" => phorum_get_url(PHORUM_READ_URL, $message['thread'], $message['message_id']), "remove_url" => phorum_get_url(PHORUM_FOLLOW_URL, $message['thread'], "stop=1"), "noemail_url" => phorum_get_url(PHORUM_FOLLOW_URL, $message['thread'], "noemail=1"), "followed_threads_url" => phorum_get_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_SUBSCRIPTION_THREADS), "msgid" => $message["msgid"], "mailmessagetpl" => 'NewReplyMessage', "mailsubjecttpl" => 'NewReplySubject');
        if (isset($_POST[PHORUM_SESSION_LONG_TERM])) {
            // strip any auth info from the read url
            $mail_data["read_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["read_url"]);
            $mail_data["remove_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["remove_url"]);
            $mail_data["noemail_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["noemail_url"]);
            $mail_data["followed_threads_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["followed_threads_url"]);
        }
        // go through the user-languages and send mail with their set lang
        foreach ($mail_users_full as $language => $mail_users) {
            $language = basename($language);
            if (file_exists("./include/lang/{$language}.php")) {
                $mail_data['language'] = $language;
                include "./include/lang/{$language}.php";
            } else {
                $mail_data['language'] = $PHORUM['language'];
                include "./include/lang/{$PHORUM['language']}.php";
            }
            $mail_data["mailmessage"] = $PHORUM["DATA"]["LANG"]['NewReplyMessage'];
            $mail_data["mailsubject"] = $PHORUM["DATA"]["LANG"]['NewReplySubject'];
            phorum_email_user($mail_users, $mail_data);
        }
    }
}