Пример #1
0
 function main($id, $mode)
 {
     global $auth, $db, $user, $template, $action;
     global $config, $phpbb_root_path, $phpEx, $request;
     global $phpbb_dispatcher;
     $quickmod = $mode == 'quickmod' ? true : false;
     switch ($action) {
         case 'lock':
         case 'unlock':
             $topic_ids = !$quickmod ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));
             if (!sizeof($topic_ids)) {
                 trigger_error('NO_TOPIC_SELECTED');
             }
             lock_unlock($action, $topic_ids);
             break;
         case 'lock_post':
         case 'unlock_post':
             $post_ids = !$quickmod ? $request->variable('post_id_list', array(0)) : array($request->variable('p', 0));
             if (!sizeof($post_ids)) {
                 trigger_error('NO_POST_SELECTED');
             }
             lock_unlock($action, $post_ids);
             break;
         case 'make_announce':
         case 'make_sticky':
         case 'make_global':
         case 'make_normal':
             $topic_ids = !$quickmod ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));
             if (!sizeof($topic_ids)) {
                 trigger_error('NO_TOPIC_SELECTED');
             }
             change_topic_type($action, $topic_ids);
             break;
         case 'move':
             $user->add_lang('viewtopic');
             $topic_ids = !$quickmod ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));
             if (!sizeof($topic_ids)) {
                 trigger_error('NO_TOPIC_SELECTED');
             }
             mcp_move_topic($topic_ids);
             break;
         case 'fork':
             $user->add_lang('viewtopic');
             $topic_ids = !$quickmod ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));
             if (!sizeof($topic_ids)) {
                 trigger_error('NO_TOPIC_SELECTED');
             }
             mcp_fork_topic($topic_ids);
             break;
         case 'delete_topic':
             $user->add_lang('viewtopic');
             // f parameter is not reliable for permission usage, however we just use it to decide
             // which permission we will check later on. So if it is manipulated, we will still catch it later on.
             $forum_id = $request->variable('f', 0);
             $topic_ids = !$quickmod ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));
             $soft_delete = $request->is_set_post('confirm') && !$request->is_set_post('delete_permanent') || !$auth->acl_get('m_delete', $forum_id) ? true : false;
             if (!sizeof($topic_ids)) {
                 trigger_error('NO_TOPIC_SELECTED');
             }
             mcp_delete_topic($topic_ids, $soft_delete, $request->variable('delete_reason', '', true));
             break;
         case 'delete_post':
             $user->add_lang('posting');
             // f parameter is not reliable for permission usage, however we just use it to decide
             // which permission we will check later on. So if it is manipulated, we will still catch it later on.
             $forum_id = $request->variable('f', 0);
             $post_ids = !$quickmod ? $request->variable('post_id_list', array(0)) : array($request->variable('p', 0));
             $soft_delete = $request->is_set_post('confirm') && !$request->is_set_post('delete_permanent') || !$auth->acl_get('m_delete', $forum_id) ? true : false;
             if (!sizeof($post_ids)) {
                 trigger_error('NO_POST_SELECTED');
             }
             mcp_delete_post($post_ids, $soft_delete, $request->variable('delete_reason', '', true));
             break;
         case 'restore_topic':
             $user->add_lang('posting');
             $topic_ids = !$quickmod ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0));
             if (!sizeof($topic_ids)) {
                 trigger_error('NO_TOPIC_SELECTED');
             }
             mcp_restore_topic($topic_ids);
             break;
         default:
             /**
              * This event allows you to handle custom quickmod options
              *
              * @event core.modify_quickmod_actions
              * @var	string	action		Topic quick moderation action name
              * @var	bool	quickmod	Flag indicating whether MCP is in quick moderation mode
              * @since 3.1.0-a4
              * @change 3.1.0-RC4 Added variables: action, quickmod
              */
             $vars = array('action', 'quickmod');
             extract($phpbb_dispatcher->trigger_event('core.modify_quickmod_actions', compact($vars)));
             break;
     }
     switch ($mode) {
         case 'front':
             include $phpbb_root_path . 'includes/mcp/mcp_front.' . $phpEx;
             $user->add_lang('acp/common');
             mcp_front_view($id, $mode, $action);
             $this->tpl_name = 'mcp_front';
             $this->page_title = 'MCP_MAIN';
             break;
         case 'forum_view':
             include $phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx;
             $user->add_lang('viewforum');
             $forum_id = $request->variable('f', 0);
             $forum_info = phpbb_get_forum_data($forum_id, 'm_', true);
             if (!sizeof($forum_info)) {
                 $this->main('main', 'front');
                 return;
             }
             $forum_info = $forum_info[$forum_id];
             mcp_forum_view($id, $mode, $action, $forum_info);
             $this->tpl_name = 'mcp_forum';
             $this->page_title = 'MCP_MAIN_FORUM_VIEW';
             break;
         case 'topic_view':
             include $phpbb_root_path . 'includes/mcp/mcp_topic.' . $phpEx;
             mcp_topic_view($id, $mode, $action);
             $this->tpl_name = 'mcp_topic';
             $this->page_title = 'MCP_MAIN_TOPIC_VIEW';
             break;
         case 'post_details':
             include $phpbb_root_path . 'includes/mcp/mcp_post.' . $phpEx;
             mcp_post_details($id, $mode, $action);
             $this->tpl_name = $action == 'whois' ? 'mcp_whois' : 'mcp_post';
             $this->page_title = 'MCP_MAIN_POST_DETAILS';
             break;
         default:
             if ($quickmod) {
                 switch ($action) {
                     case 'lock':
                     case 'unlock':
                     case 'make_announce':
                     case 'make_sticky':
                     case 'make_global':
                     case 'make_normal':
                     case 'make_onindex':
                     case 'move':
                     case 'fork':
                     case 'delete_topic':
                         trigger_error('TOPIC_NOT_EXIST');
                         break;
                     case 'lock_post':
                     case 'unlock_post':
                     case 'delete_post':
                         trigger_error('POST_NOT_EXIST');
                         break;
                 }
             }
             trigger_error('NO_MODE', E_USER_ERROR);
             break;
     }
 }
