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();
73 if ( mResolved && mFilterFeaturesExpressions.contains( layer->
id() ) )
75 expression = mFilterFeaturesExpressions[layer->
id()];
82 if ( !expression.isEmpty() )
98 QgsAccessControlFilterMap::const_iterator acIterator;
99 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
101 const QString sql = acIterator.value()->layerFilterSubsetString( layer );
102 if ( !sql.isEmpty() )
107 return sqls.isEmpty() ? QString() : QStringLiteral(
"((" ).append( sqls.join( QLatin1String(
") AND (" ) ) ).append(
"))" );
113 QgsAccessControlFilterMap::const_iterator acIterator;
114 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
116 if ( !acIterator.value()->layerPermissions( layer ).canRead )
127 QgsAccessControlFilterMap::const_iterator acIterator;
128 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
130 if ( !acIterator.value()->layerPermissions( layer ).canInsert )
141 QgsAccessControlFilterMap::const_iterator acIterator;
142 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
144 if ( !acIterator.value()->layerPermissions( layer ).canUpdate )
155 QgsAccessControlFilterMap::const_iterator acIterator;
156 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
158 if ( !acIterator.value()->layerPermissions( layer ).canDelete )
169 QStringList currentAttributes( attributes );
170 QgsAccessControlFilterMap::const_iterator acIterator;
171 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
173 currentAttributes = acIterator.value()->authorizedLayerAttributes( layer, currentAttributes );
175 return currentAttributes;
181 QgsAccessControlFilterMap::const_iterator acIterator;
182 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
184 if ( !acIterator.value()->allowToEdit( layer, feature ) )
195 QgsAccessControlFilterMap::const_iterator acIterator;
196 for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
198 const QString newKey = acIterator.value()->cacheKey();
199 if ( !newKey.isEmpty() )
211 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.
Represents a vector layer which manages a vector based data sets.