QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsaccesscontrol.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsaccesscontrol.h
3 ------------------
4 begin : 22-05-2015
5 copyright : (C) 2008 by Stéphane Brunner
6 email : stephane dot brunner at camptocamp dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSACCESSCONTROL_H
19#define QGSACCESSCONTROL_H
20
23
24#include "qgis_server.h"
25#include "qgis_sip.h"
26
27SIP_IF_MODULE( HAVE_SERVER_PYTHON_PLUGINS )
28
29
30
36class SERVER_EXPORT QgsAccessControl : public QgsFeatureFilterProvider
37{
38#ifdef SIP_RUN
40#endif
41
42 public:
45 {
46 mPluginsAccessControls = new QgsAccessControlFilterMap();
47 mResolved = false;
48 }
49
52 {
53 mPluginsAccessControls = new QgsAccessControlFilterMap( *copy.mPluginsAccessControls );
54 mFilterFeaturesExpressions = copy.mFilterFeaturesExpressions;
55 mResolved = copy.mResolved;
56 }
57
58
60 {
61 delete mPluginsAccessControls;
62 }
63
65 QgsAccessControl &operator= ( const QgsAccessControl &other )
66 {
67 if ( this != &other )
68 {
69 delete mPluginsAccessControls;
70 mPluginsAccessControls = new QgsAccessControlFilterMap( *other.mPluginsAccessControls );
71 mFilterFeaturesExpressions = other.mFilterFeaturesExpressions;
72 mResolved = other.mResolved;
73 }
74 return *this;
75 }
76
86 void resolveFilterFeatures( const QList<QgsMapLayer *> &layers );
87
91 void unresolveFilterFeatures();
92
98 void filterFeatures( const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures ) const override;
99
104 QgsFeatureFilterProvider *clone() const override SIP_FACTORY;
105
111 QString extraSubsetString( const QgsVectorLayer *layer ) const;
112
118 bool layerReadPermission( const QgsMapLayer *layer ) const;
119
125 bool layerInsertPermission( const QgsVectorLayer *layer ) const;
126
132 bool layerUpdatePermission( const QgsVectorLayer *layer ) const;
133
139 bool layerDeletePermission( const QgsVectorLayer *layer ) const;
140
147 QStringList layerAttributes( const QgsVectorLayer *layer, const QStringList &attributes ) const override;
148
155 bool allowToEdit( const QgsVectorLayer *layer, const QgsFeature &feature ) const;
156
161 bool fillCacheKey( QStringList &cacheKey ) const;
162
168 void registerAccessControl( QgsAccessControlFilter *accessControl, int priority = 0 );
169
170 private:
171 QString resolveFilterFeatures( const QgsVectorLayer *layer ) const;
172
174 QgsAccessControlFilterMap *mPluginsAccessControls = nullptr;
175
176 QMap<QString, QString> mFilterFeaturesExpressions;
177 bool mResolved;
178
179};
180
181#endif
Class defining access control interface for QGIS Server plugins.
A helper class that centralizes restrictions given by all the access control filter plugins.
~QgsAccessControl() override
QgsAccessControl()
Constructor.
QgsAccessControl(const QgsAccessControl &copy)
Constructor.
Abstract interface for use by classes that filter the features or attributes of a layer.
This class wraps a request for features to a vector layer (or directly its vector data provider).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
Base class for all map layer types.
Definition: qgsmaplayer.h:73
Represents a vector layer which manages a vector based data sets.
#define SIP_IF_MODULE(condition)
Definition: qgis_sip.h:28
#define SIP_FACTORY
Definition: qgis_sip.h:76
QMultiMap< int, QgsAccessControlFilter * > QgsAccessControlFilterMap
The registry definition.