return the query restriction for active filter. returns false if there
is no active restriction for this item.

@return string
550209
public function GetQueryRestrictionForActiveFilter()
    {
        $sQuery = $this->GetFromInternalCache('sQueryRestrictionForActiveFilter');
        if (is_null($sQuery)) {
            $aValues = $this->aActiveFilterData;
            if (is_array($aValues) && count($aValues) > 0) {
                $aValues = TTools::MysqlRealEscapeArray($aValues);
                $sItemListQuery = 'SELECT * FROM `'.MySqlLegacySupport::getInstance()->real_escape_string($this->sItemTableName).'` WHERE '.$this->GetTargetTableNameField()." IN ('".implode("','", $aValues)."')";
                $tRes = MySqlLegacySupport::getInstance()->query($sItemListQuery);
                $aIdList = array();
                while ($aItemRow = MySqlLegacySupport::getInstance()->fetch_assoc($tRes)) {
                    $aIdList[] = MySqlLegacySupport::getInstance()->real_escape_string($aItemRow['id']);
                }

                if (count($aIdList) > 0) {
                    $sQuery = '`shop_article`.`'.MySqlLegacySupport::getInstance()->real_escape_string($this->sItemFieldName)."` IN ('".implode("','", $aIdList)."')";
                }
            }
            $this->SetInternalCache('sQueryRestrictionForActiveFilter', $sQuery);
        }

        return $sQuery;
    }
572924
public function query()
    {
        $query = app()->make(RulesRepositoryContract::class)->datatable([
            'tbl_ban_management_rules.id',
            'tbl_ban_management_rules.user_id',
            'tbl_ban_management_rules.internal_reason',
            'tbl_ban_management_rules.value',
            'tbl_ban_management_rules.enabled',
            'tbl_ban_management_rules.trusted',
            'tbl_ban_management_rules.created_at',
            'tbl_ban_management_rules.expired_at'
        ]);

        if (request()->ajax()) {
            $columns = request()->get('columns', []);
            $all     = array_where($columns, function($item, $index) {
                return array_get($item, 'data') === 'status' AND array_get($item, 'search.value') === 'all';
            });

            if (!empty($all)) {
                $query->whereIn('tbl_ban_management_rules.status', [0, 1]);
            }
        }

        if (($where = $this->getDefaultWhere($query)) !== false) {
            $query->where($where);
        }

        return $query;
    }
841031
public function getFilters()
    {
        $input = $this->collection->make(
            $this->request->except($this->sortName));

        $filters = $this->collection->make();

        $input->filter(function ($value) {
            if ($this->ignoreEmptyFilters && is_string($value) &&
                (string) $value == ''
            ) {
                return false;
            }

            return true;
        })->each(function ($value, $field) use ($filters) {
            $filter = new Filter();
            $filter->setField($field);
            $filter->setValue($value);
            $filters->push($filter);
        });

        return $filters;
    }
151383
public function GetQueryRestrictionForActiveFilter()
    {
        $sQuery = $this->GetFromInternalCache('sQueryRestrictionForActiveFilter');
        if (is_null($sQuery)) {
            $aValues = $this->aActiveFilterData;
            if (count($aValues) > 0) {
                $sItemListQuery = $this->GetSQLQueryForQueryRestrictionForActiveFilter();
                $aIdList = array();
                if (!empty($sItemListQuery)) {
                    $tRes = MySqlLegacySupport::getInstance()->query($sItemListQuery);
                    $aIdList = array();
                    while ($aItemRow = MySqlLegacySupport::getInstance()->fetch_assoc($tRes)) {
                        $aIdList[] = MySqlLegacySupport::getInstance()->real_escape_string($aItemRow['source_id']);
                    }
                }

                if (count($aIdList) > 0) {
                    $sQuery = "`shop_article`.`id` IN ('".implode("','", $aIdList)."')";
                }
            }
            $this->SetInternalCache('sQueryRestrictionForActiveFilter', $sQuery);
        }

        return $sQuery;
    }
809461
public function getFilter()
    {
        if (false === $this->filter) {
            return '';
        }
        if (is_array($this->filter)) {
            return Form::get()->select($this->dataProvider->filtersKey . '[' . $this->name . ']', $this->filter, null, array(), '');
        }
        
        if (is_string($this->filter) && (strlen($this->filter) > 10)){
            return $this->filter;
        }
        
        return Form::get()->input($this->dataProvider->filtersKey . '[' . $this->name . ']');
    }
804888
public function GetSearchRestrictionLink()
    {
        // get current search... then add filter
        $oShop = $this->getShopService()->getActiveShop();
        $oSearchCache = &$oShop->GetActiveSearchObject();
        //$oSearchCache->aFilter[TdbShopCategory::FILTER_KEY_NAME] = $this->id;
        return $oSearchCache->GetSearchLink(array(TdbShopCategory::FILTER_KEY_NAME => $this->id));
    }
