[Mapbender-commits] r8741 - in trunk/mapbender: http/classes http/geoportal http/php http/plugins owsproxy/http resources/db/pgsql/UTF-8/update

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Nov 28 04:39:19 PST 2013


Author: armin11
Date: 2013-11-28 04:39:19 -0800 (Thu, 28 Nov 2013)
New Revision: 8741

Modified:
   trunk/mapbender/http/classes/class_iso19139.php
   trunk/mapbender/http/classes/class_metadata_new.php
   trunk/mapbender/http/classes/class_wms.php
   trunk/mapbender/http/geoportal/jquery.dataTables.geoportal.css
   trunk/mapbender/http/php/mod_callMetadata.php
   trunk/mapbender/http/php/mod_getDownloadOptions.php
   trunk/mapbender/http/php/mod_inspireDownloadFeed.php
   trunk/mapbender/http/php/mod_showMetadata.php
   trunk/mapbender/http/plugins/mb_downloadFeedClient.php
   trunk/mapbender/http/plugins/mb_metadata_addon.php
   trunk/mapbender/http/plugins/mb_metadata_server.php
   trunk/mapbender/owsproxy/http/index.php
   trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql
Log:
Some enhancements for metadata handling and option to create INSPIRE Atom feed from given dataset metadata

Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php	2013-11-14 13:13:44 UTC (rev 8740)
+++ trunk/mapbender/http/classes/class_iso19139.php	2013-11-28 12:39:19 UTC (rev 8741)
@@ -59,6 +59,8 @@
 	//Following two attributes are needed for generating the inspire monitoring information. They are normally not part of the iso19139!
 	var $inspireWholeArea;
 	var $inspireActualCoverage;
+	//following parameter is specific to mapbender registry and steers the automatic generation of an INSPIRE Downloadservice for the given metadata 
+	var $inspireDownload;
 	var $linkAlreadyInDB; //bool
 	var $fileIdentifierAlreadyInDB; //bool
 
@@ -104,6 +106,8 @@
 		$this->inspireCharset = "";
 		$this->inspireWholeArea = 0;
 		$this->inspireActualCoverage = 0;
+		$this->inspireDownload = 0;
+		$this->inspireDownload = 0;
 		$this->linkAlreadyInDB = false;
 		$this->fileIdentifierAlreadyInDB = false;
 	}
@@ -266,8 +270,20 @@
 			$this->tmpExtentBegin = $this->tmpExtentBegin[0];
 			$this->tmpExtentEnd = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition');		
 			$this->tmpExtentEnd = $this->tmpExtentEnd[0];
-			//spatial_res_type
-			//spatial_res_value
+			//spatial_res_type/spatial_res_value
+			$equivalentScale = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:spatialResolution/gmd:MD_Resolution/gmd:equivalentScale/gmd:MD_RepresentativeFraction/gmd:denominator/gco:Integer');
+			$equivalentScale = $equivalentScale[0];
+			$groundResolution = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:spatialResolution/gmd:MD_Resolution/gmd:distance/gco:Distance');
+			$groundResolution = $groundResolution[0];
+			if (isset($equivalentScale) && $equivalentScale != "") {
+				$this->spatialResValue = $equivalentScale;
+				$this->spatialResType = "scaleDenominator";
+			} else {
+				if (isset($groundResolution) && $groundResolution != "") {
+					$this->spatialResValue = $groundResolution;
+					$this->spatialResType = "groundDistance";
+				}
+			}
 			//ref_system
 			$this->refSystem = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:referenceSystemInfo/gmd:MD_ReferenceSystem/gmd:referenceSystemIdentifier/gmd:RS_Identifier/gmd:code/gco:CharacterString');
 			$this->refSystem = $this->refSystem[0];
@@ -738,6 +754,7 @@
 			$this->inspireCharset = $row['inspire_charset'];//"";
 			$this->inspireWholeArea = $row['inspire_whole_area'];//"";
 			$this->inspireActualCoverage = $row['inspire_actual_coverage'];//"";
+			$this->inspireDownload = $row['inspire_download'];//"";
 			//$test = print_r($row['datalinks'],true);
 			//$e = new mb_exception((string)$test);
 			$this->downloadLinks  = $this->jsonDecodeDownloadLinks($row['datalinks']);
@@ -1038,7 +1055,7 @@
 		}
 		//"SRID=4326;POLYGON((-140 -80,-140 80,170 80,170 -80,-140 -80))"
 		$postGisBbox = "SRID=4326;POLYGON((".$bboxArray[0]." ".$bboxArray[1].",".$bboxArray[0]." ".$bboxArray[3].",".$bboxArray[2]." ".$bboxArray[3].",".$bboxArray[2]." ".$bboxArray[1].",".$bboxArray[0]." ".$bboxArray[1]."))";
-		$e = new mb_exception("class_iso19139.php: bbox: ".$postGisBbox);
+		//$e = new mb_exception("class_iso19139.php: bbox: ".$postGisBbox);
 		return $postGisBbox;
 	}
 
@@ -1332,7 +1349,7 @@
 		
 		//insert an instance for iso19139 into mapbenders database
 		$sql = <<<SQL
-INSERT INTO mb_metadata (lastchanged, link, origin, md_format, data, linktype, uuid, title, createdate, changedate, abstract, searchtext, type, tmp_reference_1, tmp_reference_2, export2csw, datasetid, datasetid_codespace, randomid, fkey_mb_user_id, harvestresult, harvestexception, lineage, inspire_top_consistence, spatial_res_type, spatial_res_value, update_frequency, format, inspire_charset, ref_system, the_geom, datalinks, inspire_whole_area, inspire_actual_coverage)  VALUES(now(), $1, $18, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33)
+INSERT INTO mb_metadata (lastchanged, link, origin, md_format, data, linktype, uuid, title, createdate, changedate, abstract, searchtext, type, tmp_reference_1, tmp_reference_2, export2csw, datasetid, datasetid_codespace, randomid, fkey_mb_user_id, harvestresult, harvestexception, lineage, inspire_top_consistence, spatial_res_type, spatial_res_value, update_frequency, format, inspire_charset, ref_system, the_geom, datalinks, inspire_whole_area, inspire_actual_coverage, inspire_download)  VALUES(now(), $1, $18, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34)
 SQL;
 		$v = array(
 			$this->href,
@@ -1367,9 +1384,10 @@
 			$this->createWktBboxFromArray($this->wgs84Bbox),
 			$this->jsonEncodeDownloadLinks($this->downloadLinks),
 			$this->inspireWholeArea,
-			$this->inspireActualCoverage
+			$this->inspireActualCoverage,
+			$this->inspireDownload
 		);
-			$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON','s','i','i');
+			$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON','s','i','i','i');
 			$res = db_prep_query($sql,$v,$t);
 			return $res;
 	}
@@ -1393,7 +1411,7 @@
 		$sql .= "linktype = $4, uuid = $5, title = $6, createdate = $7, changedate = $8, lastchanged = now(), ";
 		$sql .= "abstract = $9, searchtext = $10, type = $11, tmp_reference_1 = $12, tmp_reference_2 = $13, export2csw = $14, datasetid = $15, ";
 		$sql .= "datasetid_codespace = $16, randomid = $17, harvestresult = $20, harvestexception = $21, lineage = $22, inspire_top_consistence = $23, ";
-		$sql .= "spatial_res_type = $24, spatial_res_value = $25, update_frequency = $26, format = $27, inspire_charset = $28, ref_system = $29, the_geom = $30, datalinks = $31, inspire_whole_area = $32, inspire_actual_coverage = $33 WHERE metadata_id = $19";
+		$sql .= "spatial_res_type = $24, spatial_res_value = $25, update_frequency = $26, format = $27, inspire_charset = $28, ref_system = $29, the_geom = $30, datalinks = $31, inspire_whole_area = $32, inspire_actual_coverage = $33, inspire_download = $34 WHERE metadata_id = $19";
 
 		$v = array(
 			$this->href,
@@ -1429,9 +1447,10 @@
 			$this->createWktBboxFromArray($this->wgs84Bbox),
 			$this->jsonEncodeDownloadLinks($this->downloadLinks),
 			$this->inspireWholeArea,
-			$this->inspireActualCoverage
+			$this->inspireActualCoverage,
+			$this->inspireDownload
 		);
