QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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
56 ~QgsAccessControl() override { delete mPluginsAccessControls; }
57
59 {
60 if ( this != &other )
61 {
62 delete mPluginsAccessControls;
63 mPluginsAccessControls = new QgsAccessControlFilterMap( *other.mPluginsAccessControls );
64 mFilterFeaturesExpressions = other.mFilterFeaturesExpressions;
65 mResolved = other.mResolved;
66 }
67 return *this;
68 }
69
70 bool isFilterThreadSafe() const override { return false; }
71
73 void filterFeatures( const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures ) const override;
74 QStringList layerAttributes( const QgsVectorLayer *layer, const QStringList &attributes ) const override;
75 QgsAccessControl *clone() const override SIP_FACTORY;
76
86 void resolveFilterFeatures( const QList<QgsMapLayer *> &layers );
87
91 void unresolveFilterFeatures();
92
98 QString extraSubsetString( const QgsVectorLayer *layer ) const;
99
105 bool layerReadPermission( const QgsMapLayer *layer ) const;
106
112 bool layerInsertPermission( const QgsVectorLayer *layer ) const;
113
119 bool layerUpdatePermission( const QgsVectorLayer *layer ) const;
120
126 bool layerDeletePermission( const QgsVectorLayer *layer ) const;
127
134 bool allowToEdit( const QgsVectorLayer *layer, const QgsFeature &feature ) const;
135
140 bool fillCacheKey( QStringList &cacheKey ) const;
141
147 void registerAccessControl( QgsAccessControlFilter *accessControl, int priority = 0 );
148
149 private:
150 QString resolveFilterFeatures( const QgsVectorLayer *layer ) const;
151
153 QgsAccessControlFilterMap *mPluginsAccessControls = nullptr;
154
155 QMap<QString, QString> mFilterFeaturesExpressions;
156 bool mResolved;
157};
158
159#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:60
Base class for all map layer types.
Definition qgsmaplayer.h:83
Represents a vector layer which manages a vector based dataset.
#define SIP_IF_MODULE(condition)
Definition qgis_sip.h:27
#define SIP_FACTORY
Definition qgis_sip.h:83
QMultiMap< int, QgsAccessControlFilter * > QgsAccessControlFilterMap
The registry definition.
const QString cacheKey(const QString &pathIn)