コード例 #1
0
 /**
  * Removes a single tag
  *
  * @param $tagName string
  */
 private function removeTag($tagName)
 {
     $tagName = trim($tagName);
     $normalizer = $this->namespace . '\\TaggingUtil::slug';
     $tagSlug = call_user_func($normalizer, $tagName);
     if ($count = $this->tagged()->where('tag_slug', '=', $tagSlug)->delete()) {
         TaggingUtil::decrementCount($tagName, $tagSlug, $count);
     }
 }
コード例 #2
0
 /**
  * @see Form::save()
  */
 public function save()
 {
     // set the language temporarily to the thread language
     if ($this->languageID && $this->languageID != WCF::getLanguage()->getLanguageID()) {
         $this->setLanguage($this->languageID);
     }
     parent::save();
     // search for double posts
     if ($postID = PostEditor::test($this->subject, $this->text, WCF::getUser()->userID, $this->username)) {
         HeaderUtil::redirect('index.php?page=Thread&postID=' . $postID . SID_ARG_2ND_NOT_ENCODED . '#post' . $postID);
         exit;
     }
     // save poll
     if ($this->showPoll) {
         $this->pollEditor->save();
     }
     // save thread in database
     $this->newThread = ThreadEditor::create($this->board->boardID, $this->languageID, $this->prefix, $this->subject, $this->text, WCF::getUser()->userID, $this->username, intval($this->isImportant == 1), intval($this->isImportant == 2), $this->closeThread, $this->getOptions(), $this->subscription, $this->attachmentListEditor, $this->pollEditor, intval($this->disableThread || !$this->board->getPermission('canStartThreadWithoutModeration')));
     if ($this->isImportant == 2) {
         $this->newThread->assignBoards($this->boardIDs);
     }
     // save tags
     if (MODULE_TAGGING && THREAD_ENABLE_TAGS && $this->board->getPermission('canSetTags')) {
         $tagArray = TaggingUtil::splitString($this->tags);
         if (count($tagArray)) {
             $this->newThread->updateTags($tagArray);
         }
     }
     // reset language
     if ($this->userInterfaceLanguageID !== null) {
         $this->setLanguage($this->userInterfaceLanguageID, true);
     }
     if (!$this->disableThread && $this->board->getPermission('canStartThreadWithoutModeration')) {
         // update user posts
         if (WCF::getUser()->userID && $this->board->countUserPosts) {
             require_once WBB_DIR . 'lib/data/user/WBBUser.class.php';
             WBBUser::updateUserPosts(WCF::getUser()->userID, 1);
             if (ACTIVITY_POINTS_PER_THREAD) {
                 require_once WCF_DIR . 'lib/data/user/rank/UserRank.class.php';
                 UserRank::updateActivityPoints(ACTIVITY_POINTS_PER_THREAD);
             }
         }
         // refresh counter and last post
         $this->board->addThreads();
         $this->board->setLastPost($this->newThread);
         // reset stat cache
         WCF::getCache()->clearResource('stat');
         WCF::getCache()->clearResource('boardData');
         // send notifications
         $this->newThread->sendNotification(new Post(null, array('postID' => $this->newThread->firstPostID, 'message' => $this->text, 'enableSmilies' => $this->enableSmilies, 'enableHtml' => $this->enableHtml, 'enableBBCodes' => $this->enableBBCodes)), $this->attachmentListEditor);
         $this->saved();
         // forward to post
         HeaderUtil::redirect('index.php?page=Thread&threadID=' . $this->newThread->threadID . SID_ARG_2ND_NOT_ENCODED);
     } else {
         $this->saved();
         if ($this->disableThread) {
             // forward to post
             HeaderUtil::redirect('index.php?page=Thread&threadID=' . $this->newThread->threadID . SID_ARG_2ND_NOT_ENCODED);
         } else {
             WCF::getTPL()->assign(array('url' => 'index.php?page=Board&boardID=' . $this->boardID . SID_ARG_2ND_NOT_ENCODED, 'message' => WCF::getLanguage()->get('wbb.threadAdd.moderation.redirect'), 'wait' => 5));
             WCF::getTPL()->display('redirect');
         }
     }
     exit;
 }
