/** * Enables given entries. * * @return array<array> */ public function enable() { if (empty($this->objects)) { $this->readObjects(); } $entriesIDs = array(); foreach ($this->objects as $entry) { $entry->update(array('isDisabled' => 0)); $this->addEntryData($entry->getDecoratedObject(), 'isDisabled', 0); EntryModificationLogHandler::getInstance()->enable($entry->getDecoratedObject()); $entryIDs[] = $entry->entryID; } // publish entries $entryAction = new EntryAction($this->objects, 'triggerPublication'); $entryAction->executeAction(); // enable files only if it was not initiated by enabling a specific version if (empty($this->parameters['ignoreFiles'])) { // get affected files $fileList = new EntryFileList(); $fileList->getConditionBuilder()->add("file.entryID IN (?)", array($entryIDs)); $fileList->readObjects(); // enable files $fileAction = new EntryFileAction($fileList->getObjects(), 'enable', array('ignoreEntries' => true)); $fileAction->executeAction(); } EntryEditor::rebuildEntryData($entryIDs); $this->unmarkItems(); return $this->getEntryData(); }
/** * @see \wcf\data\AbstractDatabaseObjectAction::delete() */ public function delete() { $this->prepareObjects(); $ignoreEntries = isset($this->parameters['ignoreEntries']) && $this->parameters['ignoreEntries']; $entryIDs = array(); foreach ($this->objects as $file) { if (!isset($entryIDs[$file->entryID])) { $entryIDs[$file->entryID] = $file->entryID; } } $fileStats = $this->getDetailedFileStats($entryIDs); parent::delete(); // update entries $entryEditors = $fileIDs = array(); foreach ($this->objects as $file) { $entryEditors[$file->entryID] = new EntryEditor($file->getEntry()); $fileIDs[] = $file->fileID; $fileStats[$file->entryID]['files']--; if ($file->isDisabled) { $fileStats[$file->entryID]['disabledFiles']--; } // entry has no files anymore -> delete it if (!$ignoreEntries && !$fileStats[$file->entryID]['files']) { unset($entryIDs[$file->entryID]); // deleted entries need no data update $entryEditors[$file->entryID]->delete(); EntryModificationLogHandler::getInstance()->delete($file->getEntry()); $this->addEntryData($file->entryID, 'deleted', LinkHandler::getInstance()->getLink('FilebaseOverview', array('application' => 'filebase'))); continue; } FileModificationLogHandler::getInstance()->delete($file->getDecoratedObject()); $this->addFileData($file->getDecoratedObject(), 'deleted', 1); @unlink($file->getLocation()); } if (!$ignoreEntries) { // check if the left files are all disabled and if the entry // is also disabled $disableEntries = array(); foreach ($entryIDs as $entryID) { if ($fileStats[$entryID]['files'] == $fileStats[$entryID]['disabledFiles'] && !$entryEditors[$entryID]->isDisabled) { $disableEntries[] = $fileStats[$entryID]; $this->addEntryData($entryID, 'isDisabled', 1); // after disabling the entry, the entry data // will be be rebuild in that method, so no need // to rebuild it here, too unset($entryIDs[$entryID]); } } if (!empty($disableEntries)) { $entryAction = new EntryAction($disableEntries, 'disable', array('ignoreFiles' => true)); $entryAction->executeAction(); } if (!empty($entryIDs)) { EntryEditor::rebuildEntryData($entryIDs); } } if (!empty($fileIDs)) { // delete user notifications UserNotificationHandler::getInstance()->deleteNotifications('file', 'de.incendium.filebase.file', array(), $fileIDs); // unmark files if (isset($this->parameters['unmarkItems'])) { $this->unmarkItems($fileIDs); } } return $this->getFileData(); }
/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); // update entry visit if ($this->entry->isNew()) { $entryAction = new EntryAction(array($this->entry->getDecoratedObject()), 'markAsRead', array('viewableEntry' => $this->entry)); $entryAction->executeAction(); } // get author's user profile $this->userProfile = $this->entry->getUserProfile(); // get comments $this->commentObjectTypeID = CommentHandler::getInstance()->getObjectTypeID('de.incendium.filebase.entryComment'); $this->commentManager = CommentHandler::getInstance()->getObjectType($this->commentObjectTypeID)->getProcessor(); $this->commentList = CommentHandler::getInstance()->getCommentList($this->commentManager, $this->commentObjectTypeID, $this->entryID); // get file history $this->fileList = new AccessibleEntryFileList(); $this->fileList->getConditionBuilder()->add('file.entryID = ?', array($this->entryID)); $this->fileList->sqlOrderBy = 'file.uploadTime DESC'; $this->fileList->sqlLimit = 5; $this->fileList->readObjects(); foreach ($this->fileList as $file) { $file->setEntry($this->entry->getDecoratedObject()); } // get other entries by this author $this->userEntryList = new AccessibleEntryList(); $this->userEntryList->enableCategoryLoading(false); $this->userEntryList->getConditionBuilder()->add('entry.userID = ?', array($this->entry->userID)); $this->userEntryList->getConditionBuilder()->add('entry.entryID <> ?', array($this->entry->entryID)); $this->userEntryList->sqlLimit = 5; $this->userEntryList->readObjects(); // get tags if (MODULE_TAGGING) { $this->tags = TagEngine::getInstance()->getObjectTags('de.incendium.filebase.entry', $this->entry->entryID, array($this->entry->languageID === null ? LanguageFactory::getInstance()->getDefaultLanguageID() : "")); } // fetch likes if (MODULE_LIKE) { $objectType = LikeHandler::getInstance()->getObjectType('de.incendium.filebase.likeableEntry'); LikeHandler::getInstance()->loadLikeObjects($objectType, array($this->entryID)); $this->entryLikeData = LikeHandler::getInstance()->getLikeObjects($objectType); } // add breadcrumbs $leafCategories = $this->entry->getLeafCategories(); $category = reset($leafCategories); FILEBASECore::getInstance()->setLocation($category->getParentCategories(), $category); MetaTagHandler::getInstance()->addTag('og:title', 'og:title', $this->entry->subject . ' - ' . WCF::getLanguage()->get(PAGE_TITLE), true); MetaTagHandler::getInstance()->addTag('og:url', 'og:url', LinkHandler::getInstance()->getLink('Entry', array('application' => 'filebase', 'object' => $this->entry)), true); MetaTagHandler::getInstance()->addTag('og:type', 'og:type', 'article', true); MetaTagHandler::getInstance()->addTag('og:description', 'og:description', $this->entry->teaser, true); // add tags as keywords if (!empty($this->tags)) { $keywords = ''; foreach ($this->tags as $tag) { if (!empty($keywords)) { $keywords .= ', '; } $keywords .= $tag->name; } MetaTagHandler::getInstance()->addTag('keywords', 'keywords', $keywords); } }
/** * @see \wcf\system\moderation\queue\IModerationQueueHandler::removeContent() */ public function removeContent(ModerationQueue $queue, $message) { if ($this->isValid($queue->objectID) && !$this->getEntry($queue->objectID)->isDeleted) { $action = new EntryAction(array($this->getEntry($queue->objectID)), 'trash', array('data' => array('reason' => $message))); $action->executeAction(); } }