[Mapbender-commits] r9814 - in trunk/mapbender/http: classes php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Nov 14 07:43:06 PST 2017


Author: armin11
Date: 2017-11-14 07:43:06 -0800 (Tue, 14 Nov 2017)
New Revision: 9814

Modified:
   trunk/mapbender/http/classes/class_administration.php
   trunk/mapbender/http/php/mod_dataISOMetadata.php
   trunk/mapbender/http/php/mod_featuretypeISOMetadata.php
   trunk/mapbender/http/php/mod_layerISOMetadata.php
   trunk/mapbender/http/php/mod_showMetadata.php
   trunk/mapbender/http/php/wms.php
Log:
Enhancement of unique resource identifier handling for inspire

Modified: trunk/mapbender/http/classes/class_administration.php
===================================================================
--- trunk/mapbender/http/classes/class_administration.php	2017-11-13 15:58:53 UTC (rev 9813)
+++ trunk/mapbender/http/classes/class_administration.php	2017-11-14 15:43:06 UTC (rev 9814)
@@ -1914,7 +1914,6 @@
 		}
 	}
 	
-	
 	function getInspireDownloadOptionsForLayers($layerIdArray) {
 		$v = array();
 		$t = array();
@@ -2231,12 +2230,7 @@
 			}
 		return false;
 	 }
