QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 
22 #include "qgsaccesscontrolfilter.h"
23 
24 #include <QMultiMap>
25 #include "qgis_server.h"
26 #include "qgis_sip.h"
27 
28 SIP_IF_MODULE( HAVE_SERVER_PYTHON_PLUGINS )
29 
30 class QgsAccessControlPlugin;
31 
32 
39 class SERVER_EXPORT QgsAccessControl : public QgsFeatureFilterProvider
40 {
41 #ifdef SIP_RUN
42 #include "qgsaccesscontrolfilter.h"
43 #endif
44 
45  public:
48  {
49  mPluginsAccessControls = new QgsAccessControlFilterMap();
50  mResolved = false;
51  }
52 
55  {
56  mPluginsAccessControls = new QgsAccessControlFilterMap( *copy.mPluginsAccessControls );
57  mFilterFeaturesExpressions = copy.mFilterFeaturesExpressions;
58  mResolved = copy.mResolved;
59  }
60 
61 
62  ~QgsAccessControl() override
63  {
64  delete mPluginsAccessControls;
65  }
66 
71  void resolveFilterFeatures( const QList<QgsMapLayer *> &layers );
72 
78  void filterFeatures( const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures ) const override;
79 
84  QgsFeatureFilterProvider *clone() const override SIP_FACTORY;
85 
91  QString extraSubsetString( const QgsVectorLayer *layer ) const;
92 
98  bool layerReadPermission( const QgsMapLayer *layer ) const;
99 
105  bool layerInsertPermission( const QgsVectorLayer *layer ) const;
106 
112  bool layerUpdatePermission( const QgsVectorLayer *layer ) const;
113 
119  bool layerDeletePermission( const QgsVectorLayer *layer ) const;
120 
127  QStringList layerAttributes( const QgsVectorLayer *layer, const QStringList &attributes ) const;
128 
135  bool allowToEdit( const QgsVectorLayer *layer, const QgsFeature &feature ) const;
136 
142  bool fillCacheKey( QStringList &cacheKey ) const;
143 
149  void registerAccessControl( QgsAccessControlFilter *accessControl, int priority = 0 );
150 
151  private:
152  QString resolveFilterFeatures( const QgsVectorLayer *layer ) const;
153 
155  QgsAccessControlFilterMap *mPluginsAccessControls = nullptr;
156 
157  QMap<QString, QString> mFilterFeaturesExpressions;
158  bool mResolved;
159 };
160 
161 #endif
Base class for all map layer types.
Definition: qgsmaplayer.h:63
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
#define SIP_IF_MODULE(condition)
Definition: qgis_sip.h:28
Class defining access control interface for QGIS Server plugins.
~QgsAccessControl() override
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Abstract interface for use by classes that filter the features of a layer.
#define SIP_FACTORY
Definition: qgis_sip.h:69
QgsAccessControl(const QgsAccessControl &copy)
Constructor.
QMultiMap< int, QgsAccessControlFilter * > QgsAccessControlFilterMap
The registry definition.
QgsAccessControl()
Constructor.
A helper class that centralizes restrictions given by all the access control filter plugins...
Represents a vector layer which manages a vector based data sets.