QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
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 
81  void resolveFilterFeatures( const QList<QgsMapLayer *> &layers );
82 
88  void filterFeatures( const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures ) const override;
89 
94  QgsFeatureFilterProvider *clone() const override SIP_FACTORY;
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  QStringList layerAttributes( const QgsVectorLayer *layer, const QStringList &attributes ) const override;
138 
145  bool allowToEdit( const QgsVectorLayer *layer, const QgsFeature &feature ) const;
146 
151  bool fillCacheKey( QStringList &cacheKey ) const;
152 
158  void registerAccessControl( QgsAccessControlFilter *accessControl, int priority = 0 );
159 
160  private:
161  QString resolveFilterFeatures( const QgsVectorLayer *layer ) const;
162 
164  QgsAccessControlFilterMap *mPluginsAccessControls = nullptr;
165 
166  QMap<QString, QString> mFilterFeaturesExpressions;
167  bool mResolved;
168 
169 };
170 
171 #endif
QgsAccessControl::QgsAccessControl
QgsAccessControl(const QgsAccessControl &copy)
Constructor.
Definition: qgsaccesscontrol.h:51
qgsaccesscontrolfilter.h
QgsAccessControlFilterMap
QMultiMap< int, QgsAccessControlFilter * > QgsAccessControlFilterMap
The registry definition.
Definition: qgsaccesscontrolfilter.h:127
qgsfeaturefilterprovider.h
QgsAccessControl::QgsAccessControl
QgsAccessControl()
Constructor.
Definition: qgsaccesscontrol.h:44
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsFeatureRequest
This class wraps a request for features to a vector layer (or directly its vector data provider).
Definition: qgsfeaturerequest.h:83
QgsAccessControlFilter
Class defining access control interface for QGIS Server plugins.
Definition: qgsaccesscontrolfilter.h:50
qgis_sip.h
QgsAccessControl
A helper class that centralizes restrictions given by all the access control filter plugins.
Definition: qgsaccesscontrol.h:36
SIP_IF_MODULE
#define SIP_IF_MODULE(condition)
Definition: qgis_sip.h:28
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
QgsFeatureFilterProvider
Abstract interface for use by classes that filter the features or attributes of a layer.
Definition: qgsfeaturefilterprovider.h:43
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
QgsAccessControl::~QgsAccessControl
~QgsAccessControl() override
Definition: qgsaccesscontrol.h:59