public function filter(DataList $list)
 {
     $groupids = array(0);
     if ($member = $this->getMember()) {
         $groupids = $groupids + $member->Groups()->map('ID', 'ID')->toArray();
     }
     return $list->filter("GroupID", $groupids);
 }
 /**
  * @param DataList $files
  * @return DataList
  */
 public function addFilterForFiles(DataList $files)
 {
     return $files->filter('ClassName', 'CloudinaryFile');
 }
Beispiel #3
0
	/**
	 * Returns the pages meet a certain criteria as {@see CMSSiteTreeFilter} or the subpages of a parent page
	 * defaulting to no filter and show all pages in first level.
	 * Doubles as search results, if any search parameters are set through {@link SearchForm()}.
	 * 
	 * @param Array Search filter criteria
	 * @param Int Optional parent node to filter on (can't be combined with other search criteria)
	 * @return SS_List
	 */
	public function getList($params, $parentID = 0) {
		$list = new DataList($this->stat('tree_class'));
		$filter = null;
		$ids = array();
		if(isset($params['FilterClass']) && $filterClass = $params['FilterClass']){
			if(!is_subclass_of($filterClass, 'CMSSiteTreeFilter')) {
				throw new Exception(sprintf('Invalid filter class passed: %s', $filterClass));
			}
			$filter = new $filterClass($params);
			$filterOn = true;
			foreach($pages=$filter->pagesIncluded() as $pageMap){
				$ids[] = $pageMap['ID'];
			}
			if(count($ids)) $list->where('"'.$this->stat('tree_class').'"."ID" IN ('.implode(",", $ids).')');
		} else {
			$list->filter("ParentID", is_numeric($parentID) ? $parentID : 0);
		}

		return $list;
	}