-		$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON','s','i','i');
+		$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON','s','i','i','i');
 		$res = db_prep_query($sql,$v,$t);
 		return $res;
 	}

Modified: trunk/mapbender/http/classes/class_metadata_new.php
===================================================================
--- trunk/mapbender/http/classes/class_metadata_new.php	2013-11-14 13:13:44 UTC (rev 8740)
+++ trunk/mapbender/http/classes/class_metadata_new.php	2013-11-28 12:39:19 UTC (rev 8741)
@@ -107,9 +107,11 @@
 		$this->resourceClassifications[0]['id_wms'] = 'layer_id';
 		$this->resourceClassifications[0]['id_wfs'] = 'featuretype_id';
 		$this->resourceClassifications[0]['id_wmc'] = 'wmc_serial_id';
+		$this->resourceClassifications[0]['id_dataset'] = 'metadata_id';
 		$this->resourceClassifications[0]['relation_wms'] = 'layer_md_topic_category';
 		$this->resourceClassifications[0]['relation_wfs'] = 'featuretype_md_topic_category';
 		$this->resourceClassifications[0]['relation_wmc'] = 'wmc_md_topic_category';
+		$this->resourceClassifications[0]['relation_dataset'] = 'mb_metadata_md_topic_category';
 //TODO: define this in mapbender
 
 		$this->resourceClassifications[1]['title'] = "INSPIRE"; //TODO: define the translations somewhere? - This is done in call_metadata.php before. Maybe we can get them from there? - It will be shown in the rightside categories table
@@ -118,9 +120,11 @@
 		$this->resourceClassifications[1]['id_wms'] = 'layer_id';
 		$this->resourceClassifications[1]['id_wfs'] = 'featuretype_id';
 		$this->resourceClassifications[1]['id_wmc'] = 'wmc_serial_id';
+		$this->resourceClassifications[1]['id_dataset'] = 'metadata_id';
 		$this->resourceClassifications[1]['relation_wms'] = 'layer_inspire_category';
 		$this->resourceClassifications[1]['relation_wfs'] = 'featuretype_inspire_category';
-		$this->resourceClassifications[1]['relation_wmc'] = 'wmc_inspire_category';
+		$this->resourceClassifications[1]['relation_wmc'] = 'wmc_inspire_category';		
+		$this->resourceClassifications[1]['relation_dataset'] = 'mb_metadata_inspire_category';
 //TODO: define this in mapbender
 		switch($this->languageCode){
 			case "de":
@@ -141,29 +145,27 @@
 		$this->resourceClassifications[2]['id_wms'] = 'layer_id';
 		$this->resourceClassifications[2]['id_wfs'] = 'featuretype_id';
 		$this->resourceClassifications[2]['id_wmc'] = 'wmc_serial_id';
+		$this->resourceClassifications[2]['id_dataset'] = 'metadata_id';
 		$this->resourceClassifications[2]['relation_wms'] = 'layer_custom_category';
 		$this->resourceClassifications[2]['relation_wfs'] = 'featuretype_custom_category';
 		$this->resourceClassifications[2]['relation_wmc'] = 'wmc_custom_category';
-//TODO: define this in mapbender
+		$this->resourceClassifications[1]['relation_dataset'] = 'mb_metadata_custom_category';
+		//TODO: define this in mapbender
 
-
-
-
-
-
-
 		//Defining of the different result categories		
 		$this->resourceCategories = array();
 		$this->resourceCategories[0]['name'] = 'WMS';
 		$this->resourceCategories[1]['name'] = 'WFS';
 		$this->resourceCategories[2]['name'] = 'WMC';
 		$this->resourceCategories[3]['name'] = 'DAD';
+		$this->resourceCategories[4]['name'] = 'DATASET';
 		switch($this->languageCode){
         		case 'de':
                 	$this->resourceCategories[0]['name2show'] = 'Darstellungsdienste';
 			$this->resourceCategories[1]['name2show'] = 'Such- und Download- und Erfassungsmodule';
 			$this->resourceCategories[2]['name2show'] = 'Kartenzusammenstellungen';
 			$this->resourceCategories[3]['name2show'] = 'KML/Newsfeeds';
+			$this->resourceCategories[4]['name2show'] = 'Datensätze';
 			$this->keywordTitle = 'Schlagwortliste';
        			break;
         		case 'en':
@@ -171,6 +173,7 @@
 			$this->resourceCategories[1]['name2show'] = 'Search- and Downloadservices';
 			$this->resourceCategories[2]['name2show'] = 'Combined Maps';
 			$this->resourceCategories[3]['name2show'] = 'KML/Newsfeeds';
+			$this->resourceCategories[4]['name2show'] = 'Datasets';
 			$this->keywordTitle = 'Keywordlist';
         		break;
         		case 'fr':
@@ -178,6 +181,7 @@
 			$this->resourceCategories[1]['name2show'] = 'Services de recherche et de téléchargement';
 			$this->resourceCategories[2]['name2show'] = 'Cartes composées';
 			$this->resourceCategories[3]['name2show'] = 'KML/Newsfeeds';
+			$this->resourceCategories[4]['name2show'] = 'Datasets';
 			$this->keywordTitle = 'Keywordlist';
        			break;
      			default:
@@ -185,6 +189,7 @@
 			$this->resourceCategories[1]['name2show'] = 'Such- und Download- und Erfassungsmodule';
 			$this->resourceCategories[2]['name2show'] = 'Kartenzusammenstellungen';
 			$this->resourceCategories[3]['name2show'] = 'KML/Newsfeeds';
+			$this->resourceCategories[4]['name2show'] = 'Datensätze';
 			$this->keywordTitle = 'Schlagwortliste';
 		}	
 		//not needed til now - maybe usefull for georss output
@@ -204,6 +209,10 @@
 			if (isset($this->searchResources) & strtolower($this->searchResources) === "georss") {
 				$this->georssDoc = new DOMDocument('1.0');
 			}
+			if (isset($this->searchResources) & strtolower($this->searchResources) === "dataset") {
+				$this->datasetDoc = new DOMDocument('1.0');
+				$this->generateDatasetMetadata($this->datasetDoc);
+			}
 		}
 		
 		if ($this->outputFormat === "json") {
@@ -289,6 +298,34 @@
 				#$this->resourceClasses = array();		
 				$this->generateWMCMetadata($this->wmcDoc);
 			}
+			if (isset($this->searchResources) & strtolower($this->searchResources) === "dataset") {
+				$this->databaseIdColumnName = 'metadata_id';
+				$this->databaseTableName = 'mb_metadata';
+				//$this->keywordRelation = 'layer_keyword';
+				//$this->searchView = 'wms_search_table';
+				$this->searchView = 'search_dataset_view';
+				$this->whereStrCatExtension = " AND custom_category.custom_category_hidden = 0";
+				switch ($this->orderBy) {
+					/*case "rank":
+						$this->orderBy = " ORDER BY load_count DESC";
+						break;*/
+					case "id":
+						$this->orderBy = " ORDER BY metadata_id ASC";
+						break;
+					case "title":
+						$this->orderBy = " ORDER BY title ";
+						break;
+					case "date":
+						$this->orderBy = " ORDER BY last_changed DESC ";
+						break;
+					default:
+						//$this->orderBy = " ORDER BY load_count DESC";
+						$this->orderBy = " ORDER BY title DESC";
+				}
+				
+				$this->resourceClasses = array(0,1,2);
+				$this->generateDatasetMetadata($this->datasetDoc);
+			}
 		}
 	$this->e = new mb_notice("orderBy new: ".$this->orderBy);
 	}