-	 
-	 
-	 
-	 
-	 
-	 
+	 	 
 	 /** identifies the Conf-FeatureServices where the current user is owner
 	 * 
 	 * @deprecated
@@ -2248,6 +2242,105 @@
 		$user = new User($userid); 	
 		return $user->getWfsConfByPermission();
 	 }
+    /**
+     * selects the organization info from registry 
+     *
+     * @params $resourceType string, $resourceId integer, $userId integer		
+     * @return array 
+     */
+    function getOrgaInfoFromRegistry($resourceType, $resourceId, $userId) {
+	switch ($resourceType) {
+		case "metadata":
+			$sql = "SELECT metadata_id as id, fkey_mb_group_id, fkey_mb_user_id as owner FROM mb_metadata WHERE metadata_id = $1";
+			break;
+		case "wms":
+			$sql = "SELECT wms_id as id, fkey_mb_group_id, wms_owner as owner FROM wms WHERE wms_id = $1";
+			break;
+		case "wfs":
+			$sql = "SELECT wfs_id as id, fkey_mb_group_id, wfs_owner as owner FROM wfs WHERE wfs_id = $1";
+			break;
+	}
+	//get resource owner information
+	$v = array($resourceId);
+	$t = array('i');
+	$res = db_prep_query($sql, $v, $t);
+	$owningInfo = db_fetch_array($res);
+	if (!isset($owningInfo['id'])) {
+		return false;
+	}
+	unset($sql, $v, $t, $res);
+	//get group information
+	if (!isset($owningInfo['fkey_mb_group_id']) or is_null($owningInfo['fkey_mb_group_id']) or $owningInfo['fkey_mb_group_id'] == 0){
+		$e = new mb_notice("classes/class_administration.php: fkey_mb_group_id not found!");
+		//Get information about owning user of the relation mb_user_mb_group (primary group of user) - alternatively the defined fkey_mb_group_id from the resource must be used!
+		$sql = "SELECT mb_group_name, mb_group_title, mb_group_id, mb_group_logo_path, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone, mb_group_homepage, mb_group_registry_url, a.timestamp FROM mb_group AS a, mb_user AS b, mb_user_mb_group AS c WHERE b.mb_user_id = $1  AND b.mb_user_id = c.fkey_mb_user_id AND c.fkey_mb_group_id = a.mb_group_id AND c.mb_user_mb_group_type=2 LIMIT 1";
+		$v = array($owningInfo['owner']);
+		$t = array('i');
+		$res = db_prep_query($sql, $v, $t);
+		$departmentMetadata = db_fetch_array($res);
+	} else {
+		$e = new mb_notice("classes/class_administration.php: fkey_mb_group_id found!");
+		$sql = "SELECT mb_group_name , mb_group_title, mb_group_id, mb_group_logo_path , mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone, mb_group_homepage, mb_group_registry_url, timestamp FROM mb_group WHERE mb_group_id = $1 LIMIT 1";
+		$v = array($owningInfo['fkey_mb_group_id']);
+		$t = array('i');
+		$res = db_prep_query($sql, $v, $t);
+		$departmentMetadata = db_fetch_array($res);
+	}
+	unset($sql, $v, $t, $res);
+	//infos about the owner of the service - he is the man who administrate the metadata - register the service
+	$sql = "SELECT mb_user_email, timestamp FROM mb_user WHERE mb_user_id = $1";
+	$v = array((integer)$owningInfo['owner']);
+	$t = array('i');
+	$res = db_prep_query($sql,$v,$t);
+	$userMetadata = db_fetch_array($res);
+	$e = new mb_notice("classes/class_administration.php (getOrgaInfoFromRegistry): mb_group_name  : ".$departmentMetadata['mb_group_name']);
+	$departmentMetadata['mb_user_email'] = $userMetadata['mb_user_email'];
+        $departmentMetadata['mb_user_timestamp'] = $userMetadata['timestamp'];
+	return $departmentMetadata;
+    }
+
+    /**
+     * selects the unique resource identifier codespace from registry info
+     *
+     * @params $departmentMetadata array, $metadataArray array		
+     * @return string 
+     */
+    function getIdentifierCodespaceFromRegistry($departmentMetadata, $metadataArray) {
+	if (isset($metadataArray['datasetid_codespace']) && $metadataArray['datasetid_codespace'] != "") {
+		if (substr($metadataArray['datasetid_codespace'], -1) !== '/') {
+			$uniqueResourceIdentifierCodespace = $metadataArray['datasetid_codespace'].'/';	
+		} else {
+			$uniqueResourceIdentifierCodespace =  $metadataArray['datasetid_codespace'];	
+		}
+	} else {
+		if (isset($departmentMetadata['mb_group_registry_url']) && $departmentMetadata['mb_group_registry_url'] !== "") {
+			if (substr($departmentMetadata['mb_group_registry_url'], -1) !== '/') {
+				$uniqueResourceIdentifierCodespace = $departmentMetadata['mb_group_registry_url'].'/';	
+			} else {
+				$uniqueResourceIdentifierCodespace =  $departmentMetadata['mb_group_registry_url'];	
+			}
+		} else {
+			if (isset($departmentMetadata['mb_group_homepage']) && $departmentMetadata['mb_group_homepage'] !== "") {
+				if (substr($departmentMetadata['mb_group_homepage'], -1) !== '/') {
+					$uniqueResourceIdentifierCodespace = $departmentMetadata['mb_group_homepage'].'/'.'registry/spatial/dataset/';	
+				} else {
+					$uniqueResourceIdentifierCodespace =  $departmentMetadata['mb_group_homepage'].'registry/spatial/dataset/';	
+				}
+			} else {
+				if (defined('METADATA_DEFAULT_CODESPACE')) {
+					if (substr($departmentMetadata['mb_group_homepage'], -1) !== '/') {
+						$uniqueResourceIdentifierCodespace = METADATA_DEFAULT_CODESPACE.'/'.'registry/spatial/dataset/';	
+					} else {
+						$uniqueResourceIdentifierCodespace =  METADATA_DEFAULT_CODESPACE.'registry/spatial/dataset/';	
+					}
+				} else {
+					$uniqueResourceIdentifierCodespace = "http://www.mapbender.org/registry/spatial/dataset/";
+				}
+			}
+		}
+	}
+	return $uniqueResourceIdentifierCodespace;
+    }
 	 
     /**
      * selects the gui_categories 

Modified: trunk/mapbender/http/php/mod_dataISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_dataISOMetadata.php	2017-11-13 15:58:53 UTC (rev 9813)
+++ trunk/mapbender/http/php/mod_dataISOMetadata.php	2017-11-14 15:43:06 UTC (rev 9814)
@@ -438,30 +438,11 @@
 	$t = array('i');
 	$res = db_prep_query($sql,$v,$t);
 	$mapbenderMetadata = db_fetch_array($res);
-	//infos about the registrating department, check first if a special metadata point of contact is defined in the service table - function from mod_showMetadata - TODO: should be defined in admin class
-	if (!isset($mapbenderMetadata['fkey_mb_group_id']) or is_null($mapbenderMetadata['fkey_mb_group_id']) or $mapbenderMetadata['fkey_mb_group_id'] == 0){
-		$e = new mb_notice("mod_dataISOMetadata.php: fkey_mb_group_id not found!");
-		//Get information about owning user of the relation mb_user_mb_group - alternatively the defined fkey_mb_group_id from the service must be used!
-		$sqlDep = "SELECT mb_group_name, mb_group_title, mb_group_id, mb_group_logo_path, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone, mb_group_homepage, mb_group_registry_url FROM mb_group AS a, mb_user AS b, mb_user_mb_group AS c WHERE b.mb_user_id = $1  AND b.mb_user_id = c.fkey_mb_user_id AND c.fkey_mb_group_id = a.mb_group_id AND c.mb_user_mb_group_type=2 LIMIT 1";
-		$vDep = array($mapbenderMetadata['wms_owner']);
-		$tDep = array('i');
-		$resDep = db_prep_query($sqlDep, $vDep, $tDep);
-		$departmentMetadata = db_fetch_array($resDep);
-	} else {
-		$e = new mb_notice("mod_dataISOMetadata.php: fkey_mb_group_id found!");
-		$sqlDep = "SELECT mb_group_name , mb_group_title, mb_group_id, mb_group_logo_path , mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone, mb_group_homepage, mb_group_registry_url FROM mb_group WHERE mb_group_id = $1 LIMIT 1";
-		$vDep = array($mapbenderMetadata['fkey_mb_group_id']);
-		$tDep = array('i');
-		$resDep = db_prep_query($sqlDep, $vDep, $tDep);
-		$departmentMetadata = db_fetch_array($resDep);
-	}
-	//infos about the owner of the service - he is the man who administrate the metadata - register the service
-	$sql = "SELECT mb_user_email ";
-	$sql .= "FROM mb_user WHERE mb_user_id = $1";
-	$v = array((integer)$mapbenderMetadata['wms_owner']);
-	$t = array('i');
-	$res = db_prep_query($sql,$v,$t);
-	$userMetadata = db_fetch_array($res);
+
+	//infos about the registrating department, check first if a special metadata point of contact is defined in the service table
+	$departmentMetadata = $admin->getOrgaInfoFromRegistry("wms", $mapbenderMetadata['wms_id'], $mapbenderMetadata['wms_owner']);
+	$userMetadata['mb_user_email'] = $departmentMetadata['mb_user_email'];
+
 	//check if resource is freely available to anonymous user - which are all users who search thru metadata catalogues:
 	$hasPermission=$admin->getLayerPermission($mapbenderMetadata['wms_id'],$mapbenderMetadata['layer_name'],PUBLIC_USER);
 	//schemas for metadata:

Modified: trunk/mapbender/http/php/mod_featuretypeISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_featuretypeISOMetadata.php	2017-11-13 15:58:53 UTC (rev 9813)
+++ trunk/mapbender/http/php/mod_featuretypeISOMetadata.php	2017-11-14 15:43:06 UTC (rev 9814)
@@ -139,32 +139,10 @@
 	$res = db_prep_query($sql,$v,$t);
 	$mbMeta = db_fetch_array($res);
 
-	//infos about the registrating department, check first if a special metadata point of contact is defined in the service table - function from mod_showMetadata - TODO: should be defined in admin class
-	if (!isset($mbMeta['fkey_mb_group_id']) || is_null($mbMeta['fkey_mb_group_id']) || $mbMeta['fkey_mb_group_id'] == 0){
-		$e = new mb_notice("mod_featuretypeISOMetadata.php: fkey_mb_group_id not found!");
-		//Get information about owning user of the relation mb_user_mb_group - alternatively the defined fkey_mb_group_id from the service must be used!
-		$sqlDep = "SELECT mb_group_name, mb_group_title, mb_group_id, mb_group_logo_path, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone FROM mb_group AS a, mb_user AS b, mb_user_mb_group AS c WHERE b.mb_user_id = $1  AND b.mb_user_id = c.fkey_mb_user_id AND c.fkey_mb_group_id = a.mb_group_id AND c.mb_user_mb_group_type=2 LIMIT 1";
-		$vDep = array($mbMeta['wfs_owner']);
-		$tDep = array('i');
-		$resDep = db_prep_query($sqlDep, $vDep, $tDep);
-		$departmentMetadata = db_fetch_array($resDep);
-	} else {
-		$e = new mb_notice("mod_featuretypeISOMetadata.php: fkey_mb_group_id found!");
-		$sqlDep = "SELECT mb_group_name , mb_group_title, mb_group_id, mb_group_logo_path , mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone FROM mb_group WHERE mb_group_id = $1 LIMIT 1";
-		$vDep = array($mbMeta['fkey_mb_group_id']);
-		$tDep = array('i');
-		$resDep = db_prep_query($sqlDep, $vDep, $tDep);
-		$departmentMetadata = db_fetch_array($resDep);
-	}
+	//infos about the registrating department, check first if a special metadata point of contact is defined in the service table
+	$departmentMetadata = $admin->getOrgaInfoFromRegistry("wfs", $mbMeta['wfs_id'], $mbMeta['wfs_owner']);
+	$userMetadata['mb_user_email'] = $departmentMetadata['mb_user_email'];
 
-	//infos about the owner of the service - he is the man who administrate the metadata - register the service
-	$sql = "SELECT mb_user_email ";
-	$sql .= "FROM mb_user WHERE mb_user_id = $1";
-	$v = array((integer)$mbMeta['wfs_owner']);
-	$t = array('i');
-	$res = db_prep_query($sql,$v,$t);
-	$userMetadata = db_fetch_array($res);
-
 	//TODO: check if resource is freely available to anonymous user - which are all users who search thru metadata catalogues:
 	//$hasPermission=$admin->getLayerPermission($mbMeta['wfs_id'],$mbMeta['layer_name'],PUBLIC_USER); ##################
 
@@ -409,7 +387,7 @@
 	//connectPoint **********************************
     $xmlBuilder->addValue($MD_Metadata,
             './gmd:identificationInfo/srv:SV_ServiceIdentification/srv:containsOperations/srv:SV_OperationMetadata/srv:connectPoint/gmd:CI_OnlineResource/gmd:linkage/gmd:URL',
-            "http://".$_SERVER['HTTP_HOST']."/mapbender/php/wfs.php?inspire=1&featuretype_id=".$mbMeta['featuretype_id']."&REQUEST=GetCapabilities&SERVICE=WFS&VERSION=".$mbMeta['wfs_version']);
+            "http://".$_SERVER['HTTP_HOST']."/mapbender/php/wfs.php?inspire=1&featuretype_id=".$mbMeta['featuretype_id']."&REQUEST=GetCapabilities&SERVICE=WFS");
 
 	//fill in operatesOn fields with datasetid if given
 	/*INSPIRE example: <srv:operatesOn xlink:href="http://image2000.jrc.it#image2000_1_nl2_multi"/>*/
