/** * @see \wbb\data\DatabaseObjectList::__construct() */ public function __construct() { parent::__construct(); // get object types $this->fileObjectTypeID = FileModificationLogHandler::getInstance()->getObjectType()->objectTypeID; $this->entryObjectTypeID = EntryModificationLogHandler::getInstance()->getObjectType()->objectTypeID; }
/** * Initializes the entry file modification log list. * * @param array<integer> $fileIDs * @param string $action */ public function setEntryFileData(array $fileIDs, $action = '') { $this->getConditionBuilder()->add("objectTypeID = ?", array(FileModificationLogHandler::getInstance()->getObjectType()->objectTypeID)); $this->getConditionBuilder()->add("objectID IN (?)", array($fileIDs)); if (!empty($action)) { $this->getConditionBuilder()->add("action = ?", [$action]); } }
/** * Restores given files. */ public function restore() { // update entries $fileIDs = $entryIDs = array(); foreach ($this->objects as $file) { // ignore files already restored if (!$file->isDeleted) { continue; } $parameters = array(); $entryEditor = new EntryEditor($file->getEntry()); $entryIDs[] = $file->entryID; $fileIDs[] = $file->fileID; // restore entry if at least one file is accessible if ($entryEditor->isDeleted) { $parameters['deleteTime'] = 0; $parameters['isDeleted'] = 0; EntryModificationLogHandler::getInstance()->restore($file->getEntry()); $this->addEntryData($entryEditor->entryID, 'isDeleted', 0); $this->addEntryData($entryEditor->entryID, 'ignoreFiles', 1); } // update entry if (!empty($parameters)) { $entryEditor->update($parameters); } // restore file $file->update(array('deleteTime' => 0, 'isDeleted' => 0)); FileModificationLogHandler::getInstance()->restore($file->getDecoratedObject()); if (isset($this->parameters['unmarkItems'])) { $fileIDs[] = $file->fileID; } $this->addFileData($file->getDecoratedObject(), 'isDeleted', 0); } if (!empty($entryIDs)) { $entryIDs = array_unique($entryIDs); EntryEditor::rebuildEntryData($entryIDs); } if (!empty($fileIDs)) { $this->unmarkItems($fileIDs); } return $this->getFileData(); }