@@ -507,10 +544,64 @@
 			
 	}
 
+	private function generateDatasetMetadataJSON($res, $n) {
+		//initialize object
+		$this->datasetJSON = new stdClass;
+		$this->datasetJSON->dataset = (object) array(
+				'md' => (object) array(
+					'nresults' => $n, 
+					'p' => $this->searchPages,
+					'rpp' => $this->maxResults
+					),
+				'srv' => array()
+				);
+			
+		//read out records
+		$serverCount = 0;
+		$datasetMatrix = db_fetch_all($res);
+		//sort result for accessing the right services
+		$datasetMatrix = $this->flipDiagonally($datasetMatrix);
+		//TODO check if order by db or order by php is faster! 
+		#array_multisort($wfsMatrix['wfs_id'], SORT_ASC,$wfsMatrix['featuretype_id'], SORT_ASC,$wfsMatrix['wfs_conf_id'], SORT_ASC); //have some problems - the database version is more stable
+		#print_r($wfsMatrix);
+		$datasetMatrix = $this->flipDiagonally($datasetMatrix);
+		//read out first server entry - maybe this a little bit timeconsuming TODO
+		for($i=0; $i<count($datasetMatrix);$i++){
+			$this->datasetJSON->dataset->srv[$i]->id = $datasetMatrix[$i]['metadata_id'];
+			$this->datasetJSON->dataset->srv[$i]->title = $datasetMatrix[$i]['title'];
+			$this->datasetJSON->dataset->srv[$i]->abstract = $datasetMatrix[$i]['abstract'];
+			$this->datasetJSON->dataset->srv[$i]->date = date("d.m.Y",$datasetMatrix[$i]['last_changed']);
+			$this->datasetJSON->dataset->srv[$i]->respOrg = $datasetMatrix[$i]['mb_group_name'];
+			$this->datasetJSON->dataset->srv[$i]->logoUrl = $datasetMatrix[$i]['mb_group_logo_path'];
+			//TODO: other url - to metadata uuid!
+			$this->datasetJSON->dataset->srv[$i]->mdLink = "http://".$this->hostName."/mapbender/php/mod_showMetadata.php?languageCode=".$this->languageCode."&resource=wmc&layout=tabs&id=".$datasetMatrix[$i]['metadata_id'];
+			//TODO: preview?
+			$this->datasetJSON->dataset->srv[$i]->previewURL = "http://".$this->hostName."/mapbender/geoportal/mod_showPreview.php?resource=wmc&id=".$datasetMatrix[$i]['wmc_id'];
+			$spatialSource = "";
+			$stateOrProvince = $datasetMatrix[$i]['mb_group_stateorprovince']; 
+			if ($stateOrProvince == "NULL" || $stateOrProvince == "") {
+				$spatialSource = $datasetMatrix[$i]['mb_group_country'];
+			} else {
+				$spatialSource = $datasetMatrix[$i]['mb_group_stateorprovince'];
+			}
+			$this->datasetJSON->dataset->srv[$i-$j]->iso3166 = $spatialSource;
+				
+			$this->datasetJSON->dataset->srv[$i-$j]->bbox = array($datasetMatrix[$i]['bbox']); //TODO: read out bbox from wmc $datasetMatrix[$i][''];
 
+			#$equalEPSG = $wmcMatrix[$i]['srs'];
+                       	#$isEqual = true;
+			//control if EPSG is supported by Client
+		        #if ($equalEPSG == $this->searchEPSG){
+			#	$isEqual = false;		
+		        #}	
+				
+		}
+			
+	}
 
 
 
+
 	private function generateWMSMetadataJSON($res, $n) {
 		//initialize object
 		$this->wmsJSON = new stdClass;
@@ -796,6 +887,33 @@
 		$e = new mb_notice("Wrote the MD_WMC-File");
 	}
 
+	private function generateDatasetMetadata($xmlDoc) {
+		$starttime = $this->microtime_float();
+		list($sql, $v, $t, $n) = $this->generateSearchSQL();
+		//call database search in limits
+		$res = db_prep_query($sql, $v, $t);
+		if ($this->outputFormat == 'json'){
+			//generate json
+			$this->generateDatasetMetadataJSON($res,$n);
+			$usedTime = $this->microtime_float() - $starttime;
+			//put in the time to generate the data
+			$this->datasetJSON->dataset->md->genTime = $usedTime;
+			$this->datasetJSON = $this->json->encode($this->datasetJSON);
+			if ($this->resultTarget == 'file') {
+				if($datasetFileHandle = fopen($this->tempFolder."/".$this->searchId."_".$this->searchResources."_".$this->searchPages.".json","w")){
+					fwrite($datasetFileHandle,$this->datasetJSON);
+					fclose($datasetFileHandle);
+				}
+			}
+			if ($this->resultTarget == 'web' or $this->resultTarget == 'debug') {
+				echo $this->datasetJSON;
+			}
+		}
+		$usedTime2 = $this->microtime_float() - $starttime;
+		//echo "<br>used time: ".$usedTime."<br>";
+		$e = new mb_notice("Time to generate Dataset-Metadata: ".$usedTime2);
+		$e = new mb_notice("Wrote the MD_Dataset-File");
+	}
 
 
 
@@ -847,7 +965,7 @@
 		//check for postgis version
 		//sql for get version string
 		//get version number
-		if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wmc") & $this->searchBbox != NULL) {
+		if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wmc" or strtolower($this->searchResources) === "dataset") & $this->searchBbox != NULL) {
 			//decide which type of search should be done
 			//check for postgis version cause postgis versions < 1.4 have problems when doing disjoint and inside
 			//
@@ -917,7 +1035,7 @@
 		}	
 		//search filter for md_topic_categories
 		//
-		if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wmc") & $this->isoCategories != NULL) {
+		if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wmc" or strtolower($this->searchResources) === "dataset") & $this->isoCategories != NULL) {
 			
 			$isoArray = explode(',',$this->isoCategories);
 			$topicCond = "(";
@@ -933,7 +1051,7 @@
 		}
 		//search filter for inspire_categories
 		//
-		if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wmc") & $this->inspireThemes != NULL) {
+		if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wmc" or strtolower($this->searchResources) === "dataset") & $this->inspireThemes != NULL) {
 			
 			$inspireArray = explode(',',$this->inspireThemes);
 			$inspireCond = "(";
@@ -949,7 +1067,7 @@
 		}
 		//search filter for custom_categories
 		//
-		if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wmc") & $this->customCategories != NULL) {
+		if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wmc" or strtolower($this->searchResources) === "dataset") & $this->customCategories != NULL) {
 			
 			$customArray = explode(',',$this->customCategories);
 			$customCond = "(";

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2013-11-14 13:13:44 UTC (rev 8740)
+++ trunk/mapbender/http/classes/class_wms.php	2013-11-28 12:39:19 UTC (rev 8741)
@@ -2068,15 +2068,15 @@
 			if ($this->overwriteCategories == true) {
 				$e = new mb_notice("class_wms.php - overwrite categories has been activated");
 			}
-			# save the id of each layer: set param2 true
+			//save the id of each layer: set param2 true
 			$this->objLayer[$i]->db_id = $l_id;
+			//this things can only be updated, if the service is updated thru new capabilities documents
 			if (!$updateMetadataOnly) {
 				$this->insertLayerEPSG($i);
+				$this->insertLayerDataUrls($i);
+				$this->insertLayerMetadataUrls($i);
+				$this->insertLayerStyle($i);
 			}