@@ -417,39 +395,42 @@
 	/*TODO: Exchange HTTP_HOST with other baseurl*/
     $pos = 0;
 	while ($row_metadata = db_fetch_array($res_metadataurl)) {
-        switch ($row_metadata['origin']) {
-            case 'capabilities':
-                $pos++;
-                $xmlBuilder->addValue($MD_Metadata,
-                        './gmd:identificationInfo/srv:SV_ServiceIdentification/srv:operatesOn['.$pos.']/@xlink:href',
-                        "http://" . $_SERVER['HTTP_HOST'] . "/mapbender/php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" . $row_metadata['uuid']);
-                $xmlBuilder->addValue($MD_Metadata,
-                        './gmd:identificationInfo/srv:SV_ServiceIdentification/srv:operatesOn['.$pos.']/@uuidref',
-                        $row_metadata['datasetid']);
-                break;
-            case 'metador':
-                $pos++;
-                $xmlBuilder->addValue($MD_Metadata,
-                        './gmd:identificationInfo/srv:SV_ServiceIdentification/srv:operatesOn['.$pos.']/@xlink:href',
-                        "http://" . $_SERVER['HTTP_HOST'] . "/mapbender/php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" . $row_metadata['uuid']);
-                $xmlBuilder->addValue($MD_Metadata,
-                        './gmd:identificationInfo/srv:SV_ServiceIdentification/srv:operatesOn['.$pos.']/@uuidref',
-                        defined('METADATA_DEFAULT_CODESPACE') ? METADATA_DEFAULT_CODESPACE . "#" . $row_metadata['uuid'] : "http://www.mapbender.org#" . $row_metadata['uuid']);
-                break;
-            case 'external':
-                $pos++;
-                $xmlBuilder->addValue($MD_Metadata,
-                        './gmd:identificationInfo/srv:SV_ServiceIdentification/srv:operatesOn['.$pos.']/@xlink:href',
-                        "http://" . $_SERVER['HTTP_HOST'] . "/mapbender/php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" . $row_metadata['uuid']);
-                $xmlBuilder->addValue($MD_Metadata,
-                        './gmd:identificationInfo/srv:SV_ServiceIdentification/srv:operatesOn['.$pos.']/@uuidref',
-                        $row_metadata['uuid']);
-                break;
-            default:
-                break;
-        }
-    }
 
