Returns the list of all permissions of this category.

@param string $pkCategoryHandle
@param array $filters An array containing of field name => value (to be used directly in the SQL query)

@return \Concrete\Core\Permission\Key\Key[]
551089
public static function getList($pkCategoryHandle, $filters = [])
    {
        $app = Application::getFacadeApplication();
        $db = $app->make(Connection::class);
        $q = 'select pkID from PermissionKeys inner join PermissionKeyCategories on PermissionKeys.pkCategoryID = PermissionKeyCategories.pkCategoryID where pkCategoryHandle = ?';
        foreach ($filters as $key => $value) {
            $q .= ' and ' . $key . ' = ' . $value . ' ';
        }
        $r = $db->executeQuery($q, [$pkCategoryHandle]);
        $list = [];
        while (($pkID = $r->fetchColumn()) !== false) {
            $pk = self::load($pkID);
            if ($pk) {
                $list[] = $pk;
            }
        }

        return $list;
    }
614000
private function getPermissions(): array
    {
        $model = App::shortName(get_class($this->table), 'Model/Table', 'Table');

        $values = $this->getPermissionsByModel($model);
        if (empty($values)) {
            return [];
        }

        $primaryKey = $this->table->getPrimaryKey();
        Assert::string($primaryKey);

        return [$this->table->aliasField($primaryKey) . ' IN' => array_unique($values)];
    }
219204
public static function CategoryPermissions($Escape = FALSE) {
      if(is_null(self::$_CategoryPermissions)) {
         $Session = Gdn::Session();
         
         if((is_object($Session->User) && $Session->User->Admin)) {
            self::$_CategoryPermissions = TRUE;
			} elseif(C('Garden.Permissions.Disabled.Category')) {
				if($Session->CheckPermission('Vanilla.Discussions.View'))
					self::$_CategoryPermissions = TRUE;
				else
					self::$_CategoryPermissions = array(); // no permission
         } else {
            $SQL = Gdn::SQL();
            
            $Categories = CategoryModel::Categories();
            $IDs = array();
            
            foreach ($Categories as $ID => $Category) {
               if ($Category['PermsDiscussionsView']) {
                  $IDs[] = $ID;
               }
            }

            // Check to see if the user has permission to all categories. This is for speed.
            $CategoryCount = count($Categories);
            
            if (count($IDs) == $CategoryCount)
               self::$_CategoryPermissions = TRUE;
            else {
               self::$_CategoryPermissions = array();
               foreach($IDs as $ID) {
                  self::$_CategoryPermissions[] = ($Escape ? '@' : '').$ID;
               }
            }
         }
      }
      
      return self::$_CategoryPermissions;
   }
857048
public function getFiltersFromUidList($filterUids)
    {
        if (empty($filterUids)) {
            return array();
        }

        // @Todo quotes ($this->startingPoints, filterUids)
        $table = 'tx_kesearch_filters';
        $where = 'pid in (' . $this->startingPoints . ')';
        $where .= ' AND find_in_set(uid, "' . $filterUids . '")';

        $queryBuilder = Db::getQueryBuilder('tx_kesearch_filters');
        $filterQuery = $queryBuilder
            ->select('*')
            ->from($table)
            ->add('where', $where)
            ->add('orderBy', 'find_in_set(uid, "' . $filterUids . '")')
            ->execute();

        $filterRows = [];
        while ($row = $filterQuery->fetch()) {
            $filterRows[$row['uid']] = $row;
        }

        $filterRows = $this->languageOverlay($filterRows, $table);
        return $this->addOptionsToFilters($filterRows);
    }
1021721
private function getQueryFilter($filters)
    {
        $where = '';
        if (!empty($filters))
        {
            foreach ($filters as $filterKey => $filterValue)
            {
                $where .= ' AND m.' . $filterKey . ' LIKE :' . $filterKey;
            }
            $where = ' WHERE ' . substr($where, 4);
        }
        return $where;
    }
273764
private function getMappedPermissions(array $permissions): array
    {
        $mappedPermissions = [];
        foreach ($permissions as $permission => $options) {
            $mappedPermissions[strtolower($permission)] = $permission;
            if (is_array($options) && array_key_exists('nested', $options)) {
                $mappedPermissions = array_merge($mappedPermissions, $this->getMappedPermissions($options['nested']));
            }
        }

        return $mappedPermissions;
    }
1324833
private function getAccessRights(\Category $category, \DmsLoaderParams $params)
  {
    $objAccessRight = $this->Database->prepare("SELECT * FROM tl_dms_access_rights WHERE pid = ?")
                     ->execute($category->id);
    $arrAccessRights = array();
    while ($objAccessRight->next())
    {
      $accessRight = $this->buildAccessRight($objAccessRight);
      $accessRight->category = $category;
      $arrAccessRights[$accessRight->id] = $accessRight;
    }
    return $arrAccessRights;
  }
1280739
public static function parseFilters($filters)
	{
		return array_build(static::explodeFilters($filters), function($key, $value)
		{
			return Route::parseFilter($value);
		});
	}
