/**
  * @see	\wcf\system\user\activity\event\IUserActivityEvent::prepare()
  */
 public function prepare(array $events)
 {
     $objectIDs = array();
     foreach ($events as $event) {
         $objectIDs[] = $event->objectID;
     }
     // fetch files
     $fileList = new EntryFileList();
     $fileList->setObjectIDs($objectIDs);
     $fileList->readObjects();
     $files = $fileList->getObjects();
     // fetch entries
     $entryIDs = $entries = array();
     foreach ($files as $file) {
         $entryIDs[] = $file->entryID;
     }
     $entryIDs = array_unique($entryIDs);
     if (!empty($entryIDs)) {
         $entryList = new EntryList();
         $entryList->setObjectIDs($entryIDs);
         $entryList->readObjects();
         $entries = $entryList->getObjects();
     }
     // set message
     foreach ($events as $event) {
         if (isset($files[$event->objectID]) && isset($entries[$files[$event->objectID]->entryID])) {
             $entry = $entries[$files[$event->objectID]->entryID];
             $files[$event->objectID]->setEntry($entry);
             if (!$entry->canRead()) {
                 continue;
             }
             $event->setIsAccessible();
             // title
             $text = WCF::getLanguage()->getDynamicVariable('filebase.recentActivity.entry.file', array('file' => $files[$event->objectID]));
             $event->setTitle($text);
             // description
             $event->setDescription($files[$event->objectID]->getExcerpt());
         } else {
             $event->setIsOrphaned();
         }
     }
 }
 /**
  * @see	\wcf\data\DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     parent::readObjects();
     $fileIDs = array();
     foreach ($this->objects as $file) {
         if ($file->isDeleted) {
             $fileIDs[] = $file->fileID;
         }
     }
     if (!empty($fileIDs)) {
         $this->logList = new EntryFileModificationLogList();
         $this->logList->setEntryFileData($fileIDs, 'trash');
         $this->logList->readObjects();
         foreach ($this->logList->getObjects() as $logEntry) {
             $this->objects[$logEntry->objectID]->setLogEntry($logEntry);
         }
     }
 }
 /**
  * @see	\wcf\system\moderation\queue\IModerationQueueHandler::populate()
  */
 public function populate(array $queues)
 {
     $objectIDs = array();
     foreach ($queues as $object) {
         $objectIDs[] = $object->objectID;
     }
     // fetch files
     $objectList = new EntryFileList();
     $objectList->setObjectIDs($objectIDs);
     $objectList->readObjects();
     $objects = $objectList->getObjects();
     foreach ($queues as $object) {
         if (isset($objects[$object->objectID])) {
             $object->setAffectedObject($objects[$object->objectID]);
         } else {
             $object->setIsOrphaned();
         }
     }
 }
 /**
  * @see	\wcf\data\DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     $sql = "SELECT        user_avatar.*, user_table.email, user_table.disableAvatar, user_table.enableGravatar, user_table.gravatarFileExtension,\n                    modification_log.*\n            FROM        wcf" . WCF_N . "_modification_log modification_log\n            LEFT JOIN    wcf" . WCF_N . "_user user_table\n            ON        (user_table.userID = modification_log.userID)\n            LEFT JOIN    wcf" . WCF_N . "_user_avatar user_avatar\n            ON        (user_avatar.avatarID = user_table.avatarID)\n            WHERE        modification_log.objectTypeID = ?\n                    AND modification_log.objectID = ?\n            UNION\n            SELECT        user_avatar.*, user_table.email, user_table.disableAvatar, user_table.enableGravatar, user_table.gravatarFileExtension,\n                    modification_log.*\n            FROM        wcf" . WCF_N . "_modification_log modification_log\n            LEFT JOIN    wcf" . WCF_N . "_user user_table\n            ON        (user_table.userID = modification_log.userID)\n            LEFT JOIN    wcf" . WCF_N . "_user_avatar user_avatar\n            ON        (user_avatar.avatarID = user_table.avatarID)\n            WHERE        modification_log.objectTypeID = ?\n                    AND modification_log.parentObjectID = ?\n            " . (!empty($this->sqlOrderBy) ? "ORDER BY " . $this->sqlOrderBy : '');
     $statement = WCF::getDB()->prepareStatement($sql, $this->sqlLimit, $this->sqlOffset);
     $statement->execute([$this->entryObjectTypeID, $this->entry->entryID, $this->fileObjectTypeID, $this->entry->entryID]);
     $this->objects = $statement->fetchObjects($this->objectClassName ?: $this->className);
     // use table index as array index
     $objects = [];
     foreach ($this->objects as $object) {
         $objectID = $object->{$this->getDatabaseTableIndexName()};
         $objects[$objectID] = $object;
         $this->indexToObject[] = $objectID;
     }
     $this->objectIDs = $this->indexToObject;
     $this->objects = $objects;
     $fileIDs = [];
     foreach ($this->objects as &$object) {
         if ($object->objectTypeID == $this->fileObjectTypeID) {
             $object = new ViewableEntryFileModificationLog($object);
             $fileIDs[] = $object->objectID;
         } else {
             $object = new ViewableEntryModificationLog($object);
         }
     }
     unset($object);
     if (!empty($fileIDs)) {
         $fileList = new EntryFileList();
         $fileList->setObjectIDs($fileIDs);
         $fileList->readObjects();
         foreach ($this->objects as $object) {
             if ($object instanceof ViewableEntryFileModificationLog) {
                 foreach ($fileList as $file) {
                     if ($object->objectID == $file->fileID) {
                         $object->setFile($file);
                         break;
                     }
                 }
             }
         }
     }
 }
 /**
  * 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();
 }