Пример #2
0
 function main($id, $mode)
 {
     global $auth, $db, $user, $template, $action;
     global $config, $phpbb_root_path, $phpEx;
     $quickmod = $mode == 'quickmod' ? true : false;
     switch ($action) {
         case 'lock':
         case 'unlock':
             $topic_ids = !$quickmod ? request_var('topic_id_list', array(0)) : array(request_var('t', 0));
             if (!sizeof($topic_ids)) {
                 trigger_error('NO_TOPIC_SELECTED');
             }
             lock_unlock($action, $topic_ids);
             break;
         case 'lock_post':
         case 'unlock_post':
             $post_ids = !$quickmod ? request_var('post_id_list', array(0)) : array(request_var('p', 0));
             if (!sizeof($post_ids)) {
                 trigger_error('NO_POST_SELECTED');
             }
             lock_unlock($action, $post_ids);
             break;
         case 'make_announce':
         case 'make_sticky':
         case 'make_global':
         case 'make_normal':
             $topic_ids = !$quickmod ? request_var('topic_id_list', array(0)) : array(request_var('t', 0));
             if (!sizeof($topic_ids)) {
                 trigger_error('NO_TOPIC_SELECTED');
             }
             change_topic_type($action, $topic_ids);
             break;
         case 'move':
             $user->add_lang('viewtopic');
             $topic_ids = !$quickmod ? request_var('topic_id_list', array(0)) : array(request_var('t', 0));
             if (!sizeof($topic_ids)) {
                 trigger_error('NO_TOPIC_SELECTED');
             }
             mcp_move_topic($topic_ids);
             break;
         case 'fork':
             $user->add_lang('viewtopic');
             $topic_ids = !$quickmod ? request_var('topic_id_list', array(0)) : array(request_var('t', 0));
             if (!sizeof($topic_ids)) {
                 trigger_error('NO_TOPIC_SELECTED');
             }
             mcp_fork_topic($topic_ids);
             break;
         case 'delete_topic':
             $user->add_lang('viewtopic');
             $topic_ids = !$quickmod ? request_var('topic_id_list', array(0)) : array(request_var('t', 0));
             if (!sizeof($topic_ids)) {
                 trigger_error('NO_TOPIC_SELECTED');
             }
             mcp_delete_topic($topic_ids);
             break;
         case 'delete_post':
             $user->add_lang('posting');
             $post_ids = !$quickmod ? request_var('post_id_list', array(0)) : array(request_var('p', 0));
             if (!sizeof($post_ids)) {
                 trigger_error('NO_POST_SELECTED');
             }
             mcp_delete_post($post_ids);
             break;
     }
     switch ($mode) {
         case 'front':
             include $phpbb_root_path . 'includes/mcp/mcp_front.' . $phpEx;
             $user->add_lang('acp/common');
             mcp_front_view($id, $mode, $action);
             $this->tpl_name = 'mcp_front';
             $this->page_title = 'MCP_MAIN';
             break;
         case 'forum_view':
             include $phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx;
             $user->add_lang('viewforum');
             $forum_id = request_var('f', 0);
             $forum_info = get_forum_data($forum_id, 'm_', true);
             if (!sizeof($forum_info)) {
                 $this->main('main', 'front');
                 return;
             }
             $forum_info = $forum_info[$forum_id];
             mcp_forum_view($id, $mode, $action, $forum_info);
             $this->tpl_name = 'mcp_forum';
             $this->page_title = 'MCP_MAIN_FORUM_VIEW';
             break;
         case 'topic_view':
             include $phpbb_root_path . 'includes/mcp/mcp_topic.' . $phpEx;
             mcp_topic_view($id, $mode, $action);
             $this->tpl_name = 'mcp_topic';
             $this->page_title = 'MCP_MAIN_TOPIC_VIEW';
             break;
         case 'post_details':
             include $phpbb_root_path . 'includes/mcp/mcp_post.' . $phpEx;
             mcp_post_details($id, $mode, $action);
             $this->tpl_name = $action == 'whois' ? 'mcp_whois' : 'mcp_post';
             $this->page_title = 'MCP_MAIN_POST_DETAILS';
             break;
         default:
             trigger_error('NO_MODE', E_USER_ERROR);
             break;
     }
 }
