/** * @see \wcf\system\search\ISearchableObjectType::getConditions() */ public function getConditions(IForm $form = null) { $conditionBuilder = new PreparedStatementConditionBuilder(); // accessible category ids if (isset($_POST['filebaseCategoryIDs'])) { $this->filebaseCategoryIDs = ArrayUtil::toIntegerArray($_POST['filebaseCategoryIDs']); } $categoryIDs = FilebaseCategory::getAccessibleCategoryIDs(); if (!empty($this->filebaseCategoryIDs)) { $this->filebaseCategoryIDs = array_intersect($categoryIDs, $this->filebaseCategoryIDs); } else { $this->filebaseCategoryIDs = $categoryIDs; } if (empty($this->filebaseCategoryIDs)) { throw new PermissionDeniedException(); } $conditionBuilder->add($this->getTableName() . '.entryID IN (SELECT entryID FROM filebase' . WCF_N . '_entry_to_category WHERE categoryID IN (?))', array($this->filebaseCategoryIDs)); // default conditions $conditionBuilder->add($this->getTableName() . '.isDisabled = 0'); $conditionBuilder->add($this->getTableName() . '.isDeleted = 0'); // language if (FILEBASE_ENABLE_MULTILINGUALISM && LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) { $conditionBuilder->add('(' . $this->getTableName() . '.languageID IN (?) OR ' . $this->getTableName() . '.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs())); } return $conditionBuilder; }
/** * @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; }
/** * Creates a new DeletedVersionFileList object. */ public function __construct() { parent::__construct(); // categories $accessibleCategoryIDs = FilebaseCategory::getAccessibleCategoryIDs(); if (!empty($accessibleCategoryIDs)) { $this->getConditionBuilder()->add('file.entryID IN (SELECT entryID FROM filebase' . WCF_N . '_entry_to_category WHERE categoryID IN (?))', array($accessibleCategoryIDs)); } else { $this->getConditionBuilder()->add('1=0'); } $this->getConditionBuilder()->add('file.isDeleted = ?', array(1)); }
/** * 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'); } }
/** * Creates a new AccessibleFileList object. */ public function __construct() { parent::__construct(); if ($this->applyCategoryFilter) { $accessibleCategoryIDs = FilebaseCategory::getAccessibleCategoryIDs(); if (!empty($accessibleCategoryIDs)) { $this->getConditionBuilder()->add('entry.entryID IN (SELECT entryID FROM filebase' . WCF_N . '_entry_to_category WHERE categoryID IN (?))', array($accessibleCategoryIDs)); } else { $this->getConditionBuilder()->add('1=0'); } } if (!WCF::getSession()->getPermission('mod.filebase.canModerateEntry')) { $this->getConditionBuilder()->add('entry.isDisabled = 0'); } if (!WCF::getSession()->getPermission('mod.filebase.canViewDeletedEntry')) { $this->getConditionBuilder()->add('entry.isDeleted = 0'); } // apply language filter if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) { $this->getConditionBuilder()->add('(entry.languageID IN (?) OR entry.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs())); } }
/** * @see \wcf\page\IPage::readParameters() */ public function readParameters() { parent::readParameters(); if (empty($this->objectIDs)) { // get all category ids $this->objectIDs = FilebaseCategory::getAccessibleCategoryIDs(); if (empty($this->objectIDs)) { throw new IllegalLinkException(); } } else { // validate ids foreach ($this->objectIDs as $objectID) { $category = FilebaseCategory::getCategory($objectID); // wrong ID if ($category === null) { throw new IllegalLinkException(); } // one may not enter if (!$category->isAccessible()) { throw new PermissionDeniedException(); } } } }
/** * 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; }
/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); // get categories $excludedCategoryIDs = array_diff(FilebaseCategory::getAccessibleCategoryIDs(), FilebaseCategory::getAccessibleCategoryIDs(array('canUseCategory'))); $categoryTree = new FilebaseCategoryNodeTree('de.incendium.filebase.category', 0, false, $excludedCategoryIDs); $this->categoryList = $categoryTree->getIterator(); $this->categoryList->setMaxDepth(0); if (empty($_POST)) { // multilingualism if (!empty($this->availableContentLanguages)) { if (!$this->languageID) { $language = LanguageFactory::getInstance()->getUserLanguage(); $this->languageID = $language->languageID; } if (!isset($this->availableContentLanguages[$this->languageID])) { $languageIDs = array_keys($this->availableContentLanguages); $this->languageID = array_shift($languageIDs); } } } }