* @license GNU General Public License, version 2 (GPL-2.0) * * For full copyright and license information, please see * the docs/CREDITS.txt file. * */ /** * @ignore */ if (!defined('IN_PHPBB')) { exit; } /** * mcp_queue * Handling the moderation queue */ class mcp_queue { var $p_master; var $u_action; public function __construct($p_master) { $this->p_master = $p_master; } public function main($id, $mode) { global $auth, $db, $user, $template, $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)); $delete_reason = $request->variable('delete_reason', '', true); 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, $delete_reason, $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, $delete_reason, $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_topic')) { 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 (!count($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'], )); } $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'])) { $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 (count($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']); $post_data = 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'], '', ''), 'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '', ''), 'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '', ''), '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' : '', ); /** * Alter post awaiting approval template before it is rendered * * @event core.mcp_queue_approve_details_template * @var int post_id Post ID * @var int topic_id Topic ID * @var array topic_info Topic data * @var array post_info Post data * @var array post_data Post template data * @var string message Post message * @var string post_url Post URL * @var string topic_url Topic URL * @since 3.2.2-RC1 */ $vars = array( 'post_id', 'topic_id', 'topic_info', 'post_info', 'post_data', 'message', 'post_url', 'topic_url', ); extract($phpbb_dispatcher->trigger_event('core.mcp_queue_approve_details_template', compact($vars))); $template->assign_vars($post_data); 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(); // If 'sort' is set, "Go" was pressed which is located behind the forums