/**
  * @inheritDoc
  */
 public function getOutstandingItemCount($objectID = null)
 {
     if ($this->notifications === null) {
         $this->notifications = 0;
         if (WCF::getUser()->userID) {
             $data = UserStorageHandler::getInstance()->getField('filebaseUnreaWatchedEntries');
             // cache does not exist or is outdated
             if ($data === null) {
                 $categoryIDs = FilebaseCategory::getAccessibleCategoryIDs();
                 if (!empty($categoryIDs)) {
                     $objectTypeID = UserObjectWatchHandler::getInstance()->getObjectTypeID('de.incendium.filebase.entry');
                     $conditionBuilder = new PreparedStatementConditionBuilder();
                     $conditionBuilder->add('user_object_watch.objectTypeID = ?', array($objectTypeID));
                     $conditionBuilder->add('user_object_watch.userID = ?', array(WCF::getUser()->userID));
                     $conditionBuilder->add('entry.lastChangeTime > ?', array(VisitTracker::getInstance()->getVisitTime('de.incendium.filebase.entry')));
                     $conditionBuilder->add('entry.entryID IN (SELECT entryID FROM filebase' . WCF_N . '_entry_to_category WHERE categoryID IN (?))', array($categoryIDs));
                     $conditionBuilder->add('entry.isDeleted = 0 AND entry.isDisabled = 0');
                     $conditionBuilder->add('(entry.lastChangeTime > tracked_file_visit.visitTime OR tracked_file_visit.visitTime IS NULL)');
                     $sql = "SELECT        COUNT(*) AS count\n                            FROM        wcf" . WCF_N . "_user_object_watch user_object_watch\n                            LEFT JOIN    filebase" . WCF_N . "_entry entry\n                            ON        (entry.entryID = user_object_watch.objectID)\n                            LEFT JOIN    wcf" . WCF_N . "_tracked_visit tracked_file_visit\n                            ON        (tracked_file_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.incendium.filebase.entry') . " AND tracked_file_visit.objectID = entry.entryID AND tracked_file_visit.userID = " . WCF::getUser()->userID . ")\n                            " . $conditionBuilder;
                     $statement = WCF::getDB()->prepareStatement($sql);
                     $statement->execute($conditionBuilder->getParameters());
                     $row = $statement->fetchArray();
                     $this->notifications = $row['count'];
                 }
                 // update storage data
                 UserStorageHandler::getInstance()->update(WCF::getUser()->userID, 'filebaseUnreadWatchedEntries', $this->notifications);
             } else {
                 $this->notifications = $data;
             }
         }
     }
     return $this->notifications;
 }
 /**
  * Fires notification event to notify all subscribers when added a commit.
  */
 protected function addComment()
 {
     // Fetch latest comment, it's the one we want to work with.
     // WCF 2.1 will provide direct access to the comment
     $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_comment\n\t\t\tORDER BY\tcommentID DESC";
     $statement = WCF::getDB()->prepareStatement($sql, 1);
     $statement->execute();
     $comment = $statement->fetchObject('wcf\\data\\comment\\Comment');
     $notificationObjectType = UserNotificationHandler::getInstance()->getObjectTypeProcessor(self::OBJECT_TYPE);
     $notificationObject = new CommentUserNotificationObject($comment);
     UserObjectWatchHandler::getInstance()->updateObject('de.codequake.cms.page', $comment->objectID, 'comment', self::OBJECT_TYPE, $notificationObject);
 }
 /**
  * Creates a new WatchedEntryList object.
  */
 public function __construct()
 {
     parent::__construct();
     $categoryIDs = FilebaseCategory::getAccessibleCategoryIDs();
     if (empty($categoryIDs)) {
         $this->getConditionBuilder()->add('1=0');
     } else {
         $objectTypeID = UserObjectWatchHandler::getInstance()->getObjectTypeID('de.incendium.filebase.entry');
         // add conditions
         $this->sqlConditionJoins = "LEFT JOIN filebase" . WCF_N . "_entry entry ON (entry.entryID = user_object_watch.objectID)";
         $this->getConditionBuilder()->add('user_object_watch.objectTypeID = ?', array($objectTypeID));
         $this->getConditionBuilder()->add('user_object_watch.userID = ?', array(WCF::getUser()->userID));
         $this->getConditionBuilder()->add('entry.entryID IN (SELECT entryID FROM filebase' . WCF_N . '_entry_to_category WHERE categoryID IN (?))', array($categoryIDs));
         $this->getConditionBuilder()->add('entry.isDeleted = 0 AND entry.isDisabled = 0');
     }
 }