+		$uniqueResourceIdentifierCodespace = $admin->getIdentifierCodespaceFromRegistry($departmentMetadata, $row_metadata);
+
+        	switch ($row_metadata['origin']) {
+            	case 'capabilities':
+               		$pos++;
+                	$xmlBuilder->addValue($MD_Metadata,
+                        	'./gmd:identificationInfo/srv:SV_ServiceIdentification/srv:operatesOn['.$pos.']/@xlink:href',
+                        	"http://" . $_SERVER['HTTP_HOST'] . "/mapbender/php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" . $row_metadata['uuid']);
+                	$xmlBuilder->addValue($MD_Metadata,
+                        	'./gmd:identificationInfo/srv:SV_ServiceIdentification/srv:operatesOn['.$pos.']/@uuidref',
+                        	$uniqueResourceIdentifierCodespace.$row_metadata['datasetid']);
+                	break;
+            	case 'metador':
+                	$pos++;
+                	$xmlBuilder->addValue($MD_Metadata,
+                        	'./gmd:identificationInfo/srv:SV_ServiceIdentification/srv:operatesOn['.$pos.']/@xlink:href',
+                        	"http://" . $_SERVER['HTTP_HOST'] . "/mapbender/php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" . $row_metadata['uuid'].'#spatial_dataset_'.md5($row_metadata['uuid']));
+                	$xmlBuilder->addValue($MD_Metadata,
+                        	'./gmd:identificationInfo/srv:SV_ServiceIdentification/srv:operatesOn['.$pos.']/@uuidref',
+                       		$uniqueResourceIdentifierCodespace.$row_metadata['uuid']);
+                	break;
+            	case 'external':
+                	$pos++;
+                	$xmlBuilder->addValue($MD_Metadata,
+                        	'./gmd:identificationInfo/srv:SV_ServiceIdentification/srv:operatesOn['.$pos.']/@xlink:href',
+                        	"http://" . $_SERVER['HTTP_HOST'] . "/mapbender/php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" . $row_metadata['uuid']);
+                	$xmlBuilder->addValue($MD_Metadata,
+                        	'./gmd:identificationInfo/srv:SV_ServiceIdentification/srv:operatesOn['.$pos.']/@uuidref',
+                        	$uniqueResourceIdentifierCodespace.$row_metadata['datasetid']);
+                	break;
+            	default:
+                	break;
+        	}
+    	}
+
     $xmlBuilder->addValue($MD_Metadata,
             './gmd:distributionInfo/gmd:MD_Distribution/gmd:distributionFormat/gmd:MD_Format/gmd:name/@gco:nilReason',
             'missing');

