/**
  * Creates a new UnreadNewsList object.
  */
 public function __construct()
 {
     parent::__construct();
     $this->getConditionBuilder()->add("news.time > ?", array(VisitTracker::getInstance()->getVisitTime('de.voolia.news.entry')));
     $this->getConditionBuilder()->add("tracked_visit.visitTime IS NULL");
     $this->sqlConditionJoins = "LEFT JOIN wcf" . WCF_N . "_tracked_visit tracked_visit ON (tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.voolia.news.entry') . " AND tracked_visit.objectID = news.newsID AND tracked_visit.userID = " . WCF::getUser()->userID . ")";
 }
 /**
  * Creates a new ViewableNewsList object.
  */
 public function __construct()
 {
     parent::__construct();
     // get author avatar
     if (!empty($this->sqlSelects)) {
         $this->sqlSelects .= ', ';
     }
     $this->sqlSelects .= "user_avatar.*, user_avatar.width as avatarWidth, user_avatar.height as avatarHeight, user_avatar.fileHash as avatarFileHash, user_table.*";
     $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_user user_table ON (user_table.userID = news.userID)";
     $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_user_avatar user_avatar ON (user_avatar.avatarID = user_table.avatarID)";
     // get news picture
     $this->sqlSelects .= ", news_picture.categoryID, news_picture.fileHash, news_picture.fileExtension";
     $this->sqlJoins .= " LEFT JOIN news" . WCF_N . "_news_picture news_picture ON (news.pictureID = news_picture.pictureID)";
     // get the news like status
     $this->sqlSelects .= ", like_object.likes, like_object.dislikes";
     $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_like_object like_object ON (like_object.objectTypeID = " . LikeHandler::getInstance()->getObjectType('de.voolia.news.likeableNews')->objectTypeID . " AND like_object.objectID = news.newsID)";
     if (WCF::getUser()->userID != 0) {
         // last news visit time
         if (!empty($this->sqlSelects)) {
             $this->sqlSelects .= ',';
         }
         $this->sqlSelects .= 'tracked_visit.visitTime';
         $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_tracked_visit tracked_visit ON (tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.voolia.news.entry') . " AND tracked_visit.objectID = news.newsID AND tracked_visit.userID = " . WCF::getUser()->userID . ")";
     }
 }
 /**
  * @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;
 }
 /**
  * Marks all news categories as read.
  */
 public function markAllAsRead()
 {
     VisitTracker::getInstance()->trackTypeVisit('de.incendium.linklist.entry');
     // reset the user storage data and delete notifications
     if (WCF::getUser()->userID) {
         // user storage data
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'linklistUnreadEntries');
     }
 }
 /**
  * Marks all news categories as read.
  */
 public function markAllAsRead()
 {
     VisitTracker::getInstance()->trackTypeVisit('de.incendium.cms.news.entry');
     // reset the user storage data and delete notifications
     if (WCF::getUser()->userID) {
         // user storage data
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'cmsUnreadNewsEntries');
         // user notifications
         UserNotificationHandler::getInstance()->markAsConfirmed('news', 'de.incendium.cms.news.entry', array(WCF::getUser()->userID));
     }
 }
 /**
  * Marks all news categories as read.
  */
 public function markAllAsRead()
 {
     VisitTracker::getInstance()->trackTypeVisit('de.voolia.news.entry');
     // reset the user storage data and delete notifications
     if (WCF::getUser()->userID) {
         // user storage data
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'newsUnreadEntries');
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'newsUnreadWatchedEntries');
         // user notifications
         UserNotificationHandler::getInstance()->deleteNotifications('news', 'de.voolia.news.entry', array(WCF::getUser()->userID));
     }
 }
 public function getVisitTime()
 {
     if ($this->effectiveVisitTime === null) {
         if (WCF::getUser()->userID) {
             $this->effectiveVisitTime = max($this->visitTime, VisitTracker::getInstance()->getVisitTime('de.codequake.cms.news'));
         } else {
             $this->effectiveVisitTime = max(VisitTracker::getInstance()->getObjectVisitTime('de.codequake.cms.news', $this->newsID), VisitTracker::getInstance()->getVisitTime('de.codequake.cms.news'));
         }
         if ($this->effectiveVisitTime === null) {
             $this->effectiveVisitTime = 0;
         }
     }
     return $this->effectiveVisitTime;
 }
 /**
  * Creates a new ViewableEntryList object.
  */
 public function __construct()
 {
     parent::__construct();
     // get last file
     if (!empty($this->sqlSelects)) {
         $this->sqlSelects .= ',';
     }
     $this->sqlSelects .= 'file.*';
     $this->sqlJoins .= " LEFT JOIN filebase" . WCF_N . "_file file ON (file.fileID = entry.lastFileID)";
     if (WCF::getUser()->userID != 0) {
         // last visit time
         if (!empty($this->sqlSelects)) {
             $this->sqlSelects .= ',';
         }
         $this->sqlSelects .= 'tracked_visit.visitTime';
         $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_tracked_visit tracked_visit ON (tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.incendium.filebase.entry') . " AND tracked_visit.objectID = entry.entryID AND tracked_visit.userID = " . WCF::getUser()->userID . ")";
         // subscriptions
         if (!empty($this->sqlSelects)) {
             $this->sqlSelects .= ',';
         }
         $this->sqlSelects .= 'user_object_watch.watchID, user_object_watch.notification';
         $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_user_object_watch user_object_watch ON (user_object_watch.objectTypeID = " . ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.user.objectWatch', 'de.incendium.filebase.entry')->objectTypeID . " AND user_object_watch.userID = " . WCF::getUser()->userID . " AND user_object_watch.objectID = entry.entryID)";
     }
     // get avatars
     if (!empty($this->sqlSelects)) {
         $this->sqlSelects .= ',';
     }
     $this->sqlSelects .= "user_avatar.*, user_table.*";
     $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_user user_table ON (user_table.userID = entry.userID)";
     $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_user_avatar user_avatar ON (user_avatar.avatarID = user_table.avatarID)";
     // get like status
     if (!empty($this->sqlSelects)) {
         $this->sqlSelects .= ',';
     }
     $this->sqlSelects .= "like_object.likes, like_object.dislikes";
     $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_like_object like_object ON (like_object.objectTypeID = " . LikeHandler::getInstance()->getObjectType('de.incendium.filebase.likeableEntry')->objectTypeID . " AND like_object.objectID = entry.entryID)";
     // get report status
     if (WCF::getSession()->getPermission('mod.general.canUseModeration')) {
         if (!empty($this->sqlSelects)) {
             $this->sqlSelects .= ',';
         }
         $this->sqlSelects .= "moderation_queue.queueID AS reportQueueID";
         $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_moderation_queue moderation_queue ON (moderation_queue.objectTypeID = " . ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.moderation.report', 'de.incendium.filebase.entry') . " AND moderation_queue.objectID = entry.entryID AND moderation_queue.status <> " . ModerationQueue::STATUS_DONE . " AND moderation_queue.status <> " . ModerationQueue::STATUS_REJECTED . " AND moderation_queue.status <> " . ModerationQueue::STATUS_CONFIRMED . ")";
     }
     if (!WCF::getSession()->getPermission('mod.filebase.canViewDeletedEntry')) {
         $this->loadDeleteNote = false;
     }
 }
 public function __construct()
 {
     parent::__construct();
     if (WCF::getUser()->userID != 0) {
         // last visit time
         if (!empty($this->sqlSelects)) {
             $this->sqlSelects .= ',';
         }
         $this->sqlSelects .= 'tracked_visit.visitTime';
         $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_tracked_visit tracked_visit ON (tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.codequake.cms.news') . " AND tracked_visit.objectID = news.newsID AND tracked_visit.userID = " . WCF::getUser()->userID . ")";
     }
     // get like status
     if (!empty($this->sqlSelects)) {
         $this->sqlSelects .= ',';
     }
     $this->sqlSelects .= "like_object.likes, like_object.dislikes";
     $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_like_object like_object ON (like_object.objectTypeID = " . LikeHandler::getInstance()->getObjectType('de.codequake.cms.likeableNews')->objectTypeID . " AND like_object.objectID = news.newsID)";
 }
 public function getNotifications()
 {
     if ($this->notifications === null) {
         $this->notifications = 0;
         if (WCF::getUser()->userID) {
             // load storage data
             UserStorageHandler::getInstance()->loadStorage(array(WCF::getUser()->userID));
             // get ids
             $data = UserStorageHandler::getInstance()->getStorage(array(WCF::getUser()->userID), 'cmsUnreadNews');
             // cache does not exist or is outdated
             if ($data[WCF::getUser()->userID] === null) {
                 $categoryIDs = NewsCategory::getAccessibleCategoryIDs();
                 // removed ignored boards
                 foreach ($categoryIDs as $key => $categoryID) {
                     $category = CategoryHandler::getInstance()->getCategory($categoryID);
                 }
                 if (!empty($categoryIDs)) {
                     $conditionBuilder = new PreparedStatementConditionBuilder();
                     $conditionBuilder->add("news.lastChangeTime > ?", array(VisitTracker::getInstance()->getVisitTime('de.codequake.cms.news')));
                     $conditionBuilder->add("news.newsID IN (SELECT newsID FROM cms" . WCF_N . "_news_to_category WHERE categoryID IN (?))", array($categoryIDs));
                     $conditionBuilder->add("news.isDeleted = 0 AND news.isDisabled = 0");
                     $conditionBuilder->add("tracked_visit.visitTime IS NULL");
                     // apply language filter
                     if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
                         $conditionBuilder->add('(news.languageID IN (?) OR news.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
                     }
                     $sql = "SELECT\t\tCOUNT(*) AS count\n\t\t\t\t\t\t\tFROM\t\tcms" . WCF_N . "_news news\n\t\t\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_tracked_visit tracked_visit\n\t\t\t\t\t\t\tON\t\t(tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.codequake.cms.news') . " AND tracked_visit.objectID = news.newsID AND tracked_visit.userID = " . WCF::getUser()->userID . ")\n\t\t\t\t\t\t\t" . $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, 'cmsUnreadNews', $this->notifications);
             } else {
                 $this->notifications = $data[WCF::getUser()->userID];
             }
         }
     }
     return $this->notifications;
 }
 /**
  * Calculates the number of unread entries.
  */
 protected function initUnreadEntries()
 {
     $this->unreadEntries = array();
     if (WCF::getUser()->userID) {
         $conditionBuilder = new PreparedStatementConditionBuilder();
         $conditionBuilder->add('entry.lastChangeTime > ?', array(VisitTracker::getInstance()->getVisitTime('de.incendium.linklist.entry')));
         $conditionBuilder->add('entry.isDisabled = ?', array(0));
         $conditionBuilder->add('entry.isDeleted = ?', array(0));
         // apply language filter
         if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
             $conditionBuilder->add('(entry.languageID IN (?) OR entry.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
         }
         $conditionBuilder->add('tracked_visit.visitTime IS NULL');
         $sql = "SELECT\t\tCOUNT(*) AS count, entry_to_category.categoryID\n\t\t\t\tFROM\t\tlinklist" . WCF_N . "_entry entry\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_tracked_visit tracked_visit\n\t\t\t\tON\t\t(tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.incendium.linklist.entry') . " AND tracked_visit.objectID = entry.entryID AND tracked_visit.userID = " . WCF::getUser()->userID . ")\n\t\t\t\tLEFT JOIN\tlinklist" . WCF_N . "_entry_to_category entry_to_category\n\t\t\t\tON\t\t(entry_to_category.entryID = entry.entryID)\n\t\t\t\t" . $conditionBuilder . "\n\t\t\t\tGROUP BY\tentry_to_category.categoryID";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($conditionBuilder->getParameters());
         while ($row = $statement->fetchArray()) {
             $this->unreadEntries[$row['categoryID']] = $row['count'];
         }
     }
 }
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     MessageForm::save();
     // save the news update
     $this->objectAction = new EntryUpdateAction(array($this->update), 'update', array('data' => array('subject' => $this->subject, 'message' => $this->text)));
     $this->objectAction->executeAction();
     // set news as new
     if ($this->setEntryAsNew) {
         $sql = "UPDATE    cms" . WCF_N . "_news_entry\n                    SET    time = ?\n                    WHERE    entryID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array(TIME_NOW, $this->entryID));
         $sql = "DELETE FROM    wcf" . WCF_N . "_tracked_visit\n                    WHERE        objectTypeID = ?\n                    AND        objectID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array(VisitTracker::getInstance()->getObjectTypeID('de.incendium.cms.news.entry'), $this->entryID));
         // reset the user storage data
         UserStorageHandler::getInstance()->resetAll('cmsUnreadNewsEntries');
     }
     $this->saved();
     HeaderUtil::redirect(LinkHandler::getInstance()->getLink('NewsEntry', array('application' => 'cms', 'object' => $this->entry)));
     exit;
 }
 protected function initUnreadNews()
 {
     $this->unreadNews = array();
     if (WCF::getUser()->userID) {
         $conditionBuilder = new PreparedStatementConditionBuilder();
         $conditionBuilder->add("news.lastChangeTime > ?", array(VisitTracker::getInstance()->getVisitTime('de.codequake.cms.news')));
         $conditionBuilder->add("news.isDeleted = 0");
         $conditionBuilder->add("news.isDisabled = 0");
         $conditionBuilder->add("tracked_visit.visitTime IS NULL");
         // apply language filter
         if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
             $conditionBuilder->add('(news.languageID IN (?) OR news.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
         }
         $sql = "SELECT\t\tCOUNT(*) AS count, news_to_category.categoryID\n\t\t\t\tFROM\t\tcms" . WCF_N . "_news news\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_tracked_visit tracked_visit\n\t\t\t\tON\t\t(tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.codequake.cms.news') . " AND tracked_visit.objectID = news.newsID AND tracked_visit.userID = " . WCF::getUser()->userID . ")\n\t\t\t\tLEFT JOIN\tcms" . WCF_N . "_news_to_category news_to_category\n\t\t\t\tON\t\t(news_to_category.newsID = news.newsID)\n\t\t\t\t" . $conditionBuilder . "\n\t\t\t\tGROUP BY\tnews_to_category.categoryID";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($conditionBuilder->getParameters());
         while ($row = $statement->fetchArray()) {
             $this->unreadNews[$row['categoryID']] = $row['count'];
         }
     }
 }
 /**
  * Returns the count of unread moderation queue items.
  * 
  * @param	boolean		$skipCache
  * @return	integer
  */
 public function getUnreadModerationCount($skipCache = false)
 {
     // get count
     $count = UserStorageHandler::getInstance()->getField('unreadModerationCount');
     // cache does not exist or is outdated
     if ($count === null || $skipCache) {
         // force update of non-tracked queues for this user
         $this->forceUserAssignment();
         // count outstanding and assigned queues
         $conditions = new PreparedStatementConditionBuilder();
         $conditions->add("moderation_queue_to_user.userID = ?", array(WCF::getUser()->userID));
         $conditions->add("moderation_queue_to_user.isAffected = ?", array(1));
         $conditions->add("moderation_queue.status IN (?)", array(array(ModerationQueue::STATUS_OUTSTANDING, ModerationQueue::STATUS_PROCESSING)));
         $conditions->add("moderation_queue.time > ?", array(VisitTracker::getInstance()->getVisitTime('com.woltlab.wcf.moderation.queue')));
         $conditions->add("(moderation_queue.time > tracked_visit.visitTime OR tracked_visit.visitTime IS NULL)");
         $sql = "SELECT\t\tCOUNT(*) AS count\n\t\t\t\tFROM\t\twcf" . WCF_N . "_moderation_queue_to_user moderation_queue_to_user\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_moderation_queue moderation_queue\n\t\t\t\tON\t\t(moderation_queue.queueID = moderation_queue_to_user.queueID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_tracked_visit tracked_visit\n\t\t\t\tON\t\t(tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('com.woltlab.wcf.moderation.queue') . " AND tracked_visit.objectID = moderation_queue.queueID AND tracked_visit.userID = " . WCF::getUser()->userID . ")\n\t\t\t\t" . $conditions;
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($conditions->getParameters());
         $row = $statement->fetchArray();
         $count = $row['count'];
         // update storage data
         UserStorageHandler::getInstance()->update(WCF::getUser()->userID, 'unreadModerationCount', $count);
     }
     return $count;
 }
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     parent::save();
     $this->objectAction = new NewsUpdateAction(array(), 'create', array('data' => array('newsID' => $this->newsID, 'time' => TIME_NOW, 'userID' => WCF::getUser()->userID ?: null, 'username' => WCF::getUser()->userID ? WCF::getUser()->username : $this->username, 'subject' => $this->subject, 'text' => $this->text, 'enableSmilies' => $this->enableSmilies, 'enableHtml' => $this->enableHtml, 'enableBBCodes' => $this->enableBBCodes)));
     $this->objectAction->executeAction();
     // update news entry
     $sql = "UPDATE\tnews" . WCF_N . "_news\n             \t   \tSET\tnewsUpdates = newsUpdates + 1\n             \t   \tWHERE\tnewsID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($this->newsID));
     // set news as new
     if ($this->setNewsAsNew) {
         $sql = "UPDATE\tnews" . WCF_N . "_news\n             \t   \t\tSET\ttime = ?\n\t     \t   \t\tWHERE\tnewsID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array(TIME_NOW, $this->newsID));
         $sql = "DELETE FROM\twcf" . WCF_N . "_tracked_visit\n\t\t     \t\tWHERE\t\tobjectTypeID = ?\n\t\t     \t\tAND\t\tobjectID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array(VisitTracker::getInstance()->getObjectTypeID('de.voolia.news.entry'), $this->newsID));
     }
     // redirect to news entry
     HeaderUtil::redirect(LinkHandler::getInstance()->getLink('News', array('application' => 'news', 'object' => $this->news)));
     exit;
 }
 /**
  * Returns the number of unread entries.
  * 
  * @return    integer
  */
 public static function getUnreadEntries()
 {
     if (self::$unreadEntries === null) {
         self::$unreadEntries = 0;
         if (WCF::getUser()->userID) {
             $data = UserStorageHandler::getInstance()->getField('filebaseUnreadEntries');
             // cache does not exist or is outdated
             if ($data === null) {
                 $categoryIDs = FilebaseCategory::getAccessibleCategoryIDs();
                 // removed ignored boards
                 if (!empty($categoryIDs)) {
                     $conditionBuilder = new PreparedStatementConditionBuilder();
                     $conditionBuilder->add("entry.entryID IN (SELECT entryID FROM filebase" . WCF_N . "_entry_to_category WHERE categoryID IN (?))", array($categoryIDs));
                     $conditionBuilder->add("entry.lastChangeTime > ?", array(VisitTracker::getInstance()->getVisitTime('de.incendium.filebase.entry')));
                     $conditionBuilder->add("entry.isDisabled = 0 AND entry.isDeleted = 0");
                     $conditionBuilder->add("(entry.lastChangeTime > tracked_visit.visitTime OR tracked_visit.visitTime IS NULL)");
                     // apply language filter
                     if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
                         $conditionBuilder->add('(entry.languageID IN (?) OR entry.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
                     }
                     $sql = "SELECT        COUNT(*) AS count\n                            FROM        filebase" . WCF_N . "_entry entry\n                            LEFT JOIN    wcf" . WCF_N . "_tracked_visit tracked_visit\n                            ON        (tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.incendium.filebase.entry') . " AND tracked_visit.objectID = entry.entryID AND tracked_visit.userID = " . WCF::getUser()->userID . ")\n                            " . $conditionBuilder;
                     $statement = WCF::getDB()->prepareStatement($sql);
                     $statement->execute($conditionBuilder->getParameters());
                     $row = $statement->fetchArray();
                     self::$unreadEntries = $row['count'];
                 }
                 // update storage data
                 UserStorageHandler::getInstance()->update(WCF::getUser()->userID, 'filebaseUnreadEntries', self::$unreadEntries);
             } else {
                 self::$unreadEntries = $data;
             }
         }
     }
     return self::$unreadEntries;
 }
 /**
  * Marks all news as read.
  */
 public function markAllAsRead()
 {
     //get classes
     $baseClass = $this->className;
     $articleClass = $baseClass::getBaseClass();
     VisitTracker::getInstance()->trackTypeVisit($articleClass::$objectType);
     // reset storage
     if (WCF::getUser()->userID) {
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), self::$userStorageIdentifier);
     }
 }
 /**
  * Marks all queue entries as read.
  */
 public function markAllAsRead()
 {
     VisitTracker::getInstance()->trackTypeVisit('com.woltlab.wcf.moderation.queue');
     // reset storage
     UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'unreadModerationCount');
     return array('markAllAsRead' => true);
 }
 /**
  * Marks entries as read.
  */
 public function markAsRead()
 {
     if (empty($this->parameters['visitTime'])) {
         $this->parameters['visitTime'] = TIME_NOW;
     }
     if (empty($this->objects)) {
         $this->readObjects();
     }
     $entryIDs = array();
     foreach ($this->objects as $entry) {
         $entryIDs[] = $entry->entryID;
         VisitTracker::getInstance()->trackObjectVisit('de.incendium.filebase.entry', $entry->entryID, $this->parameters['visitTime']);
     }
     // reset storage
     if (WCF::getUser()->userID) {
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'filebaseUnreadEntries');
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'filebaseUnreadWatchedEntries');
         // user notifications
         if (!empty($entryIDs)) {
             UserNotificationHandler::getInstance()->markAsConfirmed('file', 'de.incendium.filebase.file', array(WCF::getUser()->userID), $entryIDs);
         }
     }
 }
 /**
  * Marks entries as read.
  */
 public function markAsRead()
 {
     if (empty($this->parameters['visitTime'])) {
         $this->parameters['visitTime'] = TIME_NOW;
     }
     if (empty($this->objects)) {
         $this->readObjects();
     }
     $entryIDs = array();
     foreach ($this->objects as $entry) {
         $entryIDs[] = $entry->entryID;
         VisitTracker::getInstance()->trackObjectVisit('de.incendium.linklist.entry', $entry->entryID, $this->parameters['visitTime']);
     }
     // reset storage
     if (WCF::getUser()->userID) {
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'linklistUnreadEntries');
     }
 }
 /**
  * Returns true if this queue item is new for the active user.
  * 
  * @return	boolean
  */
 public function isNew()
 {
     if ($this->time > max(VisitTracker::getInstance()->getVisitTime('com.woltlab.wcf.moderation.queue'), VisitTracker::getInstance()->getObjectVisitTime('com.woltlab.wcf.moderation.queue', $this->queueID))) {
         return true;
     }
     return false;
 }
 /**
  * Calculates the number of unread news.
  */
 protected function initUnreadEntry()
 {
     $this->unreadEntry = array();
     if (WCF::getUser()->userID) {
         // add default conditions
         $conditionBuilder = new PreparedStatementConditionBuilder();
         $conditionBuilder->add('news_entry.time > ?', array(VisitTracker::getInstance()->getVisitTime('de.incendium.cms.news.entry')));
         $conditionBuilder->add('news_entry.isDisabled = 0');
         $conditionBuilder->add('news_entry.isDeleted = 0');
         $conditionBuilder->add('news_entry.isArchived = 0');
         $conditionBuilder->add('news_entry.isPublished = 1');
         $conditionBuilder->add('tracked_visit.visitTime IS NULL');
         // apply language filter
         if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
             $conditionBuilder->add('(news_entry.languageID IN (?) OR news_entry.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
         }
         $sql = "SELECT \t\tCOUNT(*) AS count, news_entry_to_category.categoryID\n\t\t\t\tFROM \t\tcms" . WCF_N . "_news_entry news_entry\n\t\t\t\tLEFT JOIN \twcf" . WCF_N . "_tracked_visit tracked_visit ON (tracked_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('de.incendium.cms.news.entry') . " AND tracked_visit.objectID = news_entry.entryID AND tracked_visit.userID = " . WCF::getUser()->userID . ")\n\t\t\t\tLEFT JOIN \tcms" . WCF_N . "_news_entry_to_category news_entry_to_category ON (news_entry_to_category.entryID = news_entry.entryID)\n\t\t\t\t" . $conditionBuilder . "\n\t\t\t\tGROUP BY\tnews_entry_to_category.categoryID";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($conditionBuilder->getParameters());
         while ($row = $statement->fetchArray()) {
             $this->unreadEntry[$row['categoryID']] = $row['count'];
         }
     }
 }
 /**
  * Marks a news as read.
  */
 public function markAsRead()
 {
     if (empty($this->parameters['visitTime'])) {
         $this->parameters['visitTime'] = TIME_NOW;
     }
     if (empty($this->objects)) {
         $this->readObjects();
     }
     $newsIDs = array();
     foreach ($this->objects as $news) {
         $newsIDs[] = $news->newsID;
         VisitTracker::getInstance()->trackObjectVisit('de.voolia.news.entry', $news->newsID, $this->parameters['visitTime']);
     }
     // reset the user storage data
     if (WCF::getUser()->userID) {
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'newsUnreadEntries');
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'newsUnreadWatchedEntries');
         // delete obsolete user notifications
         if (!empty($newsIDs)) {
             UserNotificationHandler::getInstance()->deleteNotifications('news', 'de.voolia.news.entry', array(WCF::getUser()->userID), $newsIDs);
         }
     }
 }
    protected function initUnreadArticle()
    {
        //Get application
        $classParts = explode('\\', get_called_class());
        if (WCF::getUser()->userID) {
            $conditionBuilder = new PreparedStatementConditionBuilder();
            $conditionBuilder->add(self::$articleType . '.lastChangeTime > ?', array(VisitTracker::getInstance()->getVisitTime(self::OBJECT_TYPE)));
            $conditionBuilder->add(self::$articleType . '.isDeleted = 0');
            $conditionBuilder->add(self::$articleType . '.isDisabled = 0');
            $conditionBuilder->add('tracked_visit.visitTime IS NULL');
            // apply language filter
            if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
                $conditionBuilder->add('(' . self::$articleType . '.languageID IN (?) OR ' . self::$articleType . '.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
            }
            $sql = 'SELECT		COUNT(*) AS count, ' . self::$articleType . '_to_category.categoryID
				FROM		' . $classParts[0] . WCF_N . '_' . self::$articleType . ' ' . self::$articleType . '
				LEFT JOIN	wcf' . WCF_N . '_tracked_visit tracked_visit
				ON		(tracked_visit.objectTypeID = ' . VisitTracker::getInstance()->getObjectTypeID(self::OBJECT_TYPE) . ' AND tracked_visit.objectID = ' . self::$articleType . '.' . self::$articleType . 'ID AND tracked_visit.userID = ' . WCF::getUser()->userID . ')
				LEFT JOIN	' . $classParts[0] . WCF_N . '_' . self::$articleType . '_to_category ' . self::$articleType . '_to_category
				ON		(' . self::$articleType . '_to_category.' . self::$articleType . 'ID = ' . self::$articleType . '.' . self::$articleType . 'ID)
				' . $conditionBuilder . '
				GROUP BY	' . self::$articleType . '_to_category.categoryID';
            $statement = WCF::getDB()->prepareStatement($sql);
            $statement->execute($conditionBuilder->getParameters());
            while ($row = $statement->fetchArray()) {
                $this->unreadArticles[$row['categoryID']] = $row['count'];
            }
        }
    }
