function phorum_pm_format($messages) { global $PHORUM; // Reformat message so it looks like a forum message (so we can run it // through phorum_api_message_format()) and do some PM specific formatting. foreach ($messages as $id => $message) { // The formatting code expects a message id. $messages[$id]["message_id"] = $id; // Read URLs need a folder id, so we only create that URL if // one's available. if (isset($message['pm_folder_id'])) { $folder_id = $message['pm_folder_id'] ? $message['pm_folder_id'] : $message['special_folder']; $messages[$id]["URL"]["READ"] = phorum_api_url(PHORUM_PM_URL, "page=read", "folder_id={$folder_id}", "pm_id={$id}"); } // The datestamp is only available for already posted messages. if (isset($message['datestamp'])) { $messages[$id]["raw_date"] = $message["datestamp"]; $messages[$id]["date"] = phorum_api_format_date($PHORUM["short_date_time"], $message["datestamp"]); } if (isset($message['meta']) && !is_array($message['meta'])) { $messages[$id]['meta'] = unserialize($message['meta']); } $messages[$id]["body"] = isset($message["message"]) ? $message["message"] : ""; $messages[$id]["email"] = ""; $messages[$id]["URL"]["PROFILE"] = phorum_api_url(PHORUM_PROFILE_URL, $message["user_id"]); $messages[$id]["recipient_count"] = 0; $messages[$id]["receive_count"] = 0; if (isset($message["recipients"]) && is_array($message["recipients"])) { $receive_count = 0; foreach ($message["recipients"] as $rcpt_id => $rcpt) { if (!empty($rcpt["read_flag"])) { $receive_count++; } if (!isset($rcpt["display_name"])) { $messages[$id]["recipients"][$rcpt_id]["display_name"] = $PHORUM["DATA"]["LANG"]["AnonymousUser"]; } else { $messages[$id]["recipients"][$rcpt_id]["display_name"] = empty($PHORUM["custom_display_name"]) ? htmlspecialchars($rcpt["display_name"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]) : $rcpt["display_name"]; $messages[$id]["recipients"][$rcpt_id]["URL"]["PROFILE"] = phorum_api_url(PHORUM_PROFILE_URL, $rcpt_id); } } $messages[$id]["recipient_count"] = count($message["recipients"]); $messages[$id]["receive_count"] = $receive_count; } } // Run the messages through the standard formatting code. $messages = phorum_api_format_messages($messages); // Reformat message back to a private message. foreach ($messages as $id => $message) { $messages[$id]["message"] = $message["body"]; unset($messages[$id]["body"]); } return $messages; }
// Process the arguments. $count = phorum_ajax_getarg('count', 'int>0', NULL); $forum_id = phorum_ajax_getarg('forum_id', 'int', 0); $thread_id = phorum_ajax_getarg('thread_id', 'int', 0); $threads_only = phorum_ajax_getarg('threads_only', 'boolean', 0); $format = phorum_ajax_getarg('format', 'string', 'html'); // Retrieve the recent messages. $recent = $PHORUM['DB']->get_recent_messages($count, 0, $forum_id, $thread_id, $threads_only); unset($recent["users"]); // Add newflag info to the messages. if ($PHORUM["DATA"]["LOGGEDIN"]) { $type = $threads_only ? PHORUM_NEWFLAGS_BY_THREAD : PHORUM_NEWFLAGS_BY_MESSAGE; $recent = phorum_api_newflags_apply_to_messages($recent, $type); } // Format the messages. $recent = phorum_api_format_messages($recent); // Apply the list hook to the messages. if (isset($PHORUM["hooks"]["list"])) { $recent = phorum_api_hook("list", $recent); } // Retrieve information about the forums for the active user. $allowed_forums = phorum_api_user_check_access(PHORUM_USER_ALLOW_READ, PHORUM_ACCESS_LIST); $forums = $PHORUM['DB']->get_forums($allowed_forums); foreach ($forums as $id => $forum) { $forums[$id]['url'] = phorum_get_url(PHORUM_LIST_URL, $forum['forum_id']); } // Add forum info to the messages and clean up data. foreach ($recent as $id => $message) { $recent[$id]['foruminfo'] = array('id' => $message['forum_id'], 'name' => $forums[$message['forum_id']]['name'], 'url' => $forums[$message['forum_id']]['url']); // Strip fields that the caller should not see in the return data. unset($recent[$id]['email']);
$checkvar = 1; // Get the threads $rows = array(); // get the thread set started $rows = $PHORUM['DB']->get_unapproved_list($forum, $showwaiting, $moddays); // loop through and read all the data in. foreach ($rows as $key => $row) { $numunapproved++; $rows[$key]['forumname'] = $foruminfo[$forum]['name']; $rows[$key]['checkvar'] = $checkvar; if ($checkvar) { $checkvar = 0; } $rows[$key]['forum_id'] = $forum; $rows[$key]["URL"]["READ"] = phorum_api_url(PHORUM_FOREIGN_READ_URL, $forum, $row["thread"], $row['message_id']); // we need to fake the forum_id here $PHORUM["forum_id"] = $forum; $rows[$key]["URL"]["APPROVE_MESSAGE"] = phorum_api_url(PHORUM_MODERATION_URL, PHORUM_APPROVE_MESSAGE, $row["message_id"], "prepost=1", "old_forum=" . $oldforum, "onlyunapproved=" . $showwaiting, "moddays=" . $moddays); $rows[$key]["URL"]["APPROVE_TREE"] = phorum_api_url(PHORUM_MODERATION_URL, PHORUM_APPROVE_MESSAGE_TREE, $row["message_id"], "prepost=1", "old_forum=" . $oldforum, "onlyunapproved=" . $showwaiting, "moddays=" . $moddays); $rows[$key]["URL"]["DELETE"] = phorum_api_url(PHORUM_MODERATION_URL, PHORUM_DELETE_TREE, $row["message_id"], "prepost=1", "old_forum=" . $oldforum, "onlyunapproved=" . $showwaiting, "moddays=" . $moddays); $PHORUM["forum_id"] = $oldforum; $rows[$key]["raw_short_datestamp"] = $row["datestamp"]; $rows[$key]["short_datestamp"] = phorum_api_format_date($PHORUM["short_date_time"], $row["datestamp"]); } $rows = phorum_api_format_messages($rows); $PHORUM['DATA']['PREPOST'] = array_merge($PHORUM['DATA']['PREPOST'], $rows); } if (!$numunapproved) { $PHORUM["DATA"]["UNAPPROVEDMESSAGE"] = $PHORUM["DATA"]["LANG"]["NoUnapprovedMessages"]; } $template = "cc_prepost";
/** * Collect the data that is used for the feed and pass this information * on to the requested output adapter. * * @param string $adapter * The output adapter to use. The adapters that are available are: * - rss * - atom * - html * - js * * @param integer $source_type * The type of source. This is one of: * - {@link PHORUM_FEED_VROOT} * - {@link PHORUM_FEED_FORUM} * - {@link PHORUM_FEED_THREAD} * * @param integer $id * This parameter has a different meaning for each $source_type: * - For {@link PHORUM_FEED_VROOT}: the forum_id of the (v)root. * - For {@link PHORUM_FEED_FORUM}: the forum_id of the forum. * - For {@link PHORUM_FEED_THREAD}: the message_id of the thread. * * @param integer $count * The number of messages to include in the feed. * * @param boolean $replies * TRUE to include reply messages in the feed, FALSE otherwise. * This parameter is forced to TRUE for {@link PHORUM_FEED_THREAD}. */ function phorum_api_feed($adapter, $source_type, $id, $count, $replies) { global $PHORUM; settype($id, 'int'); settype($count, 'int'); settype($source_type, 'int'); $replies = $replies ? 1 : 0; $adapter = basename($adapter); if (!preg_match('/^[a-z][\\w_]*$/', $adapter)) { trigger_error('phorum_api_feed(): Illegal feed adapter name ' . '"' . htmlspecialchars($adapter) . '" used', E_USER_ERROR); } if (!file_exists(PHORUM_PATH . '/include/api/feed/' . $adapter . '.php')) { trigger_error('phorum_api_feed(): Unknown feed adapter ' . '"' . htmlspecialchars($adapter) . '" used', E_USER_ERROR); } // ---------------------------------------------------------------------- // Prepare the data for the requested feed type // ---------------------------------------------------------------------- // Prepare data for handling a vroot feed. if ($source_type === PHORUM_FEED_VROOT) { $forums = phorum_api_forums_by_vroot($id); $thread_id = NULL; $forum_ids = array_keys($forums); $cache_part = implode(',', array_keys($forums)); } elseif ($source_type === PHORUM_FEED_FORUM) { if ($PHORUM['forum_id'] == $id) { $forum = $PHORUM; // contains all required data already } else { $forum = phorum_api_forums_by_forum_id($id); if (empty($forum)) { trigger_error("phorum_api_feed(): Forum for forum_id \"{$id}\" not found.", E_USER_ERROR); } } $forums = array($id => $forum); $thread_id = NULL; $forum_ids = array_keys($forums); $cache_part = $forum['forum_id']; } elseif ($source_type === PHORUM_FEED_THREAD) { // When a feed for a thread is requested, we always include the // reply messages for that thread in the feed. $replies = 1; // Retrieve the thread starter message. $thread = $PHORUM['DB']->get_message($id); if (empty($thread)) { trigger_error("phorum_api_feed(): Thread for message_id \"{$id}\" not found.", E_USER_ERROR); } if (!empty($thread['parent_id'])) { trigger_error("phorum_api_feed(): Message for message_id \"{$id}\" is not " . "the start message of a thread.", E_USER_ERROR); } $thread_id = $id; $forum_ids = NULL; $cache_part = $id; } else { trigger_error("phorum_api_feed(): Illegal value \"{$source_type}\" used " . "for parameter \$source_type.", E_USER_ERROR); } // ---------------------------------------------------------------------- // Retrieve the data for the requested feed // ---------------------------------------------------------------------- $data = NULL; $content_type = NULL; // Try to retrieve the data from cache. if (!empty($PHORUM['cache_rss'])) { // Build the cache key that uniquely identifies the requested feed. $cache_key = $PHORUM['user']['user_id'] . '|' . $adapter . '|' . $source_type . '|' . $cache_part . '|' . $replies . '|' . $count; $cache = phorum_api_cache_get('feed', $cache_key); if (!empty($cache)) { list($data, $content_type) = $cache; } } // No data from cache. Load the recent threads / messages // directly from the database and generate the feed data. if (empty($data)) { // ---------------------------------------------------------------- // Retrieve the messages to show // ---------------------------------------------------------------- $messages = $PHORUM['DB']->get_recent_messages($count, 0, $forum_ids, $thread_id, $replies ? LIST_RECENT_MESSAGES : LIST_RECENT_THREADS); // Temporarily, remove the user list from the messages array. $users = $messages['users']; unset($messages['users']); // Apply the "read" hook(s) to the messages. if (isset($PHORUM['hooks']['read'])) { $messages = phorum_api_hook('read', $messages); } // Apply formatting to the messages. $messages = phorum_api_format_messages($messages); // Put the array of users back in the messages array. $messages['users'] = $users; // ---------------------------------------------------------------- // Setup the feed URL, title and description based on // the type of feed that was requested. // ---------------------------------------------------------------- if ($source_type === PHORUM_FEED_VROOT) { $feed_url = phorum_api_url(PHORUM_INDEX_URL); $feed_title = strip_tags($PHORUM['DATA']['TITLE']); $feed_description = !empty($PHORUM['description']) ? $PHORUM['description'] : ''; } if ($source_type === PHORUM_FEED_FORUM) { $feed_url = phorum_api_url(PHORUM_LIST_URL); /** * @todo The formatting of the forum base feed data should * be based on the data in $forum and not the common.php * $PHORUM contents. This is left as is for now, because * the wrong data will only be shown for threads that * were moved to a different forum. */ $feed_title = strip_tags($PHORUM['DATA']['TITLE'] . ' - ' . $PHORUM['DATA']['NAME']); $feed_description = strip_tags($PHORUM['DATA']['DESCRIPTION']); } if ($source_type === PHORUM_FEED_THREAD) { // Retrieve the information for the forum to which the thread // belongs. Normally, this should be in $PHORUM already, but // let's make sure that the caller is using the correct forum id // in the URL here (since the thread might have been moved to // a different forum). $forum_id = $thread['forum_id']; if ($PHORUM['forum_id'] == $forum_id) { $forum = $PHORUM; // contains all required data already } else { $forum = phorum_api_forums_by_forum_id($forum_id); if (empty($forum)) { trigger_error("phorum_api_feed(): Forum for forum_id \"{$id}\" not found.", E_USER_ERROR); } } $forums = array($forum_id => $forum); $feed_url = phorum_api_url(PHORUM_FOREIGN_READ_URL, $thread['forum_id'], $thread_id, $thread_id); $feed_title = strip_tags($thread['subject']); $feed_description = strip_tags($thread['body']); } // ---------------------------------------------------------------- // All data has been collected. Now the feed is generated. // ---------------------------------------------------------------- require_once PHORUM_PATH . '/include/api/feed/' . $adapter . '.php'; $adapter_function = 'phorum_api_feed_' . $adapter; list($data, $content_type) = $adapter_function($messages, $forums, $feed_url, $feed_title, $feed_description, $replies); // Store the feed data in the cache for future use. if (!empty($PHORUM['cache_rss'])) { phorum_api_cache_put('feed', $cache_key, array($data, $content_type, 600)); } } // ---------------------------------------------------------------------- // Output the feed data to the client // ---------------------------------------------------------------------- header("Content-Type: {$content_type}"); print $data; /* * [hook] * feed_sent * * [description] * This hook is called whenever the feed has been sent to the client * (regardless of the cache setting). This can be used to add internal * server side tracking code. * * [category] * Feed * * [when] * Feed sent to the client * * [input] * None * * [output] * None * * [example] * <hookcode> * function phorum_mod_foo_feed_after () * { * # E.g. do server side tracking * @file_get_contents('your tracking service'); * } * </hookcode> */ phorum_api_hook('feed_sent'); // Exit explicitly here, for not giving back control to portable and // embedded Phorum setups. exit(0); }
if (isset($PHORUM["hooks"]["report"])) { $mail_data = phorum_api_hook("report", $mail_data); } phorum_api_mail($mail_users, $mail_data); $PHORUM["DATA"]["URL"]["REDIRECT"] = phorum_api_url(PHORUM_FOREIGN_READ_URL, $message["forum_id"], $message["thread"], $message['message_id']); $PHORUM["DATA"]["BACKMSG"] = $PHORUM["DATA"]["LANG"]["BackToThread"]; $PHORUM["DATA"]["OKMSG"] = $PHORUM["DATA"]["LANG"]["ReportPostSuccess"]; $template = "message"; $report = true; } } else { $PHORUM["DATA"]["ReportPostMessage"] = $PHORUM["DATA"]["LANG"]['ReportPostNotAllowed']; } } // format message list($message) = phorum_api_format_messages(array($message)); $PHORUM["DATA"]["PostSubject"] = $message["subject"]; $PHORUM["DATA"]["PostAuthor"] = $message["author"]; $PHORUM["DATA"]["PostBody"] = $message["body"]; $PHORUM["DATA"]["raw_PostDate"] = $message["datestamp"]; $PHORUM["DATA"]["PostDate"] = phorum_api_format_date($PHORUM["short_date_time"], $message["datestamp"]); $PHORUM["DATA"]["ReportURL"] = phorum_api_url(PHORUM_REPORT_URL, $message_id); // if the report was not successfully sent, keep whatever explanation they gave already if (isset($_POST["explanation"]) && !$report) { $PHORUM["DATA"]["explanation"] = $_POST["explanation"]; } else { $PHORUM["DATA"]["explanation"] = ""; } } else { $PHORUM["DATA"]["ERROR"] = $PHORUM['DATA']['LANG']['MessageNotFound']; $template = 'message';
The type of formatting to apply to the message. This can be one of "html" (default), "text" and "collapsed". EXAMPLE JSON REQUESTS { call : "format", body : "[b]Some text to format[/b]"} RETURN VALUE An object containing the formatted subject and body. For above example, this would be: { body : "<b>Some text to format</b>", subject : "" } ERRORS The call will return an error if one of the arguments is not in the right format. AUTHOR Maurice Makaay <*****@*****.**> */ if (!defined('PHORUM')) { return; } require_once PHORUM_PATH . '/include/api/format/messages.php'; // Process the arguments. $subject = phorum_ajax_getarg('subject', 'string', ''); $body = phorum_ajax_getarg('body', 'string', ''); // Format the strings. $data = phorum_api_format_messages(array(1 => array('message_id' => 1, 'subject' => $subject, 'body' => $body))); // Apply the read hook to the messages. if (isset($PHORUM["hooks"]["read"])) { $data = phorum_api_hook("read", $data); } // Return the results. phorum_ajax_return(array('subject' => $data[1]['subject'], 'body' => $data[1]['body']));
/** * @deprecated Replaced by {@link phorum_api_format_messages()}. */ function phorum_format_messages($messages, $author_spec = NULL) { require_once PHORUM_PATH . '/include/api/format/messages.php'; return phorum_api_format_messages($messages, $author_spec); }
function phorum_setup_announcements() { global $PHORUM; // This variable will be used to store the formatted announcements. $PHORUM['DATA']['MOD_ANNOUNCEMENTS'] = ''; // Check if we are on a page on which the announcements have to be shown. if (phorum_page == 'index') { // Hide the announcements, unless enabled for "index". $hide = empty($PHORUM["mod_announcements"]["pages"]["index"]); // Show announcements for the root page if "home" is enabled. if ($PHORUM['vroot'] == $PHORUM['forum_id'] && !empty($PHORUM["mod_announcements"]["pages"]["home"])) { $hide = FALSE; } if ($hide) { return; } } else { if (empty($PHORUM["mod_announcements"]["pages"][phorum_page])) { return; } } // Check if we are on a page on which the announcements have to be shown. if (!empty($PHORUM["mod_announcements"]["pages"]["home"])) { if ($PHORUM['vroot'] != $PHORUM['forum_id'] || phorum_page != 'index') { return; } } else { if (empty($PHORUM["mod_announcements"]["pages"][phorum_page])) { return; } } // Check if we need to show announcements. $ann_forum_id = NULL; // Inside a vroot, where we have a vroot configuration for the forum // to use for announcements and the current forum is not that // announcement forum. if ($PHORUM['vroot'] > 0 && !empty($PHORUM["mod_announcements"]["vroot"][$PHORUM['vroot']]) && $PHORUM["forum_id"] != $PHORUM["mod_announcements"]["vroot"][$PHORUM['vroot']]) { $ann_forum_id = $PHORUM["mod_announcements"]["vroot"][$PHORUM['vroot']]; // Inside the top level folder, where we have a forum that is configured // to be used for announcements and the current forum is not that // announcement forum. } elseif ($PHORUM['vroot'] == 0 && !empty($PHORUM["mod_announcements"]["forum_id"]) && $PHORUM["forum_id"] != $PHORUM["mod_announcements"]["forum_id"]) { $ann_forum_id = $PHORUM["mod_announcements"]["forum_id"]; } // If no announcement forum_id is found, no announcements // have to be shown. if ($ann_forum_id === NULL) { return; } // Retrieve the last number of posts from the announcement forum. $messages = $PHORUM['DB']->get_recent_messages($PHORUM["mod_announcements"]["number_to_show"], 0, $ann_forum_id, 0, true); unset($messages["users"]); // No announcements to show? Then we are done. if (count($messages) == 0) { return; } // Read the newflags information for authenticated users. $newinfo = NULL; if ($PHORUM["DATA"]["LOGGEDIN"]) { $newflagkey = $ann_forum_id . "-" . $PHORUM['user']['user_id']; if ($PHORUM['cache_newflags']) { $newinfo = phorum_api_cache_get('newflags', $newflagkey, $PHORUM['cache_version']); } if ($newinfo == NULL) { $newinfo = $PHORUM['DB']->newflag_get_flags($ann_forum_id); if ($PHORUM['cache_newflags']) { phorum_api_cache_put('newflags', $newflagkey, $newinfo, 86400, $PHORUM['cache_version']); } } } require_once PHORUM_PATH . '/include/api/format/messages.php'; // Process the announcements. foreach ($messages as $message) { // Skip this message if it's older than the number of days that was // configured in the settings screen. if (!empty($PHORUM["mod_announcements"]["days_to_show"]) && $message["datestamp"] < time() - $PHORUM["mod_announcements"]["days_to_show"] * 86400) { continue; } // Check if there are new messages in the thread. if (isset($newinfo)) { $new = 0; foreach ($message["meta"]["message_ids"] as $id) { if (!isset($newinfo[$id]) && $id > $newinfo['min_id']) { $new = 1; break; } } // There are new messages. Setup the template data for showing // a new flag. if ($new) { $message["new"] = $new ? $PHORUM["DATA"]["LANG"]["newflag"] : NULL; $message["URL"]["NEWPOST"] = phorum_api_url(PHORUM_FOREIGN_READ_URL, $message["forum_id"], $message["thread"], "gotonewpost"); } elseif ($PHORUM["mod_announcements"]["only_show_unread"]) { continue; } } // Setup template data for the message. unset($message['body']); $message["lastpost"] = phorum_api_format_date($PHORUM["short_date_time"], $message["modifystamp"]); $message["raw_datestamp"] = $message["datestamp"]; $message["datestamp"] = phorum_api_format_date($PHORUM["short_date_time"], $message["datestamp"]); $message["URL"]["READ"] = phorum_api_url(PHORUM_FOREIGN_READ_URL, $message["forum_id"], $message["message_id"]); $PHORUM["DATA"]["ANNOUNCEMENTS"][] = $message; } // If all announcements were skipped, then we are done. if (!isset($PHORUM["DATA"]["ANNOUNCEMENTS"])) { return; } // format / clean etc. the messages found $PHORUM["DATA"]["ANNOUNCEMENTS"] = phorum_api_format_messages($PHORUM["DATA"]["ANNOUNCEMENTS"]); // Build the announcements code. ob_start(); include phorum_api_template("announcements::announcements"); $PHORUM['DATA']['MOD_ANNOUNCEMENTS'] = ob_get_contents(); ob_end_clean(); }
$PHORUM['DATA']['SHOW_EMAIL_HIDE'] = empty($PHORUM['hide_email_addr']) ? 1 : 0; // If pm email notifications are enabled, then give the user a chance // to disable it. $PHORUM['DATA']['SHOW_PM_EMAIL_NOTIFY'] = !empty($PHORUM["allow_pm_email_notify"]); // The form action for the common form. $PHORUM["DATA"]["URL"]["ACTION"] = phorum_api_url(PHORUM_CONTROLCENTER_ACTION_URL); // fill the breadcrumbs-info $PHORUM['DATA']['BREADCRUMBS'][] = array('URL' => $PHORUM['DATA']['URL']['REGISTERPROFILE'], 'TEXT' => $PHORUM['DATA']['LANG']['MyProfile'], 'TYPE' => 'control'); $user = $PHORUM['user']; // Security messures. unset($user["password"]); unset($user["password_temp"]); unset($user["permissions"]); // Fake a message here so we can run the sig through format_message. $fake_messages = array(array("author" => "", "email" => "", "subject" => "", "body" => $user["signature"])); $fake_messages = phorum_api_format_messages($fake_messages); $user["signature_formatted"] = $fake_messages[0]["body"]; // Format the user signature using standard message body formatting // or HTML escape it $user["signature"] = htmlspecialchars($user["signature"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]); // HTML escape all other fields that are used in the control center. foreach ($user as $key => $val) { if (is_array($val) || substr($key, 0, 9) == 'signature') { continue; } $user[$key] = htmlspecialchars($user[$key], ENT_COMPAT, $PHORUM['DATA']['HCHARSET']); } // Initialize any custom profile fields that are not present. if (!empty($PHORUM["CUSTOM_FIELDS"][PHORUM_CUSTOM_FIELD_USER])) { foreach ($PHORUM["CUSTOM_FIELDS"][PHORUM_CUSTOM_FIELD_USER] as $id => $field) { if ($id === 'num_fields' || !empty($field['deleted'])) {
*/ // run read mods if (isset($PHORUM["hooks"]["read"])) { $messages = phorum_api_hook("read", $messages, $message_id); } // increment viewcount if enabled if ($PHORUM['count_views'] && (!isset($PHORUM['status']) || $PHORUM["status"] != PHORUM_MASTER_STATUS_READ_ONLY)) { // increment viewcount per thread if enabled $inc_thread_id = NULL; if (!empty($PHORUM['count_views_per_thread'])) { $inc_thread_id = $thread; } $PHORUM['DB']->increment_viewcount($message_id, $inc_thread_id); } // format messages $messages = phorum_api_format_messages($messages); // set up the data // this is the message that is the first in the thread $PHORUM["DATA"]["TOPIC"] = $messages[$thread]; if ($page > 1) { unset($messages[$thread]); } // this is the message that we are viewing in the threaded view. if ($PHORUM["threaded_read"]) { $PHORUM["DATA"]["MESSAGE"] = $messages[$message_id]; } // this is all messages on the page $PHORUM["DATA"]["MESSAGES"] = $messages; // No htmlspecialchars() needed. The subject is already escaped. // Strip HTML tags from the HTML title. There might be HTML in // here, because of modules adding images and formatting.
define('PREVIEW_NO_ATTACHMENT_CLICK', "javascript:alert('" . $PHORUM["DATA"]["LANG"]["PreviewNoClickAttach"] . "')"); // Create the URL and formatted size for attachment files. foreach ($previewmessage["attachments"] as $nr => $data) { $previewmessage["attachments"][$nr]["url"] = phorum_api_url(PHORUM_FILE_URL, "file={$data['file_id']}", "filename=" . urlencode($data['name'])); $previewmessage["attachments"][$nr]["download_url"] = phorum_api_url(PHORUM_FILE_URL, "file={$data['file_id']}", "filename=" . urlencode($data['name']), "download=1"); $previewmessage["attachments"][$nr]["size"] = phorum_api_format_filesize($data["size"]); } } // Fill the author for new postings with the display name // for authenticated users, if editing the author // field is not allowed. if (($mode == "post" || $mode == "reply") && !$PHORUM["DATA"]["OPTION_ALLOWED"]["edit_author"] && $PHORUM["DATA"]["LOGGEDIN"]) { $previewmessage["author"] = $message["author"] = $PHORUM["user"]["display_name"]; } // Format the message using the default formatting. $formatted = phorum_api_format_messages(array($previewmessage['message_id'] => $previewmessage)); $previewmessage = $formatted[$previewmessage['message_id']]; // Recount the number of attachments. Formatting mods might have changed // the number of attachments we have to display using default formatting. // Also, remove the attachments that are not visible from the preview data. $attach_count = 0; if (isset($previewmessage["attachments"])) { foreach ($previewmessage["attachments"] as $id => $attachment) { if ($attachment["keep"]) { $attach_count++; } else { unset($previewmessage["attachments"][$id]); } } } if ($attach_count) {
$PHORUM["DATA"]["ATTACHMENTS"] = true; $row["attachments"] = $row["meta"]["attachments"]; // unset($row["meta"]["attachments"]); foreach ($row["attachments"] as $key => $file) { $row["attachments"][$key]["size"] = phorum_api_format_filesize($file["size"]); $row["attachments"][$key]["name"] = htmlspecialchars($file['name'], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]); $row["attachments"][$key]["url"] = str_replace(array('%file_id%', '%file_name%'), array($file['file_id'], urlencode($file['name'])), $attachment_url_template); } } $rows[$id] = $row; } } // The list page needs additional formatting for the recent author data $recent_author_spec = array("recent_user_id", "recent_author", NULL, "recent_author", "RECENT_AUTHOR_PROFILE"); // format messages $rows = phorum_api_format_messages($rows, array($recent_author_spec)); // set up the data $PHORUM["DATA"]["MESSAGES"] = $rows; if ($PHORUM["DATA"]["LOGGEDIN"]) { $PHORUM["DATA"]["URL"]["MARK_READ"] = phorum_api_url(PHORUM_LIST_URL, $PHORUM["forum_id"], "markread"); } if ($PHORUM["DATA"]["MODERATOR"]) { $PHORUM["DATA"]["URL"]["UNAPPROVED"] = phorum_api_url(PHORUM_CONTROLCENTER_URL, "panel=messages"); } // add feed url if (isset($PHORUM['use_rss']) && $PHORUM['use_rss']) { $PHORUM['DATA']['FEEDS'] = array(array('URL' => phorum_api_url(PHORUM_FEED_URL, $PHORUM['forum_id'], 'type=' . $PHORUM['default_feed']), 'TITLE' => $PHORUM['DATA']['FEED'] . ' (' . strtolower($PHORUM['DATA']['LANG']['Threads']) . ')'), array("URL" => phorum_api_url(PHORUM_FEED_URL, $PHORUM['forum_id'], 'replies=1', 'type=' . $PHORUM['default_feed']), "TITLE" => $PHORUM['DATA']['FEED'] . ' (' . strtolower($PHORUM['DATA']['LANG']['Threads'] . ' + ' . $PHORUM['DATA']['LANG']['replies']) . ')')); $PHORUM["DATA"]["URL"]["FEED"] = phorum_api_url(PHORUM_FEED_URL, $PHORUM['forum_id'], 'replies=1', 'type=' . $PHORUM['default_feed']); } // include the correct template if ($PHORUM["threaded_list"]) {
$search_request_data = phorum_api_hook('search_action', $search_request_data); } // only continue if our hook was either not run or didn't return a stop request if ($search_request_data['continue']) { $arr = $PHORUM['DB']->search($phorum_search, $phorum_author, $PHORUM["args"]["match_threads"], $offset, $PHORUM["list_length"], $PHORUM["args"]["match_type"], $PHORUM["args"]["match_dates"], $PHORUM["args"]["match_forum"]); $raw_body = 0; } else { $arr['rows'] = $search_request_data['results']; $arr['count'] = $search_request_data['totals']; $raw_body = $search_request_data['raw_body']; } if (count($arr["rows"])) { $match_number = $start + 1; $forums = phorum_api_forums_by_vroot($PHORUM["vroot"], PHORUM_FLAG_INCLUDE_INACTIVE); if (!$raw_body) { $arr["rows"] = phorum_api_format_messages($arr["rows"]); } foreach ($arr["rows"] as $key => $row) { $arr["rows"][$key]["number"] = $match_number; $arr["rows"][$key]["URL"]["READ"] = phorum_api_url(PHORUM_FOREIGN_READ_URL, $row["forum_id"], $row["thread"], $row["message_id"]); // strip HTML & BB Code if (!$raw_body) { $body = phorum_api_format_strip($arr["rows"][$key]["body"]); $arr["rows"][$key]["short_body"] = mb_substr($body, 0, 400, $PHORUM["DATA"]["HCHARSET"]); } $arr["rows"][$key]["raw_datestamp"] = $row["datestamp"]; $arr["rows"][$key]["datestamp"] = phorum_api_format_relative_date($row["datestamp"]); $forum_ids[$row["forum_id"]] = $row["forum_id"]; $match_number++; } foreach ($arr["rows"] as $key => $row) {
phorum_api_cache_put('newflags', $newflagkey, $PHORUM['user']['newinfo'][$data["forum_id"]], 86400, $forums[$data["forum_id"]]['cache_version']); } } } $new = array(); foreach ($data["meta"]["message_ids"] as $mid) { if (!isset($PHORUM['user']['newinfo'][$data["forum_id"]][$mid]) && $mid > $PHORUM['user']['newinfo'][$data["forum_id"]]['min_id']) { $new[] = $mid; } } if (count($new)) { $data["new"] = $PHORUM["DATA"]["LANG"]["newflag"]; } $subscr_array_final[] = $data; } // Additional formatting for the recent author data. $recent_author_spec = array("recent_user_id", "recent_author", NULL, "recent_author", "RECENT_AUTHOR_PROFILE"); $subscr_array_final = phorum_api_format_messages($subscr_array_final, array($recent_author_spec)); $count = 0; foreach ($subscr_array_final as $id => $message) { if (isset($forums[$message['forum_id']])) { $forum = $forums[$message['forum_id']]; $subscr_array_final[$id]['ALLOW_EMAIL_NOTIFY'] = !empty($forum['allow_email_notify']); if ($subscr_array_final[$id]['ALLOW_EMAIL_NOTIFY']) { $count++; } } } $PHORUM["DATA"]["ALLOW_EMAIL_NOTIFY_COUNT"] = $count; $PHORUM['DATA']['TOPICS'] = $subscr_array_final; $template = "cc_subscriptions";