Modified: trunk/mapbender/http/php/mod_layerISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_layerISOMetadata.php	2017-11-13 15:58:53 UTC (rev 9813)
+++ trunk/mapbender/http/php/mod_layerISOMetadata.php	2017-11-14 15:43:06 UTC (rev 9814)
@@ -126,31 +126,10 @@
 		$res = db_prep_query($sql,$v,$t);
 		$serviceMetadata = db_fetch_array($res);
 	}
-	//infos about the registrating department, check first if a special metadata point of contact is defined in the service table - function from mod_showMetadata - TODO: should be defined in admin class
-	if (!isset($mapbenderMetadata['fkey_mb_group_id']) or is_null($mapbenderMetadata['fkey_mb_group_id']) or $mapbenderMetadata['fkey_mb_group_id'] == 0){
-		$e = new mb_notice("mod_layerISOMetadata.php: fkey_mb_group_id not found!");
-		//Get information about owning user of the relation mb_user_mb_group - alternatively the defined fkey_mb_group_id from the service must be used!
-		$sqlDep = "SELECT mb_group_name, mb_group_title, mb_group_id, mb_group_logo_path, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone, mb_group_homepage, mb_group_registry_url FROM mb_group AS a, mb_user AS b, mb_user_mb_group AS c WHERE b.mb_user_id = $1  AND b.mb_user_id = c.fkey_mb_user_id AND c.fkey_mb_group_id = a.mb_group_id AND c.mb_user_mb_group_type=2 LIMIT 1";
-		$vDep = array($mapbenderMetadata['wms_owner']);
-		$tDep = array('i');
-		$resDep = db_prep_query($sqlDep, $vDep, $tDep);
-		$departmentMetadata = db_fetch_array($resDep);
-	} else {
-		$e = new mb_notice("mod_layerISOMetadata.php: fkey_mb_group_id found!");
-		$sqlDep = "SELECT mb_group_name , mb_group_title, mb_group_id, mb_group_logo_path , mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone, mb_group_homepage, mb_group_registry_url FROM mb_group WHERE mb_group_id = $1 LIMIT 1";
-		$vDep = array($mapbenderMetadata['fkey_mb_group_id']);
-		$tDep = array('i');
-		$resDep = db_prep_query($sqlDep, $vDep, $tDep);
-		$departmentMetadata = db_fetch_array($resDep);
-	}
 
-	//infos about the owner of the service - he is the man who administrate the metadata - register the service
-	$sql = "SELECT mb_user_email ";
-	$sql .= "FROM mb_user WHERE mb_user_id = $1";
-	$v = array((integer)$mapbenderMetadata['wms_owner']);
-	$t = array('i');
-	$res = db_prep_query($sql,$v,$t);
-	$userMetadata = db_fetch_array($res);
+	//infos about the registrating department, check first if a special metadata point of contact is defined in the service table
+	$departmentMetadata = $admin->getOrgaInfoFromRegistry("wms", $mapbenderMetadata['wms_id'], $mapbenderMetadata['wms_owner']);
+	$userMetadata['mb_user_email'] = $departmentMetadata['mb_user_email'];
 
 	//check if resource is freely available to anonymous user - which are all users who search thru metadata catalogues:
 	$hasPermission=$admin->getLayerPermission($mapbenderMetadata['wms_id'],$mapbenderMetadata['layer_name'],PUBLIC_USER);
@@ -749,40 +728,7 @@
 		//$row_metadata['datasetid_codespace']
 		//check codespace for trailing slash - if not there - add it ;-)
 		//unique resource identifier