Example #25
0
 public function markAllAsRead()
 {
     VisitTracker::getInstance()->trackTypeVisit('de.codequake.cms.news');
     // reset storage
     if (WCF::getUser()->userID) {
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'cmsUnreadNews');
     }
 }
 /**
  * forum advanced search
  *
  * @param  Array  $filter  search filter
  * @param  Object  $oMbqDataPage
  * @param  Array  $mbqOpt
  * $mbqOpt['case'] = 'advanced' means advanced search
  * @return  Object  $oMbqDataPage
  */
 public function forumAdvancedSearch($filter = array(), $oMbqDataPage = null, $mbqOpt = array())
 {
     if ($mbqOpt['case'] == 'getLatestTopic' || $mbqOpt['case'] == 'getUnreadTopic' || $mbqOpt['case'] == 'getParticipatedTopic') {
         $oMbqRdEtForumTopic = MbqMain::$oClk->newObj('MbqRdEtForumTopic');
         if ($mbqOpt['case'] == 'getParticipatedTopic') {
             $oViewableThreadList = new ViewableThreadList();
             $oViewableThreadList->sqlOffset = $oMbqDataPage->startNum;
             $oViewableThreadList->sqlLimit = $oMbqDataPage->numPerPage;
             $oViewableThreadList->getConditionBuilder()->add('thread.isAnnouncement = 0');
             //!!!
             $oViewableThreadList->getConditionBuilder()->add('thread.threadID IN (SELECT threadID from wbb' . WCF_N . '_post where userID = ?)', array(MbqMain::$oCurMbqEtUser->userId->oriValue));
             //!!!
             $oViewableThreadList->readObjects();
             $oMbqDataPage->totalNum = $oViewableThreadList->countObjects();
             $oUnreadThreadList = new ViewableThreadList();
             $oUnreadThreadList->sqlConditionJoins = "    LEFT JOIN   wcf" . WCF_N . "_tracked_visit tracked_thread_visit\r\n                            ON      (tracked_thread_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('com.woltlab.wbb.thread') . " AND tracked_thread_visit.objectID = thread.threadID AND tracked_thread_visit.userID = " . WCF::getUser()->userID . ")\r\n                            LEFT JOIN   wcf" . WCF_N . "_tracked_visit tracked_board_visit\r\n                            ON      (tracked_board_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('com.woltlab.wbb.board') . " AND tracked_board_visit.objectID = thread.boardID AND tracked_board_visit.userID = " . WCF::getUser()->userID . ")";
             $oUnreadThreadList->sqlOffset = $oMbqDataPage->startNum;
             $oUnreadThreadList->sqlLimit = $oMbqDataPage->numPerPage;
             $oUnreadThreadList->getConditionBuilder()->add('thread.isAnnouncement = 0');
             //!!!
             $oUnreadThreadList->getConditionBuilder()->add('thread.threadID IN (SELECT threadID from wbb' . WCF_N . '_post where userID = ?)', array(MbqMain::$oCurMbqEtUser->userId->oriValue));
             //!!!
             $oUnreadThreadList->getConditionBuilder()->add('thread.lastPostTime > ?', array(VisitTracker::getInstance()->getVisitTime('com.woltlab.wbb.thread')));
             $oUnreadThreadList->getConditionBuilder()->add("(thread.lastPostTime > tracked_thread_visit.visitTime OR tracked_thread_visit.visitTime IS NULL)");
             $oUnreadThreadList->getConditionBuilder()->add("(thread.lastPostTime > tracked_board_visit.visitTime OR tracked_board_visit.visitTime IS NULL)");
             $oUnreadThreadList->readObjects();
             $oMbqDataPage->totalUnreadNum = $oUnreadThreadList->countObjects();
             /* common begin */
             $mbqOpt['case'] = 'byObjsViewableThread';
             $mbqOpt['oMbqDataPage'] = $oMbqDataPage;
             return $oMbqRdEtForumTopic->getObjsMbqEtForumTopic($oViewableThreadList->getObjects(), $mbqOpt);
         } elseif ($mbqOpt['case'] == 'getLatestTopic') {
             $oViewableThreadList = new ViewableThreadList();
             $oViewableThreadList->sqlOffset = $oMbqDataPage->startNum;
             $oViewableThreadList->sqlLimit = $oMbqDataPage->numPerPage;
             $oViewableThreadList->getConditionBuilder()->add('thread.isAnnouncement = 0');
             //!!!
             $oViewableThreadList->getConditionBuilder()->add('thread.boardID IN (?)', array(MbqMain::$oMbqAppEnv->accessibleBoardIds));
             $oViewableThreadList->readObjects();
             $oMbqDataPage->totalNum = $oViewableThreadList->countObjects();
             /* common begin */
             $mbqOpt['case'] = 'byObjsViewableThread';
             $mbqOpt['oMbqDataPage'] = $oMbqDataPage;
             return $oMbqRdEtForumTopic->getObjsMbqEtForumTopic($oViewableThreadList->getObjects(), $mbqOpt);
             /* common end */
         } elseif ($mbqOpt['case'] == 'getUnreadTopic') {
             require_once MBQ_APPEXTENTION_PATH . 'ExttMbqBoardQuickSearchAction.php';
             $oExttMbqBoardQuickSearchAction = new ExttMbqBoardQuickSearchAction();
             $oExttMbqBoardQuickSearchAction->exttMbqStartNum = $oMbqDataPage->startNum;
             $oExttMbqBoardQuickSearchAction->exttMbqNumPerPage = $oMbqDataPage->numPerPage;
             $ret = $oExttMbqBoardQuickSearchAction->execute();
             $oMbqDataPage->totalNum = $ret['total'];
             $newMbqOpt['case'] = 'byTopicIds';
             $newMbqOpt['oMbqDataPage'] = $oMbqDataPage;
             $oMbqDataPage = $oMbqRdEtForumTopic->getObjsMbqEtForumTopic($ret['topicIds'], $newMbqOpt);
             return $oMbqDataPage;
         }
     } elseif ($mbqOpt['case'] == 'searchTopic') {
         $oMbqRdEtForumTopic = MbqMain::$oClk->newObj('MbqRdEtForumTopic');
         $oViewableThreadList = new ViewableThreadList();
         $oViewableThreadList->sqlOffset = $oMbqDataPage->startNum;
         $oViewableThreadList->sqlLimit = $oMbqDataPage->numPerPage;
         $oViewableThreadList->getConditionBuilder()->add('thread.isAnnouncement = 0');
         //!!!
         $oViewableThreadList->getConditionBuilder()->add('thread.boardID IN (?)', array(MbqMain::$oMbqAppEnv->accessibleBoardIds));
         $oViewableThreadList->getConditionBuilder()->add('thread.threadID IN (SELECT threadID from wbb' . WCF_N . '_post as mbqPost where mbqPost.subject LIKE ? OR mbqPost.message LIKE ?)', array('%' . addcslashes($filter['keywords'], '_%') . '%', '%' . addcslashes($filter['keywords'], '_%') . '%'));
         //!!!
         $oViewableThreadList->readObjects();
         $oMbqDataPage->totalNum = $oViewableThreadList->countObjects();
         /* common begin */
         $mbqOpt['case'] = 'byObjsViewableThread';
         $mbqOpt['oMbqDataPage'] = $oMbqDataPage;
         return $oMbqRdEtForumTopic->getObjsMbqEtForumTopic($oViewableThreadList->getObjects(), $mbqOpt);
         /* common end */
     } elseif ($mbqOpt['case'] == 'searchPost') {
         $oMbqRdEtForumPost = MbqMain::$oClk->newObj('MbqRdEtForumPost');
         $oViewablePostList = new ViewablePostList();
         $oViewablePostList->sqlConditionJoins .= 'INNER JOIN wbb' . WCF_N . '_thread thread ON (post.threadID = thread.threadID AND thread.isAnnouncement = 0)';
         //!!!
         $oViewablePostList->getConditionBuilder()->add('thread.boardID IN (?)', array(MbqMain::$oMbqAppEnv->accessibleBoardIds));
         $oViewablePostList->getConditionBuilder()->add('(post.subject LIKE ? OR post.message LIKE ?)', array('%' . addcslashes($filter['keywords'], '_%') . '%', '%' . addcslashes($filter['keywords'], '_%') . '%'));
         //!!!
         $oViewablePostList->readObjects();
         $oMbqDataPage->totalNum = $oViewablePostList->countObjects();
         /* common begin */
         $mbqOpt['case'] = 'byObjsViewablePost';
         $mbqOpt['oMbqDataPage'] = $oMbqDataPage;
         return $oMbqRdEtForumPost->getObjsMbqEtForumPost($oViewablePostList->getObjects(), $mbqOpt);
         /* common end */
     } elseif ($mbqOpt['case'] == 'advanced') {
         MbqError::alert('', __METHOD__ . ',line:' . __LINE__ . '.' . MBQ_ERR_INFO_NOT_ACHIEVE);
     }
     MbqError::alert('', __METHOD__ . ',line:' . __LINE__ . '.' . MBQ_ERR_INFO_UNKNOWN_CASE);
 }
 /**
  * @see	wcf\action\IAction::execute()
  */
 public function execute()
 {
     //parent::execute();  //!!!
     $this->readParameters();
     //!!!
     // set active menu item (for error messages)
     //PageMenu::getInstance()->setActiveMenuItem('wbb.header.menu.board');
     // build conditions
     $sql = '';
     $conditionBuilder = new PreparedStatementConditionBuilder();
     switch ($this->mode) {
         case 'unreadPosts':
             $conditionBuilder->add('thread.boardID IN (?)', array($this->boardIDs));
             $conditionBuilder->add('thread.lastPostTime > ?', array(VisitTracker::getInstance()->getVisitTime('com.woltlab.wbb.thread')));
             $conditionBuilder->add('thread.isDeleted = 0');
             $conditionBuilder->add('thread.isDisabled = 0');
             $conditionBuilder->add('thread.movedThreadID IS NULL');
             $conditionBuilder->add('(thread.lastPostTime > tracked_thread_visit.visitTime OR tracked_thread_visit.visitTime IS NULL)');
             $conditionBuilder->add('(thread.lastPostTime > tracked_board_visit.visitTime OR tracked_board_visit.visitTime IS NULL)');
             if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
                 $conditionBuilder->add('(thread.languageID IN (?) OR thread.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
             }
             $conditionBuilder->add('thread.isAnnouncement = 0');
             //!!!
             $sql = "SELECT\t\tthread.threadID\n\t\t\t\t\tFROM\t\twbb" . WCF_N . "_thread thread\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_tracked_visit tracked_thread_visit\n\t\t\t\t\tON\t\t(tracked_thread_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('com.woltlab.wbb.thread') . " AND tracked_thread_visit.objectID = thread.threadID AND tracked_thread_visit.userID = " . WCF::getUser()->userID . ")\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_tracked_visit tracked_board_visit\n\t\t\t\t\tON\t\t(tracked_board_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('com.woltlab.wbb.board') . " AND tracked_board_visit.objectID = thread.boardID AND tracked_board_visit.userID = " . WCF::getUser()->userID . ")\n\t\t\t\t\t" . $conditionBuilder . "\n\t\t\t\t\tORDER BY\tthread.lastPostTime DESC";
             $exttMbqSqlCount = "SELECT\t\tcount(thread.threadID) as totalNum\n\t\t\t\t\tFROM\t\twbb" . WCF_N . "_thread thread\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_tracked_visit tracked_thread_visit\n\t\t\t\t\tON\t\t(tracked_thread_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('com.woltlab.wbb.thread') . " AND tracked_thread_visit.objectID = thread.threadID AND tracked_thread_visit.userID = " . WCF::getUser()->userID . ")\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_tracked_visit tracked_board_visit\n\t\t\t\t\tON\t\t(tracked_board_visit.objectTypeID = " . VisitTracker::getInstance()->getObjectTypeID('com.woltlab.wbb.board') . " AND tracked_board_visit.objectID = thread.boardID AND tracked_board_visit.userID = " . WCF::getUser()->userID . ")\n\t\t\t\t\t" . $conditionBuilder;
             break;
             /*
             case 'undoneThreads':
             	$boardIDs = array();
             	foreach ($this->boardIDs as $boardID) {
             		if (BoardCache::getInstance()->getBoard($boardID)->enableMarkingAsDone) $boardIDs[] = $boardID;
             	}
             	if (empty($boardIDs)) {
             		throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.search.error.noMatches', array('query' => '')));
             	}
             	
             	$conditionBuilder->add('thread.boardID IN (?)', array($boardIDs));
             	$conditionBuilder->add('thread.isDone = 0');
             	$conditionBuilder->add('thread.isDeleted = 0');
             	$conditionBuilder->add('thread.isDisabled = 0');
             	$conditionBuilder->add('thread.movedThreadID IS NULL');
             	if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
             		$conditionBuilder->add('(thread.languageID IN (?) OR thread.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
             	}
             	
             	$sql = "SELECT		thread.threadID
             		FROM		wbb".WCF_N."_thread thread
             		".$conditionBuilder."		
             		ORDER BY	thread.lastPostTime DESC";
             break;
             */
     }
     // build search hash
     $searchHash = StringUtil::getHash($sql);
     // execute query
     $matches = array();
     $statement = WCF::getDB()->prepareStatement($sql, $this->exttMbqNumPerPage, $this->exttMbqStartNum);
     $statement->execute($conditionBuilder->getParameters());
     while ($row = $statement->fetchArray()) {
         $matches[] = array('objectID' => $row['threadID'], 'objectType' => 'com.woltlab.wbb.post');
     }
     //get total count
     $exttMbqStatementCount = WCF::getDB()->prepareStatement($exttMbqSqlCount);
     $exttMbqStatementCount->execute($conditionBuilder->getParameters());
     while ($exttMbqRecord = $exttMbqStatementCount->fetchArray()) {
         $exttMbqTotal = $exttMbqRecord['totalNum'];
     }
     // check result
     /*
     if (!count($matches)) {
     	throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.search.error.noMatches', array('query' => '')));
     }
     */
     // save result in database
     $searchData = array('packageID' => PACKAGE_ID, 'query' => '', 'results' => $matches, 'additionalData' => array('com.woltlab.wbb.post' => array('findThreads' => 1)), 'sortOrder' => 'DESC', 'sortField' => 'time', 'objectTypes' => array('com.woltlab.wbb.post'));
     $searchData = serialize($searchData);
     $search = SearchEditor::create(array('userID' => WCF::getUser()->userID ?: null, 'searchData' => $searchData, 'searchTime' => TIME_NOW, 'searchType' => 'messages', 'searchHash' => $searchHash));
     // forward to result page
     //HeaderUtil::redirect(LinkHandler::getInstance()->getLink('SearchResult', array('id' => $search->searchID)));
     //exit;
     $exttMbqRetIds = array();
     foreach ($matches as $exttMbqTopicId) {
         $exttMbqRetIds[] = $exttMbqTopicId['objectID'];
     }
     return array('total' => $exttMbqTotal, 'topicIds' => $exttMbqRetIds);
 }
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     parent::save();
     $this->objectAction = new EntryUpdateAction(array(), 'create', array('data' => array('entryID' => $this->entryID, 'time' => TIME_NOW, 'userID' => WCF::getUser()->userID ?: null, 'username' => WCF::getUser()->userID ? WCF::getUser()->username : $this->username, 'subject' => $this->subject, 'message' => $this->text, 'enableSmilies' => $this->enableSmilies, 'enableHtml' => $this->enableHtml, 'enableBBCodes' => $this->enableBBCodes)));
     $this->objectAction->executeAction();
     // update news entry
     $sql = "UPDATE\tcms" . WCF_N . "_news_entry\n                SET\tentryUpdates = entryUpdates + 1\n             \tWHERE\tentryID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($this->entryID));
     // set news as new
     if ($this->setEntryAsNew) {
         $sql = "UPDATE\tcms" . WCF_N . "_news_entry\n                    SET\ttime = ?\n\t     \t   \t\tWHERE\tentryID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array(TIME_NOW, $this->entryID));
         $sql = "DELETE FROM\twcf" . WCF_N . "_tracked_visit\n\t\t            WHERE\t\tobjectTypeID = ?\n\t\t            AND\t\tobjectID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array(VisitTracker::getInstance()->getObjectTypeID('de.incendium.cms.news.entry'), $this->entryID));
         // reset the user storage data
         UserStorageHandler::getInstance()->resetAll('cmsUnreadNewsEntries');
     }
     // quotes
     MessageQuoteManager::getInstance()->saved();
     // redirect to news entry
     HeaderUtil::redirect(LinkHandler::getInstance()->getLink('NewsEntry', array('application' => 'cms', 'object' => $this->entry)));
     exit;
 }