Lizmap Web Client 3.11.0

filterDatasource
in package

Manage and give access to lizmap configuration.

Tags
author

3liz

copyright

2017 3liz

see
http://3liz.com
license

Mozilla Public License : http://www.mozilla.org/MPL/

Table of Contents

Properties

$provider  : mixed
$cnx  : mixed
$config  : mixed
$data  : mixed
$datasource  : mixed
$errors  : mixed
$layer  : mixed
$layerId  : mixed
$layername  : mixed
$lproj  : mixed
$project  : mixed
$repository  : mixed
$restrictionSql  : null|string
$status  : mixed

Methods

__construct()  : mixed
Create the datasource of a layer used by the filter tools.
getErrors()  : mixed
getExtent()  : mixed
getFeatureCount()  : mixed
getMinAndMaxValues()  : mixed
getStatus()  : mixed
getUniqueValues()  : mixed
getData()  : array<string|int, mixed>|jDbResultSet
return data as jDbResultSet or errors as array.
checkFilterColumns()  : bool
Check that the columns referenced by the SQL filter can be queried by the filter tools.
checkFilterFields()  : bool
Check that the requested fields can be queried by the filter tools.
getFilterFieldNames()  : array<string|int, string>
Get the names of the layer fields which can be queried by the filter tools.
getFilterLayerIds()  : array<string|int, string>
Get the ids of the layers which can be queried by the filter tools.
getRestrictionSql()  : string
Get the SQL conditions restricting the layer data.
sqliteFunctionExists()  : bool
Check whether a SQL function is available on the SQLite/SpatiaLite connection.
validateFilter()  : false|string
Validate the SQL filter.

Properties

$restrictionSql

private null|string $restrictionSql

the SQL conditions restricting the layer data, null if not computed yet

Methods

__construct()

Create the datasource of a layer used by the filter tools.

public __construct(string $repository, string $project, string $layerId) : mixed

The status is false, with errors, if the project is not accessible, or if the layer is not a vector layer used by the form filter or the time manager.

Parameters
$repository : string

the repository key

$project : string

the project key

$layerId : string

the layer id

getExtent()

public getExtent(mixed $crs[, mixed $filter = null ]) : mixed
Parameters
$crs : mixed
$filter : mixed = null

getFeatureCount()

public getFeatureCount([mixed $filter = null ]) : mixed
Parameters
$filter : mixed = null

getMinAndMaxValues()

public getMinAndMaxValues(mixed $fieldname[, mixed $filter = null ]) : mixed
Parameters
$fieldname : mixed
$filter : mixed = null

getUniqueValues()

public getUniqueValues(mixed $fieldname[, mixed $filter = null ]) : mixed
Parameters
$fieldname : mixed
$filter : mixed = null

getData()

return data as jDbResultSet or errors as array.

protected getData(mixed $sql) : array<string|int, mixed>|jDbResultSet
Parameters
$sql : mixed
Return values
array<string|int, mixed>|jDbResultSet

checkFilterColumns()

Check that the columns referenced by the SQL filter can be queried by the filter tools.

private checkFilterColumns(string $filter) : bool

Without this check, a filter on any column, e.g. a hidden one, could be used to guess its values by counting the features. PostgreSQL compares the column names case-sensitively, SQLite does not.

Parameters
$filter : string

the validated SQL filter

Return values
bool —

true if all the referenced columns can be queried

checkFilterFields()

Check that the requested fields can be queried by the filter tools.

private checkFilterFields(array<string|int, string> $fields) : bool

The errors are set if a field is not used by the filter tools, to avoid exposing the values of other fields.

Parameters
$fields : array<string|int, string>

the requested field names

Return values
bool —

true if all the fields can be queried

getFilterFieldNames()

Get the names of the layer fields which can be queried by the filter tools.

private getFilterFieldNames() : array<string|int, string>

These are the fields of the form filter configuration of the layer, the date fields of the time manager configuration of the layer, and the primary key fields, used by the form filter to get the ids of the filtered features.

Return values
array<string|int, string> —

the field names

getFilterLayerIds()

Get the ids of the layers which can be queried by the filter tools.

private getFilterLayerIds() : array<string|int, string>

These are the layers of the form filter configuration, and the layers of the time manager, which uses the filter service to get the min and max values of its date fields.

Return values
array<string|int, string> —

the layer ids

getRestrictionSql()

Get the SQL conditions restricting the layer data.

private getRestrictionSql() : string

The data returned by the filter service must be the same as the data the user can get with WFS: the datasource SQL filter is applied, and, unless the user can override them, the filter by login and the filter by polygon configured in the Lizmap plugin.

The filter by polygon is computed by the Lizmap plugin of QGIS Server. If the request fails, the plugin helper returns a filter returning no data, so that no feature is exposed.

Return values
string —

the SQL conditions, each one starting with " AND ", or an empty string if the data is not restricted

sqliteFunctionExists()

Check whether a SQL function is available on the SQLite/SpatiaLite connection.

private sqliteFunctionExists(string $functionName) : bool
Parameters
$functionName : string

the function name to look up (case-insensitive)

Return values
bool —

true if available, or if availability cannot be determined

validateFilter()

Validate the SQL filter.

private validateFilter(string $filter) : false|string

If it is not valid, we return 1>2 to force the return of empty data. If it references a column not used by the filter tools, the errors are set.

Parameters
$filter : string

The SQL filter

Return values
false|string —

The processed filter, or false if a column is not allowed

On this page

Search results