public function processUsers(XenForo_DataWriter_DiscussionMessage_Post $dw)
 {
     if ($this->_controller->getInput()->filterSingle('ImageRestrictionDataIsComing', XenForo_Input::UINT)) {
         $usernames = $this->_controller->getInput()->filterSingle('ImageRestrictionUsers', XenForo_Input::STRING, array('array' => true));
         foreach (array_keys($usernames) as $i) {
             if (empty($usernames[$i])) {
                 unset($usernames[$i]);
             }
         }
         if (!empty($usernames)) {
             $userModel = $this->_controller->getModelFromCache('XenForo_Model_User');
             $fetchOptions = array();
             $invalidNames = array();
             $users = $userModel->getUsersByNames($usernames, $fetchOptions, $invalidNames);
             try {
                 if (!empty($invalidNames)) {
                     throw new XenForo_Exception(new XenForo_Phrase('th_imagerestriction_users_not_found_x_imagerestriction', array('users' => implode(', ', $invalidNames))), true);
                 }
             } catch (Exception $e) {
                 XenForo_Error::logException($e);
             }
             $dw->setImageRestrictionUsers($users);
         } else {
             $dw->setImageRestrictionUsers(array());
         }
     }
 }
Exemplo n.º 2
0
 public function Tinhte_XenTag_actionSave(XenForo_DataWriter_DiscussionMessage_Post $dw)
 {
     /* @var $tagModel Tinhte_XenTag_Model_Tag */
     $tagModel = $this->getModelFromCache('Tinhte_XenTag_Model_Tag');
     $forum = $dw->getExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM);
     $thread = $this->_getPostModel()->Tinhte_XenTag_getThread($dw->get('post_id'));
     if ($tagModel->canTagThread($thread, $forum)) {
         $tags = $this->getModelFromCache('Tinhte_XenTag_Model_Tag')->processInput($this->_input);
         if ($tags !== false) {
             /* @var $threadDw XenForo_DataWriter_Discussion_Thread */
             $threadDw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
             $threadDw->setExistingData($dw->get('thread_id'));
             $threadDw->Tinhte_XenTag_setTags($tags);
             $threadDw->save();
         }
     }
     // sondh@2012-08-11
     // just to be safe...
     unset($GLOBALS[Tinhte_XenTag_Constants::GLOBALS_CONTROLLERPUBLIC_POST_SAVE]);
 }
Exemplo n.º 3
0
 protected function _setSilentEditOptions(array $post, array $thread, array $forum, XenForo_DataWriter_DiscussionMessage_Post $dw)
 {
     if ($this->_getPostModel()->canControlSilentEdit($post, $thread, $forum)) {
         $logEdit = !$this->_input->filterSingle('silent', XenForo_Input::UINT);
         $dw->setOption(XenForo_DataWriter_DiscussionMessage_Post::OPTION_UPDATE_EDIT_DATE, $logEdit);
         if (!$logEdit && $this->_input->filterSingle('clear_edit', XenForo_Input::UINT)) {
             $dw->set('last_edit_date', 0);
         }
     }
 }
Exemplo n.º 4
0
 public static function updateThreadDwFromPostDw(XenForo_DataWriter_Discussion_Thread $threadDw, XenForo_DataWriter_DiscussionMessage_Post $postDw)
 {
     if (!Tinhte_XenTag_Option::get('tagThreadWithHashtags')) {
         return false;
     }
     $message = $postDw->get('message');
     $tagTexts = Tinhte_XenTag_Integration::parseHashtags($message);
     $threadTags = $threadDw->Tinhte_XenTag_getTags();
     $threadTagTexts = Tinhte_XenTag_Helper::getTextsFromTagsOrTexts($threadTags);
     $threadSafes = Tinhte_XenTag_Helper::getSafeTagsTextArrayForSearch($threadTagTexts);
     $isChanged = false;
     foreach ($tagTexts as $tagText) {
         $safe = Tinhte_XenTag_Helper::getSafeTagTextForSearch($tagText);
         if (!in_array($safe, $threadSafes)) {
             $threadTags[] = $tagText;
             $threadSafes[] = $safe;
             $isChanged = true;
         }
     }
     if ($isChanged) {
         $threadDw->Tinhte_XenTag_setTags($threadTags);
         return true;
     }
     return false;
 }