/**
  * @see	\wcf\system\worker\IWorker::execute()
  */
 public function execute()
 {
     parent::execute();
     if (!$this->loopCount) {
         // reset activity points
         UserActivityPointHandler::getInstance()->reset('de.incendium.filebase.activityPointEvent.entry');
         // reset search index
         SearchIndexManager::getInstance()->reset('de.incendium.filebase.entry');
     }
     if (!count($this->objectList)) {
         return;
     }
     // fetch cumulative likes
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("objectTypeID = ?", array(ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.like.likeableObject', 'de.incendium.filebase.likeableEntry')));
     $conditions->add("objectID IN (?)", array($this->objectList->getObjectIDs()));
     $sql = "SELECT\tobjectID, cumulativeLikes\n\t\t\tFROM\twcf" . WCF_N . "_like_object\n\t\t\t" . $conditions;
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute($conditions->getParameters());
     $cumulativeLikes = array();
     while ($row = $statement->fetchArray()) {
         $cumulativeLikes[$row['objectID']] = $row['cumulativeLikes'];
     }
     // prepare statements
     $attachmentObjectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', 'de.incendium.filebase.entry');
     $sql = "SELECT\t\tCOUNT(*) AS attachments\n\t\t\tFROM\t\twcf" . WCF_N . "_attachment\n\t\t\tWHERE\t\tobjectTypeID = ?\n\t\t\t\t\tAND objectID = ?";
     $attachmentStatement = WCF::getDB()->prepareStatement($sql);
     $itemsToUser = array();
     foreach ($this->objectList as $entry) {
         $editor = new EntryEditor($entry);
         $data = array();
         // count attachments
         $attachmentStatement->execute(array($attachmentObjectType->objectTypeID, $entry->entryID));
         $row = $attachmentStatement->fetchArray();
         $data['attachments'] = $row['attachments'];
         // update cumulative likes
         $data['cumulativeLikes'] = isset($cumulativeLikes[$entry->entryID]) ? $cumulativeLikes[$entry->entryID] : 0;
         $editor->update($data);
         if ($entry->userID) {
             if (!isset($itemsToUser[$entry->userID])) {
                 $itemsToUser[$entry->userID] = 0;
             }
             $itemsToUser[$entry->userID]++;
         }
         // update search index
         SearchIndexManager::getInstance()->add('de.incendium.filebase.entry', $entry->entryID, $entry->message, $entry->subject, $entry->time, $entry->userID, $entry->username, $entry->languageID);
     }
     // update activity points
     UserActivityPointHandler::getInstance()->fireEvents('de.incendium.filebase.activityPointEvent.entry', $itemsToUser, false);
 }
 /**
  * @see	\wcf\system\comment\manager\ICommentManager::updateCounter()
  */
 public function updateCounter($objectID, $value)
 {
     $entry = new Entry($objectID);
     $editor = new EntryEditor($entry);
     $editor->updateCounters(array('comments' => $value));
 }
 /**
  * Restores given entries.
  * 
  * @return	array<array>
  */
 public function restore()
 {
     $entryIDs = array();
     foreach ($this->objects as $entry) {
         $entry->update(array('deleteTime' => 0, 'isDeleted' => 0));
         $entryIDs[] = $entry->entryID;
         $this->addEntryData($entry->getDecoratedObject(), 'isDeleted', 0);
         EntryModificationLogHandler::getInstance()->restore($entry->getDecoratedObject());
     }
     $this->restoreFiles($entryIDs);
     EntryEditor::rebuildEntryData($entryIDs);
     $this->unmarkItems();
     UserStorageHandler::getInstance()->resetAll('filebaseUnreadEntries');
     UserStorageHandler::getInstance()->resetAll('filebaseUnreadWatchedEntries');
     return $this->getEntryData();
 }
 /**
  * @see	\wcf\page\IPage::show()
  */
 public function show()
 {
     parent::show();
     // update download counter
     if (!WCF::getUser()->userID || WCF::getUser()->userID != $this->entry->userID) {
         $editor = new EntryEditor($this->entry);
         $editor->updateCounters(array('downloads' => 1));
         $editor = new EntryFileEditor($this->file);
         $editor->updateCounters(array('downloads' => 1));
     }
     // send file to client
     $this->fileReader->send();
     exit;
 }
 /**
  * @see	\wcf\data\like\object\ILikeObject::updateLikeCounter()
  */
 public function updateLikeCounter($cumulativeLikes)
 {
     // update cumulative likes
     $editor = new EntryEditor($this->getDecoratedObject());
     $editor->update(array('cumulativeLikes' => $cumulativeLikes));
 }
 /**
  * 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();
 }