-			$this->insertLayerDataUrls($i);
-			$this->insertLayerMetadataUrls($i);
-			# TABLE layer_style for each layer
-			$this->insertLayerStyle($i);
 			if($this->overwrite == true){
 				$this->insertLayerKeyword($i);
 				//$this->insertLayerCategories($i); //Don't overwrite layer categories by default any longer - it will make problems - maybe the wms 1.3.0 possibilities are a better way
@@ -2088,7 +2088,7 @@
 		}
 	}
 	function insertGuiLayer($i,$myWMS,$gui_id){
-		# table gui_layer
+		//table gui_layer
 		$sql = "INSERT INTO gui_layer (fkey_gui_id, fkey_layer_id, gui_layer_wms_id, ";
 		$sql .= "gui_layer_status, gui_layer_selectable, gui_layer_visible, gui_layer_queryable, ";
 		$sql .= "gui_layer_querylayer,gui_layer_minscale,gui_layer_maxscale, gui_layer_priority, gui_layer_style, gui_layer_title) ";

Modified: trunk/mapbender/http/geoportal/jquery.dataTables.geoportal.css
===================================================================
--- trunk/mapbender/http/geoportal/jquery.dataTables.geoportal.css	2013-11-14 13:13:44 UTC (rev 8740)
+++ trunk/mapbender/http/geoportal/jquery.dataTables.geoportal.css	2013-11-28 12:39:19 UTC (rev 8741)
@@ -175,5 +175,7 @@
 	font-size: 14px;
 	background-color: white;
 }
+a {
+	color:#8b8b8b:
+}
 
-

Modified: trunk/mapbender/http/php/mod_callMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_callMetadata.php	2013-11-14 13:13:44 UTC (rev 8740)
+++ trunk/mapbender/http/php/mod_callMetadata.php	2013-11-28 12:39:19 UTC (rev 8741)
@@ -38,7 +38,7 @@
 $accessRestrictions = "false"; 
 $languageCode = "de";
 $outputFormat = 'json';
-#$searchResources = "wms,wfs,wmc,georss";
+#$searchResources = "wms,wfs,wmc,georss,dataset";
 #$searchResources = "wms";
 $searchPages = "1";
 $resourceIds = NULL; //resourceIds is used to get a comma separated list with ids of the resources - layer - featuretypes - wmc