コード例 #3
0
 /**
  * @see Page::readData()
  */
 public function readData()
 {
     parent::readData();
     if (!count($_POST)) {
         $this->closeThread = $this->thread->isClosed;
         $this->text = $this->post->message;
         $this->subject = $this->post->subject;
         $this->subscription = $this->thread->subscribed;
         $this->prefix = $this->thread->prefix;
         if ($this->thread->isSticky) {
             $this->isImportant = 1;
         }
         if ($this->thread->isAnnouncement) {
             $this->isImportant = 2;
         }
         $this->boardIDs = $this->thread->getAssignedBoards();
         $this->languageID = $this->thread->languageID;
         $this->editReason = $this->post->editReason;
         $this->enableSmilies = $this->post->enableSmilies;
         $this->enableHtml = $this->post->enableHtml;
         $this->enableBBCodes = $this->post->enableBBCodes;
         $this->showSignature = $this->post->showSignature;
         // tags
         if (THREAD_ENABLE_TAGS && $this->thread->firstPostID == $this->postID) {
             $this->tags = TaggingUtil::buildString($this->thread->getTags(array($this->languageID)));
         }
     }
     // get post list
     if ($this->thread->firstPostID != $this->postID) {
         try {
             require_once WBB_DIR . 'lib/data/post/PostEditPostList.class.php';
             $this->postList = new PostEditPostList($this->post, $this->thread, $this->board);
             $this->attachments = $this->postList->attachments;
             if (count($this->attachments) > 0) {
                 require_once WCF_DIR . 'lib/data/attachment/MessageAttachmentList.class.php';
                 MessageAttachmentList::removeEmbeddedAttachments($this->attachments);
             }
         } catch (SystemException $e) {
         }
     }
 }
コード例 #4
0
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     $state = 'private';
     // save entry
     $entry = ContestEditor::create($this->userID, $this->groupID, $this->subject, $this->text, $this->getOptions(), $state, $this->classIDArray, $this->participants, $this->jurys, $this->prices, $this->sponsors, $this->attachmentListEditor);
     $this->saved();
     $contestID = $entry->contestID;
     if ($this->sponsortalk_trigger) {
         require_once WCF_DIR . 'lib/data/contest/sponsortalk/ContestSponsortalkEditor.class.php';
         $sponsortalk = ContestSponsortalkEditor::create($contestID, $this->sponsortalk_message, WCF::getUser()->userID, WCF::getUser()->username);
     }
     if ($this->jurytalk_trigger) {
         require_once WCF_DIR . 'lib/data/contest/jurytalk/ContestJurytalkEditor.class.php';
         $jurytalk = ContestJurytalkEditor::create($contestID, $this->jurytalk_message, WCF::getUser()->userID, WCF::getUser()->username);
     }
     if ($this->comment_trigger) {
         require_once WCF_DIR . 'lib/data/contest/comment/ContestCommentEditor.class.php';
         $comment = ContestCommentEditor::create($contestID, $this->comment_message, WCF::getUser()->userID, WCF::getUser()->username);
     }
     // save tags
     if (MODULE_TAGGING) {
         $tagArray = TaggingUtil::splitString($this->tags);
         if (count($tagArray)) {
             $entry->updateTags($tagArray);
         }
     }
     // forward
     HeaderUtil::redirect('index.php?page=Contest&contestID=' . $entry->contestID . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }
コード例 #5
0
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // save entry
     $this->entry->update($this->userID, $this->groupID, $this->subject, $this->text, $this->fromTime, $this->untilTime, $this->state, $this->getOptions(), $this->classIDArray, $this->attachmentListEditor);
     $this->saved();
     // save tags
     if (MODULE_TAGGING) {
         $tagArray = TaggingUtil::splitString($this->tags);
         if (count($tagArray)) {
             $this->entry->updateTags($tagArray);
         }
     }
     // forward
     HeaderUtil::redirect('index.php?page=Contest&contestID=' . $this->entry->contestID . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }