예제 #1
0
 public function actionEdit()
 {
     /*  @var $handler SimplePortal_ItemHandler_Abstract */
     $form = new SimplePortal_Form_Item($this->_input);
     $input = $form->getValidatedInputFields();
     $conditions = $form->getConditions($input);
     if (!($item = SimplePortal_Static::getItemModel()->getPortalItem($conditions))) {
         $item = SimplePortal_Static::getItemModel()->getDefaultItem();
         if (!isset($conditions['content_id'], $conditions['content_type'])) {
             return $this->responseMessage('Invalid portal item condition');
         }
         $item['content_id'] = $conditions['content_id'];
         $item['content_type'] = $conditions['content_type'];
     }
     $handler = SimplePortal_Static::getItemModel()->getPortalItemHandlerClass($item['content_type']);
     if ($this->isConfirmedPost()) {
         if (isset($item['portalItem_id'])) {
             $data = $handler->getItemById($item['content_id']);
             if ($deleteItem = $this->_input->filterSingle('delete_item', XenForo_Input::UINT)) {
                 return $this->deleteItem($item, $data, $input);
             }
             $this->saveItem($item, $input, $handler, $data);
             return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false));
         }
         $dm = XenForo_DataWriter::create('SimplePortal_DataWriter_PortalItem');
         $handler->processAdditonalSaveData($dm, $input);
         $this->setDwFieldsFromInput($dm, $input);
         $dm->save();
         $data = $handler->getItemById($input['content_id']);
         XenForo_Model_Log::logModeratorAction($input['content_type'], $data, SimplePortal_Static::MOD_ACTION_PROMOTE);
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false));
     }
     $viewParams = array('categories' => $this->getModelFromCache('SimplePortal_Model_Category')->getAllCategories(), 'content_type' => $item['content_type'], 'content_id' => $item['content_id'], 'item' => $item, 'attachments' => $handler->getAttachmentsForContent($input['content_id']));
     return $this->responseView('SimplePortal_ViewPublic_Manage', 'el_portal_confirm', $viewParams);
 }
 protected function _preDispatch($action)
 {
     parent::_preDispatch($action);
     if (!SimplePortal_Static::getItemModel()->canPromoteItem(null, array())) {
         throw $this->getNoPermissionResponseException();
     }
 }
예제 #3
0
 protected function _discussionPreSave()
 {
     parent::_discussionPreSave();
     // TODO: Change the autogenerated stub
     if (in_array($this->get('node_id'), SimplePortal_Static::option('autopromotenodes')) or XenForo_Application::isRegistered('extraportal.promoteThread')) {
         $this->setOption(self::OPTION_PROMOTE_TO_PORTAL, true);
     }
 }
예제 #4
0
 public static function demote($contentType, $contentId)
 {
     $condition = array('content_type' => $contentType, 'content_id' => $contentId);
     $portalItem = SimplePortal_Static::getItemModel()->getPortalItem($condition);
     if ($portalItem) {
         $dw = XenForo_DataWriter::create('SimplePortal_DataWriter_PortalItem');
         $dw->setExistingData($portalItem);
         $dw->delete();
     }
 }
예제 #5
0
 public static function removePortelItems($contentType)
 {
     $items = SimplePortal_Static::getItemModel()->getPortalItems(array('content_type' => $contentType));
     foreach ($items as $itemId => $data) {
         $dw = XenForo_DataWriter::create('SimplePortal_DataWriter_PortalItem');
         $dw->setExistingData($itemId);
         $dw->delete();
         unset($dw);
     }
 }
예제 #6
0
 public function canPromoteItem($type, array $data, &$errorPhraseKey = '', array $nodePermissions = null, array $viewingUser = null)
 {
     $canPromote = false;
     $this->standardizeViewingUserReference($viewingUser);
     if ($type) {
         $handler = SimplePortal_Static::getItemModel()->getPortalItemHandlerClass($type);
         if ($handler) {
             $canPromote = $handler->canPromote($data);
         }
     } else {
         $canPromote = $this->canPromoteItems();
     }
     return $canPromote;
 }
예제 #7
0
 public function actionAddThread()
 {
     $forumId = $this->_input->filterSingle('node_id', XenForo_Input::UINT);
     $forumName = $this->_input->filterSingle('node_name', XenForo_Input::STRING);
     $ftpHelper = $this->getHelper('ForumThreadPost');
     $promoteToPortal = $this->_input->filterSingle('promote_to_portal', XenForo_Input::UINT);
     if ($promoteToPortal && SimplePortal_Static::getItemModel()->canPromoteItem('thread', $ftpHelper->assertForumValidAndViewable($forumId ? $forumId : $forumName))) {
         $form = new SimplePortal_Form_Item($this->_input);
         $input = $form->getValidatedInputFields();
         XenForo_Application::set('extraportal.promoteThread', $input);
     }
     $parentReturn = parent::actionAddThread();
     return $parentReturn;
 }
 public static function getPromoteFormElement($content, $params, XenForo_Template_Abstract $template)
 {
     $contentType = $params['content_type'];
     $contentData = $params['content_data'];
     // if we'll ever need it, we have it now, without changing anything in the templates:)
     $contentId = $params['content_id'];
     if (self::getItemModel()->canPromoteItem($contentType, $contentData)) {
         if ($contentType == 'thread' && in_array($contentData['node_id'], SimplePortal_Static::option('autopromotenodes'))) {
             //thread will be promoted automatically... we don't need the form
             return '';
         }
         $viewParams = array('categories' => self::getItemModel()->getModelFromCache('SimplePortal_Model_Category')->getAllCategories(), 'content_type' => 'thread', 'item' => self::getItemModel()->getDefaultItem());
         return $template->create('el_portal_promothread', array_merge($template->getParams(), $viewParams));
     }
 }