@@ -305,7 +305,7 @@
  	} else {
 		$testArray = explode(',',$testMatch);
 		for($i=0; $i<count($testArray);$i++){
-			if (!($testArray[$i] == 'wms' or $testArray[$i] == 'wfs' or $testArray[$i] == 'wmc' or $testArray[$i] == 'data')) {
+			if (!($testArray[$i] == 'wms' or $testArray[$i] == 'wfs' or $testArray[$i] == 'wmc' or $testArray[$i] == 'dataset')) {
 			//echo 'searchResources: <b>'.$testMatch.'</b>at least one of them does not exists!<br/>'; 
 			echo 'Parameter <b>searchResources</b>at least one of them does not exists! (wms,wfs,wmc,data)<br/>';
 			die();
@@ -587,6 +587,7 @@
 		$resourceCategories['wms'] = 'Darstellungsdienste';
 		$resourceCategories['wfs'] = 'Such- und Download- und Erfassungsmodule';
 		$resourceCategories['wmc'] = 'Kartenzusammenstellungen';
+		$resourceCategories['dataset'] = 'Datensätze';
 		$resourceCategories['georss'] = 'KML/Newsfeeds';
 
 		$orderByTitle['header'] = 'Sortierung nach:';
@@ -612,6 +613,7 @@
 		$resourceCategories['wms'] = 'Viewingservices';
 		$resourceCategories['wfs'] = 'Search- and Downloadservices';
 		$resourceCategories['wmc'] = 'Combined Maps';
+		$resourceCategories['dataset'] = 'Datasets';
 		$resourceCategories['georss'] = 'KML/Newsfeeds';
 
 		$orderByTitle['header'] = 'Sort by:';
@@ -636,6 +638,7 @@
 		$resourceCategories['wms'] = 'Services de visualisation';
 		$resourceCategories['wfs'] = 'Services de recherche et de téléchargement';
 		$resourceCategories['wmc'] = 'Cartes composées';
+		$resourceCategories['dataset'] = 'Datasets';
 		$resourceCategories['georss'] = 'KML/Newsfeeds';
 
 		$orderByTitle['header'] = 'classé selon:';
@@ -660,6 +663,7 @@
 		$resourceCategories['wms'] = 'Darstellungsdienste';
 		$resourceCategories['wfs'] = 'Such- und Downloaddienste';
 		$resourceCategories['wmc'] = 'Kartenzusammenstellungen';
+		$resourceCategories['dataset'] = 'Datasets';
 		$resourceCategories['georss'] = 'KML/Newsfeeds';
 
 		$orderByTitle['header'] = 'Sortierung nach:';
@@ -672,6 +676,9 @@
 
 }	
 
+//write language code to session! TODO: This is problematic, cause it is too late for the translation! Should be done before!
+Mapbender::session()->set("mb_lang",$languageCode);
+
 $queryJSON = new stdClass;
 $queryJSON->searchFilter = (object) array();
 $queryJSON->searchFilter->origURL = $searchURL;
@@ -1012,7 +1019,7 @@
 //Name of searchResult files
 //searchid_wms_1.json
 //searchid_wfs_1.json
-//searchid_wmc_1.json - doesn't exists till now
+//searchid_wmc_1.json
 //searchid_georss_1.json - doesn't exists till now
 //categories files - will only be generated when the search is started and resultType = 'file'. if the categories files already exists it will not be updated! - Here we can spare a reasonable amount of calculating power. Another approach is to generate a md5 hash of an ordered searchURL. With this we can cache the requests!
 

Modified: trunk/mapbender/http/php/mod_getDownloadOptions.php
===================================================================
--- trunk/mapbender/http/php/mod_getDownloadOptions.php	2013-11-14 13:13:44 UTC (rev 8740)
+++ trunk/mapbender/http/php/mod_getDownloadOptions.php	2013-11-28 12:39:19 UTC (rev 8741)
@@ -79,7 +79,7 @@
 
 $sql .= "union select NULL as service_id, NULL as service_uuid, NULL as resource_id, 'metadata' as resource_type, NULL ";
 
-$sql .= "as datalink, datalinks as datalink_text, format FROM mb_metadata WHERE mb_metadata.uuid = $1;";
+$sql .= "as datalink, datalinks as datalink_text, format FROM mb_metadata WHERE mb_metadata.uuid = $1 and inspire_download = 1;";
 
 
 /*

Modified: trunk/mapbender/http/php/mod_inspireDownloadFeed.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireDownloadFeed.php	2013-11-14 13:13:44 UTC (rev 8740)
+++ trunk/mapbender/http/php/mod_inspireDownloadFeed.php	2013-11-28 12:39:19 UTC (rev 8741)
@@ -446,6 +446,9 @@
 				case "wfs":
 					$mimetype = "application/gml+xml";
 				break;
+				case "metadata":
+					$mimetype = $formatsMimetype[$mapbenderMetadata[$m]->format];
+				break;
 	}
 	//part which generates the feed 
 	$feed =  $feedDoc->createElementNS('http://a9.com/-/spec/opensearch/1.1/', 'OpenSearchDescription');
@@ -580,7 +583,7 @@
 		break;
 		case "metadata":
 			$sql = <<<SQL
-select 'metadata' as origin,mb_metadata.metadata_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace,  mb_metadata.lastchanged as md_timestamp, box2d(the_geom) as bbox2d, datalinks FROM mb_metadata where uuid = $1;
+select 'metadata' as origin,mb_metadata.metadata_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.fkey_mb_user_id,  mb_metadata.lastchanged as md_timestamp, box2d(the_geom) as bbox2d, datalinks FROM mb_metadata where uuid = $1 and inspire_download = 1;
 SQL;
 		break;
 		case "all":
@@ -593,7 +596,7 @@
 		
 SQL;
 			$sql[2] =  <<<SQL
-select *, 'wfs' as origin from (select mb_metadata.metadata_id, featuretype_relation.featuretype_name, featuretype_relation.fkey_wfs_id, featuretype_relation.inspire_download, featuretype_relation.featuretype_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, featuretype_relation.featuretype_title, featuretype_relation.featuretype_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace,  featuretype_relation.featuretype_latlon_bbox as latlonbbox, featuretype_relation.featuretype_srs, mb_metadata.lastchanged as md_timestamp from (select * from wfs_featuretype inner join ows_relation_metadata on wfs_featuretype.featuretype_id = ows_relation_metadata.fkey_featuretype_id) as featuretype_relation inner join mb_metadata on featuretype_relation.fkey_metadata_id = mb_metadata.metada
 ta_id where mb_metadata.uuid = $1) as featuretype_data inner join wfs on featuretype_data.fkey_wfs_id = wfs.wfs_id;		
+select *, 'wfs' as origin from (select mb_metadata.metadata_id, featuretype_relation.featuretype_name, featuretype_relation.fkey_wfs_id, featuretype_relation.inspire_download, featuretype_relation.featuretype_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, featuretype_relation.featuretype_title, featuretype_relation.featuretype_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, featuretype_relation.featuretype_latlon_bbox as latlonbbox, featuretype_relation.featuretype_srs, mb_metadata.lastchanged as md_timestamp from (select * from wfs_featuretype inner join ows_relation_metadata on wfs_featuretype.featuretype_id = ows_relation_metadata.fkey_featuretype_id) as featuretype_relation inner join mb_metadata on featuretype_relation.fkey_metadata_id = mb_metadata.metadat
 a_id where mb_metadata.uuid = $1) as featuretype_data inner join wfs on featuretype_data.fkey_wfs_id = wfs.wfs_id;		
 SQL;
 		break;
 	}

Modified: trunk/mapbender/http/php/mod_showMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_showMetadata.php	2013-11-14 13:13:44 UTC (rev 8740)
+++ trunk/mapbender/http/php/mod_showMetadata.php	2013-11-28 12:39:19 UTC (rev 8741)
@@ -1121,6 +1121,9 @@
 					case "wfsrequest":
 						$metadataList .= "  <a href='../plugins/mb_downloadFeedClient.php?url=".urlencode($mapbenderUrl."/php/mod_inspireDownloadFeed.php?id=".$row["uuid"]."&type=SERVICE&generateFrom=wfs&wfsid=".$option->serviceId)."'><img src='../img/osgeo_graphics/geosilk/vector_download.png' title='".$translation['Download GML data from INSPIRE Download Service']."'/></a>";
 						break;
+					case "downloadlink":
+						$metadataList .= "  <a href='../plugins/mb_downloadFeedClient.php?url=".urlencode($mapbenderUrl."/php/mod_inspireDownloadFeed.php?id=".$row["uuid"]."&type=SERVICE&generateFrom=metadata")."'><img src='../img/osgeo_graphics/geosilk/link_download.png' title='".$translation['Download linked data from INSPIRE Download Service']."'/></a>";
+						break;
 				}	
 			}	
 		}

Modified: trunk/mapbender/http/plugins/mb_downloadFeedClient.php
===================================================================
--- trunk/mapbender/http/plugins/mb_downloadFeedClient.php	2013-11-14 13:13:44 UTC (rev 8740)
+++ trunk/mapbender/http/plugins/mb_downloadFeedClient.php	2013-11-28 12:39:19 UTC (rev 8741)
@@ -8,8 +8,8 @@
 	$testMatch = $_REQUEST["url"];
 	$pattern = '/^http\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?$/';		
  	if (!preg_match($pattern,$testMatch)){ 
-		echo 'url: <b>'.$testMatch.'</b> is not a valid url.<br/>'; 
-		die(); 		
+		//echo 'url: <b>'.$testMatch.'</b> is not a valid url.<br/>'; 
+		//die(); 		
  	}
 	$url = urldecode($testMatch);
 	$testMatch = NULL;	

Modified: trunk/mapbender/http/plugins/mb_metadata_addon.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_addon.php	2013-11-14 13:13:44 UTC (rev 8740)
+++ trunk/mapbender/http/plugins/mb_metadata_addon.php	2013-11-28 12:39:19 UTC (rev 8741)
@@ -207,7 +207,7 @@
 			<!--<label for="spatial_res_type" class="error"><?php echo _mb("Please set the resolution type!");?>-->
 			</label>
 			<label><?php echo _mb("Value of resolution");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Value of spatial resolution in [m] or scale denominator");?>'}" src="../img/questionmark.png" alt="" /></label>
-			<input class="required digits" name="spatial_res_value" id="spatial_res_value"/>
+			<input class="required" name="spatial_res_value" id="spatial_res_value"/>
 		</fieldset>
 		<!-- Dropdown List of CRS which are defined in mapbender.conf. For those CRS the layer extents will be computed by mapbender - this is relevant for INSPIRE.-->
 		
@@ -246,8 +246,11 @@
 		<fieldset>
 		<label for="downloadlink">
 			<?php echo _mb("Download link to dataset");?>
-			<input class="" name="downloadlink" id="downloadlink"/>
 		</label>
+		
+		<input class="" name="downloadlink" id="downloadlink"/>
+		<?php echo _mb("Enable INSPIRE DLS");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Activating this checkbox will enable the generation of an INSPIRE DLS based on ATOM feed for the given link!");?>'}" src="../img/questionmark.png" alt="" />
+		<input name="inspire_download" id="inspire_download" type="checkbox"/>
 		</fieldset>
 	</div>
 	<div id="tabs-7">

Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php	2013-11-14 13:13:44 UTC (rev 8740)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php	2013-11-28 12:39:19 UTC (rev 8741)
@@ -734,6 +734,16 @@
 				default:
 				break;	
 			}
+			switch ($mbMetadata->inspireDownload) {
+				case 0 :
+					$resultObj["inspire_download"] = false;
+					break;
+				case 1 :
+					$resultObj["inspire_download"] = true;
+					break;
+				default:
+				break;	
+			}
 			//categories and keywords
 			$resultObj["md_md_topic_category_id"] = $mbMetadata->isoCategories;
 			$resultObj["md_custom_category_id"] = $mbMetadata->customCategories;
@@ -798,6 +808,11 @@
 			} else {
 				$mbMetadata->inspireTopConsistence = 'f';
 			}
+			if ($data->inspire_download) {
+				$mbMetadata->inspireDownload = 1;
+			} else {
+				$mbMetadata->inspireDownload = 0;
+			}
 			//$mbMetadata->fileIdentifier = $metadataId;
 			$mbMetadata->href = $data->link;
 			$mbMetadata->title = $data->title;
@@ -1039,6 +1054,11 @@
 		} else {
 			$mbMetadata->inspireActualCoverage = 0;
 		}
+		if ($data->inspire_download == "on") {
+			$mbMetadata->inspire_download = 1;
+		} else {
+			$mbMetadata->inspire_download = 0;
+		}
 		//Check if origin is external and export2csw is activated!
 		if ($origin == 'external' ) {
 			//harvest link from location, parse the content for datasetid and push xml into data column

Modified: trunk/mapbender/owsproxy/http/index.php
===================================================================
--- trunk/mapbender/owsproxy/http/index.php	2013-11-14 13:13:44 UTC (rev 8740)
+++ trunk/mapbender/owsproxy/http/index.php	2013-11-28 12:39:19 UTC (rev 8741)
@@ -26,6 +26,11 @@
 $width = 400;
 $height = 400;
 /***** conf *****/
+if (ini_get('session.save_handler') == "memcache") {
+	$memcache_obj = new Memcache;
+	$memcache_obj->connect('localhost', 11211);
+	$e = new mb_notice("sessions stored to memcached");
+}
 $postdata = $HTTP_RAW_POST_DATA;
 $owsproxyService = $_REQUEST['wms']; //ToDo: change this to 'service' in the apache url-rewriting
 $query = new QueryHandler();
@@ -33,10 +38,7 @@
 $reqParams = $query->getRequestParams();
 $e = new mb_notice("incoming request: ".OWSPROXY."/".$_REQUEST['sid']."/".$_REQUEST['wms'].$query->getRequest());
 $e = new mb_notice("owsproxy requested from: ".$_SERVER["REMOTE_ADDR"]);
-//check if proxy request came from grabbing whitelist - for grabbing
-if (!defined("OWSPROXY_SESSION_GRABBING_WHITELIST")){
-	$grabbingAllowed = true;
-}
+
 if (defined("OWSPROXY_SESSION_GRABBING_WHITELIST")) {
 	$whiteListArray = explode(",", OWSPROXY_SESSION_GRABBING_WHITELIST);
 	if (in_array($_SERVER["REMOTE_ADDR"], $whiteListArray)) {
@@ -46,44 +48,90 @@
 		$grabbingAllowed = false;
 		$e = new mb_notice("Grabbing not allowed for IP: ".$_SERVER["REMOTE_ADDR"]."!");
 	}
+} else {
+	$grabbingAllowed = false;
 }
-//check session
-//session_regenerate_id(TRUE);
+
 $e = new mb_notice("Initial session_id: ".session_id());
 //The session can be set by a given cookie value or was newly created by core/globalSettings.php
 //either empty (without mb_user_id value) - when the corresponding session file was lost or timed out
 //or filled, when there was an actual mapbender session before
 //check if mb_user_id is given and is an string with an integer:
 if(!$_SESSION['mb_user_id'] && !is_int($_SESSION['mb_user_id'])){
-	$e = new mb_notice("Newly initialized session - no logged in mapbender user!");
+	$e = new mb_notice("Newly initialized session - no logged in mapbender user for this session!");
 }
 //Possibility to grap an existing session:
 if (defined("OWSPROXY_ALLOW_SESSION_GRABBING") && OWSPROXY_ALLOW_SESSION_GRABBING == true) {
 	if ($grabbingAllowed) {
 		//first check is to find out if a session with the current sid exists! If so use this one, if not use the current one which was generated from globalSettings.php
-		if (file_exists(ini_get('session.save_path')."/sess_".$_REQUEST["sid"]) && session_id() !== $_REQUEST["sid"]) {
-			//there is a current session for the requested url
-			$e = new mb_notice("A current session exists for this url and will be used!");
-			$oldsessionId = session_id();
-			$tmpSessionFile = ini_get('session.save_path')."/sess_".session_id();
-			//do the following only, if a user is in this session - maybe it is a session which was generated from an external application and therefor it is empty!
-			session_id($_REQUEST["sid"]);
-			$e = new mb_notice("Grabbed session with id: ".session_id());
-			//kill dynamical session
-			//@unlink($tmpSessionFile);
-			$e = new mb_notice("Following user was found and will be used for authorization: ".Mapbender::session()->get('mb_user_id'));
-			$foundUserId = Mapbender::session()->get('mb_user_id');
-			if (!isset($foundUserId) || $foundUserId =='') {
-				$e = new mb_notice("No user found in the existing session - switch to the old one!");
-				session_id($oldsessionId);
-			} else {
-				//delete session as it will not be needed any longer
-				$e = new mb_notice("Following no longer needed session will be deleted: ".$tmpSessionFile);
-				@unlink($tmpSessionFile);
+		switch (ini_get('session.save_handler')) {
+			//$e = new mb_notice("filesystem session found");
+			case "files":
+				$e = new mb_notice("filesystem session found");
+				if (file_exists(ini_get('session.save_path')."/sess_".$_REQUEST["sid"]) && session_id() !== $_REQUEST["sid"]) {
+					//there is a current session for the requested url
+					$e = new mb_notice("A current session exists for this url and will be used!");
+					$oldsessionId = session_id();
+					$tmpSessionFile = ini_get('session.save_path')."/sess_".session_id();
+					//do the following only, if a user is in this session - maybe it is a session which was generated from an external application and therefor it is empty!
+					session_id($_REQUEST["sid"]);
+					$e = new mb_notice("Grabbed session with id: ".session_id());
+					//kill dynamical session
+					//@unlink($tmpSessionFile);
+					$e = new mb_notice("Following user was found and will be used for authorization: ".Mapbender::session()->get('mb_user_id'));
+					$foundUserId = Mapbender::session()->get('mb_user_id');
+					if (!isset($foundUserId) || $foundUserId =='') {
+						$e = new mb_notice("No user found in the existing session - switch to the initial old one!");	
+						
+						session_id($oldsessionId);
+						//unset($tmpSessionFile);
+					} else {
+						//delete session as it will not be needed any longer
+						$e = new mb_notice("User found in grabbed session. Following temporary session will be deleted: ".$tmpSessionFile);
+						@unlink($tmpSessionFile);
+						unset($tmpSessionFile);
+					}
+				} else {
+				$e = new mb_notice("session exists but maybe no user in this session?");
 			}
+			break;
+			case "memcache":
+				//check if a session exists for the SID param and if this session
+				$currentSession = $memcache_obj->get($_REQUEST["sid"]);
+				if ($currentSession !== false && session_id() !== $_REQUEST["sid"]) {
+					//there is a current session for the requested url
+					$e = new mb_notice("A current session exists for this url and will be used!");
+					//$oldsessionId = session_id();
+					//get actual session as key from memcached - new if not there
+					$tmpSessionFile = session_id();
+					//$tmpSessionFile = ini_get('session.save_path')."/sess_".session_id();
+					//do the following only, if a user is in this session - maybe it is a session which was generated from an external application and therefor it is empty!
+					session_id($_REQUEST["sid"]);
+					$e = new mb_notice("Grabbed session with id: ".session_id());
+					//kill dynamical session
+					//@unlink($tmpSessionFile);
+					$e = new mb_notice("Following user was found and will be used for authorization: ".Mapbender::session()->get('mb_user_id'));
+					$foundUserId = Mapbender::session()->get('mb_user_id');
+					if (!isset($foundUserId) || $foundUserId =='') {
+						$e = new mb_notice("No user found in the existing session - switch to the initial one!");
+						session_id($tmpSessionFile);
+						//unset($tmpSessionFile);
+					} else {
+						//delete old initial session  as it will not be needed any longer
+						$e = new mb_notice("Following temporary session will be deleted: ".$tmpSessionFile);
+						//delete session from memcached
+						//@unlink($tmpSessionFile);
+						$memcache_obj->delete($tmpSessionFile);
+						unset($tmpSessionFile);
+					}	
+				}
+			break;
 		}
 	}
 }
+
+//check for user
+
 //check if current session has the same id as the session which is requested in the owsproxy url
 //exchange them, if they differ and redirect to an new one with the current session
 if (session_id() !== $_REQUEST["sid"]) {
@@ -98,8 +146,21 @@
 }
 //this is the request which may have been redirected
 //check for given user session with user_id which can be tested again the authorization
-if(!$_SESSION['mb_user_id']){
-	$e = new mb_notice("user_id not found in session");
+(integer)$foundUserId = Mapbender::session()->get('mb_user_id');
+$e = new mb_notice("Found user id: ".$foundUserId ." of type: ".gettype($foundUserId));
+
+
+if(is_int($foundUserId) &&  $foundUserId > 0){	
+	//Define the session to be temporary. This file can be deleted after the request was successful. It will be generated every time again.
+	switch (ini_get('session.save_handler')) {
+		case "files":
+			$tmpSessionFile = ini_get('session.save_path')."/sess_".session_id();
+		break;
+		case "memcache":
+			$tmpSessionFile = session_id();
+		break;
+	}
+	$e = new mb_notice("user_id not found in session!");
 	//if configured in mapbender.conf, create guest session so that also proxied service can be watched in external applications when they are available to the anonymous user
 	//only possible for webapplications - in case of desktop applications the user have to use his credentials and http_auth module
 	if (defined("OWSPROXY_ALLOW_PUBLIC_USER") && OWSPROXY_ALLOW_PUBLIC_USER && defined("PUBLIC_USER") && PUBLIC_USER != "") {
@@ -107,20 +168,31 @@
   		Mapbender::session()->set("mb_user_id",PUBLIC_USER);
 		Mapbender::session()->set("external_proxy_user",true);
 		Mapbender::session()->set("mb_user_ip",$_SERVER['REMOTE_ADDR']);
-		//Define name of temporal session file. This file can be deleted after the request was successful. It will be generated every time again.
-		$tmpSessionFile = ini_get('session.save_path')."/sess_".session_id();
 		$e = new mb_notice("Permission allowed for public user with id: ".PUBLIC_USER);
 	} else {
 		$e = new mb_notice("Permission denied - public user not allowed to access ressource!");
 		//kill actual session file 
-		$tmpSessionFile = ini_get('session.save_path')."/sess_".session_id();
-		$e = new mb_notice("delete temporary session file: ".$tmpSessionFile);
-		@unlink($tmpSessionFile);
-		throwE(array("Permission denied"," - no current session found and ","public user not allowed to access ressource!"));
-		die();
+		switch (ini_get('session.save_handler')) {
+			case "files":
+				$e = new mb_notice("delete temporary session file: ".$tmpSessionFile);
+				@unlink($tmpSessionFile);
+				throwE(array("Permission denied"," - no current session found and ","public user not allowed to access ressource!"));
+				unset($tmpSessionFile);
+				die();
+			break;
+			case "memcache":
+				$e = new mb_notice("delete temporary session ".session_id());
+				$memcache_obj->delete($tmpSessionFile);
+				//@unlink($tmpSessionFile);
+				throwE(array("Permission denied"," - no current session found and ","public user not allowed to access ressource!"));
+				unset($tmpSessionFile);
+				die();
+			break;
+		}
 	}
 } else {
-	$e= new mb_notice("mb_user_id found in session: ".$_SESSION['mb_user_id']);
+	$e = new mb_notice("mb_user_id found in session: ".$_SESSION['mb_user_id']);
+	$e = new mb_notice("tmpSessionFile: exists: ".isset($tmpSessionFile));
 }
 //start the session to be able to write urls to it - for 
 session_start();//maybe it was started by globalSettings.php
@@ -148,7 +220,7 @@
 		$request = $query->getRequest();
 		if(isset($auth)){
 			getCapabilities($request,$auth);
-			#$mb_exception = new mb_exception("auth: ".$auth['auth_type']);
+			#$mb_notice = new mb_notice("auth: ".$auth['auth_type']);
 		}
 		else {
 			getCapabilities($request);
@@ -241,10 +313,22 @@
 	default:
 		
 }
-if (isset($tmpSessionFile) && file_exists($tmpSessionFile)) {
-	$e = new mb_exception("Following no longer needed session will be deleted: ".$tmpSessionFile);
-	@unlink($tmpSessionFile);
+//why delete session here - only if it was temporary?
+switch (ini_get('session.save_handler')) {
+	case "files":
+		if (isset($tmpSessionFile) && file_exists($tmpSessionFile)) {
+			$e = new mb_notice("Following temporary session will be deleted: ".$tmpSessionFile);
+			@unlink($tmpSessionFile);
+		}
+	break;
+	case "memcache":
+		if (isset($tmpSessionFile) && $memcache_obj->get($tmpSessionFile) != false) {
+			$e = new mb_notice("Following temporary session will be deleted: ".$tmpSessionFile);
+			$memcache_obj->delete($tmpSessionFile);
+		}
+	break;
 }
+
 /*********************************************************/
 function throwE($e){
 	global $reqParams, $imageformats;
@@ -403,7 +487,7 @@
  */
 
 function getWfsFeaturesFromTransaction($data){
-	new mb_notice("owsproxy.getWfsFeaturesFromTransaction.data: ".$data);
+	new mb_exception("owsproxy.getWfsFeaturesFromTransaction.data: ".$data);
 	if(!$data || $data == ""){
 		return false;
 	}
@@ -484,11 +568,11 @@
 	preg_match_all($pattern,$content,$matches);
 	for($i=0; $i<count($matches[1]); $i++){
 		$req = $matches[1][$i];
-		$notice = new mb_notice("owsproxy found URL ".$i.": ".$req);
-		#$notice = new mb_notice("owsproxy id:".$req);
+		$notice = new mb_exception("owsproxy found URL ".$i.": ".$req);
+		#$notice = new mb_exception("owsproxy id:".$req);
 		$id = registerURL($req);
 		$extReq = setExternalRequest($id);
-		$notice = new mb_notice("MD5 URL ".$id." - external link: ".$extReq);
+		$notice = new mb_exception("MD5 URL ".$id." - external link: ".$extReq);
 		$content = str_replace($req,$extReq,$content);
 	}
 	return $content;
@@ -597,7 +681,7 @@
 	$res = db_prep_query($sql, $v, $t);
 	if($row = db_fetch_array($res)) {
 		if (strpos($row["legendurl"],'http') !== 0) {
-			$e = new mb_notice("combine legendurls!");
+			$e = new mb_exception("combine legendurls!");
 			return $getLegendUrl.$row["legendurl"];
 		}
 		return $row["legendurl"];
@@ -689,7 +773,7 @@
 		$t = array("i","s");
 		$res = db_prep_query($sql, $v, $t);
 		if(!($row = db_fetch_array($res))){
-			$notice = new mb_notice("Permissioncheck failed no wfs conf for wfs ".$service["wfs_id"]." with feturetype ".$feature);
+			$notice = new mb_exception("Permissioncheck failed no wfs conf for wfs ".$service["wfs_id"]." with feturetype ".$feature);
 			throwE(array("No wfs_conf data for featuretype ".$feature));
 			die();	
 		}
@@ -697,7 +781,7 @@
 		
 		//check permission
 		if(!in_array($conf_id, $myconfs)){
-			$notice = new mb_notice("Permissioncheck failed:".$conf_id." not in ".implode(",", $myconfs));
+			$notice = new mb_exception("Permissioncheck failed:".$conf_id." not in ".implode(",", $myconfs));
 			throwE(array("Permission denied."," -> ".$conf_id, implode(",", $myconfs)));
 			die();
 		}
@@ -708,7 +792,7 @@
 
 function checkLayerPermission($wms_id,$l){
 	global $n, $owsproxyService;
-//	$notice = new mb_notice("owsproxy: checkLayerpermission: wms: ".$wms_id.", layer: ".$l);
+//	$notice = new mb_exception("owsproxy: checkLayerpermission: wms: ".$wms_id.", layer: ".$l);
 	$myl = split(",",$l);
 	$r = array();
 	foreach($myl as $mysl){

Modified: trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql
===================================================================
--- trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql	2013-11-14 13:13:44 UTC (rev 8740)
+++ trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql	2013-11-28 12:39:19 UTC (rev 8741)
@@ -9,3 +9,149 @@
 ALTER TABLE wfs DROP COLUMN inspire_daily_requests;
 ALTER TABLE wfs ADD COLUMN inspire_annual_requests bigint;
 
+--new option to search for datasets in the internal mb_metadata table 
+-- View: search_dataset_view
+
+-- DROP VIEW search_dataset_view;
+
+CREATE OR REPLACE VIEW search_dataset_view AS 
+ SELECT dataset_dep.fkey_mb_user_id AS user_id, dataset_dep.dataset_id, dataset_dep.srs AS dataset_srs, dataset_dep.title, dataset_dep.abstract AS dataset_abstract, f_collect_searchtext_dataset(dataset_dep.dataset_id) AS searchtext, dataset_dep.dataset_timestamp, dataset_dep.department, dataset_dep.mb_group_name, dataset_dep.mb_group_title, dataset_dep.mb_group_country, 0 AS load_count, dataset_dep.mb_group_stateorprovince, f_collect_inspire_cat_dataset(dataset_dep.dataset_id) AS md_inspire_cats, f_collect_custom_cat_dataset(dataset_dep.dataset_id) AS md_custom_cats, f_collect_topic_cat_dataset(dataset_dep.dataset_id) AS md_topic_cats, dataset_dep.bbox, dataset_dep.mb_group_logo_path
+   FROM ( SELECT mb_metadata.the_geom as bbox, mb_metadata.ref_system as srs, mb_metadata.metadata_id AS dataset_id, mb_metadata.title, mb_metadata.abstract, mb_metadata.lastchanged as dataset_timestamp, mb_metadata.fkey_mb_user_id, user_dep.mb_group_id AS department, user_dep.mb_group_name, user_dep.mb_group_title, user_dep.mb_group_country, user_dep.mb_group_stateorprovince, user_dep.mb_group_logo_path
+           FROM ( SELECT registrating_groups.fkey_mb_user_id AS mb_user_id, mb_group.mb_group_id, mb_group.mb_group_name, mb_group.mb_group_title, mb_group.mb_group_country, mb_group.mb_group_stateorprovince, mb_group.mb_group_logo_path
+                   FROM registrating_groups, mb_group
+                  WHERE registrating_groups.fkey_mb_group_id = mb_group.mb_group_id) user_dep, mb_metadata
+          WHERE user_dep.mb_user_id = mb_metadata.fkey_mb_user_id) dataset_dep
+  ORDER BY dataset_dep.dataset_id;
+
+ALTER TABLE search_dataset_view
+  OWNER TO postgres;
+
+-- Function: f_collect_custom_cat_dataset(integer)
+
+-- DROP FUNCTION f_collect_custom_cat_dataset(integer);
+
+CREATE OR REPLACE FUNCTION f_collect_custom_cat_dataset(integer)
+  RETURNS text AS
+$BODY$DECLARE
+  i_dataset_id ALIAS FOR $1;
+  custom_cat_string  TEXT;
+  custom_cat_record  RECORD;
+
+BEGIN
+custom_cat_string := '';
+
+FOR custom_cat_record IN SELECT DISTINCT mb_metadata_custom_category.fkey_custom_category_id from mb_metadata_custom_category WHERE mb_metadata_custom_category.fkey_metadata_id=$1  LOOP
+custom_cat_string := custom_cat_string || '{' ||custom_cat_record.fkey_custom_category_id || '}';
+END LOOP ;
+  
+RETURN custom_cat_string;
+
+END;
+$BODY$
+  LANGUAGE plpgsql VOLATILE STRICT
+  COST 100;
+ALTER FUNCTION f_collect_custom_cat_dataset(integer)
+  OWNER TO postgres;
+
+-- Function: f_collect_inspire_cat_dataset(integer)
+
+-- DROP FUNCTION f_collect_inspire_cat_dataset(integer);
+
+CREATE OR REPLACE FUNCTION f_collect_inspire_cat_dataset(integer)
+  RETURNS text AS
+$BODY$DECLARE
+  i_dataset_id ALIAS FOR $1;
+  inspire_cat_string  TEXT;
+  inspire_cat_record  RECORD;
+
+BEGIN
+inspire_cat_string := '';
+
+FOR inspire_cat_record IN SELECT DISTINCT mb_metadata_inspire_category.fkey_inspire_category_id from mb_metadata_inspire_category WHERE mb_metadata_inspire_category.fkey_metadata_id=$1  LOOP
+inspire_cat_string := inspire_cat_string || '{' ||inspire_cat_record.fkey_inspire_category_id || '}';
+END LOOP ;
+  
+RETURN inspire_cat_string;
+
+END;
+$BODY$
+  LANGUAGE plpgsql VOLATILE STRICT
+  COST 100;
+ALTER FUNCTION f_collect_inspire_cat_dataset(integer)
+  OWNER TO postgres;
+
+-- Function: f_collect_topic_cat_dataset(integer)
+
+-- DROP FUNCTION f_collect_topic_cat_dataset(integer);
+
+CREATE OR REPLACE FUNCTION f_collect_topic_cat_dataset(integer)
+  RETURNS text AS
+$BODY$DECLARE
+  i_dataset_serial_id ALIAS FOR $1;
+  topic_cat_string  TEXT;
+  topic_cat_record  RECORD;
+
+BEGIN
+topic_cat_string := '';
+
+FOR topic_cat_record IN SELECT mb_metadata_md_topic_category.fkey_md_topic_category_id from mb_metadata_md_topic_category WHERE mb_metadata_md_topic_category.fkey_metadata_id=$1  LOOP
+topic_cat_string := topic_cat_string || '{' ||topic_cat_record.fkey_md_topic_category_id || '}';
+END LOOP ;
+  
+RETURN topic_cat_string;
+
+END;
+$BODY$
+  LANGUAGE plpgsql VOLATILE STRICT
+  COST 100;
+ALTER FUNCTION f_collect_topic_cat_dataset(integer)
+  OWNER TO postgres;
+
+
+-- Function: f_collect_searchtext_dataset(integer)
+
+-- DROP FUNCTION f_collect_searchtext_dataset(integer);
+
+CREATE OR REPLACE FUNCTION f_collect_searchtext_dataset(integer)
+  RETURNS text AS
+$BODY$
+DECLARE
+    p_dataset_id ALIAS FOR $1;
+    
+    r_keywords RECORD;
+    l_result TEXT;
+BEGIN
+    l_result := '';
+    l_result := l_result || (SELECT COALESCE(title, '') || ' ' || COALESCE(abstract, '') FROM mb_metadata WHERE metadata_id = p_dataset_id);
+    FOR r_keywords IN SELECT DISTINCT keyword FROM
+        (SELECT keyword FROM mb_metadata_keyword L JOIN keyword K ON (K.keyword_id = L.fkey_keyword_id AND L.fkey_metadata_id = p_dataset_id)
+        ) AS __keywords__ LOOP
+        l_result := l_result || ' ' || COALESCE(r_keywords.keyword, '');
+    END LOOP;
+   l_result := UPPER(l_result);
+   l_result := replace(replace(replace(replace(replace(replace(replace(l_result,'Ä','AE'),'ß','SS'),'Ö','OE'),'Ü','UE'),'ä','AE'),'ü','UE'),'ö','OE');
+
+    RETURN l_result;
+END;
+$BODY$
+  LANGUAGE plpgsql VOLATILE
+  COST 100;
+ALTER FUNCTION f_collect_searchtext_dataset(integer)
+  OWNER TO postgres;
+
+--DROP VIEW search_dataset_view;
+--DROP FUNCTION f_collect_custom_cat_dataset(integer);
+-- DROP FUNCTION f_collect_inspire_cat_dataset(integer);
+-- DROP FUNCTION f_collect_topic_cat_dataset(integer);
+-- DROP FUNCTION f_collect_searchtext_dataset(integer);
+
+ALTER TABLE custom_category ALTER COLUMN custom_category_key TYPE varchar(255);
+
+-- Column: inspire_download
+
+-- ALTER TABLE mb_metadata DROP COLUMN inspire_download;
+
+ALTER TABLE mb_metadata ADD COLUMN inspire_download integer;
+UPDATE mb_metadata SET inspire_download = 0 WHERE inspire_download IS NULL;
+
+alter table layer_style alter column legendurl type text;



More information about the Mapbender_commits mailing list