Beispiel #1
0
 public function Tinhte_XenTag_actionSave(XenForo_DataWriter_Discussion_Thread $dw)
 {
     /* @var $tagModel Tinhte_XenTag_Model_Tag */
     $tagModel = $this->getModelFromCache('Tinhte_XenTag_Model_Tag');
     $forum = $dw->getExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM);
     $thread = $dw->getMergedData();
     if (!empty($forum) and $tagModel->canTagThread($thread, $forum)) {
         $tags = $tagModel->processInput($this->_input);
         if ($tags !== false) {
             $dw->Tinhte_XenTag_setTags($tags);
         }
     }
     // sondh@2012-08-11
     // just to be safe...
     unset($GLOBALS[Tinhte_XenTag_Constants::GLOBALS_CONTROLLERPUBLIC_THREAD_SAVE]);
 }
Beispiel #2
0
 public function Tinhte_XenTag_actionAddThread(XenForo_DataWriter_Discussion_Thread $dw)
 {
     /* @var $tagModel Tinhte_XenTag_Model_Tag */
     $tagModel = $this->getModelFromCache('Tinhte_XenTag_Model_Tag');
     $forum = $dw->Tinhte_XenTag_getForumData();
     if ($tagModel->canTagThread(false, $forum)) {
         // only save tags if this user has the permission
         $tags = $tagModel->processInput($this->_input);
         if ($tags !== false) {
             $dw->Tinhte_XenTag_setTags($tags);
         }
     }
     $postDw = $dw->getFirstMessageDw();
     $postDw->setExtraData(Tinhte_XenTag_XenForo_DataWriter_DiscussionMessage_Post::DATA_SKIP_UPDATE_THREAD_TAGS, true);
     $dw->setExtraData(Tinhte_XenTag_XenForo_DataWriter_Discussion_Thread_Base::DATA_UPDATE_TAGS_FROM_POST, true);
     // sondh@2012-08-11
     // just to be safe...
     unset($GLOBALS[Tinhte_XenTag_Constants::GLOBALS_CONTROLLERPUBLIC_FORUM_ADD_THREAD]);
 }
Beispiel #3
0
 /**
  * Logs the moderator actions for thread edits.
  *
  * @param array $thread
  * @param XenForo_DataWriter_Discussion_Thread $dw
  * @param array $skip Array of keys to skip logging for
  */
 protected function _updateModeratorLogThreadEdit(array $thread, XenForo_DataWriter_Discussion_Thread $dw, array $skip = array())
 {
     $newData = $dw->getMergedNewData();
     if ($newData) {
         $oldData = $dw->getMergedExistingData();
         $basicLog = array();
         foreach ($newData as $key => $value) {
             $oldValue = isset($oldData[$key]) ? $oldData[$key] : '-';
             switch ($key) {
                 case 'sticky':
                     XenForo_Model_Log::logModeratorAction('thread', $thread, $value ? 'stick' : 'unstick');
                     break;
                 case 'discussion_open':
                     XenForo_Model_Log::logModeratorAction('thread', $thread, $value ? 'unlock' : 'lock');
                     break;
                 case 'discussion_state':
                     if ($value == 'visible' && $oldValue == 'moderated') {
                         XenForo_Model_Log::logModeratorAction('thread', $thread, 'approve');
                     } else {
                         if ($value == 'visible' && $oldValue == 'deleted') {
                             XenForo_Model_Log::logModeratorAction('thread', $thread, 'undelete');
                         } else {
                             if ($value == 'deleted') {
                                 XenForo_Model_Log::logModeratorAction('thread', $thread, 'delete_soft', array('reason' => ''));
                             } else {
                                 if ($value == 'moderated') {
                                     XenForo_Model_Log::logModeratorAction('thread', $thread, 'unapprove');
                                 }
                             }
                         }
                     }
                     break;
                 case 'title':
                     XenForo_Model_Log::logModeratorAction('thread', $thread, 'title', array('old' => $oldValue));
                     break;
                 case 'prefix_id':
                     if ($oldValue) {
                         $phrase = new XenForo_Phrase('thread_prefix_' . $oldValue);
                         $oldValue = $phrase->render();
                     } else {
                         $oldValue = '-';
                     }
                     XenForo_Model_Log::logModeratorAction('thread', $thread, 'prefix', array('old' => $oldValue));
                     break;
                 default:
                     if (!in_array($key, $skip)) {
                         $basicLog[$key] = $oldValue;
                     }
             }
         }
         if ($basicLog) {
             XenForo_Model_Log::logModeratorAction('thread', $thread, 'edit', $basicLog);
         }
     }
 }
Beispiel #4
0
 public function setExtraData($name, $value)
 {
     if ($name == self::DATA_FORUM) {
         if (is_array($value) && isset($value['node_id'])) {
             XenForo_DataWriter_Discussion_Thread::setForumCacheItem($value);
         }
     }
     return parent::setExtraData($name, $value);
 }
Beispiel #5
0
 protected function _updateModeratorLogThreadEdit(array $thread, XenForo_DataWriter_Discussion_Thread $dw, array $skip = array())
 {
     $newData = $dw->getMergedNewData();
     if ($newData) {
         $oldData = $dw->getMergedExistingData();
         $basicLog = array();
         foreach ($newData as $key => $value) {
             $oldValue = isset($oldData[$key]) ? $oldData[$key] : '-';
             switch ($key) {
                 case 'moderate_replies_th':
                     XenForo_Model_Log::logModeratorAction('thread', $thread, $value ? 'enable_moderate_replies' : 'disable_moderate_replies');
                     $skip[] = 'moderate_replies_th';
                     break;
             }
         }
     }
     return parent::_updateModeratorLogThreadEdit($thread, $dw, $skip);
 }
 /**
  *
  * @param XenForo_DataWriter_Discussion_Thread $dw
  */
 public function processThumbnails(XenForo_DataWriter_Discussion_Thread $dw)
 {
     $thumbnailUrl = $this->_input->filterSingle('thumbnail_url', XenForo_Input::STRING);
     $dw->set('thumbnail_url', $thumbnailUrl);
 }
Beispiel #7
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;
 }