Пример #3
0
    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&amp;p={$post_id}&amp;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&amp;f={$post_info['forum_id']}&amp;p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=approve_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&amp;mode=report_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&amp;mode=user_notes&amp;u=' . $post_info['user_id']), 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&amp;mode=warn_user&amp;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 ? '&amp;mode=unapproved_topics' : '&amp;mode=unapproved_posts')) . '&amp;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&amp;mode=approve_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id . '&amp;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('&nbsp; &nbsp;', $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'] . '&amp;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'] . '&amp;p=' . $row['post_id']) . ($mode == 'unapproved_posts' ? '#p' . $row['post_id'] : ''), 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&amp;start={$start}&amp;mode=approve_details&amp;f={$row['forum_id']}&amp;p={$row['post_id']}" . ($mode == 'unapproved_topics' ? "&amp;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 . "&amp;f={$forum_id}&amp;st={$sort_days}&amp;sk={$sort_key}&amp;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;
        }
    }
Пример #4
0
        break;
    case 'fork':
        $_CLASS['core_user']->add_lang('viewtopic');
        $topic_ids = get_topic_ids($quick_mod);
        if (empty($topic_ids)) {
            trigger_error('NO_TOPIC_SELECTED');
        }
        mcp_fork_topic($topic_ids);
        break;
    case 'delete_topic':
        $_CLASS['core_user']->add_lang('viewtopic');
        $topic_ids = get_topic_ids($quick_mod);
        if (empty($topic_ids)) {
            trigger_error('NO_TOPIC_SELECTED');
        }
        mcp_delete_topic($topic_ids);
        break;
    case 'delete_post':
        $_CLASS['core_user']->add_lang('posting');
        $post_ids = get_post_ids($quick_mod);
        if (empty($post_ids)) {
            trigger_error('NO_POST_SELECTED');
        }
        mcp_delete_post($post_ids);
        break;
    default:
        trigger_error("Unknown mode: {$mode}");
        break;
}
script_close(false);
function get_topic_ids($quick_mod)