Exemplo n.º 1
0
 /**
  * Loads associated options.
  */
 protected function loadOptions()
 {
     if (!empty($this->options)) {
         return;
     }
     $optionList = PollManager::getInstance()->getPollOptions(array($this->pollID));
     foreach ($optionList as $option) {
         $this->options[$option->optionID] = $option;
         if ($option->voted) {
             $this->isParticipant = true;
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @see	\cms\system\content\type\IContentType::validate()
  */
 public function validate($data)
 {
     PollManager::getInstance()->validate();
 }
Exemplo n.º 3
0
 public function assignVariables()
 {
     parent::assignVariables();
     if (WCF::getSession()->getPermission('user.cms.news.canStartPoll') && MODULE_POLL) {
         PollManager::getInstance()->assignVariables();
     }
     if ($this->imageID && $this->imageID != 0) {
         $this->image = FileCache::getInstance()->getFile($this->imageID);
     }
     WCF::getTPL()->assign(array('categoryList' => $this->categoryList, 'categoryIDs' => $this->categoryIDs, 'imageID' => $this->imageID, 'image' => $this->image, 'teaser' => $this->teaser, 'time' => $this->time, 'action' => $this->action, 'tags' => $this->tags, 'allowedFileExtensions' => explode("\n", StringUtil::unifyNewlines(WCF::getSession()->getPermission('user.cms.news.allowedAttachmentExtensions')))));
 }
Exemplo n.º 4
0
 /**
  * @see	\wcf\page\IPage::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     I18nHandler::getInstance()->assignVariables();
     if ($this->objectType->objectType == 'de.codequake.cms.content.type.poll') {
         PollManager::getInstance()->assignVariables();
     }
     WCF::getTPL()->assign(array('action' => 'add', 'contentData' => $this->contentData, 'contentList' => $this->contentList, 'cssClasses' => $this->cssClasses, 'objectType' => $this->objectType, 'pageID' => $this->pageID, 'pageList' => $this->pageList, 'parentID' => $this->parentID, 'position' => $this->position, 'showOrder' => $this->showOrder));
 }
Exemplo n.º 5
0
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     if (empty($_POST)) {
         $this->title = $this->content->getTitle();
         I18nHandler::getInstance()->setOptions('title', PACKAGE_ID, $this->content->title, 'cms.content.title\\d+');
         $this->pageID = $this->content->pageID;
         $this->cssClasses = $this->content->cssClasses;
         $this->parentID = $this->content->parentID;
         $this->showOrder = $this->content->showOrder;
         $this->position = $this->content->position;
         $this->contentData = $this->content->contentData;
         if ($this->objectType->objectType == 'de.codequake.cms.content.type.poll') {
             PollManager::getInstance()->setObject('de.codequake.cms.content', $this->content->contentID, $this->contentData['pollID']);
         }
         foreach ($this->objectType->getProcessor()->multilingualFields as $field) {
             I18nHandler::getInstance()->setOptions($field, PACKAGE_ID, $this->contentData[$field], 'cms.content.' . $field . '\\d+');
         }
     }
     // overwrite content list
     $this->contentList = new DrainedPositionContentNodeTree(null, $this->pageID, $this->contentID, $this->position);
     $this->contentList = $this->contentList->getIterator();
 }
 /**
  * @see	\wcf\page\IPage::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     // quotes
     MessageQuoteManager::getInstance()->assignVariables();
     // poll
     if ($this->canCreatePoll()) {
         PollManager::getInstance()->assignVariables();
     }
     WCF::getTPL()->assign(array('action' => $this->action, 'subject' => $this->subject, 'text' => $this->text, 'teaser' => $this->teaser, 'categoryList' => $this->categoryList, 'categoryIDs' => $this->categoryIDs, 'enableAutomaticArchiving' => $this->enableAutomaticArchiving, 'archivingDate' => $this->archivingDate, 'enableDelayedPublication' => $this->enableDelayedPublication, 'publicationDate' => $this->publicationDate, 'pictureID' => $this->pictureID, 'picture' => $this->picture, 'isHot' => $this->isHot, 'sources' => $this->sources, 'tags' => $this->tags, 'showSignatureSetting' => false, 'messageQuoteCount' => MessageQuoteManager::getInstance()->countQuotes()));
 }
Exemplo n.º 7
0
 /**
  * Adds a user vote.
  * 
  * @param	array<mixed>	$returnValues
  */
 protected function vote(array &$returnValues)
 {
     $pollAction = new \wcf\data\poll\PollAction(array($this->poll), 'vote', array('optionIDs' => $this->optionIDs));
     $pollAction->executeAction();
     // update poll object
     $polls = PollManager::getInstance()->getPolls(array($this->pollID));
     $this->poll = $polls[$this->pollID];
     if ($this->relatedObject !== null) {
         $this->poll->setRelatedObject($this->relatedObject);
     }
     // render result template
     $this->getResult($returnValues);
     // render vote template if votes are changeable
     if ($this->poll->isChangeable) {
         $this->getVote($returnValues);
     }
     $returnValues['canVote'] = $this->poll->isChangeable ? 1 : 0;
 }
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     MessageForm::save();
     if (WCF::getSession()->getPermission('mod.news.canEditNewsWithoutNote') && $this->editNoteSuppress == 1) {
         $this->news->editCount = 0;
         $this->editReason = '';
         $this->news->editTime = 0;
     }
     // save the news entry
     $data = array('subject' => $this->subject, 'text' => $this->text, 'teaser' => $this->teaser, 'languageID' => $this->languageID, 'enableBBCodes' => $this->enableBBCodes, 'enableHtml' => $this->enableHtml, 'enableSmilies' => $this->enableSmilies, 'editCount' => $this->news->editCount + 1, 'editReason' => $this->editReason, 'editTime' => TIME_NOW, 'editUser' => WCF::getUser()->username, 'editReason' => $this->editReason, 'editNoteSuppress' => $this->editNoteSuppress, 'isHot' => $this->isHot);
     // delayed publication
     if ($this->enableDelayedPublication) {
         $data['isPublished'] = 0;
         $dateTime = \DateTime::createFromFormat('Y-m-d H:i', $this->publicationDate, WCF::getUser()->getTimeZone());
         $data['publicationDate'] = $dateTime->getTimestamp();
     } else {
         $data['isPublished'] = 1;
         $data['publicationDate'] = 0;
     }
     // automatic archivation
     if ($this->enableAutomaticArchiving) {
         $dateTime = \DateTime::createFromFormat('Y-m-d H:i', $this->archivingDate, WCF::getUser()->getTimeZone());
         $data['archivingDate'] = $dateTime->getTimestamp();
     } else {
         $data['archivingDate'] = 0;
     }
     // news picture
     if (NEWS_ENABLE_NEWSPICTURE && $this->pictureID) {
         $data['pictureID'] = $this->pictureID;
     }
     $newsData = array('attachmentHandler' => $this->attachmentHandler, 'categoryIDs' => $this->categoryIDs, 'data' => $data);
     if (NEWS_ENTRY_ENABLE_SOURCES) {
         $newsData['sources'] = $this->sources;
     }
     if (MODULE_TAGGING) {
         $newsData['tags'] = $this->tags;
     }
     // save poll
     if ($this->canCreatePoll()) {
         $pollID = PollManager::getInstance()->save($this->news->newsID);
         if ($pollID) {
             $newsEditor = new NewsEditor($this->news);
             $newsEditor->update(array('pollID' => $pollID));
         }
     }
     $this->objectAction = new NewsAction(array($this->news), 'update', $newsData);
     $this->objectAction->executeAction();
     $this->saved();
     HeaderUtil::redirect(LinkHandler::getInstance()->getLink('News', array('application' => 'news', 'object' => $this->news)));
     exit;
 }
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     MessageForm::save();
     // save the news entry
     $data = array('subject' => $this->subject, 'message' => $this->text, 'languageID' => $this->languageID, 'enableBBCodes' => $this->enableBBCodes, 'enableHtml' => $this->enableHtml, 'enableSmilies' => $this->enableSmilies, 'isFeatured' => $this->isFeatured);
     // delayed publication
     if ($this->enableDelayedPublication) {
         $data['isPublished'] = 0;
         $dateTime = \DateTime::createFromFormat('Y-m-d H:i', $this->publicationDate, WCF::getUser()->getTimeZone());
         $data['publicationDate'] = $dateTime->getTimestamp();
     } else {
         $data['isPublished'] = 1;
         $data['publicationDate'] = 0;
     }
     if (WCF::getSession()->getPermission('user.news.canEditEntryDate')) {
         $data['time'] = $this->entryDateObj->getTimestamp();
     }
     $entryData = array('attachmentHandler' => $this->attachmentHandler, 'categoryIDs' => $this->categoryIDs, 'isEdit' => true, 'editReason' => $this->editReason, 'data' => $data);
     if (MODULE_TAGGING) {
         $entryData['tags'] = $this->tags;
     }
     // save poll
     if ($this->canCreatePoll()) {
         $pollID = PollManager::getInstance()->save($this->entry->entryID);
         if ($pollID) {
             $entryEditor = new EntryEditor($this->entry);
             $entryEditor->update(array('pollID' => $pollID));
         }
     }
     $this->objectAction = new EntryAction(array($this->entry), 'update', $entryData);
     $this->objectAction->executeAction();
     $this->saved();
     HeaderUtil::redirect(LinkHandler::getInstance()->getLink('NewsEntry', array('application' => 'cms', 'object' => $this->entry)));
     exit;
 }
Exemplo n.º 10
0
 public function save()
 {
     MessageForm::save();
     if ($this->time != '') {
         $dateTime = \DateTime::createFromFormat("Y-m-d H:i", $this->time, WCF::getUser()->getTimeZone());
     }
     $data = array('subject' => $this->subject, 'message' => $this->text, 'teaser' => $this->teaser, 'time' => $this->time != '' ? $dateTime->getTimestamp() : TIME_NOW, 'enableBBCodes' => $this->enableBBCodes, 'showSignature' => $this->showSignature, 'enableHtml' => $this->enableHtml, 'imageID' => $this->imageID ?: null, 'enableSmilies' => $this->enableSmilies, 'lastChangeTime' => TIME_NOW, 'isDisabled' => $this->time != '' && $dateTime->getTimestamp() > TIME_NOW ? 1 : 0, 'lastEditor' => WCF::getUser()->username, 'lastEditorID' => WCF::getUser()->userID);
     $newsData = array('data' => $data, 'categoryIDs' => $this->categoryIDs, 'tags' => $this->tags, 'attachmentHandler' => $this->attachmentHandler);
     $action = new NewsAction(array($this->newsID), 'update', $newsData);
     $resultValues = $action->executeAction();
     $this->saved();
     // re-define after saving
     $this->news = new News($this->newsID);
     if (WCF::getSession()->getPermission('user.cms.news.canStartPoll') && MODULE_POLL) {
         $pollID = PollManager::getInstance()->save($this->news->newsID);
         if ($pollID && $pollID != $this->news->pollID) {
             $editor = new NewsEditor($this->news);
             $editor->update(array('pollID' => $pollID));
         } else {
             if (!$pollID && $this->news->pollID) {
                 $editor = new NewsEditor($this->news);
                 $editor->update(array('pollID' => null));
             }
         }
     }
     HeaderUtil::redirect(LinkHandler::getInstance()->getLink('News', array('application' => 'cms', 'object' => $this->news)));
     exit;
 }
 /**
  * @see	\wcf\data\IDeleteAction::delete()
  */
 public function delete()
 {
     // delete news entries
     parent::delete();
     // collect data
     $newsIDs = $perUserCount = $pollIDs = array();
     foreach ($this->objects as $news) {
         $newsIDs[] = $news->newsID;
         if ($news->pollID) {
             $pollIDs[] = $news->pollID;
         }
         if (!$news->isDisabled) {
             if (!isset($perUserCount[$news->userID])) {
                 $perUserCount[$news->userID] = 0;
             }
             $perUserCount[$news->userID]++;
         }
     }
     if (!empty($newsIDs)) {
         // delete like data
         LikeHandler::getInstance()->removeLikes('de.voolia.news.likeableNews', $newsIDs);
         // delete comments
         CommentHandler::getInstance()->deleteObjects('de.voolia.news.comment', $newsIDs);
         // delete tag to object entries
         TagEngine::getInstance()->deleteObjects('de.voolia.news.entry', $newsIDs);
         // delete entry activity events
         UserActivityEventHandler::getInstance()->removeEvents('de.voolia.news.recentActivityEvent.news', $newsIDs);
         UserActivityPointHandler::getInstance()->removeEvents('de.voolia.news.activityPointEvent.news', $perUserCount);
         // delete entry from search index
         SearchIndexManager::getInstance()->delete('de.voolia.news.entry', $newsIDs);
         // remove object from moderation queue
         ModerationQueueActivationManager::getInstance()->removeModeratedContent('de.voolia.news.entry', $newsIDs);
     }
     // delete a poll
     if (!empty($pollIDs)) {
         PollManager::getInstance()->removePolls($pollIDs);
     }
     // reset the user storage data
     UserStorageHandler::getInstance()->resetAll('newsUnreadEntries');
     UserStorageHandler::getInstance()->resetAll('newsUnreadWatchedEntries');
     // reset the news cache
     NewsEditor::resetNewsStatsCache();
 }
 /**
  * @see	\wcf\page\IPage::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     // quotes
     MessageQuoteManager::getInstance()->assignVariables();
     // poll
     if ($this->canCreatePoll()) {
         PollManager::getInstance()->assignVariables();
     }
     WCF::getTPL()->assign(array('action' => 'add', 'subject' => $this->subject, 'text' => $this->text, 'categoryList' => $this->categoryList, 'categoryIDs' => $this->categoryIDs, 'enableDelayedPublication' => $this->enableDelayedPublication, 'publicationDate' => $this->publicationDate, 'isFeatured' => $this->isFeatured, 'tags' => $this->tags, 'showSignatureSetting' => false, 'messageQuoteCount' => MessageQuoteManager::getInstance()->countQuotes()));
 }
 /**
  * @see	\wcf\data\IDeleteAction::delete()
  */
 public function delete()
 {
     if (empty($this->objects)) {
         $this->readObjects();
     }
     // collect data
     $entryIDs = $entyData = $attachmentEntryIDs = $perUserCount = $pollIDs = array();
     foreach ($this->objects as $entry) {
         $entryIDs[] = $entry->entryID;
         $entryData[$entry->entryID] = $entry->userID;
         if ($entry->pollID) {
             $pollIDs[] = $entry->pollID;
         }
         if ($entry->attachments) {
             $attachmentEntryIDs[] = $entry->entryID;
         }
         if (!$entry->isDisabled) {
             if (!isset($perUserCount[$entry->userID])) {
                 $perUserCount[$entry->userID] = 0;
             }
             $perUserCount[$entry->userID]++;
         }
     }
     // remove user activity events
     $this->removeActivityEvents($entryData);
     // remove entries
     foreach ($this->objects as $entry) {
         $entry->delete();
         $this->addEntryData($entry->getDecoratedObject(), 'deleted', LinkHandler::getInstance()->getLink('NewsOverview', array('application' => 'cms')));
         NewsEntryModificationLogHandler::getInstance()->delete($entry->getDecoratedObject());
     }
     if (!empty($entryIDs)) {
         // delete like data
         LikeHandler::getInstance()->removeLikes('de.incendium.cms.like.likeableNews', $entryIDs);
         // delete comments
         CommentHandler::getInstance()->deleteObjects('de.incendium.cms.news.comment', $entryIDs);
         // delete tag to object entries
         TagEngine::getInstance()->deleteObjects('de.incendium.cms.news.entry', $entryIDs);
         // delete entry activity events
         UserActivityEventHandler::getInstance()->removeEvents('de.incendium.cms.news.recentActivityEvent.entry', $entryIDs);
         UserActivityPointHandler::getInstance()->removeEvents('de.incendium.cms.news.activityPointEvent.entry', $perUserCount);
         // delete entry from search index
         SearchIndexManager::getInstance()->delete('de.incendium.cms.news.entry', $entryIDs);
         // remove object from moderation queue
         ModerationQueueActivationManager::getInstance()->removeModeratedContent('de.incendium.cms.news.entry', $entryIDs);
     }
     // delete a poll
     if (!empty($pollIDs)) {
         PollManager::getInstance()->removePolls($pollIDs);
     }
     // delete attachments
     if (!empty($attachmentEntryIDs)) {
         AttachmentHandler::removeAttachments('de.incendium.cms.news.entry', $attachmentEntryIDs);
     }
     // reset the user storage data
     UserStorageHandler::getInstance()->resetAll('cmsUnreadNewsEntries');
     $this->unmarkItems();
     return $this->getEntryData();
 }