예제 #9
0
 /**
  * @param $controllerResponse
  * @param $controllerName
  * @param $action
  */
 protected function _postDispatch($controllerResponse, $controllerName, $action)
 {
     parent::_postDispatch($controllerResponse, $controllerName, $action);
     if ($controllerResponse instanceof XenForo_ControllerResponse_View) {
         if (!XenForo_Autoloader::getInstance()->autoload('SimplePortal_BrandingFree')) {
             $controllerResponse->params['show_portal_branding'] = true;
         }
         $portalContainer = $this->getPortalConfig();
         if (isset($portalContainer->container)) {
             $controllerResponse->containerParams = array('containerTemplate' => $portalContainer->container);
         }
         if (SimplePortal_Static::option('defaultSidebar')) {
             $viewParams = $this->_getDefaultSidebarParams();
             $controllerResponse->params += $viewParams;
         }
     }
 }
예제 #10
0
 public function actionIndex()
 {
     /** @var $forumModel xenForo_Model_Forum */
     $forumModel = $this->getModelFromCache('XenForo_Model_Forum');
     /** @var $nodeModel XenForo_Model_Node */
     $nodeModel = $this->getModelFromCache('XenForo_Model_Node');
     $forums = $nodeModel->getViewableNodeList();
     foreach ($forums as $forumId => $forum) {
         if ($forum['node_type_id'] == 'Forum' && $forumModel->canPostThreadInForum($forumModel->getForumById($forumId, array(XenForo_Model_Thread::FETCH_FORUM_OPTIONS)))) {
             $forums[$forumId]['is_forum'] = true;
         } else {
             if ($forum['node_type_id'] != 'Category') {
                 unset($forums[$forumId]);
             }
         }
     }
     $viewParams = array('forums' => $forums, 'additionalTypes' => SimplePortal_Static::getItemModel()->getAdditonalTypesForCreateNewForm());
     return $this->responseView('SimplePortal_ViewPublic_CreateNewContent', 'el_portal_create_new', $viewParams);
 }
예제 #11
0
 public function actionIndex()
 {
     if (isset($this->getPortalConfig()->only_container, $this->getPortalConfig()->container)) {
         return $this->responseView('SimplePortal_ViewPublic_Index', $this->getPortalConfig()->container, array());
     }
     $page = max(1, $this->_input->filterSingle('page', XenForo_Input::UINT));
     $categoryId = $this->_input->filterSingle('category_id', XenForo_Input::UINT);
     $category = $this->getPortalCategoryHelper()->assertCategoryValid($categoryId);
     $extraReturn = $this->getExtraContent($page, $category);
     if ($extraReturn && $extraReturn instanceof XenForo_ControllerResponse_Abstract) {
         return $extraReturn;
     }
     if ($category) {
         $categoryId = $category['category_id'];
     } else {
         $categoryId = 0;
     }
     $itemsPerPage = SimplePortal_Static::option('perPage');
     if ($categoryId) {
         $this->canonicalizeRequestUrl(XenForo_Link::buildPublicLink('portal/categories', $category, array('page' => $page)));
     } else {
         $this->canonicalizeRequestUrl(XenForo_Link::buildPublicLink('portal', $category, array('page' => $page)));
     }
     $conditions = array('category_id' => $categoryId);
     $fetchOptions = array('perPage' => $itemsPerPage, 'page' => $page);
     $categories = $this->getModelFromCache('SimplePortal_Model_Category')->getAllCategories();
     $fetchOptions = SimplePortal_Static::getItemModel()->getDefaultFetchOptions($fetchOptions);
     $fetchOptions += array('join' => SimplePortal_Model_PortalItem::FETCH_CATEGORY);
     $items = SimplePortal_Static::getItemModel()->getPortalItems($conditions, $fetchOptions);
     $items = SimplePortal_Static::getItemModel()->fetchPortalItemsData($items);
     $itemHandlers = SimplePortal_Static::getItemModel()->getPortalItemHandlerClasses();
     $viewParams = array('items' => $items, 'itemCount' => count($items), 'totalItems' => SimplePortal_Static::getItemModel()->countItems($conditions), 'page' => $page, 'postsPerPage' => $itemsPerPage, 'categories' => $categories, 'handlerClasses' => $itemHandlers);
     if (isset($this->getPortalConfig()->showInlineAttachments) or !XenForo_Application::getOptions()->strip_portal_attachments) {
         $viewParams['showInlineAttachments'] = true;
     }
     if ($categoryId) {
         $viewParams += array('current_category' => $categories[$categoryId]);
         $viewParams += array('linkparams' => array('category_id' => $categoryId));
     } else {
         $viewParams += array('current_category' => false);
     }
     return $this->wrapPage($viewParams);
 }
