function main($id, $mode) { global $auth, $db, $user, $template, $cache; global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container, $phpbb_dispatcher; include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $forum_id = request_var('f', 0); $start = request_var('start', 0); $this->page_title = 'MCP_REPORTS'; switch ($action) { case 'close': case 'delete': include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; $report_id_list = request_var('report_id_list', array(0)); if (!sizeof($report_id_list)) { trigger_error('NO_REPORT_SELECTED'); } close_report($report_id_list, $mode, $action); break; } switch ($mode) { case 'report_details': $user->add_lang(array('posting', 'viewforum', 'viewtopic')); $post_id = request_var('p', 0); // closed reports are accessed by report id $report_id = request_var('r', 0); $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u WHERE ' . ($report_id ? 'r.report_id = ' . $report_id : "r.post_id = {$post_id}") . ' AND rr.reason_id = r.reason_id AND r.user_id = u.user_id AND r.pm_id = 0 ORDER BY report_closed ASC'; $result = $db->sql_query_limit($sql, 1); $report = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$report) { trigger_error('NO_REPORT'); } $phpbb_notifications = $phpbb_container->get('notification_manager'); $phpbb_notifications->mark_notifications_read('notification.type.report_post', $post_id, $user->data['user_id']); if (!$report_id && $report['report_closed']) { trigger_error('REPORT_CLOSED'); } $post_id = $report['post_id']; $report_id = $report['report_id']; $parse_post_flags = $report['reported_post_enable_bbcode'] ? OPTION_FLAG_BBCODE : 0; $parse_post_flags += $report['reported_post_enable_smilies'] ? OPTION_FLAG_SMILIES : 0; $parse_post_flags += $report['reported_post_enable_magic_url'] ? OPTION_FLAG_LINKS : 0; $post_info = phpbb_get_post_data(array($post_id), 'm_report', true); if (!sizeof($post_info)) { trigger_error('NO_REPORT_SELECTED'); } $post_info = $post_info[$post_id]; $reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']); if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])])) { $reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])]; $reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]; } if (topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) { $template->assign_vars(array('S_TOPIC_REVIEW' => true, 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], 'TOPIC_TITLE' => $post_info['topic_title'], 'REPORTED_POST_ID' => $post_id)); } $topic_tracking_info = $extensions = $attachments = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($post_info['topic_id'] => $post_info); $topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']); } $post_unread = isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']] ? true : false; $message = generate_text_for_display($report['reported_post_text'], $report['reported_post_uid'], $report['reported_post_bitfield'], $parse_post_flags, false); $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text'])); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE post_msg_id = ' . $post_id . ' AND in_message = 0 AND filetime <= ' . (int) $report['report_time'] . ' ORDER BY filetime DESC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[] = $row; } $db->sql_freeresult($result); if (sizeof($attachments)) { $update_count = array(); parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments)) { $template->assign_var('S_HAS_ATTACHMENTS', true); foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } } $template->assign_vars(array('S_MCP_REPORT' => true, 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => $post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE, 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_REPORT_CLOSED' => $report['report_closed'], 'S_USER_NOTES' => true, 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $report['user_id']), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARN_REPORTER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '', 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '', 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $post_info['forum_id']), 'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']), 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports' . ($post_info['post_reported'] ? '&mode=reports' : '&mode=reports_closed') . '&start=' . $start . '&f=' . $post_info['forum_id']) . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'REPORT_DATE' => $user->format_date($report['report_time']), 'REPORT_ID' => $report_id, 'REPORT_REASON_TITLE' => $reason['title'], 'REPORT_REASON_DESCRIPTION' => $reason['description'], 'REPORT_TEXT' => $report['report_text'], 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $post_info['post_subject'] ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], 'POST_IPADDR' => $auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '') ? @gethostbyaddr($post_info['poster_ip']) : '', 'POST_ID' => $post_info['post_id'], 'U_LOOKUP_IP' => $auth->acl_get('m_info', $post_info['forum_id']) ? $this->u_action . '&r=' . $report_id . '&p=' . $post_id . '&f=' . $forum_id . '&lookup=' . $post_info['poster_ip'] . '#ip' : '')); $this->tpl_name = 'mcp_post'; break; case 'reports': case 'reports_closed': $topic_id = request_var('t', 0); $forum_info = array(); $forum_list_reports = get_forum_list('m_report', false, true); $forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs // Remove forums we cannot read foreach ($forum_list_reports as $k => $forum_data) { if (!isset($forum_list_read[$forum_data['forum_id']])) { unset($forum_list_reports[$k]); } } unset($forum_list_read); if ($topic_id) { $topic_info = phpbb_get_topic_data(array($topic_id)); if (!sizeof($topic_info)) { trigger_error('TOPIC_NOT_EXIST'); } if ($forum_id != $topic_info[$topic_id]['forum_id']) { $topic_id = 0; } else { $topic_info = $topic_info[$topic_id]; $forum_id = (int) $topic_info['forum_id']; } } $forum_list = array(); if (!$forum_id) { foreach ($forum_list_reports as $row) { $forum_list[] = $row['forum_id']; } if (!sizeof($forum_list)) { trigger_error('NOT_MODERATOR'); } $global_id = $forum_list[0]; $sql = 'SELECT SUM(forum_topics_approved) as sum_forum_topics FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list); $result = $db->sql_query($sql); $forum_info['forum_topics_approved'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); } else { $forum_info = phpbb_get_forum_data(array($forum_id), 'm_report'); if (!sizeof($forum_info)) { trigger_error('NOT_MODERATOR'); } $forum_info = $forum_info[$forum_id]; $forum_list = array($forum_id); } $forum_list[] = 0; $forum_data = array(); $pagination = $phpbb_container->get('pagination'); $forum_options = '<option value="0"' . ($forum_id == 0 ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>'; foreach ($forum_list_reports as $row) { $forum_options .= '<option value="' . $row['forum_id'] . '"' . ($forum_id == $row['forum_id'] ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . $row['forum_name'] . '</option>'; $forum_data[$row['forum_id']] = $row; } unset($forum_list_reports); $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); phpbb_mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); $forum_topics = $total == -1 ? $forum_info['forum_topics_approved'] : $total; $limit_time_sql = $sort_days ? 'AND r.report_time >= ' . (time() - $sort_days * 86400) : ''; if ($mode == 'reports') { $report_state = 'AND p.post_reported = 1 AND r.report_closed = 0'; } else { $report_state = 'AND r.report_closed = 1'; } $sql = 'SELECT r.report_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . REPORTS_TABLE . ' r ' . ($sort_order_sql[0] == 'u' ? ', ' . USERS_TABLE . ' u' : '') . ($sort_order_sql[0] == 'r' ? ', ' . USERS_TABLE . ' ru' : '') . ' WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . "\n\t\t\t\t\t\t{$report_state}\n\t\t\t\t\t\tAND r.post_id = p.post_id\n\t\t\t\t\t\t" . ($sort_order_sql[0] == 'u' ? 'AND u.user_id = p.poster_id' : '') . ' ' . ($sort_order_sql[0] == 'r' ? 'AND ru.user_id = r.user_id' : '') . ' ' . ($topic_id ? 'AND p.topic_id = ' . $topic_id : '') . "\n\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\tAND r.pm_id = 0\n\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\tORDER BY {$sort_order_sql}"; /** * Alter sql query to get report id of all reports for requested forum and topic or just forum * * @event core.mcp_reports_get_reports_query_before * @var string sql String with the query to be executed * @var array forum_list List of forums that contain the posts * @var int topic_id topic_id in the page request * @var string limit_time_sql String with the SQL code to limit the time interval of the post (Note: May be empty string) * @var string sort_order_sql String with the ORDER BY SQL code used in this query * @since 3.1.0-RC4 */ $vars = array('sql', 'forum_list', 'topic_id', 'limit_time_sql', 'sort_order_sql'); extract($phpbb_dispatcher->trigger_event('core.mcp_reports_get_reports_query_before', compact($vars))); $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $i = 0; $report_ids = array(); while ($row = $db->sql_fetchrow($result)) { $report_ids[] = $row['report_id']; $row_num[$row['report_id']] = $i++; } $db->sql_freeresult($result); if (sizeof($report_ids)) { $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . ' AND t.topic_id = p.topic_id AND r.post_id = p.post_id AND u.user_id = p.poster_id AND ru.user_id = r.user_id AND r.pm_id = 0 ORDER BY ' . $sort_order_sql; $result = $db->sql_query($sql); $report_data = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('postrow', array('U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']), 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=reports&start={$start}&mode=report_details&f={$row['forum_id']}&r={$row['report_id']}"), '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']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'REPORTER_FULL' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'FORUM_NAME' => $forum_data[$row['forum_id']]['forum_name'], 'POST_ID' => $row['post_id'], 'POST_SUBJECT' => $row['post_subject'] ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_TIME' => $user->format_date($row['post_time']), 'REPORT_ID' => $row['report_id'], 'REPORT_TIME' => $user->format_date($row['report_time']), 'TOPIC_TITLE' => $row['topic_title'], 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '')); } $db->sql_freeresult($result); unset($report_ids, $row); } $base_url = $this->u_action . "&f={$forum_id}&t={$topic_id}&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}"; $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); // Now display the page $template->assign_vars(array('L_EXPLAIN' => $mode == 'reports' ? $user->lang['MCP_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_REPORTS_CLOSED_EXPLAIN'], 'L_TITLE' => $mode == 'reports' ? $user->lang['MCP_REPORTS_OPEN'] : $user->lang['MCP_REPORTS_CLOSED'], 'L_ONLY_TOPIC' => $topic_id ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', 'S_MCP_ACTION' => $this->u_action, 'S_FORUM_OPTIONS' => $forum_options, 'S_CLOSED' => $mode == 'reports_closed' ? true : false, 'TOPIC_ID' => $topic_id, 'TOTAL' => $total, 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total))); $this->tpl_name = 'mcp_reports'; break; } }
/** * MCP Forum View */ function mcp_forum_view($id, $mode, $action, $forum_info) { global $template, $db, $user, $auth, $cache, $module; global $phpEx, $phpbb_root_path, $config; global $request, $phpbb_dispatcher, $phpbb_container; $user->add_lang(array('viewtopic', 'viewforum')); include_once $phpbb_root_path . 'includes/functions_display.' . $phpEx; // merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action $merge_select = $action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics' ? true : false; $forum_id = $forum_info['forum_id']; $start = $request->variable('start', 0); $topic_id_list = $request->variable('topic_id_list', array(0)); $post_id_list = $request->variable('post_id_list', array(0)); $source_topic_ids = array($request->variable('t', 0)); $to_topic_id = $request->variable('to_topic_id', 0); $url_extra = ''; $url_extra .= $forum_id ? "&f={$forum_id}" : ''; $url_extra .= $GLOBALS['topic_id'] ? '&t=' . $GLOBALS['topic_id'] : ''; $url_extra .= $GLOBALS['post_id'] ? '&p=' . $GLOBALS['post_id'] : ''; $url_extra .= $GLOBALS['user_id'] ? '&u=' . $GLOBALS['user_id'] : ''; $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?{$url_extra}"); // Resync Topics switch ($action) { case 'resync': $topic_ids = $request->variable('topic_id_list', array(0)); mcp_resync_topics($topic_ids); break; case 'merge_topics': $source_topic_ids = $topic_id_list; case 'merge_topic': if ($to_topic_id) { merge_topics($forum_id, $source_topic_ids, $to_topic_id); } break; } /** * Get some data in order to execute other actions. * * @event core.mcp_forum_view_before * @var string action The action * @var array forum_info Array with forum infos * @var int start Start value * @var array topic_id_list Array of topics ids * @var array post_id_list Array of posts ids * @var array source_topic_ids Array of source topics ids * @var int to_topic_id Array of destination topics ids * @since 3.1.6-RC1 */ $vars = array('action', 'forum_info', 'start', 'topic_id_list', 'post_id_list', 'source_topic_ids', 'to_topic_id'); extract($phpbb_dispatcher->trigger_event('core.mcp_forum_view_before', compact($vars))); /* @var $pagination \phpbb\pagination */ $pagination = $phpbb_container->get('pagination'); $selected_ids = ''; if (sizeof($post_id_list) && $action != 'merge_topics') { foreach ($post_id_list as $num => $post_id) { $selected_ids .= '&post_id_list[' . $num . ']=' . $post_id; } } else { if (sizeof($topic_id_list) && $action == 'merge_topics') { foreach ($topic_id_list as $num => $topic_id) { $selected_ids .= '&topic_id_list[' . $num . ']=' . $topic_id; } } } make_jumpbox($url . "&i={$id}&action={$action}&mode={$mode}" . ($merge_select ? $selected_ids : ''), $forum_id, false, 'm_', true); $topics_per_page = $forum_info['forum_topics_per_page'] ? $forum_info['forum_topics_per_page'] : $config['topics_per_page']; $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); phpbb_mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id); $forum_topics = $total == -1 ? $forum_info['forum_topics_approved'] : $total; $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : ''; $base_url = $url . "&i={$id}&action={$action}&mode={$mode}&sd={$sort_dir}&sk={$sort_key}&st={$sort_days}" . ($merge_select ? $selected_ids : ''); $pagination->generate_template_pagination($base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start); $template->assign_vars(array('ACTION' => $action, 'FORUM_NAME' => $forum_info['forum_name'], 'FORUM_DESCRIPTION' => generate_text_for_display($forum_info['forum_desc'], $forum_info['forum_desc_uid'], $forum_info['forum_desc_bitfield'], $forum_info['forum_desc_options']), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'S_CAN_REPORT' => $auth->acl_get('m_report', $forum_id), 'S_CAN_DELETE' => $auth->acl_get('m_delete', $forum_id), 'S_CAN_RESTORE' => $auth->acl_get('m_approve', $forum_id), 'S_CAN_MERGE' => $auth->acl_get('m_merge', $forum_id), 'S_CAN_MOVE' => $auth->acl_get('m_move', $forum_id), 'S_CAN_FORK' => $auth->acl_get('m_', $forum_id), 'S_CAN_LOCK' => $auth->acl_get('m_lock', $forum_id), 'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id), 'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id), 'S_MERGE_SELECT' => $merge_select ? true : false, 'S_CAN_MAKE_NORMAL' => $auth->acl_gets('f_sticky', 'f_announce', 'f_announce_global', $forum_id), 'S_CAN_MAKE_STICKY' => $auth->acl_get('f_sticky', $forum_id), 'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id), 'S_CAN_MAKE_ANNOUNCE_GLOBAL' => $auth->acl_get('f_announce_global', $forum_id), 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id), 'U_VIEW_FORUM_LOGS' => $auth->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=logs&mode=forum_logs&f=' . $forum_id) : '', 'S_MCP_ACTION' => $url . "&i={$id}&forum_action={$action}&mode={$mode}&start={$start}" . ($merge_select ? $selected_ids : ''), 'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics))); // Grab icons $icons = $cache->obtain_icons(); $topic_rows = array(); if ($config['load_db_lastread']) { $read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')'; $read_tracking_select = ', tt.mark_time'; } else { $read_tracking_join = $read_tracking_select = ''; } /* @var $phpbb_content_visibility \phpbb\content_visibility */ $phpbb_content_visibility = $phpbb_container->get('content.visibility'); $sql = 'SELECT t.topic_id FROM ' . TOPICS_TABLE . ' t WHERE t.forum_id = ' . $forum_id . ' AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . "\n\t\t\t{$limit_time_sql}\n\t\tORDER BY t.topic_type DESC, {$sort_order_sql}"; /** * Modify SQL query before MCP forum view topic list is queried * * @event core.mcp_view_forum_modify_sql * @var string sql SQL query for forum view topic list * @var int forum_id ID of the forum * @var string limit_time_sql SQL query part for limit time * @var string sort_order_sql SQL query part for sort order * @var int topics_per_page Number of topics per page * @var int start Start value * @since 3.1.2-RC1 */ $vars = array('sql', 'forum_id', 'limit_time_sql', 'sort_order_sql', 'topics_per_page', 'start'); extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_sql', compact($vars))); $result = $db->sql_query_limit($sql, $topics_per_page, $start); $topic_list = $topic_tracking_info = array(); while ($row_ary = $db->sql_fetchrow($result)) { $topic_list[] = $row_ary['topic_id']; } $db->sql_freeresult($result); $sql = "SELECT t.*{$read_tracking_select}\n\t\tFROM " . TOPICS_TABLE . " t {$read_tracking_join}\n\t\tWHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true); $result = $db->sql_query($sql); while ($row_ary = $db->sql_fetchrow($result)) { $topic_rows[$row_ary['topic_id']] = $row_ary; } $db->sql_freeresult($result); // If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync if (!sizeof($topic_list) && $forum_topics && $start > 0) { redirect($url . "&i={$id}&action={$action}&mode={$mode}"); } // Get topic tracking info if (sizeof($topic_list)) { if ($config['load_db_lastread']) { $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time'])); } else { $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list); } } foreach ($topic_list as $topic_id) { $row_ary =& $topic_rows[$topic_id]; $replies = $phpbb_content_visibility->get_count('topic_posts', $row_ary, $forum_id) - 1; if ($row_ary['topic_status'] == ITEM_MOVED) { $unread_topic = false; } else { $unread_topic = isset($topic_tracking_info[$topic_id]) && $row_ary['topic_last_post_time'] > $topic_tracking_info[$topic_id] ? true : false; } // Get folder img, topic status/type related information $folder_img = $folder_alt = $topic_type = ''; topic_status($row_ary, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); $topic_title = censor_text($row_ary['topic_title']); $topic_unapproved = ($row_ary['topic_visibility'] == ITEM_UNAPPROVED || $row_ary['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row_ary['forum_id']) ? true : false; $posts_unapproved = $row_ary['topic_visibility'] == ITEM_APPROVED && $row_ary['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row_ary['forum_id']) ? true : false; $topic_deleted = $row_ary['topic_visibility'] == ITEM_DELETED; $u_mcp_queue = $topic_unapproved || $posts_unapproved ? $url . '&i=queue&mode=' . ($topic_unapproved ? 'approve_details' : 'unapproved_posts') . '&t=' . $row_ary['topic_id'] : ''; $u_mcp_queue = !$u_mcp_queue && $topic_deleted ? $url . '&i=queue&mode=deleted_topics&t=' . $topic_id : $u_mcp_queue; $topic_row = array('ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row_ary['forum_id']) && $row_ary['topic_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_ICON_IMG' => !empty($icons[$row_ary['icon_id']]) ? $icons[$row_ary['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$row_ary['icon_id']]) ? $icons[$row_ary['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$row_ary['icon_id']]) ? $icons[$row_ary['icon_id']]['height'] : '', 'UNAPPROVED_IMG' => $topic_unapproved || $posts_unapproved ? $user->img('icon_topic_unapproved', $topic_unapproved ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 'DELETED_IMG' => $topic_deleted ? $user->img('icon_topic_deleted', 'POSTS_DELETED') : '', 'TOPIC_AUTHOR' => get_username_string('username', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']), 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']), 'U_TOPIC_AUTHOR' => get_username_string('profile', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']), 'LAST_POST_AUTHOR' => get_username_string('username', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']), 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']), 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']), 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']), 'TOPIC_TYPE' => $topic_type, 'TOPIC_TITLE' => $topic_title, 'REPLIES' => $phpbb_content_visibility->get_count('topic_posts', $row_ary, $row_ary['forum_id']) - 1, 'LAST_POST_TIME' => $user->format_date($row_ary['topic_last_post_time']), 'FIRST_POST_TIME' => $user->format_date($row_ary['topic_time']), 'LAST_POST_SUBJECT' => $row_ary['topic_last_post_subject'], 'LAST_VIEW_TIME' => $user->format_date($row_ary['topic_last_view_time']), 'S_TOPIC_REPORTED' => !empty($row_ary['topic_reported']) && empty($row_ary['topic_moved_id']) && $auth->acl_get('m_report', $row_ary['forum_id']) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, 'S_TOPIC_DELETED' => $topic_deleted, 'S_UNREAD_TOPIC' => $unread_topic); if ($row_ary['topic_status'] == ITEM_MOVED) { $topic_row = array_merge($topic_row, array('U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row_ary['topic_moved_id']}"), 'U_DELETE_TOPIC' => $auth->acl_get('m_delete', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&f={$forum_id}&topic_id_list[]={$row_ary['topic_id']}&mode=forum_view&action=delete_topic") : '', 'S_MOVED_TOPIC' => true, 'TOPIC_ID' => $row_ary['topic_moved_id'])); } else { if ($action == 'merge_topic' || $action == 'merge_topics') { $u_select_topic = $url . "&i={$id}&mode=forum_view&action={$action}&to_topic_id=" . $row_ary['topic_id'] . $selected_ids; } else { $u_select_topic = $url . "&i={$id}&mode=topic_view&action=merge&to_topic_id=" . $row_ary['topic_id'] . $selected_ids; } $topic_row = array_merge($topic_row, array('U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&f={$forum_id}&t={$row_ary['topic_id']}&mode=topic_view"), 'S_SELECT_TOPIC' => $merge_select && !in_array($row_ary['topic_id'], $source_topic_ids) ? true : false, 'U_SELECT_TOPIC' => $u_select_topic, 'U_MCP_QUEUE' => $u_mcp_queue, 'U_MCP_REPORT' => $auth->acl_get('m_report', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&mode=topic_view&t=' . $row_ary['topic_id'] . '&action=reports') : '', 'TOPIC_ID' => $row_ary['topic_id'], 'S_TOPIC_CHECKED' => $topic_id_list && in_array($row_ary['topic_id'], $topic_id_list) ? true : false)); } $row = $row_ary; /** * Modify the topic data before it is assigned to the template in MCP * * @event core.mcp_view_forum_modify_topicrow * @var array row Array with topic data * @var array topic_row Template array with topic data * @since 3.1.0-a1 */ $vars = array('row', 'topic_row'); extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_topicrow', compact($vars))); $row_ary = $row; unset($row); $template->assign_block_vars('topicrow', $topic_row); } unset($topic_rows); }
public function main($id, $mode) { global $auth, $db, $user, $template, $cache, $request; global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container; global $phpbb_dispatcher; include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $forum_id = $request->variable('f', 0); $start = $request->variable('start', 0); $this->page_title = 'MCP_QUEUE'; switch ($action) { case 'approve': case 'restore': include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; $post_id_list = $request->variable('post_id_list', array(0)); $topic_id_list = $request->variable('topic_id_list', array(0)); if (!empty($post_id_list)) { self::approve_posts($action, $post_id_list, 'queue', $mode); } else { if (!empty($topic_id_list)) { self::approve_topics($action, $topic_id_list, 'queue', $mode); } else { trigger_error('NO_POST_SELECTED'); } } break; case 'delete': $post_id_list = $request->variable('post_id_list', array(0)); $topic_id_list = $request->variable('topic_id_list', array(0)); if (!empty($post_id_list)) { if (!function_exists('mcp_delete_post')) { global $phpbb_root_path, $phpEx; include $phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx; } mcp_delete_post($post_id_list, false, '', $action); } else { if (!empty($topic_id_list)) { if (!function_exists('mcp_delete_topic')) { global $phpbb_root_path, $phpEx; include $phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx; } mcp_delete_topic($topic_id_list, false, '', $action); } else { trigger_error('NO_POST_SELECTED'); } } break; case 'disapprove': $post_id_list = $request->variable('post_id_list', array(0)); $topic_id_list = $request->variable('topic_id_list', array(0)); if (!empty($topic_id_list) && $mode == 'deleted_topics') { if (!function_exists('mcp_delete_topics')) { global $phpbb_root_path, $phpEx; include $phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx; } mcp_delete_topic($topic_id_list, false, '', 'disapprove'); return; } if (!class_exists('messenger')) { include $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; } if (!empty($topic_id_list)) { $post_visibility = $mode == 'deleted_topics' ? ITEM_DELETED : array(ITEM_UNAPPROVED, ITEM_REAPPROVE); $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' WHERE ' . $db->sql_in_set('post_visibility', $post_visibility) . ' AND ' . $db->sql_in_set('topic_id', $topic_id_list); $result = $db->sql_query($sql); $post_id_list = array(); while ($row = $db->sql_fetchrow($result)) { $post_id_list[] = (int) $row['post_id']; } $db->sql_freeresult($result); } if (!empty($post_id_list)) { self::disapprove_posts($post_id_list, 'queue', $mode); } else { trigger_error('NO_POST_SELECTED'); } break; } switch ($mode) { case 'approve_details': $this->tpl_name = 'mcp_post'; $user->add_lang(array('posting', 'viewtopic')); $post_id = $request->variable('p', 0); $topic_id = $request->variable('t', 0); /* @var $phpbb_notifications \phpbb\notification\manager */ $phpbb_notifications = $phpbb_container->get('notification_manager'); if ($topic_id) { $topic_info = phpbb_get_topic_data(array($topic_id), 'm_approve'); if (isset($topic_info[$topic_id]['topic_first_post_id'])) { $post_id = (int) $topic_info[$topic_id]['topic_first_post_id']; $phpbb_notifications->mark_notifications('topic_in_queue', $topic_id, $user->data['user_id']); } else { $topic_id = 0; } } $phpbb_notifications->mark_notifications('post_in_queue', $post_id, $user->data['user_id']); $post_info = phpbb_get_post_data(array($post_id), 'm_approve', true); if (!sizeof($post_info)) { trigger_error('NO_POST_SELECTED'); } $post_info = $post_info[$post_id]; if ($post_info['topic_first_post_id'] != $post_id && topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) { $template->assign_vars(array('S_TOPIC_REVIEW' => true, 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], 'TOPIC_TITLE' => $post_info['topic_title'])); } $extensions = $attachments = $topic_tracking_info = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($post_info['topic_id'] => $post_info); $topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']); } $post_unread = isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']] ? true : false; // Process message, leave it uncensored $parse_flags = ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; $message = generate_text_for_display($post_info['post_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], $parse_flags, false); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { $extensions = $cache->obtain_attach_extensions($post_info['forum_id']); $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE post_msg_id = ' . $post_id . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[] = $row; } $db->sql_freeresult($result); if (sizeof($attachments)) { $update_count = array(); parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments)) { $template->assign_var('S_HAS_ATTACHMENTS', true); foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } } // Deleting information if ($post_info['post_visibility'] == ITEM_DELETED && $post_info['post_delete_user']) { // User having deleted the post also being the post author? if (!$post_info['post_delete_user'] || $post_info['post_delete_user'] == $post_info['poster_id']) { $display_username = get_username_string('full', $post_info['poster_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']); } else { $sql = 'SELECT u.user_id, u.username, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE p.post_id = ' . $post_info['post_id'] . ' AND p.post_delete_user = u.user_id'; $result = $db->sql_query($sql); $post_delete_userinfo = $db->sql_fetchrow($result); $db->sql_freeresult($result); $display_username = get_username_string('full', $post_info['post_delete_user'], $post_delete_userinfo['username'], $post_delete_userinfo['user_colour']); } $l_deleted_by = $user->lang('DELETED_INFORMATION', $display_username, $user->format_date($post_info['post_delete_time'], false, true)); } else { $l_deleted_by = ''; } $post_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']); $topic_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']); $template->assign_vars(array('S_MCP_QUEUE' => true, 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&p={$post_id}&f={$forum_id}"), 'S_CAN_DELETE_POST' => $auth->acl_get('m_delete', $post_info['forum_id']), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => $post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE, 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, 'S_POST_DELETED' => $post_info['post_visibility'] == ITEM_DELETED, 'DELETED_MESSAGE' => $l_deleted_by, 'DELETE_REASON' => $post_info['post_delete_reason'], 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '', 'U_VIEW_POST' => $post_url, 'U_VIEW_TOPIC' => $topic_url, 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue' . ($topic_id ? '&mode=unapproved_topics' : '&mode=unapproved_posts')) . '&start=' . $start . '">', '</a>'), 'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'), 'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '<a href="' . $topic_url . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $post_info['post_subject'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], 'POST_IPADDR' => $auth->acl_get('m_info', $post_info['forum_id']) && $request->variable('lookup', '') ? @gethostbyaddr($post_info['poster_ip']) : '', 'POST_ID' => $post_info['post_id'], 'S_FIRST_POST' => $post_info['topic_first_post_id'] == $post_id, 'U_LOOKUP_IP' => $auth->acl_get('m_info', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id . '&lookup=' . $post_info['poster_ip']) . '#ip' : '')); break; case 'unapproved_topics': case 'unapproved_posts': case 'deleted_topics': case 'deleted_posts': $m_perm = 'm_approve'; $is_topics = $mode == 'unapproved_topics' || $mode == 'deleted_topics' ? true : false; $is_restore = $mode == 'deleted_posts' || $mode == 'deleted_topics' ? true : false; $visibility_const = !$is_restore ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED; $user->add_lang(array('viewtopic', 'viewforum')); $topic_id = $request->variable('t', 0); $forum_info = array(); /* @var $pagination \phpbb\pagination */ $pagination = $phpbb_container->get('pagination'); if ($topic_id) { $topic_info = phpbb_get_topic_data(array($topic_id)); if (!sizeof($topic_info)) { trigger_error('TOPIC_NOT_EXIST'); } $topic_info = $topic_info[$topic_id]; $forum_id = $topic_info['forum_id']; } $forum_list_approve = get_forum_list($m_perm, false, true); $forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs // Remove forums we cannot read foreach ($forum_list_approve as $k => $forum_data) { if (!isset($forum_list_read[$forum_data['forum_id']])) { unset($forum_list_approve[$k]); } } unset($forum_list_read); if (!$forum_id) { $forum_list = array(); foreach ($forum_list_approve as $row) { $forum_list[] = $row['forum_id']; } if (!sizeof($forum_list)) { trigger_error('NOT_MODERATOR'); } $sql = 'SELECT SUM(forum_topics_approved) as sum_forum_topics FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list); $result = $db->sql_query($sql); $forum_info['forum_topics_approved'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); } else { $forum_info = phpbb_get_forum_data(array($forum_id), $m_perm); if (!sizeof($forum_info)) { trigger_error('NOT_MODERATOR'); } $forum_info = $forum_info[$forum_id]; $forum_list = $forum_id; } $forum_options = '<option value="0"' . ($forum_id == 0 ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>'; foreach ($forum_list_approve as $row) { $forum_options .= '<option value="' . $row['forum_id'] . '"' . ($forum_id == $row['forum_id'] ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . truncate_string($row['forum_name'], 30, 255, false, $user->lang['ELLIPSIS']) . '</option>'; } $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); phpbb_mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); $forum_topics = $total == -1 ? $forum_info['forum_topics_approved'] : $total; $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : ''; $forum_names = array(); if (!$is_topics) { $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . ($sort_order_sql[0] == 'u' ? ', ' . USERS_TABLE . ' u' : '') . ' WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . ' AND ' . $db->sql_in_set('p.post_visibility', $visibility_const) . ' ' . ($sort_order_sql[0] == 'u' ? 'AND u.user_id = p.poster_id' : '') . ' ' . ($topic_id ? 'AND p.topic_id = ' . $topic_id : '') . "\n\t\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\t\tAND (t.topic_visibility <> p.post_visibility\n\t\t\t\t\t\t\t\tOR t.topic_delete_user = 0)\n\t\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\t\tORDER BY {$sort_order_sql}"; /** * Alter sql query to get posts in queue to be accepted * * @event core.mcp_queue_get_posts_query_before * @var string sql Associative array with the query to be executed * @var array forum_list List of forums that contain the posts * @var int visibility_const Integer with one of the possible ITEM_* constant values * @var int topic_id If topic_id not equal to 0, the topic id to filter the posts to display * @var string limit_time_sql String with the SQL code to limit the time interval of the post (Note: May be empty string) * @var string sort_order_sql String with the ORDER BY SQL code used in this query * @since 3.1.0-RC3 */ $vars = array('sql', 'forum_list', 'visibility_const', 'topic_id', 'limit_time_sql', 'sort_order_sql'); extract($phpbb_dispatcher->trigger_event('core.mcp_queue_get_posts_query_before', compact($vars))); $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $i = 0; $post_ids = array(); while ($row = $db->sql_fetchrow($result)) { $post_ids[] = $row['post_id']; $row_num[$row['post_id']] = $i++; } $db->sql_freeresult($result); if (sizeof($post_ids)) { $sql = 'SELECT t.topic_id, t.topic_title, t.forum_id, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' AND t.topic_id = p.topic_id AND u.user_id = p.poster_id ORDER BY ' . $sort_order_sql; $result = $db->sql_query($sql); $post_data = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $forum_names[] = $row['forum_id']; $post_data[$row['post_id']] = $row; } $db->sql_freeresult($result); foreach ($post_ids as $post_id) { $rowset[] = $post_data[$post_id]; } unset($post_data, $post_ids); } else { $rowset = array(); } } else { $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_attachment AS post_attachment, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' AND ' . $db->sql_in_set('topic_visibility', $visibility_const) . "\n\t\t\t\t\t\t\tAND topic_delete_user <> 0\n\t\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\t\tORDER BY {$sort_order_sql}"; /** * Alter sql query to get information on all topics in the list of forums provided. * * @event core.mcp_queue_get_posts_for_topics_query_before * @var string sql String with the query to be executed * @var array forum_list List of forums that contain the posts * @var int visibility_const Integer with one of the possible ITEM_* constant values * @var int topic_id topic_id in the page request * @var string limit_time_sql String with the SQL code to limit the time interval of the post (Note: May be empty string) * @var string sort_order_sql String with the ORDER BY SQL code used in this query * @since 3.1.0-RC3 */ $vars = array('sql', 'forum_list', 'visibility_const', 'topic_id', 'limit_time_sql', 'sort_order_sql'); extract($phpbb_dispatcher->trigger_event('core.mcp_queue_get_posts_for_topics_query_before', compact($vars))); $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $forum_names[] = $row['forum_id']; $rowset[] = $row; } $db->sql_freeresult($result); } if (sizeof($forum_names)) { // Select the names for the forum_ids $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_names); $result = $db->sql_query($sql, 3600); $forum_names = array(); while ($row = $db->sql_fetchrow($result)) { $forum_names[$row['forum_id']] = $row['forum_name']; } $db->sql_freeresult($result); } foreach ($rowset as $row) { if (empty($row['post_username'])) { $row['post_username'] = $row['username'] ?: $user->lang['GUEST']; } $template->assign_block_vars('postrow', array('U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']), 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . ($mode == 'unapproved_posts' ? '#p' . $row['post_id'] : ''), 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&start={$start}&mode=approve_details&f={$row['forum_id']}&p={$row['post_id']}" . ($mode == 'unapproved_topics' ? "&t={$row['topic_id']}" : '')), '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']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_ID' => $row['post_id'], 'TOPIC_ID' => $row['topic_id'], 'FORUM_NAME' => $forum_names[$row['forum_id']], 'POST_SUBJECT' => $row['post_subject'] != '' ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'TOPIC_TITLE' => $row['topic_title'], 'POST_TIME' => $user->format_date($row['post_time']), 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '')); } unset($rowset, $forum_names); $base_url = $this->u_action . "&f={$forum_id}&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}"; $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); // Now display the page $template->assign_vars(array('L_DISPLAY_ITEMS' => !$is_topics ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'], 'L_EXPLAIN' => $user->lang['MCP_QUEUE_' . strtoupper($mode) . '_EXPLAIN'], 'L_TITLE' => $user->lang['MCP_QUEUE_' . strtoupper($mode)], 'L_ONLY_TOPIC' => $topic_id ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', 'S_FORUM_OPTIONS' => $forum_options, 'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')), 'S_TOPICS' => $is_topics, 'S_RESTORE' => $is_restore, 'TOPIC_ID' => $topic_id, 'TOTAL' => $user->lang(!$is_topics ? 'VIEW_TOPIC_POSTS' : 'VIEW_FORUM_TOPICS', (int) $total))); $this->tpl_name = 'mcp_queue'; break; } }
/** * Split topic */ function split_topic($action, $topic_id, $to_forum_id, $subject) { global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $config; $post_id_list = request_var('post_id_list', array(0)); $forum_id = request_var('forum_id', 0); $start = request_var('start', 0); if (!sizeof($post_id_list)) { $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']); return; } if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_split'))) { return; } $post_id = $post_id_list[0]; $post_info = phpbb_get_post_data(array($post_id)); if (!sizeof($post_info)) { $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']); return; } $post_info = $post_info[$post_id]; $subject = trim($subject); // Make some tests if (!$subject) { $template->assign_var('MESSAGE', $user->lang['EMPTY_SUBJECT']); return; } if ($to_forum_id <= 0) { $template->assign_var('MESSAGE', $user->lang['NO_DESTINATION_FORUM']); return; } $forum_info = phpbb_get_forum_data(array($to_forum_id), 'f_post'); if (!sizeof($forum_info)) { $template->assign_var('MESSAGE', $user->lang['USER_CANNOT_POST']); return; } $forum_info = $forum_info[$to_forum_id]; if ($forum_info['forum_type'] != FORUM_POST) { $template->assign_var('MESSAGE', $user->lang['FORUM_NOT_POSTABLE']); return; } $redirect = request_var('redirect', build_url(array('quickmod'))); $s_hidden_fields = build_hidden_fields(array('i' => 'main', 'post_id_list' => $post_id_list, 'f' => $forum_id, 'mode' => 'topic_view', 'start' => $start, 'action' => $action, 't' => $topic_id, 'redirect' => $redirect, 'subject' => $subject, 'to_forum_id' => $to_forum_id, 'icon' => request_var('icon', 0))); $success_msg = $return_link = ''; if (confirm_box(true)) { if ($action == 'split_beyond') { $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); 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) : ''; if ($sort_order_sql[0] == 'u') { $sql = 'SELECT p.post_id, p.forum_id, p.post_visibility FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u\n\t\t\t\t\tWHERE p.topic_id = {$topic_id}\n\t\t\t\t\t\tAND p.poster_id = u.user_id\n\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\tORDER BY {$sort_order_sql}"; } else { $sql = 'SELECT p.post_id, p.forum_id, p.post_visibility FROM ' . POSTS_TABLE . " p\n\t\t\t\t\tWHERE p.topic_id = {$topic_id}\n\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\tORDER BY {$sort_order_sql}"; } $result = $db->sql_query_limit($sql, 0, $start); $store = false; $post_id_list = array(); 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 || $row['post_visibility'] == ITEM_REAPPROVE) && !$auth->acl_get('m_approve', $row['forum_id'])) { // continue; } // Start to store post_ids as soon as we see the first post that was selected if ($row['post_id'] == $post_id) { $store = true; } if ($store) { $post_id_list[] = $row['post_id']; } } $db->sql_freeresult($result); } if (!sizeof($post_id_list)) { trigger_error('NO_POST_SELECTED'); } $icon_id = request_var('icon', 0); $sql_ary = array('forum_id' => $to_forum_id, 'topic_title' => $subject, 'icon_id' => $icon_id, 'topic_visibility' => 1); $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $db->sql_query($sql); $to_topic_id = $db->sql_nextid(); move_posts($post_id_list, $to_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']); // Change topic title of first post $sql = 'UPDATE ' . POSTS_TABLE . "\n\t\t\tSET post_subject = '" . $db->sql_escape($subject) . "'\n\t\t\tWHERE post_id = {$post_id_list[0]}"; $db->sql_query($sql); // Copy topic subscriptions to new topic $sql = 'SELECT user_id, notify_status FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id = ' . $topic_id; $result = $db->sql_query($sql); $sql_ary = array(); while ($row = $db->sql_fetchrow($result)) { $sql_ary[] = array('topic_id' => (int) $to_topic_id, 'user_id' => (int) $row['user_id'], 'notify_status' => (int) $row['notify_status']); } $db->sql_freeresult($result); if (sizeof($sql_ary)) { $db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary); } // Copy bookmarks to new topic $sql = 'SELECT user_id FROM ' . BOOKMARKS_TABLE . ' WHERE topic_id = ' . $topic_id; $result = $db->sql_query($sql); $sql_ary = array(); while ($row = $db->sql_fetchrow($result)) { $sql_ary[] = array('topic_id' => (int) $to_topic_id, 'user_id' => (int) $row['user_id']); } $db->sql_freeresult($result); if (sizeof($sql_ary)) { $db->sql_multi_insert(BOOKMARKS_TABLE, $sql_ary); } $success_msg = 'TOPIC_SPLIT_SUCCESS'; // Update forum statistics set_config_count('num_topics', 1, true); // 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 = reapply_sid($redirect); meta_refresh(3, $redirect); trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link); } else { confirm_box(false, $action == 'split_all' ? 'SPLIT_TOPIC_ALL' : 'SPLIT_TOPIC_BEYOND', $s_hidden_fields); } }
function main($id, $mode) { global $auth, $db, $user, $template, $cache, $request; global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container; include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; include_once $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx; /* @var $pagination \phpbb\pagination */ $pagination = $phpbb_container->get('pagination'); $start = $request->variable('start', 0); $this->page_title = 'MCP_PM_REPORTS'; switch ($action) { case 'close': case 'delete': include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; $report_id_list = $request->variable('report_id_list', array(0)); if (!sizeof($report_id_list)) { trigger_error('NO_REPORT_SELECTED'); } if (!function_exists('close_report')) { include $phpbb_root_path . 'includes/mcp/mcp_reports.' . $phpEx; } close_report($report_id_list, $mode, $action, true); break; } switch ($mode) { case 'pm_report_details': $user->add_lang(array('posting', 'viewforum', 'viewtopic', 'ucp')); $report_id = $request->variable('r', 0); $sql = 'SELECT r.pm_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u WHERE r.report_id = ' . $report_id . ' AND rr.reason_id = r.reason_id AND r.user_id = u.user_id AND r.post_id = 0 ORDER BY report_closed ASC'; $result = $db->sql_query_limit($sql, 1); $report = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$report_id || !$report) { trigger_error('NO_REPORT'); } /* @var $phpbb_notifications \phpbb\notification\manager */ $phpbb_notifications = $phpbb_container->get('notification_manager'); $phpbb_notifications->mark_notifications_by_parent('report_pm', $report_id, $user->data['user_id']); $pm_id = $report['pm_id']; $report_id = $report['report_id']; $pm_info = phpbb_get_pm_data(array($pm_id)); if (!sizeof($pm_info)) { trigger_error('NO_REPORT_SELECTED'); } $pm_info = $pm_info[$pm_id]; write_pm_addresses(array('to' => $pm_info['to_address'], 'bcc' => $pm_info['bcc_address']), (int) $pm_info['author_id']); $reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']); if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])])) { $reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])]; $reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]; } // Process message, leave it uncensored $parse_flags = ($pm_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; $message = generate_text_for_display($pm_info['message_text'], $pm_info['bbcode_uid'], $pm_info['bbcode_bitfield'], $parse_flags, false); $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text'])); if ($pm_info['message_attachment'] && $auth->acl_get('u_pm_download')) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE post_msg_id = ' . $pm_id . ' AND in_message = 1 ORDER BY filetime DESC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[] = $row; } $db->sql_freeresult($result); if (sizeof($attachments)) { $update_count = array(); parse_attachments(0, $message, $attachments, $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments)) { $template->assign_var('S_HAS_ATTACHMENTS', true); foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } } $template->assign_vars(array('S_MCP_REPORT' => true, 'S_PM' => true, 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=pm_reports&mode=pm_report_details&r=' . $report_id), 'S_CAN_VIEWIP' => $auth->acl_getf_global('m_info'), 'S_POST_REPORTED' => $pm_info['message_reported'], 'S_REPORT_CLOSED' => $report['report_closed'], 'S_USER_NOTES' => true, 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=pm_reports&mode=pm_report_details&r=' . $report_id), 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $report['user_id']), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $pm_info['author_id']), 'U_MCP_WARN_REPORTER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '', 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $pm_info['author_id']) : '', 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'MINI_POST_IMG' => $user->img('icon_post_target', 'POST'), 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=pm_reports' . ($pm_info['message_reported'] ? '&mode=pm_reports' : '&mode=pm_reports_closed') . '&start=' . $start) . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'REPORT_DATE' => $user->format_date($report['report_time']), 'REPORT_ID' => $report_id, 'REPORT_REASON_TITLE' => $reason['title'], 'REPORT_REASON_DESCRIPTION' => $reason['description'], 'REPORT_TEXT' => $report['report_text'], 'POST_AUTHOR_FULL' => get_username_string('full', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), 'POST_AUTHOR' => get_username_string('username', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), 'U_POST_AUTHOR' => get_username_string('profile', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), 'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $pm_info['message_subject'] ? $pm_info['message_subject'] : $user->lang['NO_SUBJECT'], 'POST_DATE' => $user->format_date($pm_info['message_time']), 'POST_IP' => $pm_info['author_ip'], 'POST_IPADDR' => $auth->acl_getf_global('m_info') && $request->variable('lookup', '') ? @gethostbyaddr($pm_info['author_ip']) : '', 'POST_ID' => $pm_info['msg_id'], 'U_LOOKUP_IP' => $auth->acl_getf_global('m_info') ? $this->u_action . '&r=' . $report_id . '&pm=' . $pm_id . '&lookup=' . $pm_info['author_ip'] . '#ip' : '')); $this->tpl_name = 'mcp_post'; break; case 'pm_reports': case 'pm_reports_closed': $user->add_lang(array('ucp')); $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); phpbb_mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total); $limit_time_sql = $sort_days ? 'AND r.report_time >= ' . (time() - $sort_days * 86400) : ''; if ($mode == 'pm_reports') { $report_state = 'p.message_reported = 1 AND r.report_closed = 0'; } else { $report_state = 'r.report_closed = 1'; } $sql = 'SELECT r.report_id FROM ' . PRIVMSGS_TABLE . ' p, ' . REPORTS_TABLE . ' r ' . ($sort_order_sql[0] == 'u' ? ', ' . USERS_TABLE . ' u' : '') . ($sort_order_sql[0] == 'r' ? ', ' . USERS_TABLE . ' ru' : '') . "\n\t\t\t\t\tWHERE {$report_state}\n\t\t\t\t\t\tAND r.pm_id = p.msg_id\n\t\t\t\t\t\t" . ($sort_order_sql[0] == 'u' ? 'AND u.user_id = p.author_id' : '') . ' ' . ($sort_order_sql[0] == 'r' ? 'AND ru.user_id = r.user_id' : '') . "\n\t\t\t\t\t\tAND r.post_id = 0\n\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\tORDER BY {$sort_order_sql}"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $i = 0; $report_ids = array(); while ($row = $db->sql_fetchrow($result)) { $report_ids[] = $row['report_id']; $row_num[$row['report_id']] = $i++; } $db->sql_freeresult($result); if (sizeof($report_ids)) { $sql = 'SELECT p.*, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . "\n\t\t\t\t\t\t\tAND r.pm_id = p.msg_id\n\t\t\t\t\t\t\tAND p.author_id = u.user_id\n\t\t\t\t\t\t\tAND ru.user_id = r.user_id\n\t\t\t\t\t\tORDER BY {$sort_order_sql}"; $result = $db->sql_query($sql); $pm_list = $pm_by_id = array(); while ($row = $db->sql_fetchrow($result)) { $pm_by_id[(int) $row['msg_id']] = $row; $pm_list[] = (int) $row['msg_id']; } $db->sql_freeresult($result); if (sizeof($pm_list)) { $address_list = get_recipient_strings($pm_by_id); foreach ($pm_list as $message_id) { $row = $pm_by_id[$message_id]; $template->assign_block_vars('postrow', array('U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=pm_reports&mode=pm_report_details&r={$row['report_id']}"), 'PM_AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['username'], $row['user_colour']), 'PM_AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['username'], $row['user_colour']), 'PM_AUTHOR' => get_username_string('username', $row['author_id'], $row['username'], $row['user_colour']), 'U_PM_AUTHOR' => get_username_string('profile', $row['author_id'], $row['username'], $row['user_colour']), 'REPORTER_FULL' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'PM_SUBJECT' => $row['message_subject'] ? $row['message_subject'] : $user->lang['NO_SUBJECT'], 'PM_TIME' => $user->format_date($row['message_time']), 'REPORT_ID' => $row['report_id'], 'REPORT_TIME' => $user->format_date($row['report_time']), 'RECIPIENTS' => implode($user->lang['COMMA_SEPARATOR'], $address_list[$row['msg_id']]), 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $row['message_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '')); } } } $base_url = $this->u_action . "&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}"; $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); // Now display the page $template->assign_vars(array('L_EXPLAIN' => $mode == 'pm_reports' ? $user->lang['MCP_PM_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_PM_REPORTS_CLOSED_EXPLAIN'], 'L_TITLE' => $mode == 'pm_reports' ? $user->lang['MCP_PM_REPORTS_OPEN'] : $user->lang['MCP_PM_REPORTS_CLOSED'], 'S_PM' => true, 'S_MCP_ACTION' => $this->u_action, 'S_CLOSED' => $mode == 'pm_reports_closed' ? true : false, 'TOTAL' => $total, 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total))); $this->tpl_name = 'mcp_reports'; break; } }