/** * Deletes given entries. * * @return array<array> */ public function delete() { if (empty($this->objects)) { $this->readObjects(); } $entryIDs = $entyData = $attachmentEntryIDs = $userCounters = array(); foreach ($this->objects as $entry) { $entryData[$entry->entryID] = $entry->userID; $entryIDs[] = $entry->entryID; if ($entry->attachments) { $attachmentEntryIDs[] = $entry->entryID; } if (!$entry->isDisabled) { if (!isset($userToItems[$entry->userID])) { $userToItems[$entry->userID] = 0; } $userToItems[$entry->userID]++; } } // remove user activity events $this->removeActivityEvents($entryData); // remove files $fileList = new EntryFileList(); $fileList->getConditionBuilder()->add("file.entryID IN (?)", array(array_keys($entryData))); $fileList->readObjects(); $fileAction = new EntryFileAction($fileList->getObjects(), 'delete', array('ignoreEntries' => true)); $fileAction->executeAction(); // remove entries foreach ($this->objects as $entry) { $entry->delete(); $this->addEntryData($entry->getDecoratedObject(), 'deleted', LinkHandler::getInstance()->getLink('FilebaseOverview', array('application' => 'filebase'))); EntryModificationLogHandler::getInstance()->delete($entry->getDecoratedObject()); } if (!empty($entryIDs)) { // delete like data LikeHandler::getInstance()->removeLikes('de.incendium.filebase.likeableEntry', $entryIDs); // delete comments CommentHandler::getInstance()->deleteObjects('de.incendium.filebase.entryComment', $entryIDs); // delete tag to object entries TagEngine::getInstance()->deleteObjects('de.incendium.filebase.entry', $entryIDs); // delete entry from search index SearchIndexManager::getInstance()->delete('de.incendium.filebase.entry', $entryIDs); } // decrease user entry counter if (!empty($userCounters)) { EntryEditor::updateEntryCounter($userCounters); } // delete attachments if (!empty($attachmentEntryIDs)) { AttachmentHandler::removeAttachments('de.incendium.filebase.entry', $attachmentEntryIDs); } // delete subscriptions UserObjectWatchHandler::getInstance()->deleteObjects('de.incendium.filebase.entry', $entryIDs); $this->unmarkItems(); return $this->getEntryData(); }
/** * @see \wcf\system\moderation\queue\IModerationQueueHandler::removeContent() */ public function removeContent(ModerationQueue $queue, $message) { if ($this->isValid($queue->objectID)) { $objectAction = new EntryFileAction(array($this->getFile($queue->objectID)), 'delete'); $objectAction->executeAction(); } }
/** * Enables given files. */ public function enable() { $enableEntries = $fileIDs = array(); foreach ($this->objects as $file) { if (empty($this->parameters['ignoreEntries']) && $file->getEntry()->isDisabled) { $enableEntries[] = $file->entryID; } $file->update(array('isDisabled' => 0)); $fileIDs[] = $file->fileID; $this->addFileData($file->getDecoratedObject(), 'isDisabled', 0); FileModificationLogHandler::getInstance()->enable($file->getDecoratedObject()); } // trigger publication $fileAction = new EntryFileAction($this->objects, 'triggerPublication'); $fileAction->executeAction(); $this->removeModeratedContent($fileIDs); if (!empty($enableEntries)) { $entryAction = new EntryAction(array_unique($enableEntries), 'enable', array('ignoreFiles' => true)); $entryAction->executeAction(); foreach ($enableEntries as $entryID) { $this->addEntryData($entryID, 'isDisabled', 0); $this->addEntryData($entryID, 'ignoreFiles', 1); } } $this->unmarkItems(); return $this->getFileData(); }