Filtered layer by user — Set some features visible/editable or not for some users

Princípio

The filtering feature presented allows you to filter the data displayed on the map based on the logged in user. It is possible to filter only vector layers because Lizmap uses a column in the attribute table.

Filtering currently uses the ID of the user group connected. It’s active for all requests to QGIS server, and thus concerns:

There are two kinds of filtering :

  • based on attributes

  • based on spatial relationship

Filtering by spatial relationship

Princípio

In this panel, we can:

  • configure a polygon layer to use for spatial filtering

  • configure layers which must be filtered by the filtering layer

../../_images/filter-polygon.gif

Pré-requisitos

The Lizmap plugin in QGIS Server must be installed with at least Lizmap QGIS plugin 3.6. Otherwise, the filter won’t work and all data will be visible. See Lizmap QGIS Server plugin.

Configuring the tool

../../_images/interface-filter-by-polygon.jpg
  1. Choose the polygon layer used for filtering

  2. Choose the field in this layer which has Lizmap groups, separated by a comma.

  3. Add a layer to filter to this tool:

    1. Click the add_layer_svg button.

    2. Choose the layer to filter

    3. Choose the primary key of the layer

    4. Choose if the filtering if for both visualisation and editing or only editing

    5. Choose either intersection or contain spatial relationship.

  • To edit a layer in the table, select it and click the edit_layer_svg button or double click on the row.

  • To remove a layer from the table, select it and click the remove_layer_svg button.

For your information, performance will be better when using PostgreSQL layers : either filtering or filtered layers or both.

Filtering by attribute

Exemplo

Está disponível um vídeo tutorial em: https://vimeo.com/83966790

Configuring the tool

Para utilizar a ferramenta de filtragem de dados no Lizmap Web Client, deve:

  • ter acesso à interface de administração do Lizmap Web Client

Aqui estão os passos detalhados para configurar este recurso:

Aviso

In Lizmap Web Client administration, in the repository properties, be sure that anonymous and other relevant groups are not checked for Always see complete layers data, even if filtered by login. See Definir as permissões de cada grupo.

  • Check group ID or user ID in the administration interface:

    • To know group ID, you must go to the administration interface SYSTEM ‣ Groups of users for rights: ID appears in parentheses after the name of each group (under the title Groups of new users)

    • Or to know the user ID, just use its login.

  • For all vector layers which is desired filter data, just add a text column that will hold the ID for each line who has the right to display this feature.

    • Fill this column for each line of the attribute table with the ID (using the calculator, for example).

    • It is possible to set all as the value in some lines to disable the filter: All users will see the data for these lines.

    • Se o valor nesta coluna para uma linha não corresponder a um grupo de utilizadores, os dados não serão apresentados para nenhum dos utilizadores.

../../_images/interface-add-filter-by-login.jpg
  • Add the layer in the table Filter Data by User panel:

    1. Click the add_layer_svg button.

    2. Select layer from the dropdown list

    3. Select the field with the ID

    4. Check the box if the field contains user ID, instead of group ID

  • To edit a layer in the table, select it and click the edit_layer_svg button or double click on the row.

  • To remove a layer from the table, select it and click the remove_layer_svg button.

Aviso

Disable the client cache and cache server for all filtered layers. Otherwise, the data displayed will not be updated between each connection or user logout!

Edition

If you have enabled the edition (see Editing — Edit a layer from the web interface) on the filtered layer, the field containing the ID will be editable with:

  • either a combobox for a non admin user with either his own login or all

  • or a line edit to write a value for a admin user