diff options
Diffstat (limited to 'phpBB/includes/mcp/mcp_topic.php')
-rw-r--r-- | phpBB/includes/mcp/mcp_topic.php | 214 |
1 files changed, 145 insertions, 69 deletions
diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index cdb88bf2bf..ba86484040 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -1,9 +1,13 @@ <?php /** * -* @package mcp -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ @@ -20,16 +24,17 @@ if (!defined('IN_PHPBB')) */ function mcp_topic_view($id, $mode, $action) { - global $phpEx, $phpbb_root_path, $config; - global $template, $db, $user, $auth, $cache, $phpbb_container; + global $phpEx, $phpbb_root_path, $config, $request; + global $template, $db, $user, $auth, $phpbb_container, $phpbb_dispatcher; - $url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . extra_url()); + $url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . phpbb_extra_url()); - $user->add_lang('viewtopic'); + /* @var $pagination \phpbb\pagination */ $pagination = $phpbb_container->get('pagination'); + $user->add_lang('viewtopic'); - $topic_id = request_var('t', 0); - $topic_info = get_topic_data(array($topic_id), false, true); + $topic_id = $request->variable('t', 0); + $topic_info = phpbb_get_topic_data(array($topic_id), false, true); if (!sizeof($topic_info)) { @@ -39,16 +44,16 @@ function mcp_topic_view($id, $mode, $action) $topic_info = $topic_info[$topic_id]; // Set up some vars - $icon_id = request_var('icon', 0); - $subject = utf8_normalize_nfc(request_var('subject', '', true)); - $start = request_var('start', 0); - $sort_days_old = request_var('st_old', 0); - $forum_id = request_var('f', 0); - $to_topic_id = request_var('to_topic_id', 0); - $to_forum_id = request_var('to_forum_id', 0); + $icon_id = $request->variable('icon', 0); + $subject = $request->variable('subject', '', true); + $start = $request->variable('start', 0); + $sort_days_old = $request->variable('st_old', 0); + $forum_id = $request->variable('f', 0); + $to_topic_id = $request->variable('to_topic_id', 0); + $to_forum_id = $request->variable('to_forum_id', 0); $sort = isset($_POST['sort']) ? true : false; - $submitted_id_list = request_var('post_ids', array(0)); - $checked_ids = $post_id_list = request_var('post_id_list', array(0)); + $submitted_id_list = $request->variable('post_ids', array(0)); + $checked_ids = $post_id_list = $request->variable('post_id_list', array(0)); // Resync Topic? if ($action == 'resync') @@ -110,17 +115,18 @@ function mcp_topic_view($id, $mode, $action) $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); - mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); + phpbb_mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); - $limit_time_sql = ($sort_days) ? 'AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; + /* @var $phpbb_content_visibility \phpbb\content_visibility */ $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + $limit_time_sql = ($sort_days) ? 'AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; if ($total == -1) { $total = $phpbb_content_visibility->get_count('topic_posts', $topic_info, $topic_info['forum_id']); } - $posts_per_page = max(0, request_var('posts_per_page', intval($config['posts_per_page']))); + $posts_per_page = max(0, $request->variable('posts_per_page', intval($config['posts_per_page']))); if ($posts_per_page == 0) { $posts_per_page = $total; @@ -143,23 +149,13 @@ function mcp_topic_view($id, $mode, $action) $result = $db->sql_query_limit($sql, $posts_per_page, $start); $rowset = $post_id_list = array(); - $bbcode_bitfield = ''; while ($row = $db->sql_fetchrow($result)) { $rowset[] = $row; $post_id_list[] = $row['post_id']; - $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); } $db->sql_freeresult($result); - if ($bbcode_bitfield !== '') - { - include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); - $bbcode = new bbcode(base64_encode($bbcode_bitfield)); - } - - $topic_tracking_info = array(); - // Get topic tracking info if ($config['load_db_lastread']) { @@ -175,11 +171,9 @@ function mcp_topic_view($id, $mode, $action) $has_unapproved_posts = $has_deleted_posts = false; // Grab extensions - $extensions = $attachments = array(); + $attachments = array(); if ($topic_info['topic_attachment'] && sizeof($post_id_list)) { - $extensions = $cache->obtain_attach_extensions($topic_info['forum_id']); - // Get attachments... if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id'])) { @@ -198,6 +192,30 @@ function mcp_topic_view($id, $mode, $action) } } + /** + * Event to modify the post data for the MCP topic review before assigning the posts + * + * @event core.mcp_topic_modify_post_data + * @var array attachments List of attachments post_id => array of attachments + * @var int forum_id The forum ID we are currently in + * @var int id ID of the tab we are displaying + * @var string mode Mode of the MCP page we are displaying + * @var array post_id_list Array with post ids we are going to display + * @var array rowset Array with the posts data + * @var int topic_id The topic ID we are currently reviewing + * @since 3.1.7-RC1 + */ + $vars = array( + 'attachments', + 'forum_id', + 'id', + 'mode', + 'post_id_list', + 'rowset', + 'topic_id', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_topic_modify_post_data', compact($vars))); + foreach ($rowset as $i => $row) { $message = $row['post_text']; @@ -212,7 +230,7 @@ function mcp_topic_view($id, $mode, $action) parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count); } - if ($row['post_visibility'] == ITEM_UNAPPROVED) + if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) { $has_unapproved_posts = true; } @@ -224,7 +242,7 @@ function mcp_topic_view($id, $mode, $action) $post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false; - $template->assign_block_vars('postrow', array( + $post_row = array( 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), @@ -239,15 +257,47 @@ function mcp_topic_view($id, $mode, $action) 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id'])), - 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $topic_info['forum_id'])), + 'S_POST_UNAPPROVED' => (($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $topic_info['forum_id'])), 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED && $auth->acl_get('m_approve', $topic_info['forum_id'])), 'S_CHECKED' => (($submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list)) || in_array(intval($row['post_id']), $checked_ids)) ? true : false, 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, 'U_POST_DETAILS' => "$url&i=$id&p={$row['post_id']}&mode=post_details" . (($forum_id) ? "&f=$forum_id" : ''), 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '', - 'U_MCP_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '') + 'U_MCP_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '', + ); + + /** + * Event to modify the template data block for topic reviews in the MCP + * + * @event core.mcp_topic_review_modify_row + * @var int id ID of the tab we are displaying + * @var string mode Mode of the MCP page we are displaying + * @var int topic_id The topic ID we are currently reviewing + * @var int forum_id The forum ID we are currently in + * @var int start Start item of this page + * @var int current_row_number Number of the post on this page + * @var array post_row Template block array of the current post + * @var array row Array with original post and user data + * @var array topic_info Array with topic data + * @var int total Total posts count + * @since 3.1.4-RC1 + */ + $vars = array( + 'id', + 'mode', + 'topic_id', + 'forum_id', + 'start', + 'current_row_number', + 'post_row', + 'row', + 'topic_info', + 'total', ); + extract($phpbb_dispatcher->trigger_event('core.mcp_topic_review_modify_row', compact($vars))); + + $template->assign_block_vars('postrow', $post_row); // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments[$row['post_id']])) @@ -274,7 +324,7 @@ function mcp_topic_view($id, $mode, $action) // Has the user selected a topic for merge? if ($to_topic_id) { - $to_topic_info = get_topic_data(array($to_topic_id), 'm_merge'); + $to_topic_info = phpbb_get_topic_data(array($to_topic_id), 'm_merge'); if (!sizeof($to_topic_info)) { @@ -352,11 +402,11 @@ function mcp_topic_view($id, $mode, $action) */ function split_topic($action, $topic_id, $to_forum_id, $subject) { - global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $config; + global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $config, $phpbb_log, $request; - $post_id_list = request_var('post_id_list', array(0)); - $forum_id = request_var('forum_id', 0); - $start = request_var('start', 0); + $post_id_list = $request->variable('post_id_list', array(0)); + $forum_id = $request->variable('forum_id', 0); + $start = $request->variable('start', 0); if (!sizeof($post_id_list)) { @@ -364,13 +414,13 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) return; } - if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_split'))) + if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_split'))) { return; } $post_id = $post_id_list[0]; - $post_info = get_post_data(array($post_id)); + $post_info = phpbb_get_post_data(array($post_id)); if (!sizeof($post_info)) { @@ -394,7 +444,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) return; } - $forum_info = get_forum_data(array($to_forum_id), 'f_post'); + $forum_info = phpbb_get_forum_data(array($to_forum_id), 'f_post'); if (!sizeof($forum_info)) { @@ -410,7 +460,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) return; } - $redirect = request_var('redirect', build_url(array('quickmod'))); + $redirect = $request->variable('redirect', build_url(array('quickmod'))); $s_hidden_fields = build_hidden_fields(array( 'i' => 'main', @@ -423,9 +473,8 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) 'redirect' => $redirect, 'subject' => $subject, 'to_forum_id' => $to_forum_id, - 'icon' => request_var('icon', 0)) + 'icon' => $request->variable('icon', 0)) ); - $success_msg = $return_link = ''; if (confirm_box(true)) { @@ -434,7 +483,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); - mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); + phpbb_mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : ''; @@ -462,7 +511,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) while ($row = $db->sql_fetchrow($result)) { // If split from selected post (split_beyond), we split the unapproved items too. - if ($row['post_visibility'] == ITEM_UNAPPROVED && !$auth->acl_get('m_approve', $row['forum_id'])) + if (($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && !$auth->acl_get('m_approve', $row['forum_id'])) { // continue; } @@ -486,7 +535,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) trigger_error('NO_POST_SELECTED'); } - $icon_id = request_var('icon', 0); + $icon_id = $request->variable('icon', 0); $sql_ary = array( 'forum_id' => $to_forum_id, @@ -501,11 +550,19 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) $to_topic_id = $db->sql_nextid(); move_posts($post_id_list, $to_topic_id); - $topic_info = get_topic_data(array($topic_id)); + $topic_info = phpbb_get_topic_data(array($topic_id)); $topic_info = $topic_info[$topic_id]; - add_log('mod', $to_forum_id, $to_topic_id, 'LOG_SPLIT_DESTINATION', $subject); - add_log('mod', $forum_id, $topic_id, 'LOG_SPLIT_SOURCE', $topic_info['topic_title']); + $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SPLIT_DESTINATION', false, array( + 'forum_id' => $to_forum_id, + 'topic_id' => $to_topic_id, + $subject + )); + $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SPLIT_SOURCE', false, array( + 'forum_id' => $forum_id, + 'topic_id' => $topic_id, + $topic_info['topic_title'] + )); // Change topic title of first post $sql = 'UPDATE ' . POSTS_TABLE . " @@ -559,11 +616,11 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) $success_msg = 'TOPIC_SPLIT_SUCCESS'; // Update forum statistics - set_config_count('num_topics', 1, true); + $config->increment('num_topics', 1, false); // Link back to both topics $return_link = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']) . '">', '</a>') . '<br /><br />' . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>'); - $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); + $redirect = $request->variable('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); $redirect = reapply_sid($redirect); meta_refresh(3, $redirect); @@ -580,7 +637,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) */ function merge_posts($topic_id, $to_topic_id) { - global $db, $template, $user, $phpEx, $phpbb_root_path, $auth; + global $db, $template, $user, $phpEx, $phpbb_root_path, $phpbb_log, $request; if (!$to_topic_id) { @@ -588,18 +645,26 @@ function merge_posts($topic_id, $to_topic_id) return; } - $topic_data = get_topic_data(array($to_topic_id), 'm_merge'); + $sync_topics = array($topic_id, $to_topic_id); + + $topic_data = phpbb_get_topic_data($sync_topics, 'm_merge'); - if (!sizeof($topic_data)) + if (!sizeof($topic_data) || empty($topic_data[$to_topic_id])) { $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']); return; } + $sync_forums = array(); + foreach ($topic_data as $data) + { + $sync_forums[$data['forum_id']] = $data['forum_id']; + } + $topic_data = $topic_data[$to_topic_id]; - $post_id_list = request_var('post_id_list', array(0)); - $start = request_var('start', 0); + $post_id_list = $request->variable('post_id_list', array(0)); + $start = $request->variable('start', 0); if (!sizeof($post_id_list)) { @@ -607,12 +672,12 @@ function merge_posts($topic_id, $to_topic_id) return; } - if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge'))) + if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge'))) { return; } - $redirect = request_var('redirect', build_url(array('quickmod'))); + $redirect = $request->variable('redirect', build_url(array('quickmod'))); $s_hidden_fields = build_hidden_fields(array( 'i' => 'main', @@ -624,21 +689,26 @@ function merge_posts($topic_id, $to_topic_id) 'redirect' => $redirect, 't' => $topic_id) ); - $success_msg = $return_link = ''; + $return_link = ''; if (confirm_box(true)) { $to_forum_id = $topic_data['forum_id']; - move_posts($post_id_list, $to_topic_id); - add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']); + move_posts($post_id_list, $to_topic_id, false); + + $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MERGE', false, array( + 'forum_id' => $to_forum_id, + 'topic_id' => $to_topic_id, + $topic_data['topic_title'] + )); // Message and return links $success_msg = 'POSTS_MERGED_SUCCESS'; // Does the original topic still exist? If yes, link back to it $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . ' + FROM ' . POSTS_TABLE . ' WHERE topic_id = ' . $topic_id; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); @@ -662,9 +732,15 @@ function merge_posts($topic_id, $to_topic_id) phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', array($topic_id), $to_topic_id); } + // Re-sync the topics and forums because the auto-sync was deactivated in the call of move_posts() + sync('topic_reported', 'topic_id', $sync_topics); + sync('topic_attachment', 'topic_id', $sync_topics); + sync('topic', 'topic_id', $sync_topics, true); + sync('forum', 'forum_id', $sync_forums, true, true); + // Link to the new topic $return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>'); - $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); + $redirect = $request->variable('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); $redirect = reapply_sid($redirect); meta_refresh(3, $redirect); |