Example #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);
 }
Example #2
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;
 }