예제 #12
0
 public static function prepareMessage($item, XenForo_BbCode_Parser $bbCodeParser, array $bbCodeOptions, XenForo_View $view)
 {
     $message = $item['data']['message'];
     if ($bbCodeOptions['states']['viewAttachments']) {
         $string = preg_replace('#\\[(quoteee)[^\\]]*\\].*\\[/\\1\\]#siU', ' ', $message);
     } else {
         $string = preg_replace('#\\[(attach|quote)[^\\]]*\\].*\\[/\\1\\]#siU', ' ', $message);
     }
     $formatter = XenForo_BbCode_Formatter_Base::create('ImageCount');
     $parser = XenForo_BbCode_Parser::create($formatter);
     $parser->render($string);
     if (isset($item['data']['attachments'])) {
         $item['attachments'] = $item['data']['attachments'];
     }
     $item['mediaCount'] = $formatter->getMediaCount();
     $item['message'] = XenForo_Helper_String::wholeWordTrim($string, SimplePortal_Static::option('charlimit'));
     $item['messageHtml'] = XenForo_ViewPublic_Helper_Message::getBbCodeWrapper($item, $bbCodeParser, $bbCodeOptions);
     if (strpos($item['messageHtml'], SimplePortal_Static::PORTAL_PREVIEW_ENDSTRING)) {
         $item['messageHtml'] = strstr($item['messageHtml'], SimplePortal_Static::PORTAL_PREVIEW_ENDSTRING, true);
     }
     return $item;
 }
예제 #13
0
 public function actionPromote()
 {
     $handler = SimplePortal_Static::getItemModel()->getPortalItemHandlerClass('thread');
     if ($handler && $handler->canPromote()) {
         if ($this->isConfirmedPost()) {
             $itemIds = $this->getInlineModIds(false);
             $categoryId = $this->_input->filterSingle('category_id', XenForo_Input::UINT);
             $additionalData = array();
             if ($categoryId) {
                 $additionalData = array(SimplePortal_Helper_Content::CATEGORY_ID => $categoryId);
             }
             foreach ($itemIds as $threadId) {
                 if (!$handler->isAlreadyPromoted('thread', $threadId)) {
                     SimplePortal_Helper_Content::promote('thread', $threadId, $additionalData);
                     $this->getModelFromCache('SimplePortal_Model_PortalItem')->logModerationAction('thread', $threadId, SimplePortal_Static::MOD_ACTION_PROMOTE);
                 }
             }
             $this->clearCookie();
             return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect());
         } else {
             $threadIds = $this->getInlineModIds();
             $redirect = $this->getDynamicRedirect();
             if (!$threadIds) {
                 return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirect);
             }
             $conditions = array('content_type' => 'thread', 'content_id' => $threadIds);
             $alreadyPromoted = SimplePortal_Static::getItemModel()->getPortalItems($conditions, array(), 'content_id');
             $threadIds = array_diff($threadIds, array_keys($alreadyPromoted));
             $redirect = $this->getDynamicRedirect();
             if (!$threadIds) {
                 return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirect);
             }
             $viewParams = array('threadIds' => $threadIds, 'threadCount' => count($threadIds), 'redirect' => $redirect, 'categories' => $this->getModelFromCache('SimplePortal_Model_Category')->getAllCategories(), 'contentType' => new XenForo_Phrase('threads'), 'alreadyPromoted' => count($alreadyPromoted));
             return $this->responseView('SimplePortal_ViewPublic_InlineMod_Thread', 'el_portal_inline_mod_thread_promote', $viewParams);
         }
     }
     return $this->responseNoPermission();
 }
예제 #14
0
 public function canPromote(array $item = array(), array $viewingUser = null)
 {
     $perm = SimplePortal_Static::hasPermission('promoteThreadToPortal');
     return $perm;
 }
예제 #15
0
 protected function _preDispatch($action)
 {
     if (!SimplePortal_Static::canManageCategories()) {
         throw $this->getNoPermissionResponseException();
     }
 }
예제 #16
0
 public function addInlineModOptionToThread(array &$thread, array $forum, array $nodePermissions = null, array $viewingUser = null)
 {
     $parentReturn = parent::addInlineModOptionToThread($thread, $forum, $nodePermissions, $viewingUser);
     $parentReturn['promote'] = SimplePortal_Static::getItemModel()->canPromoteItem('thread', $thread);
     return $parentReturn;
 }