40 QStringList expressions = QStringList();
41 QgsAccessControlFilterMap::const_iterator acIterator;
43 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
45 const QString expression = acIterator.value()->layerFilterExpression( layer );
46 if ( !expression.isEmpty() )
48 expressions.append( expression );
53 if ( !expressions.isEmpty() )
55 expression = QStringLiteral(
"((" ).append( expressions.join( QLatin1String(
") AND (" ) ) ).append(
"))" );
64 mFilterFeaturesExpressions.clear();
74 if ( mResolved && mFilterFeaturesExpressions.contains( layer->
id() ) )
76 expression = mFilterFeaturesExpressions[layer->
id()];
83 if ( !expression.isEmpty() )
99 QgsAccessControlFilterMap::const_iterator acIterator;
100 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
102 const QString sql = acIterator.value()->layerFilterSubsetString( layer );
103 if ( !sql.isEmpty() )
108 return sqls.isEmpty() ? QString() : QStringLiteral(
"((" ).append( sqls.join( QLatin1String(
") AND (" ) ) ).append(
"))" );
114 QgsAccessControlFilterMap::const_iterator acIterator;
115 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
117 if ( !acIterator.value()->layerPermissions( layer ).canRead )
128 QgsAccessControlFilterMap::const_iterator acIterator;
129 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
131 if ( !acIterator.value()->layerPermissions( layer ).canInsert )
142 QgsAccessControlFilterMap::const_iterator acIterator;
143 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
145 if ( !acIterator.value()->layerPermissions( layer ).canUpdate )
156 QgsAccessControlFilterMap::const_iterator acIterator;
157 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
159 if ( !acIterator.value()->layerPermissions( layer ).canDelete )
170 QStringList currentAttributes( attributes );
171 QgsAccessControlFilterMap::const_iterator acIterator;
172 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
174 currentAttributes = acIterator.value()->authorizedLayerAttributes( layer, currentAttributes );
176 return currentAttributes;
182 QgsAccessControlFilterMap::const_iterator acIterator;
183 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
185 if ( !acIterator.value()->allowToEdit( layer, feature ) )
196 QgsAccessControlFilterMap::const_iterator acIterator;
197 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
199 const QString newKey = acIterator.value()->cacheKey();
200 if ( ! newKey.isEmpty() )
212 mPluginsAccessControls->insert( priority, accessControl );
Class defining access control interface for QGIS Server plugins.
QStringList layerAttributes(const QgsVectorLayer *layer, const QStringList &attributes) const override
Returns the authorized layer attributes.
bool layerUpdatePermission(const QgsVectorLayer *layer) const
Returns the layer update right.
void filterFeatures(const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures) const override
Filter the features of the layer.
bool layerInsertPermission(const QgsVectorLayer *layer) const
Returns the layer insert right.
bool layerReadPermission(const QgsMapLayer *layer) const
Returns the layer read right.
bool fillCacheKey(QStringList &cacheKey) const
Fill the capabilities caching key.
bool allowToEdit(const QgsVectorLayer *layer, const QgsFeature &feature) const
Are we authorized to modify the following geometry.
QgsFeatureFilterProvider * clone() const override
Returns a clone of the object.
bool layerDeletePermission(const QgsVectorLayer *layer) const
Returns the layer delete right.
void resolveFilterFeatures(const QList< QgsMapLayer * > &layers)
Resolve features' filter of layers The method fetch filter's expressions returned from access control...
void registerAccessControl(QgsAccessControlFilter *accessControl, int priority=0)
Register an access control filter.
void unresolveFilterFeatures()
Clear expression's cache computed from resolveFilterFeatures
QgsAccessControl()
Constructor.
QString extraSubsetString(const QgsVectorLayer *layer) const
Returns an additional subset string (typically SQL) filter.
Abstract interface for use by classes that filter the features or attributes of a layer.
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & combineFilterExpression(const QString &expression)
Modifies the existing filter expression to add an additional expression filter.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Base class for all map layer types.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
Represents a vector layer which manages a vector based data sets.
@ VectorLayer
Vector layer.