QGIS API Documentation 3.99.0-Master (752b475928d)
Loading...
Searching...
No Matches
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
21#include "qgis_server.h"
22#include "qgis_sip.h"
25
26SIP_IF_MODULE( HAVE_SERVER_PYTHON_PLUGINS )
27
28
29
34class SERVER_EXPORT QgsAccessControl : public QgsFeatureFilterProvider
35{
36#ifdef SIP_RUN
38#endif
39
40 public:
43 {
44 mPluginsAccessControls = new QgsAccessControlFilterMap();
45 mResolved = false;
46 }
47
49 {
50 mPluginsAccessControls = new QgsAccessControlFilterMap( *copy.mPluginsAccessControls );
51 mFilterFeaturesExpressions = copy.mFilterFeaturesExpressions;
52 mResolved = copy.mResolved;
53 }
54
55
57 {
58 delete mPluginsAccessControls;
59 }
60
62 {
63 if ( this != &other )
64 {
65 delete mPluginsAccessControls;
66 mPluginsAccessControls = new QgsAccessControlFilterMap( *other.mPluginsAccessControls );
67 mFilterFeaturesExpressions = other.mFilterFeaturesExpressions;
68 mResolved = other.mResolved;
69 }
70 return *this;
71 }
72
73 bool isFilterThreadSafe() const override { return false; }
74
76 void filterFeatures( const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures ) const override;
77 QStringList layerAttributes( const QgsVectorLayer *layer, const QStringList &attributes ) const override;
78 QgsAccessControl *clone() const override SIP_FACTORY;
79
89 void resolveFilterFeatures( const QList<QgsMapLayer *> &layers );
90
94 void unresolveFilterFeatures();
95
101 QString extraSubsetString( const QgsVectorLayer *layer ) const;
102
108 bool layerReadPermission( const QgsMapLayer *layer ) const;
109
115 bool layerInsertPermission( const QgsVectorLayer *layer ) const;
116
122 bool layerUpdatePermission( const QgsVectorLayer *layer ) const;
123
129 bool layerDeletePermission( const QgsVectorLayer *layer ) const;
130
137 bool allowToEdit( const QgsVectorLayer *layer, const QgsFeature &feature ) const;
138
143 bool fillCacheKey( QStringList &cacheKey ) const;
144
150 void registerAccessControl( QgsAccessControlFilter *accessControl, int priority = 0 );
151
152 private:
153 QString resolveFilterFeatures( const QgsVectorLayer *layer ) const;
154
156 QgsAccessControlFilterMap *mPluginsAccessControls = nullptr;
157
158 QMap<QString, QString> mFilterFeaturesExpressions;
159 bool mResolved;
160};
161
162#endif
Defines 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)
bool isFilterThreadSafe() const override
Returns true if the filterFeature function is thread safe, which will lead to reliance on layer ID in...
QgsAccessControl & operator=(const QgsAccessControl &other)
virtual Q_DECL_DEPRECATED void filterFeatures(const QgsVectorLayer *layer, QgsFeatureRequest &featureRequest) const
Add additional filters to the feature request to further restrict the features returned by the reques...
QgsFeatureFilterProvider()=default
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:58
Base class for all map layer types.
Definition qgsmaplayer.h:80
Represents a vector layer which manages a vector based dataset.
#define SIP_IF_MODULE(condition)
Definition qgis_sip.h:28
#define SIP_FACTORY
Definition qgis_sip.h:84
QMultiMap< int, QgsAccessControlFilter * > QgsAccessControlFilterMap
The registry definition.