168886
public static function getCategoryFilterValues($filter, $categoryId) {
        /* @var $class ActiveRecordInterface */

        $class = $filter->type->class_name;
        $objects = $class::find()
            ->joinWith('products p')
            ->where(['p.category_id' => $categoryId])
            ->all();

        return $objects;
    }
896656
public function getProductsByCategoryId($categoryId, $filterByNewProducts = false, $keyword = '', $productId = 0, $countMode = false)
    {
        $params = [
            'active' => APP_ON
        ];
        if (! $this->getLoggedUser()) {
            $params['isPrivate'] = APP_OFF;
        }

        $sql = 'SELECT ';
        $sql .= $this->getFieldsForProductListQuery();
        $sql .= "FROM ".$this->tablePrefix."product Products ";

        if (! $filterByNewProducts) {
            $sql .= "LEFT JOIN ".$this->tablePrefix."category_product CategoryProducts ON CategoryProducts.id_product = Products.id_product
                 LEFT JOIN ".$this->tablePrefix."category Categories ON CategoryProducts.id_category = Categories.id_category ";
        }

        $sql .= $this->getJoinsForProductListQuery();
        $sql .= $this->getConditionsForProductListQuery();

        if (! $filterByNewProducts) {
            $params['categoryId'] = $categoryId;
            $sql .= " AND CategoryProducts.id_category = :categoryId ";
            $sql .= " AND Categories.active = :active";
        }

        if ($filterByNewProducts) {
            $params['dateAdd'] = date('Y-m-d', strtotime('-' . Configure::read('appDb.FCS_DAYS_SHOW_PRODUCT_AS_NEW') . ' DAYS'));
            $sql .= " AND DATE_FORMAT(Products.created, '%Y-%m-%d') > :dateAdd";
        }

        if ($keyword != '') {
            $params['keyword'] = '%' . $keyword . '%';
            $sql .= " AND (Products.name LIKE :keyword OR Products.description_short LIKE :keyword) ";
        }

        if ($productId > 0) {
            $params['productId'] = $productId;
            $sql .= " AND Products.id_product = :productId ";
        }

        $sql .= $this->getOrdersForProductListQuery();
        $statement = $this->getConnection()->prepare($sql);
        $statement->execute($params);
        $products = $statement->fetchAll('assoc');
        $products = $this->hideProductsWithActivatedDeliveryRhythmOrDeliveryBreak($products);

        if (! $countMode) {
            return $products;
        } else {
            return count($products);
        }

        return $products;
    }
1116866
public function getGroupMembers($groupId,  array $filters = [])
	{
		return $this->sendRequest(
			$this->createRequest('GET', sprintf('groups/%d/members', $groupId), [
				'query' => $filters
			])
		);
	}
1309665
public static function lists($field, $filters = null)
    {
        $model = new static;

        $query = static::query(null, $model)->where($filters);

        $list = [];

        if (is_string($field)) {
            $keyField = $model->getPrimaryKey();
            $valueField = $field;

            $query = $query->select([$keyField, $valueField]);
            if (in_array('display_order', $model->getFields(), true)) {
                return $query->orderBy(['display_order' => SORT_DESC, $keyField => SORT_ASC])->fetch(true);
            } else {
                return $query->orderBy($keyField)->fetch(true);
            }
        } else {
            $keyField = key($field);
            $valueField = current($field);
            /** @noinspection ForeachSourceInspection */
            foreach ($query->select([$keyField, $valueField])->fetch(true) as $v) {
                $key = $v[$keyField];
                $value = $v[$valueField];

                if (!isset($list[$key])) {
                    $list[$key] = $value;
                } elseif (is_array($list[$key])) {
                    $list[$key][] = $value;
                } else {
                    $list[$key] = [$list[$key], $value];
                }
            }

            return $list;
        }
    }
665575
private function getParentPermissions() : array
    {
        $result = [];
        foreach ($this->table->associations() as $association) {
            if (! $this->isSupportedJoinAssociation($association)) {
                continue;
            }

            if (! $this->isParentModuleAssociation($association)) {
                continue;
            }

            $foreignKey = $association->getForeignKey();
            Assert::string($foreignKey);

            $field = sprintf('%s IN', $foreignKey);
            $result[$field] = $this->getPermissionsByModel($this->getModelByAssociation($association));
        }

        return $result;
    }
1310445
public function getSearchQueriesByChildren(CategoryInterface $rootCategory)
    {
        $queries     = [];
        $childrenIds = $rootCategory->getResource()->getChildren($rootCategory, false);

        if (!empty($childrenIds)) {
            $storeId            = $this->getStoreId();
            $categoryCollection = $this->categoryCollectionFactory->create()->setStoreId($storeId);

            $categoryCollection
                ->setStoreId($this->getStoreId())
                ->addIsActiveFilter()
                ->addIdFilter($childrenIds)
                ->addAttributeToSelect(['virtual_category_root', 'is_virtual_category', 'virtual_rule']);

            foreach ($categoryCollection as $category) {
                $childQuery = $this->getCategorySearchQuery($category);
                if ($childQuery !== null) {
                    $queries[$category->getId()] = $childQuery;
                }
            }
        }

        return $queries;
    }
