예제 #1
0
파일: mcp_main.php 프로젝트: tqangxl/phpbb
 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;
     }
 }