filterCategoryPermissions() public static method

Remove categories that a user does not have permission to view.
public static filterCategoryPermissions ( array $categoryIDs ) : array
$categoryIDs array An array of categories to filter.
return array Returns an array of category IDs that are okay to view.
 public function getData($Limit = false)
 {
     if ($Limit === false) {
         $Limit = C('Plugins.DiscussionEvent.MaxDiscussionEvents');
     }
     $DiscussionEventModel = new DiscussionEventModel();
     // Check for individual categories:
     $Where = array();
     if ($this->CategoryID) {
         $Where['d.CategoryID'] = CategoryModel::filterCategoryPermissions(array($this->CategoryID));
     } else {
         $DiscussionEventModel->Watching = true;
     }
     $this->setData('DiscussionEvents', $DiscussionEventModel->getByDiscussionEventRange(0, $Limit, false, false, $Where));
 }
 /**
  * Get the data for the module.
  *
  * @param int|bool $limit Override the number of discussions to display.
  */
 public function getData($limit = false)
 {
     if (!$limit) {
         $limit = $this->Limit;
     }
     $discussionModel = new DiscussionModel();
     $categoryIDs = $this->getCategoryIDs();
     $where = array('Announce' => 'all');
     if ($categoryIDs) {
         $where['d.CategoryID'] = CategoryModel::filterCategoryPermissions($categoryIDs);
     } else {
         $discussionModel->Watching = true;
     }
     $this->setData('Discussions', $discussionModel->get(0, $limit, $where));
 }
 /**
  * Default all discussions view: chronological by most recent comment.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $Page Multiplied by PerPage option to determine offset.
  */
 public function index($Page = false)
 {
     // Figure out which discussions layout to choose (Defined on "Homepage" settings page).
     $Layout = c('Vanilla.Discussions.Layout');
     switch ($Layout) {
         case 'table':
             if ($this->SyndicationMethod == SYNDICATION_NONE) {
                 $this->View = 'table';
             }
             break;
         default:
             // $this->View = 'index';
             break;
     }
     Gdn_Theme::section('DiscussionList');
     // Check for the feed keyword.
     if ($Page === 'feed' && $this->SyndicationMethod != SYNDICATION_NONE) {
         $Page = 'p1';
     }
     // Determine offset from $Page
     list($Offset, $Limit) = offsetLimit($Page, c('Vanilla.Discussions.PerPage', 30), true);
     $Page = PageNumber($Offset, $Limit);
     // Allow page manipulation
     $this->EventArguments['Page'] =& $Page;
     $this->EventArguments['Offset'] =& $Offset;
     $this->EventArguments['Limit'] =& $Limit;
     $this->fireEvent('AfterPageCalculation');
     // Set canonical URL
     $this->canonicalUrl(url(ConcatSep('/', 'discussions', PageNumber($Offset, $Limit, true, false)), true));
     // We want to limit the number of pages on large databases because requesting a super-high page can kill the db.
     $MaxPages = c('Vanilla.Discussions.MaxPages');
     if ($MaxPages && $Page > $MaxPages) {
         throw notFoundException();
     }
     // Setup head.
     if (!$this->data('Title')) {
         $Title = c('Garden.HomepageTitle');
         $DefaultControllerRoute = val('Destination', Gdn::router()->GetRoute('DefaultController'));
         if ($Title && $DefaultControllerRoute == 'discussions') {
             $this->title($Title, '');
         } else {
             $this->title(t('Recent Discussions'));
         }
     }
     if (!$this->Description()) {
         $this->Description(c('Garden.Description', null));
     }
     if ($this->Head) {
         $this->Head->AddRss(url('/discussions/feed.rss', true), $this->Head->title());
     }
     // Add modules
     $this->addModule('DiscussionFilterModule');
     $this->addModule('NewDiscussionModule');
     $this->addModule('CategoriesModule');
     $this->addModule('BookmarkedModule');
     $this->setData('Breadcrumbs', array(array('Name' => t('Recent Discussions'), 'Url' => '/discussions')));
     // Set criteria & get discussions data
     $this->setData('Category', false, true);
     $DiscussionModel = new DiscussionModel();
     // Check for individual categories.
     $categoryIDs = $this->getCategoryIDs();
     $where = array();
     if ($categoryIDs) {
         $where['d.CategoryID'] = CategoryModel::filterCategoryPermissions($categoryIDs);
     } else {
         $DiscussionModel->Watching = true;
     }
     // Get Discussion Count
     $CountDiscussions = $DiscussionModel->getCount($where);
     if ($MaxPages) {
         $CountDiscussions = min($MaxPages * $Limit, $CountDiscussions);
     }
     $this->setData('CountDiscussions', $CountDiscussions);
     // Get Announcements
     $this->AnnounceData = $Offset == 0 ? $DiscussionModel->GetAnnouncements($where) : false;
     $this->setData('Announcements', $this->AnnounceData !== false ? $this->AnnounceData : array(), true);
     // Get Discussions
     $this->DiscussionData = $DiscussionModel->getWhere($where, $Offset, $Limit);
     $this->setData('Discussions', $this->DiscussionData, true);
     $this->setJson('Loading', $Offset . ' to ' . $Limit);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->EventArguments['PagerType'] = 'Pager';
     $this->fireEvent('BeforeBuildPager');
     if (!$this->data('_PagerUrl')) {
         $this->setData('_PagerUrl', 'discussions/{Page}');
     }
     $this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
     $this->Pager->ClientID = 'Pager';
     $this->Pager->configure($Offset, $Limit, $this->data('CountDiscussions'), $this->data('_PagerUrl'));
     PagerModule::Current($this->Pager);
     $this->setData('_Page', $Page);
     $this->setData('_Limit', $Limit);
     $this->fireEvent('AfterBuildPager');
     // Deliver JSON data if necessary
     if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
         $this->setJson('LessRow', $this->Pager->toString('less'));
         $this->setJson('MoreRow', $this->Pager->toString('more'));
         $this->View = 'discussions';
     }
     $this->render();
 }