23 #include <QStringList> 29 if ( l->type() == QgsMapLayer::LayerType::VectorLayer )
41 QStringList expressions = QStringList();
42 QgsAccessControlFilterMap::const_iterator acIterator;
44 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
46 QString expression = acIterator.value()->layerFilterExpression( layer );
47 if ( !expression.isEmpty() )
49 expressions.append( expression );
54 if ( !expressions.isEmpty() )
56 expression = QStringLiteral(
"((" ).append( expressions.join( QStringLiteral(
") AND (" ) ) ).append(
"))" );
68 if ( mResolved && mFilterFeaturesExpressions.keys().contains( layer->
id() ) )
70 expression = mFilterFeaturesExpressions[layer->
id()];
77 if ( !expression.isEmpty() )
93 QgsAccessControlFilterMap::const_iterator acIterator;
94 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
96 QString sql = acIterator.value()->layerFilterSubsetString( layer );
102 return sqls.isEmpty() ? QString() : QStringLiteral(
"((" ).append( sqls.join( QStringLiteral(
") AND (" ) ) ).append(
"))" );
108 QgsAccessControlFilterMap::const_iterator acIterator;
109 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
111 if ( !acIterator.value()->layerPermissions( layer ).canRead )
122 QgsAccessControlFilterMap::const_iterator acIterator;
123 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
125 if ( !acIterator.value()->layerPermissions( layer ).canInsert )
136 QgsAccessControlFilterMap::const_iterator acIterator;
137 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
139 if ( !acIterator.value()->layerPermissions( layer ).canUpdate )
150 QgsAccessControlFilterMap::const_iterator acIterator;
151 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
153 if ( !acIterator.value()->layerPermissions( layer ).canDelete )
164 QStringList currentAttributes( attributes );
165 QgsAccessControlFilterMap::const_iterator acIterator;
166 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
168 currentAttributes = acIterator.value()->authorizedLayerAttributes( layer, currentAttributes );
170 return currentAttributes;
176 QgsAccessControlFilterMap::const_iterator acIterator;
177 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
179 if ( !acIterator.value()->allowToEdit( layer, feature ) )
190 QgsAccessControlFilterMap::const_iterator acIterator;
191 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
193 QString newKey = acIterator.value()->cacheKey();
194 if ( newKey.length() == 0 )
207 mPluginsAccessControls->insert( priority, accessControl );
bool fillCacheKey(QStringList &cacheKey) const
Fill the capabilities caching key.
bool layerInsertPermission(const QgsVectorLayer *layer) const
Returns the layer insert right.
Base class for all map layer types.
bool layerUpdatePermission(const QgsVectorLayer *layer) const
Returns the layer update right.
void resolveFilterFeatures(const QList< QgsMapLayer * > &layers)
Resolve features' filter of layers.
QString extraSubsetString(const QgsVectorLayer *layer) const
Returns an additional subset string (typically SQL) filter.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Class defining access control interface for QGIS Server plugins.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
Abstract interface for use by classes that filter the features of a layer.
QgsFeatureFilterProvider * clone() const override
Returns a clone of the object.
bool allowToEdit(const QgsVectorLayer *layer, const QgsFeature &feature) const
Are we authorized to modify the following geometry.
QgsAccessControl()
Constructor.
QStringList layerAttributes(const QgsVectorLayer *layer, const QStringList &attributes) const
Returns the authorized layer attributes.
void filterFeatures(const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures) const override
Filter the features of the layer.
void registerAccessControl(QgsAccessControlFilter *accessControl, int priority=0)
Register an access control filter.
bool layerDeletePermission(const QgsVectorLayer *layer) const
Returns the layer delete right.
Represents a vector layer which manages a vector based data sets.
bool layerReadPermission(const QgsMapLayer *layer) const
Returns the layer read right.