Hi.
I have a geoserver layer that is loaded with WMS. It has a 'place' field through which the layer is filtered depending on the places that the user has access to.
I load the layer like this:
In 'query' I put the place that the user has access
var query = 'place:13';
var places= new OpenLayers.Layer.WMS(layer.Name, layer.Url,
{ layers: layer.LayerName, viewparams: query, transparent: true, format: 'image/png' },
{
singleTile: true, opacity: 1, isBaseLayer: false, queryable: true,
visibility: false, noLegend: false, featureInfoFormat: 'application/vnd.ogc.gml', transitionEffect: 'resize',
metadata: {
wfs: {
protocol: 'fromWMSLayer'
}
The layer loads it perfectly, the user can only see the places that he has access.
The problem comes when using the searchPanel, the search is performed on the entire original layer instead of on the loaded layer, which is filtered.
Then a user has access to all places
I tried to load the layer like this:
var places= new OpenLayers.Layer.WMS(layer.Name, layer.Url,
{ layers: layer.LayerName, viewparams: query, transparent: true, format: 'image/png' },
{
singleTile: true, opacity: 1, isBaseLayer: false, queryable: true,
visibility: false, noLegend: false, featureInfoFormat: 'application/vnd.ogc.gml', transitionEffect: 'resize',
metadata: {
wfs: {
protocol: new OpenLayers.Protocol.WFS({
url: url_wfs,
params: { CQL_FILTER: "place= 13" },
featureNS: url,
featureType: 'places',
// or with this filter
defaultFilter: new OpenLayers.Filter.Logical({
type: OpenLayers.Filter.Logical.OR,
filters: [
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "place",
value: "13"
}),
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "place",
value: "14"
})
]
})
})
//or in this way
//filter: new OpenLayers.Filter.Logical({
// type: OpenLayers.Filter.Logical.OR,
// filters: [
// new OpenLayers.Filter.Comparison({
// type: OpenLayers.Filter.Comparison.EQUAL_TO,
// property: "place",
// value: "13"
// }),
// new OpenLayers.Filter.Comparison({
// type: OpenLayers.Filter.Comparison.EQUAL_TO,
// property: "place",
// value: "14"
// })
// ]
//})
}
}
});
With none of the options mentioned it works.
Searches return all objects in the layer, without the initial filter.
What can I do to keep the initial filter in searches and so the user can only filter on the data that have access?
Thanks in advance, regards