-		if (isset($row_metadata['datasetid_codespace']) && $row_metadata['datasetid_codespace'] != "") {
-			if (substr($row_metadata['datasetid_codespace'], -1) !== '/') {
-				$uniqueResourceIdentifierCodespace = $row_metadata['datasetid_codespace'].'/';	
-			} else {
-				$uniqueResourceIdentifierCodespace =  $row_metadata['datasetid_codespace'];	
-			}
-		} else {
-
-			if (isset($departmentMetadata['mb_group_registry_url']) && $departmentMetadata['mb_group_registry_url'] !== "") {
-				if (substr($departmentMetadata['mb_group_registry_url'], -1) !== '/') {
-					$uniqueResourceIdentifierCodespace = $departmentMetadata['mb_group_registry_url'].'/';	
-				} else {
-					$uniqueResourceIdentifierCodespace =  $departmentMetadata['mb_group_registry_url'];	
-				}
-			} else {
-				if (isset($departmentMetadata['mb_group_homepage']) && $departmentMetadata['mb_group_homepage'] !== "") {
-					if (substr($departmentMetadata['mb_group_homepage'], -1) !== '/') {
-						$uniqueResourceIdentifierCodespace = $departmentMetadata['mb_group_homepage'].'/'.'registry/spatial/dataset/';	
-					} else {
-						$uniqueResourceIdentifierCodespace =  $departmentMetadata['mb_group_homepage'].'registry/spatial/dataset/';	
-					}
-				} else {
-					if (defined('METADATA_DEFAULT_CODESPACE')) {
-						if (substr($departmentMetadata['mb_group_homepage'], -1) !== '/') {
-							$uniqueResourceIdentifierCodespace = METADATA_DEFAULT_CODESPACE.'/'.'registry/spatial/dataset/';	
-						} else {
-							$uniqueResourceIdentifierCodespace =  METADATA_DEFAULT_CODESPACE.'registry/spatial/dataset/';	
-						}
-					} else {
-						$uniqueResourceIdentifierCodespace = "http://www.mapbender.org/registry/spatial/dataset/";
-					}
-				}
-			}
-		}
+		$uniqueResourceIdentifierCodespace = $admin->getIdentifierCodespaceFromRegistry($departmentMetadata, $row_metadata);
 		switch ($row_metadata['origin']) {
 			case 'capabilities':
 				$operatesOn=$iso19139->createElement("srv:operatesOn");

Modified: trunk/mapbender/http/php/mod_showMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_showMetadata.php	2017-11-13 15:58:53 UTC (rev 9813)
+++ trunk/mapbender/http/php/mod_showMetadata.php	2017-11-14 15:43:06 UTC (rev 9814)
@@ -618,25 +618,15 @@
 
 */
 
-//$e = new mb_exception("mod_showMetadata: fkey_mb_group_id from wms or wfs table: ".$resourceMetadata['fkey_mb_group_id']);
-if (!isset($resourceMetadata['fkey_mb_group_id']) or is_null($resourceMetadata['fkey_mb_group_id']) or $resourceMetadata['fkey_mb_group_id'] == 0){
-	$e = new mb_notice("mod_showMetadata: fkey_mb_group_id not found!");
-	//Get information about owning user of the relation mb_user_mb_group - alternatively the defined fkey_mb_group_id from the service must be used!
-	$sqlDep = "SELECT mb_group_name as metadatapointofcontactorgname, mb_group_title as metadatapointofcontactorgtitle, mb_group_id, mb_group_logo_path  as metadatapointofcontactorglogo, mb_group_address as metadatapointofcontactorgaddress, mb_group_email as metadatapointofcontactorgemail, mb_group_postcode as metadatapointofcontactorgpostcode, mb_group_city as metadatapointofcontactorgcity, mb_group_voicetelephone as metadatapointofcontactorgtelephone, mb_group_facsimiletelephone as metadatapointofcontactorgfax FROM mb_group AS a, mb_user AS b, mb_user_mb_group AS c WHERE b.mb_user_id = $1  AND b.mb_user_id = c.fkey_mb_user_id AND c.fkey_mb_group_id = a.mb_group_id AND c.mb_user_mb_group_type=2 LIMIT 1";
-	$vDep = array($resourceMetadata['owner']);
-	$tDep = array('i');
-	$resDep = db_prep_query($sqlDep, $vDep, $tDep);
-	$metadataContactGroup = db_fetch_array($resDep);
-	$e = new mb_notice("mod_showMetadata: mb_group_id: ".$metadataContactGroup['mb_group_id']);
-	$e = new mb_notice("mod_showMetadata: mb_group_logo_path: ".$metadataContactGroup['metadatapointofcontactorglogo']);
-} else {
-	$e = new mb_notice("mod_showMetadata: fkey_mb_group_id found!");
-	$sqlDep = "SELECT mb_group_name as metadatapointofcontactorgname, mb_group_title as metadatapointofcontactorgtitle, mb_group_id, mb_group_logo_path  as metadatapointofcontactorglogo, mb_group_address as metadatapointofcontactorgaddress, mb_group_email as metadatapointofcontactorgemail, mb_group_postcode as metadatapointofcontactorgpostcode, mb_group_city as metadatapointofcontactorgcity, mb_group_voicetelephone as metadatapointofcontactorgtelephone, mb_group_facsimiletelephone as metadatapointofcontactorgfax FROM mb_group WHERE mb_group_id = $1 LIMIT 1";
-	$vDep = array($resourceMetadata['fkey_mb_group_id']);
-	$tDep = array('i');
-	$resDep = db_prep_query($sqlDep, $vDep, $tDep);
-	$metadataContactGroup = db_fetch_array($resDep);
+if ($resource == 'layer') {
+	$serviceType = "wms";
 }
+if ($resource == 'featuretype') {
+	$serviceType = "wfs";
+}
+
+$metadataContactGroup = $admin->getOrgaInfoFromRegistry($serviceType, $resourceMetadata['serviceid'], $resourceMetadata['owner']);
+
 //Get Geometry Type if featuretype info was requested
 if ($resource == 'featuretype') {
 	$getTypeSql = "SELECT element_id, element_type from wfs_element WHERE fkey_featuretype_id = $1 AND element_type LIKE '%PropertyType';";
@@ -647,8 +637,6 @@
 	$resourceMetadata['featuretype_geomType'] = $featuretypeElements['element_type'];
 }
 
-
-
 $e = new mb_notice("mod_showMetadata: mb_group_name: ".$metadataContactGroup['mb_group_name']);
 //db select for layer previews
 if ($resource == 'wms' or $resource == 'layer') {
@@ -784,8 +772,8 @@
 	$html .= '};';
 	$html .= '</script>';
 
-/*if ($metadataContactGroup['metadatapointofcontactorglogo'] != '') {
-	$html .= "<img src='".$metadataContactGroup['metadatapointofcontactorglogo']."'  height='30'>";
+/*if ($metadataContactGroup['mb_group_logo_path'] != '') {
+	$html .= "<img src='".$metadataContactGroup['mb_group_logo_path']."'  height='30'>";
 }
 //TODO use right name
 $html .= displayText($resourceMetadata['contactorganization']);
@@ -905,8 +893,8 @@
 
 
 
-if ($metadataContactGroup['metadatapointofcontactorglogo'] != '') {
-	$html .= $t_a.$translation['contactOrganization'].$t_b."<img src='".$metadataContactGroup['metadatapointofcontactorglogo']."'  height='30'>";
+if ($metadataContactGroup['mb_group_logo_path'] != '') {
+	$html .= $t_a.$translation['contactOrganization'].$t_b."<img src='".$metadataContactGroup['mb_group_logo_path']."'  height='30'>";
 }
 $html .= displayText($metadataContactGroup['metadatacontactorganization']).$t_c;
 if ($resourceMetadata['contentabstract'] != '') {
@@ -1255,14 +1243,14 @@
 	$html .= '<h4>'.$translation['metadataProvider'].'</h4>';
 }
 $html .= $tableBegin;
-if ($metadataContactGroup['metadatapointofcontactorglogo'] != '') {
-	$html .= $t_a.$translation['logo'].$t_b."<img src='".$metadataContactGroup['metadatapointofcontactorglogo']."'  height='30'>".$t_c;
+if ($metadataContactGroup['mb_group_logo_path'] != '') {
+	$html .= $t_a.$translation['logo'].$t_b."<img src='".$metadataContactGroup['mb_group_logo_path']."'  height='30'>".$t_c;
 }
 
-$html .= $t_a.$translation['contactOrganization'].$t_b.displayText($metadataContactGroup['metadatapointofcontactorgtitle']).$t_c;
-$html .= $t_a.$translation['contactAddress'].$t_b.displayText($metadataContactGroup['metadatapointofcontactorgaddress']).$t_c;
-$html .= $t_a.$translation['city'].$t_b.displayText($metadataContactGroup['metadatapointofcontactorgpostcode'].' '.$metadataContactGroup['metadatapointofcontactorgcity']).$t_c;
-$html .= $t_a.$translation['email'].$t_b.displayText($metadataContactGroup['metadatapointofcontactorgemail']).$t_c;
+$html .= $t_a.$translation['contactOrganization'].$t_b.displayText($metadataContactGroup['mb_group_title']).$t_c;
+$html .= $t_a.$translation['contactAddress'].$t_b.displayText($metadataContactGroup['mb_group_address']).$t_c;
+$html .= $t_a.$translation['city'].$t_b.displayText($metadataContactGroup['mb_group_postcode'].' '.$metadataContactGroup['mb_group_city']).$t_c;
+$html .= $t_a.$translation['email'].$t_b.displayText($metadataContactGroup['mb_group_email']).$t_c;
 $html .= $tableEnd;
 if ($resource !== 'wmc') {
 	$html .= '<h4>'.$translation['serviceProvider'].'</h4>';

Modified: trunk/mapbender/http/php/wms.php
===================================================================
--- trunk/mapbender/http/php/wms.php	2017-11-13 15:58:53 UTC (rev 9813)
+++ trunk/mapbender/http/php/wms.php	2017-11-14 15:43:06 UTC (rev 9814)
@@ -158,40 +158,21 @@
 	echo createExceptionXml("Layer not defined", "Unknown layer id " . $layerId);
 	die;
 }
-//get group information from wms table if not get it from another source
-if (!isset($wms_row['fkey_mb_group_id']) or is_null($wms_row['fkey_mb_group_id']) or $wms_row['fkey_mb_group_id'] == 0){
-	$e = new mb_notice("wms.php: fkey_mb_group_id not found!");
-	//Get information about owning user of the relation mb_user_mb_group - alternatively the defined fkey_mb_group_id from the service must be used!
-	$sqlDep = "SELECT mb_group_name as metadatapointofcontactorgname, mb_group_homepage as metadatapointofcontactorgurl, mb_group_registry_url as metadatapointofcontactregistryurl, mb_group_title as metadatapointofcontactorgtitle, mb_group_id, mb_group_logo_path  as metadatapointofcontactorglogo, mb_group_address as metadatapointofcontactorgaddress, mb_group_email as metadatapointofcontactorgemail, mb_group_postcode as metadatapointofcontactorgpostcode, mb_group_city as metadatapointofcontactorgcity, mb_group_voicetelephone as metadatapointofcontactorgtelephone, mb_group_facsimiletelephone as metadatapointofcontactorgfax FROM mb_group AS a, mb_user AS b, mb_user_mb_group AS c WHERE b.mb_user_id = $1  AND b.mb_user_id = c.fkey_mb_user_id AND c.fkey_mb_group_id = a.mb_group_id AND c.mb_user_mb_group_type=2 LIMIT 1";
-	$vDep = array($wms_row['wms_owner']);
-	$tDep = array('i');
-	$resDep = db_prep_query($sqlDep, $vDep, $tDep);
-	$metadataContactGroup = db_fetch_array($resDep);
-	$e = new mb_notice("wms.php: owner: ".$wms_row['owner']);
-	$e = new mb_notice("wms.php: mb_group_id: ".$metadataContactGroup['mb_group_id']);
-	$e = new mb_notice("wms.php: mb_group_logo_path: ".$metadataContactGroup['metadatapointofcontactorglogo']);
-} else {
-	$e = new mb_notice("wms.php: fkey_mb_group_id found!");
-	$sqlDep = "SELECT mb_group_name as metadatapointofcontactorgname, mb_group_homepage as metadatapointofcontactorgurl, mb_group_registry_url as metadatapointofcontactregistryurl, mb_group_title as metadatapointofcontactorgtitle, mb_group_id, mb_group_logo_path  as metadatapointofcontactorglogo, mb_group_address as metadatapointofcontactorgaddress, mb_group_email as metadatapointofcontactorgemail, mb_group_postcode as metadatapointofcontactorgpostcode, mb_group_city as metadatapointofcontactorgcity, mb_group_voicetelephone as metadatapointofcontactorgtelephone, mb_group_facsimiletelephone as metadatapointofcontactorgfax FROM mb_group WHERE mb_group_id = $1 LIMIT 1";
-	$vDep = array($wms_row['fkey_mb_group_id']);
-	$tDep = array('i');
-	$resDep = db_prep_query($sqlDep, $vDep, $tDep);
-	$metadataContactGroup = db_fetch_array($resDep);
-}
 
-$AuthorityName = $metadataContactGroup["metadatapointofcontactorgname"];
+//infos about the registrating department, check first if a special metadata point of contact is defined in the service table
+$metadataContactGroup = $admin->getOrgaInfoFromRegistry("wms", $wms_row["wms_id"], $wms_row["wms_owner"]);
 
+$AuthorityName = $metadataContactGroup["mb_group_name"];
+//TODO: Problem - there is no single codespace if datasets have different ones !!!! - Find a generic solution  
+//$uniqueResourceIdentifierCodespace = $admin->getIdentifierCodespaceFromRegistry($departmentMetadata, $row_metadata);
+
 //check for given urls
-if (isset($metadataContactGroup["metadatapointofcontactregistryurl"]) && $metadataContactGroup["metadatapointofcontactregistryurl"] !== "") {
-	$AuthorityUrl = $metadataContactGroup["metadatapointofcontactregistryurl"];
+if (isset($metadataContactGroup["mb_group_registry_url"]) && $metadataContactGroup["mb_group_registry_url"] !== "") {
+	$AuthorityUrl = $metadataContactGroup["mb_group_registry_url"];
 } else {
-	$AuthorityUrl = $metadataContactGroup["metadatapointofcontactorgurl"];
+	$AuthorityUrl = $metadataContactGroup["mb_group_homepage"];
 }
 
-if (substr($AuthorityUrl, -1) !== '/') {
-	$AuthorityUrl = $AuthorityUrl.'/';		
-}
-
 if ($AuthorityName == '') {
 	$AuthorityName = "defaultauthority";
 }



More information about the Mapbender_commits mailing list