/** * 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); } }
/** * Send a new forum message for moderation to the moderator(s). * * @param array $message * An array containing the data for a forum message. */ function phorum_api_mail_message_moderate($message) { // Not "global $PHORUM", because we do not want the loading of language // files to override our already loaded language file. $PHORUM = $GLOBALS['PHORUM']; // Retrieve the list of moderators for the current forum. $moderators = phorum_api_user_list_moderators($PHORUM['forum_id'], $PHORUM['email_ignore_admin'], TRUE); // The list moderators function returns user_id => mail address. // We want the full user info, so we can lookup the preferred // language for the moderators. $moderators = phorum_api_user_get(array_keys($moderators)); // Sort all moderators by their preferred language. $recipients = array(); foreach ($moderators as $moderator) { if (!isset($recipients[$moderator['user_language']])) { $recipients[$moderator['user_language']] = array($moderator['email']); } else { $recipients[$moderator['user_language']][] = $moderator['email']; } } // No moderators (oomph)? Then we are done. if (empty($recipients)) { return; } if ($message['status'] > 0) { $mailsubjecttpl = 'NewUnModeratedSubject'; $mailmessagetpl = 'NewUnModeratedMessage'; } else { $mailsubjecttpl = 'NewModeratedSubject'; $mailmessagetpl = 'NewModeratedMessage'; } $mail_data = array('forumname' => strip_tags($PHORUM['DATA']['NAME']), 'forum_id' => $message['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'], 'fully_body' => $message['body'], 'plain_body' => wordwrap(phorum_api_format_strip($message['body']), 72), 'approve_url' => phorum_api_url_no_uri_auth(PHORUM_CONTROLCENTER_URL, 'panel=messages'), 'read_url' => phorum_api_url_no_uri_auth(PHORUM_READ_URL, $message['thread'], $message['message_id']), 'mailmessagetpl' => $mailmessagetpl, 'mailsubjecttpl' => $mailsubjecttpl); 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'][$mailmessagetpl]; $mail_data['mailsubject'] = $PHORUM['DATA']['LANG'][$mailsubjecttpl]; phorum_api_mail($addresses, $mail_data); } }
/** * Send a PM notification by mail. * * @param array $message * An array containing the private message data. * * @param array $recipients * An array of users that have received the PM. */ function phorum_api_mail_pm_notify($message, $recipients) { // Not "global $PHORUM", because we do not want the loading of language // files to override our already loaded language file. $PHORUM = $GLOBALS['PHORUM']; // Sort all recipients that want a notification by their preferred language. $recipients_by_lang = array(); foreach ($recipients as $recipient) { if ($recipient['pm_email_notify']) { if (!isset($recipients_by_lang[$recipient['user_language']])) { $recipients_by_lang[$recipient['user_language']] = array($recipient); } else { $recipients_by_lang[$recipient['user_language']][] = $recipient; } } } // No users found that want a notification? Then we are done. if (empty($recipients_by_lang)) { return; } // Build the data array for phorum_api_mail(). $mail_data = array('pm_message_id' => $message['pm_message_id'], 'author' => phorum_api_user_get_display_name($message['user_id'], $message['from_username'], PHORUM_FLAG_PLAINTEXT), 'subject' => $message['subject'], 'full_body' => $message['message'], 'plain_body' => wordwrap(phorum_api_format_strip($message['message']), 72), 'read_url' => phorum_api_url_no_uri_auth(PHORUM_PM_URL, 'page=read', 'pm_id=' . $message['pm_message_id']), 'mailmessagetpl' => 'PMNotifyMessage', 'mailsubjecttpl' => 'PMNotifySubject'); foreach ($recipients_by_lang as $language => $users) { $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']['PMNotifyMessage']; $mail_data['mailsubject'] = $PHORUM['DATA']['LANG']['PMNotifySubject']; $addresses = array(); foreach ($users as $user) { $addresses[] = $user['email']; } phorum_api_mail($addresses, $mail_data); } }
* [input] * None * * [output] * None */ if (isset($PHORUM['hooks']['before_logout'])) { phorum_api_hook('before_logout'); } phorum_api_user_session_destroy(PHORUM_FORUM_SESSION); // Determine the URL to redirect the user to. The hook "after_logout" // can be used by module writers to set a custom redirect URL. if (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) { $url = $_SERVER['HTTP_REFERER']; } else { $url = phorum_api_url_no_uri_auth(PHORUM_LIST_URL); } /* * [hook] * after_logout * * [description] * This hook can be used for performing tasks after a successful * user logout and for changing the page to which the user will be * redirected (by returning a different redirection URL). The user * data will still be available in <literal>$PHORUM["user"]</literal> * at this point. * * [category] * Login/Logout *