public function get(UserOnline $user, $languageVariable = '')
 {
     if ($category = CategoryHandler::getInstance()->getCategory($user->objectID)) {
         $category = new NewsCategory($category);
         if ($category->getPermission('canView')) {
             return WCF::getLanguage()->getDynamicVariable($languageVariable, array('category' => $category));
         }
     }
     return '';
 }
Exemplo n.º 2
0
 public static function getAccessibleCategoryIDs($permissions = array('canViewCategory'))
 {
     $categoryIDs = array();
     foreach (CategoryHandler::getInstance()->getCategories(self::OBJECT_TYPE_NAME) as $category) {
         $result = true;
         $category = new NewsCategory($category);
         foreach ($permissions as $permission) {
             $result = $result && $category->getPermission($permission);
         }
         if ($result) {
             $categoryIDs[] = $category->categoryID;
         }
     }
     return $categoryIDs;
 }
 /**
  * Returns a list with category ids of accessible news categories.
  * 
  * @param	array		$permissions
  * @return	array<integer>
  */
 public static function getAccessibleCategoryIDs(array $permissions = array('canManageCategory'))
 {
     $categoryIDs = array();
     foreach (CategoryHandler::getInstance()->getCategories('de.incendium.cms.news.category') as $category) {
         $result = true;
         $category = new NewsCategory($category);
         foreach ($permissions as $permission) {
             $result = $result && $category->getPermission($permission);
         }
         if ($result) {
             $categoryIDs[] = $category->categoryID;
         }
     }
     return $categoryIDs;
 }
 public function __construct(array $categoryIDs)
 {
     parent::__construct();
     if (!empty($categoryIDs)) {
         $this->getConditionBuilder()->add('news_to_category.categoryID IN (?)', array($categoryIDs));
         $this->getConditionBuilder()->add('news.newsID = news_to_category.newsID');
     } else {
         $this->getConditionBuilder()->add('1=0');
     }
     foreach ($categoryIDs as $categoryID) {
         $category = new NewsCategory(CategoryHandler::getInstance()->getCategory($categoryID));
         if (!$category->getPermission('canViewDelayedNews')) {
             $this->getConditionBuilder()->add('news.isDisabled = ?', array(0));
         }
     }
 }
Exemplo n.º 5
0
 public function validate()
 {
     parent::validate();
     // categories
     if (empty($this->categoryIDs)) {
         throw new UserInputException('categoryIDs');
     }
     foreach ($this->categoryIDs as $categoryID) {
         $category = CategoryHandler::getInstance()->getCategory($categoryID);
         if ($category === null) {
             throw new UserInputException('categoryIDs');
         }
         $category = new NewsCategory($category);
         if (!$category->isAccessible() || !$category->getPermission('canAddNews')) {
             throw new UserInputException('categoryIDs');
         }
     }
     if (MODULE_POLL && WCF::getSession()->getPermission('user.cms.news.canStartPoll')) {
         PollManager::getInstance()->validate();
     }
 }