QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 "qgis_server.h"
25 #include "qgis_sip.h"
26 
27 SIP_IF_MODULE( HAVE_SERVER_PYTHON_PLUGINS )
28 
29 
30 
36 class SERVER_EXPORT QgsAccessControl : public QgsFeatureFilterProvider
37 {
38 #ifdef SIP_RUN
39 #include "qgsaccesscontrolfilter.h"
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 
59  ~QgsAccessControl() override
60  {
61  delete mPluginsAccessControls;
62  }
63 
68  void resolveFilterFeatures( const QList<QgsMapLayer *> &layers );
69 
75  void filterFeatures( const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures ) const override;
76 
81  QgsFeatureFilterProvider *clone() const override SIP_FACTORY;
82 
88  QString extraSubsetString( const QgsVectorLayer *layer ) const;
89 
95  bool layerReadPermission( const QgsMapLayer *layer ) const;
96 
102  bool layerInsertPermission( const QgsVectorLayer *layer ) const;
103 
109  bool layerUpdatePermission( const QgsVectorLayer *layer ) const;
110 
116  bool layerDeletePermission( const QgsVectorLayer *layer ) const;
117 
124  QStringList layerAttributes( const QgsVectorLayer *layer, const QStringList &attributes ) const;
125 
132  bool allowToEdit( const QgsVectorLayer *layer, const QgsFeature &feature ) const;
133 
139  bool fillCacheKey( QStringList &cacheKey ) const;
140 
146  void registerAccessControl( QgsAccessControlFilter *accessControl, int priority = 0 );
147 
148  private:
149  QString resolveFilterFeatures( const QgsVectorLayer *layer ) const;
150 
152  QgsAccessControlFilterMap *mPluginsAccessControls = nullptr;
153 
154  QMap<QString, QString> mFilterFeaturesExpressions;
155  bool mResolved;
156 };
157 
158 #endif
Base class for all map layer types.
Definition: qgsmaplayer.h:78
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.