diff -urNad mapserver-5.6.3~/mapogcsos.c mapserver-5.6.3/mapogcsos.c --- mapserver-5.6.3~/mapogcsos.c 2009-10-20 15:38:46.000000000 +0200 +++ mapserver-5.6.3/mapogcsos.c 2010-04-30 15:02:22.828247103 +0200 @@ -1379,7 +1379,7 @@ { lp = (GET_LAYER(map, i)); - if (lp->status == MS_DELETE) + if (lp->status == MS_DELETE || msIsLayerHidden(lp) == MS_TRUE) continue; value = msOWSLookupMetadata(&(lp->metadata), "S", "offering_id"); diff -urNad mapserver-5.6.3~/mapserver.h mapserver-5.6.3/mapserver.h --- mapserver-5.6.3~/mapserver.h 2010-03-22 19:50:43.000000000 +0100 +++ mapserver-5.6.3/mapserver.h 2010-04-30 15:02:22.832247199 +0200 @@ -2206,6 +2206,8 @@ MS_DLL_EXPORT int msCheckParentPointer(void* p, char* objname); +MS_DLL_EXPORT int msIsLayerHidden( layerObj *lp ); + MS_DLL_EXPORT int *msAllocateValidClassGroups(layerObj *lp, int *nclasses); /* ==================================================================== */ /* End of prototypes for functions in maputil.c */ diff -urNad mapserver-5.6.3~/maputil.c mapserver-5.6.3/maputil.c --- mapserver-5.6.3~/maputil.c 2009-10-16 20:17:05.000000000 +0200 +++ mapserver-5.6.3/maputil.c 2010-04-30 15:02:22.832247199 +0200 @@ -1965,3 +1965,18 @@ #endif } + +/* + Ticket #1952, #2582, #337: check if layer is marked as hidden +*/ +int msIsLayerHidden( layerObj *lp ) { + const char *value; + int bIsLayerHidden = MS_FALSE; /* Layer is enable by default */ + + if( (value = msOWSLookupMetadata(&(lp->metadata), "MO", "hidden_layer")) ) { + if( strcasecmp("true", value) == 0 ) + bIsLayerHidden = MS_TRUE; + } + + return( bIsLayerHidden ); +} diff -urNad mapserver-5.6.3~/mapwcs.c mapserver-5.6.3/mapwcs.c --- mapserver-5.6.3~/mapwcs.c 2009-10-19 16:55:32.000000000 +0200 +++ mapserver-5.6.3/mapwcs.c 2010-04-30 15:02:22.832247199 +0200 @@ -681,7 +681,7 @@ coverageMetadataObj cm; int status; - if((layer->status == MS_DELETE) || !msWCSIsLayerSupported(layer)) return MS_SUCCESS; /* not an error, this layer cannot be served via WCS */ + if((layer->status == MS_DELETE) || msIsLayerHidden(layer) == MS_TRUE || !msWCSIsLayerSupported(layer)) return MS_SUCCESS; /* not an error, this layer cannot be served via WCS */ status = msWCSGetCoverageMetadata(layer, &cm); if(status != MS_SUCCESS) return MS_FAILURE; diff -urNad mapserver-5.6.3~/mapwfs.c mapserver-5.6.3/mapwfs.c --- mapserver-5.6.3~/mapwfs.c 2010-02-23 20:30:57.000000000 +0100 +++ mapserver-5.6.3/mapwfs.c 2010-04-30 15:02:22.832247199 +0200 @@ -452,7 +452,7 @@ layerObj *lp; lp = GET_LAYER(map, i); - if (lp->status == MS_DELETE) + if (lp->status == MS_DELETE || msIsLayerHidden(lp) == MS_TRUE) continue; /* List only vector layers in which DUMP=TRUE */ diff -urNad mapserver-5.6.3~/mapwms.c mapserver-5.6.3/mapwms.c --- mapserver-5.6.3~/mapwms.c 2010-02-22 01:20:06.000000000 +0100 +++ mapserver-5.6.3/mapwms.c 2010-04-30 15:02:22.836247296 +0200 @@ -1890,7 +1890,10 @@ if (numNestedGroups[index] <= level) /* no more subgroups */ { /* we are at the deepest level of the group branchings, so add layer now. */ - msDumpLayer(map, GET_LAYER(map, index), nVersion, script_url_encoded, ""); + /* if it is not marked as hidden */ + if (!msIsLayerHidden( GET_LAYER(map, index) )) + msDumpLayer(map, GET_LAYER(map, index), nVersion, script_url_encoded, ""); + pabLayerProcessed[index] = 1; /* done */ } else /* not yet there, we have to deal with this group and possible subgroups and layers. */ @@ -2419,6 +2422,9 @@ layerObj *lp; lp = (GET_LAYER(map, i)); + if (msIsLayerHidden(lp) == MS_TRUE) + pabLayerProcessed[i] = 1; /* Hide layer from capabilities */ + if (pabLayerProcessed[i] || (lp->status == MS_DELETE)) continue; /* Layer has already been handled */ @@ -2463,7 +2469,9 @@ GET_LAYER(map, j)->group && strcmp(lp->group, GET_LAYER(map, j)->group) == 0 ) { - msDumpLayer(map, (GET_LAYER(map, j)), nVersion, script_url_encoded, " "); + if (!msIsLayerHidden( GET_LAYER(map, j) )) /* Don't dump hidden layers */ + msDumpLayer(map, (GET_LAYER(map, j)), nVersion, script_url_encoded, " "); + pabLayerProcessed[j] = 1; } }