Exemple #4
0
 /**
  * @see	\wcf\data\AbstractDatabaseObjectAction::update()
  */
 public function update()
 {
     // set default values for last editor
     if (!isset($this->parameters['data']['lastEditorID'])) {
         $this->parameters['data']['lastEditorID'] = WCF::getUser()->userID;
         $this->parameters['data']['lastEditorName'] = WCF::getUser()->username;
     }
     // set default value for last edit time
     if (!isset($this->parameters['data']['lastEditTime'])) {
         $this->parameters['data']['lastEditTime'] = TIME_NOW;
     }
     // perform update
     parent::update();
     $pageIDs = $publishedPageIDs = array();
     foreach ($this->objects as $pageEditor) {
         $pageIDs[] = $pageEditor->pageID;
         // update stylesheets
         if (isset($this->parameters['stylesheetIDs'])) {
             $pageEditor->updateStylesheetIDs($this->parameters['stylesheetIDs']);
         }
         if (!$pageEditor->isPublished) {
             $publishedPageIDs[] = $pageEditor->pageID;
         }
     }
     // delete subscriptions if subscribing isn't allowed anymore
     if (isset($this->parameters['data']['allowSubscribing']) && !$this->parameters['data']['allowSubscribing']) {
         UserObjectWatchHandler::getInstance()->deleteObjects('de.codequake.cms.page', $pageIDs);
     }
     // trigger new publications
     if (isset($this->parameters['data']['isPublished']) && $this->parameters['data']['isPublished'] == 1 && !empty($publishedPageIDs)) {
         $action = new PageAction($publishedPageIDs, 'triggerPublication');
         $action->executeAction();
     }
 }
 /**
  * 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();
 }
 /**
  * Triggers the publication of news entries.
  */
 public function triggerPublication()
 {
     if (empty($this->objects)) {
         $this->readObjects();
     }
     foreach ($this->objects as $news) {
         // fire user activity event
         UserActivityEventHandler::getInstance()->fireEvent('de.voolia.news.recentActivityEvent.news', $news->newsID, $news->languageID, $news->userID);
         UserActivityPointHandler::getInstance()->fireEvent('de.voolia.news.activityPointEvent.news', $news->newsID, $news->userID);
         // update the watched news objects
         $notificationObject = new NewsUserNotificationObject($news->getDecoratedObject());
         foreach ($news->getCategoryIDs() as $categoryID) {
             UserObjectWatchHandler::getInstance()->updateObject('de.voolia.news.category', $categoryID, 'news', 'de.voolia.news.entry', $notificationObject);
         }
     }
     // reset the user storage data
     UserStorageHandler::getInstance()->resetAll('newsUnreadEntries');
     // reset the news cache
     NewsEditor::resetNewsStatsCache();
 }
 /**
  * Triggers the publication of entry file.
  */
 public function triggerPublication()
 {
     if (empty($this->objects)) {
         $this->readObjects();
     }
     foreach ($this->objects as $file) {
         $entryEditor = new EntryEditor($file->getEntry());
         // update entries
         if (!$file->isFirstFile() && empty($this->parameters['isFirstFile'])) {
             // update last file
             if ($file->uploadTime > $entryEditor->lastChangeTime) {
                 $entryEditor->update(array('lastChangeTime' => $file->uploadTime, 'lastFileID' => $file->fileID, 'files' => $entryEditor->files + 1));
             }
             // fire activity event
             if ($entryEditor->userID) {
                 UserActivityEventHandler::getInstance()->fireEvent('de.incendium.filebase.recentActivityEvent.file', $file->fileID, $entryEditor->languageID, $entryEditor->userID, $file->uploadTime);
             }
             // update watched objects
             UserObjectWatchHandler::getInstance()->updateObject('de.incendium.filebase.entry', $entryEditor->entryID, 'file', 'de.incendium.filebase.file', new FileUserNotificationObject($file->getDecoratedObject()));
         }
     }
     // reset storage
     UserStorageHandler::getInstance()->resetAll('filebaseUnreadEntries');
     UserStorageHandler::getInstance()->resetAll('filebaseUnreadWatchedEntries');
 }
 /**
  * Returns the list of the subscribed news categories.
  * 
  * @return	array<integer>
  */
 public static function getSubscribedCategoryIDs()
 {
     if (self::$subscribedCategories === null) {
         self::$subscribedCategories = array();
         if (WCF::getUser()->userID) {
             // load the user storage data
             UserStorageHandler::getInstance()->loadStorage(array(WCF::getUser()->userID));
             // get the ids
             $data = UserStorageHandler::getInstance()->getStorage(array(WCF::getUser()->userID), 'newsSubscribedCategories');
             // if the cache does not exist, or is outdated
             if ($data[WCF::getUser()->userID] === null) {
                 $objectTypeID = UserObjectWatchHandler::getInstance()->getObjectTypeID('de.voolia.news.category');
                 $sql = "SELECT\tobjectID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_object_watch\n\t\t\t\t\t\tWHERE\tobjectTypeID = ?\n\t\t\t\t\t\tAND\tuserID = ?";
                 $statement = WCF::getDB()->prepareStatement($sql);
                 $statement->execute(array($objectTypeID, WCF::getUser()->userID));
                 while ($row = $statement->fetchArray()) {
                     self::$subscribedCategories[] = $row['objectID'];
                 }
                 // update the user storage data
                 UserStorageHandler::getInstance()->update(WCF::getUser()->userID, 'newsSubscribedCategories', serialize(self::$subscribedCategories));
             } else {
                 self::$subscribedCategories = unserialize($data[WCF::getUser()->userID]);
             }
         }
     }
     return self::$subscribedCategories;
 }
 /**
  * @see	\wcf\system\category\ICategoryType::afterDeletion()
  */
 public function afterDeletion(CategoryEditor $categoryEditor)
 {
     // delete the news category subscriptions
     UserObjectWatchHandler::getInstance()->deleteObjects('de.voolia.news.category', array($categoryEditor->categoryID));
 }