324057
private function getQueryFilter()
    {
        $query = null;

        $this->category->setIsActive(true);

        if ($this->category->getIsVirtualCategory() || $this->category->getId()) {
            $query = $this->category->getVirtualRule()->getCategorySearchQuery($this->category);
        }

        if ((bool) $this->category->getIsVirtualCategory() === false) {
            $queryParams = [];

            if ($query !== null) {
                $queryParams['should'][] = $query;
            }

            $idFilters = [
                'should'  => $this->category->getAddedProductIds(),
                'mustNot' => $this->category->getDeletedProductIds(),
            ];

            foreach ($idFilters as $clause => $productIds) {
                if ($productIds && !empty($productIds)) {
                    $queryParams[$clause][] = $this->getEntityIdFilterQuery($productIds);
                }
            }

            $query = $this->queryFactory->create(QueryInterface::TYPE_BOOL, $queryParams);
        }

        return $query;
    }
319688
protected function get_indexing_restrictions() {
        global $DB;

        // This includes completely empty configdata, and also three other values that are
        // equivalent to empty:
        // - A serialized completely empty object.
        // - A serialized object with one field called '0' (string not int) set to boolean false
        //   (this can happen after backup and restore, at least historically).
        // - A serialized null.
        $stupidobject = (object)[];
        $zero = '0';
        $stupidobject->{$zero} = false;
        return [$DB->sql_compare_text('bi.configdata') . " != ? AND " .
                $DB->sql_compare_text('bi.configdata') . " != ? AND " .
                $DB->sql_compare_text('bi.configdata') . " != ? AND " .
                $DB->sql_compare_text('bi.configdata') . " != ?",
                ['', base64_encode(serialize((object)[])), base64_encode(serialize($stupidobject)),
                base64_encode(serialize(null))]];
    }
227327
public function get_filters() {
        $filterkeys = [
            ASSIGN_FILTER_SUBMITTED,
            ASSIGN_FILTER_NOT_SUBMITTED,
            ASSIGN_FILTER_REQUIRE_GRADING,
            ASSIGN_FILTER_GRANTED_EXTENSION
        ];

        $current = get_user_preferences('assign_filter', '');

        $filters = [];
        // First is always "no filter" option.
        array_push($filters, [
            'key' => 'none',
            'name' => get_string('filternone', 'assign'),
            'active' => ($current == '')
        ]);

        foreach ($filterkeys as $key) {
            array_push($filters, [
                'key' => $key,
                'name' => get_string('filter' . $key, 'assign'),
                'active' => ($current == $key)
            ]);
        }
        return $filters;
    }
1019987
public function sql()
    {
        if ($this->active()) {
            if ($this->hasFilters()) {
                $sql = $this->byFilters();
                if ($this->isNegating()) {
                    return $this->operator().' '.$sql;
                }
                return $sql;
            }

            if ($this->hasCondition()) {
                $sql = $this->byCondition();
                if ($this->isNegating()) {
                    return $this->operator().' ('.$sql.')';
                }
                return $sql;
            }

            if ($this->hasFields()) {
                return $this->byPredicate();
            }
        }

        return '';
    }
838571
public function isFilterable()
    {
        $hasFilters = false;

        foreach ($this->columns as $column) {
            if ($column->isFilterable()) {
                $hasFilters = true;
                break;
            }
        }

        return $hasFilters;
    }
444735
protected function getAllowedActions()
    {
        $allowed = $this->getAssignedActions()->filter(function (Action $action) {
            return $action->pivot->provision === 'pass';
        })->pluck('slug')->all();

        return $allowed;
    }
791318
public function GetQueryRestrictionForActiveFilter()
    {
        $sQuery = '';
        $sValue = $this->GetActiveValue();
        if ('1' == $sValue) {
            $sQuery = '`shop_article_stock`.`'.MySqlLegacySupport::getInstance()->real_escape_string($this->sItemFieldName).'` > 0';
        }

        return $sQuery;
    }
506391
protected function checkRequestFilters()
	{
		$filterName = Yii::app()->getRequest()->getParam($this->saveFilterVar);
		if (!$filterName)
			return false;

		if (!count($this->filteredBy))
			return false;

		$key = $this->generateRegistryItemKey();
		if ($this->jsonStorage->getData($key, $this->registry))
			return false;

		$data = array('name' => $filterName);
		$data['options'] = array(get_class($this->model) => $this->filteredBy);
		$this->jsonStorage->setData($key, $data, $this->registry);

		Yii::app()->getController()->redirect($this->redirectRoute);
		return true;
	}
297432
public function findOne()
    {
        $finder = $this->dataMapper->findOne();

        foreach ($this->restrictions as $filter) {
            $finder = $finder->with($filter['field'], $filter['op'], $filter['value']);
        }

        return $finder;
    }
889676
protected function filter()
    {
        $filter = null;

        if (   (!$filter = $this->is("classFilter"))
            && (!$filter = $this->is("idFilter"))
            && (!$filter = $this->is("attrFilter"))
            && (!$filter = $this->is("pseudoFilter"))
        ) {
            return false;
        }
        return $filter;
    }
1097567
public function getQuery() {
        $query = 'SELECT '.implode(', ', $this->fields)
                .' FROM '.implode(', ', $this->from);
        if (count($this->conditions) > 0) {
            $query = $query.' WHERE '.implode(' AND ', $this->conditions);
        }
        $query = rtrim($query).';';

        return $query;
    }