コード例 #1
0
ファイル: Post.php プロジェクト: Sywooch/forums
 /**
  * Gets the search form controller response for this type.
  *
  * @see XenForo_Search_DataHandler_Abstract::getSearchFormControllerResponse()
  */
 public function getSearchFormControllerResponse(XenForo_ControllerPublic_Abstract $controller, XenForo_Input $input, array $viewParams)
 {
     $params = $input->filterSingle('c', XenForo_Input::ARRAY_SIMPLE);
     $viewParams['search']['reply_count'] = empty($params['reply_count']) ? '' : $params['reply_count'];
     if (!empty($params['prefix'])) {
         $viewParams['search']['prefixes'] = array_fill_keys(explode(' ', $params['prefix']), true);
     } else {
         $viewParams['search']['prefixes'] = array();
     }
     /** @var $threadPrefixModel XenForo_Model_ThreadPrefix */
     $threadPrefixModel = XenForo_Model::create('XenForo_Model_ThreadPrefix');
     $viewParams['prefixes'] = $threadPrefixModel->getPrefixesByGroups();
     if ($viewParams['prefixes']) {
         $visiblePrefixes = $threadPrefixModel->getVisiblePrefixIds();
         foreach ($viewParams['prefixes'] as $key => &$prefixes) {
             foreach ($prefixes as $prefixId => $prefix) {
                 if (!isset($visiblePrefixes[$prefixId])) {
                     unset($prefixes[$prefixId]);
                 }
             }
             if (!count($prefixes)) {
                 unset($viewParams['prefixes'][$key]);
             }
         }
     }
     $viewParams['search']['thread'] = array();
     if (!empty($params['thread'])) {
         $threadModel = $this->_getThreadModel();
         $thread = $threadModel->getThreadById($params['thread'], array('join' => XenForo_Model_Thread::FETCH_FORUM, 'permissionCombinationId' => XenForo_Visitor::getPermissionCombinationId()));
         if ($thread) {
             $permissions = XenForo_Permission::unserializePermissions($thread['node_permission_cache']);
             if ($threadModel->canViewThreadAndContainer($thread, $thread, $null, $permissions)) {
                 $viewParams['search']['thread'] = $this->_getThreadModel()->getThreadById($params['thread']);
             }
         }
     }
     return $controller->responseView('XenForo_ViewPublic_Search_Form_Post', 'search_form_post', $viewParams);
 }
コード例 #2
0
ファイル: Post.php プロジェクト: Sywooch/forums
 protected function _moveOrCopyPostsAction($permissionMethod, $actionMethod, $viewName, $templateName)
 {
     if ($this->isConfirmedPost()) {
         $input = $this->_input->filter(array('thread_type' => XenForo_Input::STRING, 'node_id' => XenForo_Input::UINT, 'title' => XenForo_Input::STRING, 'prefix_id' => XenForo_Input::UINT, 'existing_url' => XenForo_Input::STRING, 'send_author_alert' => XenForo_Input::BOOLEAN, 'author_alert_reason' => XenForo_Input::STRING));
         if ($input['thread_type'] == 'new') {
             $viewableNodes = $this->getModelFromCache('XenForo_Model_Node')->getViewableNodeList();
             if (!isset($viewableNodes[$input['node_id']])) {
                 return $this->responseNoPermission();
             }
             $options = array('threadType' => 'new', 'threadNodeId' => $input['node_id'], 'threadTitle' => $input['title'], 'threadPrefixId' => $input['prefix_id']);
         } else {
             $threadId = 0;
             $results = $this->parseRouteUrl($input['existing_url']);
             if ($results && !empty($results['params']['thread_id'])) {
                 /** @var XenForo_Model_Thread $threadModel */
                 $threadModel = $this->getModelFromCache('XenForo_Model_Thread');
                 $thread = $threadModel->getThreadById($results['params']['thread_id'], array('join' => XenForo_Model_Thread::FETCH_FORUM, 'permissionCombinationId' => XenForo_Visitor::getPermissionCombinationId()));
                 if ($thread) {
                     $permissions = XenForo_Permission::unserializePermissions($thread['node_permission_cache']);
                     if ($threadModel->canViewThreadAndContainer($thread, $thread, $null, $permissions) && $threadModel->canMergeThread($thread, $thread, $null, $permissions)) {
                         $threadId = $thread['thread_id'];
                     }
                 }
             }
             if (!$threadId) {
                 return $this->responseError(new XenForo_Phrase('existing_thread_not_found_or_no_merge_permission'));
             }
             $options = array('threadType' => 'existing', 'threadId' => $threadId);
         }
         $options['authorAlert'] = $input['send_author_alert'];
         $options['authorAlertReason'] = $input['author_alert_reason'];
         $this->_assertPostOnly();
         $ids = $this->getInlineModIds(false);
         $newThread = $this->getInlineModTypeModel()->{$actionMethod}($ids, $options, $errorPhraseKey);
         if (!$newThread) {
             throw $this->getErrorOrNoPermissionResponseException($errorPhraseKey);
         }
         $this->clearCookie();
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('threads', $newThread));
     } else {
         $postIds = $this->getInlineModIds();
         $handler = $this->_getInlineModPostModel();
         if (!$handler->{$permissionMethod}($postIds, $errorPhraseKey)) {
             throw $this->getErrorOrNoPermissionResponseException($errorPhraseKey);
         }
         $redirect = $this->getDynamicRedirect();
         if (!$postIds) {
             return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirect);
         }
         $firstPost = $this->_getPostModel()->getPostById(reset($postIds), array('join' => XenForo_Model_Post::FETCH_THREAD + XenForo_Model_Post::FETCH_FORUM));
         $viewParams = array('postIds' => $postIds, 'postCount' => count($postIds), 'firstPost' => $firstPost, 'nodes' => $this->getModelFromCache('XenForo_Model_Node')->getViewableNodeList(), 'redirect' => $redirect, 'prefixes' => $this->_getPrefixModel()->getUsablePrefixesInForums($firstPost['node_id']), 'forcePrefixes' => XenForo_Application::get('threadPrefixes') ? true : false);
         return $this->responseView($viewName, $templateName, $viewParams);
     }
 }
コード例 #3
0
 /**
  * Gets the search form controller response for this type.
  *
  * @see XenForo_Search_DataHandler_Abstract::getSearchFormControllerResponse()
  */
 public function getSearchFormControllerResponse(XenForo_ControllerPublic_Abstract $controller, XenForo_Input $input, array $viewParams)
 {
     $params = $input->filterSingle('c', XenForo_Input::ARRAY_SIMPLE);
     $viewParams['search']['reply_count'] = empty($params['reply_count']) ? '' : $params['reply_count'];
     $viewParams['search']['conversation'] = array();
     if (!empty($params['conversation'])) {
         $conversationModel = $this->_getConversationModel();
         $conversation = $conversationModel->getConversationById($params['conversation'], array('join' => XenForo_Model_Conversation::FETCH_FORUM, 'permissionCombinationId' => XenForo_Visitor::getPermissionCombinationId()));
         if ($conversation) {
             $permissions = XenForo_Permission::unserializePermissions($conversation['node_permission_cache']);
             if ($conversationModel->canViewConversationAndContainer($conversation, $conversation, $null, $permissions)) {
                 $viewParams['search']['conversation'] = $this->_getConversationModel()->getConversationById($params['conversation']);
             }
         }
     }
     return $controller->responseView('ThemeHouse_ConvSearch_ViewPublic_Search_Form_ConversationMessage', 'search_form_conversation_message', $viewParams);
 }