1090479
private function _getObjectsByFilter(Filter $filterQuery)
    {
        $records = [];
        $props = [];
        $filters = [];
        foreach ($filterQuery->getComparisons() as $comparison) {
            $props[] = $comparison->prop;
            if ($comparison->expression && $comparison->comparison && $comparison->prop) {
                $expression = ($comparison->expression !== 'WHERE') ? $comparison->expression . ' ' : '';
                $prop = is_int($comparison->val) ? 'CAST(' . $comparison->prop . ' AS INT)' : $comparison->prop;
                $compare = $comparison->comparison;
                $value = (!isset($comparison->val) || is_null($comparison->val)) ? 'NULL' : $comparison->val;
                $filters[] = $expression . $prop . ' ' . $compare . ' \'' . $value . '\'';
            }
        }

        $props = array_unique($props);
        $joins = [];
        foreach ($props as $prop)
        {
            $standardFields = [
                '__id',
                '__type',
                '__collection',
                '__origin'
            ];
            if (!in_array($prop, $standardFields)) {
                $asTbl = $this->_generateAlphaToken();
                $joins[] =
                    'JOIN(' .
                        'SELECT id, val AS ' . $prop . ' ' .
                        'FROM ' . $this->_name . '__index ' .
                        'WHERE prop = \'' . $prop . '\'' .
                    ') AS ' . $asTbl . ' ' .
                    'ON A.id = ' . $asTbl . '.id';
            }
        }

        $select = Statement::get(
            'GET_OBJECTS_BY_FILTER',
            [
                '@collection' => $this->_name,
                '@columns' => (count($props) > 0) ? ', ' . implode($props, ', ') : '',
                '@joinColumns' => (count($joins) > 0) ? implode($joins, ' ') . ' ' : '',
                '@type' => $this->_connector->quote($filterQuery->getIndexType()),
                '@filters' => ($filters) ? 'AND (' . implode($filters, ' ') . ') ' : '',
                '@order' => $filterQuery->getOrderBy(),
                '@reverse' => ($filterQuery->getReverse()) ? 'DESC' : 'ASC',
                '@limit' => $filterQuery->getLength(),
                '@offset' => $filterQuery->getOffset()
            ]
        );

        $result = $this->_connector->query($select);
        if ($result) {
            $records = $result->fetchAll();
        }
        return ($records) ? array_map([$this, '_mapObjectIds'], $records) : [];
    }
927508
protected function getFilteredPermissions()
    {
        $permissions = BackendAuth::listTabbedPermissions();

        if ($this->user->isSuperUser()) {
            return $permissions;
        }

        foreach ($permissions as $tab => $permissionsArray) {
            foreach ($permissionsArray as $index => $permission) {
                if (!$this->user->hasAccess($permission->code)) {
                    unset($permissionsArray[$index]);
                }
            }

            if (empty($permissionsArray)) {
                unset($permissions[$tab]);
            }
            else {
                $permissions[$tab] = $permissionsArray;
            }
        }

        return $permissions;
    }
101183
public function all($filters = array())
	{
		// load all session keys
		$result   = $this->database->scan(0, array('MATCH' => $this->prefix . '*'));
		$cursor   = $result[0];
		$sessions = $result[1];

		// var to hold distinct sessions
		$distinct = array();

		// loop through all session keys and get data
		foreach ($sessions as $k => $v)
		{
			// get session data for key
			$sessions[$k] = $this->database->hgetall($v);
			$userid       = $sessions[$k]->userid;
			$guest        = $sessions[$k]->guest;
			$client       = $sessions[$k]->client_id;

			// guest filter
			if (isset($filters['guest']) && $filters['guest'] != $guest)
			{
				unset($sessions[$k]);
				continue;
			}

			// client filter
			if (isset($filters['client']))
			{
				// make sure is array
				if (!is_array($filters['client']))
				{
					$filters['client'] = array($filters['client']);
				}
				// check to make sure client is in what we want
				if (!in_array($client, $filters['client']))
				{
					unset($sessions[$k]);
					continue;
				}
			}

			// distinct filter
			if (isset($filters['distinct']) && $filters['distinct'] == 1)
			{
				if (isset($distinct[$client]) && in_array($userid, array_keys($distinct[$client])))
				{
					$key         = $distinct[$client][$userid]->key;
					$beforeTime  = $distinct[$client][$userid]->time;
					$currentTime = $sessions[$k]->time;

					// is this sessions time greater then the 
					// previous one saved for this user for this client?
					if ($currentTime < $beforeTime)
					{
						$key = $k;
					}

					unset($sessions[$key]);
					continue;
				}
				else
				{
					$sessions[$k]->key = $k;
					$distinct[$client][$userid] = $sessions[$k];
				}
			}
		}

		// return array of session objects
		return array_values(array_filter($sessions));
	}