[Mapbender-commits] r7705 - in trunk/mapbender/http: classes plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Mar 15 09:27:30 EDT 2011


Author: armin11
Date: 2011-03-15 06:27:30 -0700 (Tue, 15 Mar 2011)
New Revision: 7705

Modified:
   trunk/mapbender/http/classes/class_wfsToDb.php
   trunk/mapbender/http/classes/class_wfs_factory.php
   trunk/mapbender/http/classes/class_wms.php
   trunk/mapbender/http/plugins/mb_metadata_edit.js
   trunk/mapbender/http/plugins/mb_metadata_edit.php
   trunk/mapbender/http/plugins/mb_metadata_server.php
   trunk/mapbender/http/plugins/mb_metadata_wfs_edit.js
   trunk/mapbender/http/plugins/mb_metadata_wfs_edit.php
   trunk/mapbender/http/plugins/mb_metadata_wfs_server.php
Log:
Debug of metadata editors for wms and wfs. Extending reader and writer for wms and wfs objects for new columns uuid, ..._network_access.

Modified: trunk/mapbender/http/classes/class_wfsToDb.php
===================================================================
--- trunk/mapbender/http/classes/class_wfsToDb.php	2011-03-14 08:55:43 UTC (rev 7704)
+++ trunk/mapbender/http/classes/class_wfsToDb.php	2011-03-15 13:27:30 UTC (rev 7705)
@@ -113,8 +113,8 @@
 		$sql .= "city = $16, deliverypoint = $17, administrativearea = $18, ";
 		$sql .= "postalcode = $19, voice = $20, facsimile = $21, ";
 		$sql .= "electronicmailaddress = $22, country = $23, ";
-		$sql .= "wfs_timestamp = $24 ";
-		$sql .= "WHERE wfs_id = $25";
+		$sql .= "wfs_timestamp = $24, wfs_network_access = $25, fkey_mb_group_id = $26 ";
+		$sql .= "WHERE wfs_id = $27";
 
 		$v = array(
 			$aWfs->getVersion(), 
@@ -140,11 +140,13 @@
 			$aWfs->facsimile,
 			$aWfs->electronicMailAddress,
 			$aWfs->country, 
-			strtotime("now"), 
+			strtotime("now"),
+			$aWfs->network_access,
+			$aWfs->fkey_mb_group_id,
 			$aWfs->id
 		);
 			
-		$t = array('s', 's', 's', 's', 's', 's', 's', 's' ,'s' ,'s' ,'s' ,'s','s' ,'s','s','s','s','s','s','s','s','s','s','i' ,'i');
+		$t = array('s', 's', 's', 's', 's', 's', 's', 's' ,'s' ,'s' ,'s' ,'s','s' ,'s','s','s','s','s','s','s','s','s','s','i','i','i','i');
 		$e = new mb_exception("UPDATING WFS " . $aWfs->id);
 		$res = db_prep_query($sql, $v, $t);
 		if (!$res) {

Modified: trunk/mapbender/http/classes/class_wfs_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_factory.php	2011-03-14 08:55:43 UTC (rev 7704)
+++ trunk/mapbender/http/classes/class_wfs_factory.php	2011-03-15 13:27:30 UTC (rev 7705)
@@ -59,7 +59,7 @@
 	 * @param $id Integer
 	 * @param $aWfs Wfs is being created by the subclass
 	 */
-	public function createFromDb ($id) {
+	public function createFromDb ($id, $withProxyUrls = true) {
 		if (func_num_args() == 2) {
 			$aWfs = func_get_arg(1);
 		}
@@ -90,14 +90,14 @@
 			$aWfs->getCapabilitiesDoc = db_result($res, $cnt, "wfs_getcapabilities_doc");
 			$aWfs->uploadUrl = db_result($res, $cnt, "wfs_upload_url");
 			$aWfs->describeFeatureType = db_result($res, $cnt, "wfs_describefeaturetype");			
-			if(!$hasOwsproxyUrl){
+			if(!$hasOwsproxyUrl || !$withProxyUrls){
 				$aWfs->getFeature = db_result($res, $cnt, "wfs_getfeature");
 			}
 			else{
 				$aWfs->getFeature = $owsproxyUrl;
 			}
 			new mb_notice("class_wfs_factory.getFeature.url: ".$aWfs->getFeature);
-			if(!$hasOwsproxyUrl){
+			if(!$hasOwsproxyUrl || !$withProxyUrls){
 				$aWfs->transaction = db_result($res, $cnt, "wfs_transaction");
 			}
 			else{
@@ -108,7 +108,10 @@
 			$aWfs->accessconstraints = db_result($res, $cnt, "accessconstraints");
 			$aWfs->owner = db_result($res, $cnt, "wfs_owner");
 			$aWfs->timestamp = db_result($res, $cnt, "wfs_timestamp");
-			
+			$aWfs->timestamp_create = db_result($res, $cnt, "wfs_timestamp_create");
+			$aWfs->network_access = db_result($res, $cnt, "wfs_network_access");
+			$aWfs->fkey_mb_group_id = db_result($res, $cnt, "fkey_mb_group_id");
+			$aWfs->uuid = db_result($res, $cnt, "uuid");
 			// Featuretypes
 			$sql_fe = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 ORDER BY featuretype_id";
 			$v = array($aWfs->id);
@@ -124,6 +127,7 @@
 				$ft->title = db_result($res_fe, $cnt_fe, "featuretype_title");
 				$ft->summary = db_result($res_fe, $cnt_fe, "featuretype_abstract");
 				$ft->srs = db_result($res_fe, $cnt_fe, "featuretype_srs");
+				$ft->uuid = db_result($res_fe, $cnt_fe, "uuid");
 				
 				// Elements
 				$sql_el = "SELECT * FROM wfs_element WHERE fkey_featuretype_id = $1 ORDER BY element_id";

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2011-03-14 08:55:43 UTC (rev 7704)
+++ trunk/mapbender/http/classes/class_wms.php	2011-03-15 13:27:30 UTC (rev 7705)
@@ -2158,14 +2158,16 @@
 		$sql .= "wms_userlayer = $11, ";
 		$sql .= "wms_userstyle = $12, ";
 		$sql .= "wms_remotewfs = $13, ";
-		$sql .= "wms_network_access = $14 ";
-		$sql .= " WHERE wms_id = $15";
+		$sql .= "wms_network_access = $14, ";
+		$sql .= "fkey_mb_group_id = $15, ";
+		$sql .= "uuid = $16 ";
+		$sql .= " WHERE wms_id = $17";
 	
 		$v = array($this->wms_version,$this->wms_getcapabilities,
 			$this->wms_getmap,$this->wms_getfeatureinfo,$this->wms_getlegendurl,
 			$admin->char_encode($this->wms_getcapabilities_doc),$this->wms_upload_url,Mapbender::session()->get("mb_user_id"),strtotime("now"),
-			$this->wms_supportsld,$this->wms_userlayer,$this->wms_userstyle,$this->wms_remotewfs,$this->wms_network_access, $myWMS);
-		$t = array('s','s','s','s','s','s','s','i','i','s','s','s','s','i','i');
+			$this->wms_supportsld,$this->wms_userlayer,$this->wms_userstyle,$this->wms_remotewfs,$this->wms_network_access, $this->fkey_mb_group_id ,$this->uuid ,$myWMS);
+		$t = array('s','s','s','s','s','s','s','i','i','s','s','s','s','i','i','s','i');
 	
 		$res = db_prep_query($sql,$v,$t);
 		if(!$res){
@@ -2189,14 +2191,16 @@
 			$sql .= "contactvoicetelephone = $13, ";
 			$sql .= "contactfacsimiletelephone = $14, ";
 			$sql .= "contactelectronicmailaddress = $15, ";
-			$sql .= "wms_network_access = $16 ";
-			$sql .= " WHERE wms_id = $17";
+			$sql .= "wms_network_access = $16, ";
+			$sql .= "fkey_mb_group_id = $17, ";
+			$sql .= "uuid = $18 ";
+			$sql .= " WHERE wms_id = $19";
 		
 			$v = array($this->wms_title,$this->wms_abstract,$this->fees,$this->accessconstraints,
 				$this->contactperson,$this->contactposition,$this->contactorganization,$this->address,
 				$this->city,$this->stateorprovince,$this->postcode,$this->country,$this->contactvoicetelephone,
-				$this->contactfacsimiletelephone,$this->contactelectronicmailaddress,$this->wms_network_access,$myWMS);
-			$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','i','i');
+				$this->contactfacsimiletelephone,$this->contactelectronicmailaddress,$this->wms_network_access, $this->fkey_mb_group_id ,$this->uuid, $myWMS);
+			$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','i','i','s','i');
 			$res = db_prep_query($sql,$v,$t);
 			if(!$res){
 				db_rollback();	
@@ -2802,6 +2806,7 @@
 			$this->country = $row2["country"];
 			$this->contactelectronicmailaddress = $row2["contactelectronicmailaddress"];
 			$this->wms_network_access = $row2["wms_network_access"];
+			$this->fkey_mb_group_id = $row2["fkey_mb_group_id"];
 			$this->uuid = $row2["uuid"];
 			
 			#some default

Modified: trunk/mapbender/http/plugins/mb_metadata_edit.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_edit.js	2011-03-14 08:55:43 UTC (rev 7704)
+++ trunk/mapbender/http/plugins/mb_metadata_edit.js	2011-03-15 13:27:30 UTC (rev 7705)
@@ -83,6 +83,29 @@
 		req.send();		
 	};
 
+	this.fillMdContact = function(obj) {
+		// get mdContact from server per fkey_mb_group_id
+		var req = new Mapbender.Ajax.Request({
+			url: "../plugins/mb_metadata_server.php",
+			method: "getContactMetadata",
+			parameters: {
+				"id": obj
+			},
+			callback: function (obj, result, message) {
+				if (!result) {
+					return;
+				}
+				//fill form on a not so easy way ;-)
+				for (var key in obj) {
+					if (key == 'mb_group_title' || key == 'mb_group_address' || key == 'mb_group_postcode' || key == 'mb_group_city' || key == 'mb_group_logo_path' || key == 'mb_group_email' || key == 'mb_group_voicetelephone'){
+						document.getElementById(key).value = obj[key];
+					}
+				}
+			}
+		});
+		req.send();
+	}	
+
 	this.fill = function (obj) {
 		$metadataForm.easyform("fill", obj);
 	};

Modified: trunk/mapbender/http/plugins/mb_metadata_edit.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_edit.php	2011-03-14 08:55:43 UTC (rev 7704)
+++ trunk/mapbender/http/plugins/mb_metadata_edit.php	2011-03-15 13:27:30 UTC (rev 7705)
@@ -1,5 +1,6 @@
 <?php
 	require_once dirname(__FILE__) . "/../../core/globalSettings.php";
+	require_once dirname(__FILE__) . "/../classes/class_user.php";
 ?>
 
 <fieldset>
@@ -14,27 +15,28 @@
 	<p>
 		<label for="wms_title"><?php echo _mb("WMS Title (OWS)");?>:</label>
 		<input name="wms_title" id="wms_title" class="required"/>
-		<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+		<img class="metadata_img" title="<?php echo _mb("INSPIRE 1.1: resource title");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 	<p>
     	<label for="wms_abstract"><?php echo _mb("WMS Abstract (OWS)");?>:</label>
     	<input name="wms_abstract" id="wms_abstract"/>
-    	<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+    	<img class="metadata_img" title="<?php echo _mb("INSPIRE 1.2: resource abstract");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+	<img class="help-dialog" title="<?php echo _mb("Help for INSPIRE Abstract");?>" help="{text:'<?php echo _mb("INSPIRE demands some information about the spatial resolution in the abstract tag of the capabilities document. Please insert some words about it.");?>'}" src="../img/questionmark.png" alt="" />
 	</p>
 	<p>
 		<label for="wms_keywords"><?php echo _mb("WMS Keywords (OWS)");?>:</label>
     	<input readonly="readonly" name="wms_keywords" id="wms_keywords"/>
-    	<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+    	<img class="metadata_img" title="<?php echo _mb("INSPIRE 3: keyword");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 	<p>
 		<label for="fees"><?php echo _mb("WMS Fees (OWS)");?>:</label>
     	<input name="fees" id="fees"/>
-    	<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+    	<img class="metadata_img" title="<?php echo _mb("INSPIRE 8.1: conditions applying to access and use");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 	<p>
 		<label for="accessconstraints"><?php echo _mb("WMS AccessConstraints (OWS)");?>:</label>
 		<input name="accessconstraints" id="accessconstraints"/>
-    	<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+    	<img class="metadata_img" title="<?php echo _mb("INSPIRE 8.2: limitations on public access");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 <?php
 	$sql = "SELECT termsofuse_id, name FROM termsofuse";
@@ -82,7 +84,7 @@
 	<p>
 		<label for="contactorganization"><?php echo _mb("Contact Organisation (WMS)");?>:</label>
     	<input name="contactorganization" id="contactorganization"/>
-    	<img  class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+    	<img  class="metadata_img" title="<?php echo _mb("INSPIRE 9.1: responsible party name");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 	<p>
 		<label for="address"><?php echo _mb("Contact Address (WMS)");?>:</label>
@@ -107,16 +109,78 @@
 	<p>
 	  	<label for="contactelectronicmailaddress"><?php echo _mb("Contact Electronic Mail Address (WMS)");?>:</label>
       	<input name="contactelectronicmailaddress" id="contactelectronicmailaddress" class="required email"/>
-     	<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+     	<img class="metadata_img" title="<?php echo _mb("INSPIRE 9.1: responsible party email");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 	<p>
 	  	<label for="wms_timestamp_create"><?php echo _mb("Date of first registration (Registry)");?>:</label>
       	<input readonly="readonly" name="wms_timestamp_create" id="wms_timestamp_create"/>
-      	<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+      	<img class="metadata_img" title="<?php echo _mb("INSPIRE 5.2: date of publication");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 	<p>
 	  	<label for="wms_timestamp"><?php echo _mb("Date of last revision (Registry)");?>:</label>
       	<td><input readonly="readonly" name="wms_timestamp" id="wms_timestamp"/>
-      	<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+      	<img class="metadata_img" title="<?php echo _mb("INSPIRE 10.2: metadata date");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 </fieldset>
+<fieldset>
+	<legend><?php echo _mb("Metadata Point of contact (registry)");?>: <img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Information about the organization which is responsible for contributing the metadata. The information will be automaticcaly generated from the mapbender database mb_group object. The information came from the primary group of the service owner or from a group which has authorized the owner to publish metadata in their name.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+
+<?php
+//selectbox for organizationswhich allows the publishing of metadatasets for the specific user
+	$sql = "SELECT fkey_mb_group_id, mb_group_name FROM (SELECT fkey_mb_group_id FROM mb_user_mb_group WHERE fkey_mb_user_id = $1 AND (mb_user_mb_group_type = 3 OR mb_user_mb_group_type = 2)) AS a LEFT JOIN mb_group ON a.fkey_mb_group_id = mb_group.mb_group_id";
+	$user = new User();
+	$userId = $user->id;
+	$v = array($userId);
+	$t = array('i');
+	$res = db_prep_query($sql,$v,$t);
+	$metadataGroup = array();
+	while ($row = db_fetch_assoc($res)) {
+		$metadataGroup[$row["fkey_mb_group_id"]] = $row["mb_group_name"];
+	}
+?>
+	<p>
+		<label for="mb_group_name"><?php echo _mb("Organization responsible for metadata");?>:</label>
+    	<select name="fkey_mb_group_id" id="fkey_mb_group_id" onChange="var chosenoption=this.options[this.selectedIndex];$('#mb_md_edit').mapbender().fillMdContact(chosenoption.value);">
+			<option value="0">...</option>
+<?php
+	foreach ($metadataGroup as $key => $value) {
+		echo "<option value='" . $key . "'>" . htmlentities($value, ENT_QUOTES, CHARSET) . "</option>";
+	}
+?>
+		</select>
+    	<img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Selection of different organizations which authorized you to publish metadata in their name.");?>'}" src="../img/questionmark.png" alt="" />
+	</p>
+<!-- end of selection for the different organizations -->
+
+	<p>
+		<label for="mb_group_title"><?php echo _mb("Title");?>:</label>
+		<input readonly="readonly" name="mb_group_title" id="mb_group_title"/>
+		<img class="metadata_img" title="<?php echo _mb("INSPIRE 10.1: metadata point of contact name");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+	</p>
+	<p>
+		<label for="mb_group_address"><?php echo _mb("Address");?>:</label>
+		<input readonly="readonly" name="mb_group_address" id="mb_group_address"/>
+	</p>
+	<p>
+		<label for="mb_group_postcode"><?php echo _mb("Postcode");?>:</label>
+		<input readonly="readonly" name="mb_group_postcode" id="mb_group_postcode"/>
+	</p>
+	<p>
+		<label for="mb_group_city"><?php echo _mb("City");?>:</label>
+		<input readonly="readonly" name="mb_group_city" id="mb_group_city"/>
+	</p>
+	<p>
+		<label for="mb_group_voicetelephone"><?php echo _mb("Telephone");?>:</label>
+		<input readonly="readonly" name="mb_group_voicetelephone" id="mb_group_voicetelephone"/>
+	</p>
+	<p>
+		<label for="mb_group_email"><?php echo _mb("Email");?>:</label>
+		<input readonly="readonly" name="mb_group_email" id="mb_group_email"/>
+		<img class="metadata_img" title="<?php echo _mb("INSPIRE 10.1: metadata point of contact email");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+	</p>
+	<p>
+		<label for="mb_group_logo_path"><?php echo _mb("Logo url");?>:</label>
+		<input readonly="readonly" name="mb_group_logo_path" id="mb_group_logo_path"/>
+	</p>
+
+</fieldset>

Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php	2011-03-14 08:55:43 UTC (rev 7704)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php	2011-03-15 13:27:30 UTC (rev 7705)
@@ -98,19 +98,22 @@
 			"contactelectronicmailaddress",
 			"wms_timestamp", 
 			"wms_timestamp_create",
-			"wms_network_access"
+			"wms_network_access",
+			"fkey_mb_group_id"
 		);
 
 		$resultObj = array();
 		foreach ($fields as $field) {
 			if ($field == "wms_timestamp" || $field == "wms_timestamp_create") {
 				if ($wms->$field != "") {
+	
 					$resultObj[$field] = date('d.m.Y', $wms->$field);
 					
 				}
 			}
 			else {
-				$resultObj[$field] = $wms->$field;	
+				$resultObj[$field] = $wms->$field;
+				//$e = new mb_exception("mb_metadata_server: resultObject[".$field."]=".$wms->$field);	
 			}
 		}
 		
@@ -154,6 +157,60 @@
 		}
 		
 		$resultObj['wms_network_access'] = $resultObj['wms_network_access'] == 1 ? true : false;
+		
+		//get contact information from group relation
+		//check if fkey_mb_group_id has been defined before - in service table
+		if ($resultObj["fkey_mb_group_id"] == "" || !isset($resultObj["fkey_mb_group_id"])){
+			$e = new mb_notice("fkey_mb_group_id is null or empty");
+			//check if primary group is set 
+			$user = new User;
+			$userId = $user->id;
+			$e = new mb_exception("user id:".$userId);
+			$sql = <<<SQL
+	
+SELECT fkey_mb_group_id, mb_group_name, mb_group_title, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_logo_path, mb_group_voicetelephone FROM (SELECT fkey_mb_group_id FROM mb_user_mb_group WHERE fkey_mb_user_id = $1 AND mb_user_mb_group_type = 2) AS a LEFT JOIN mb_group ON a.fkey_mb_group_id = mb_group.mb_group_id
+
+SQL;
+			$v = array($userId);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+			$row = array();
+			if ($res) {
+				$row = db_fetch_assoc($res);
+				$resultObj["fkey_mb_group_id"] = $row["fkey_mb_group_id"];
+				$resultObj["mb_group_title"] = $row["mb_group_title"];
+				$resultObj["mb_group_address"] = $row["mb_group_address"];
+				$resultObj["mb_group_email"] = $row["mb_group_email"];
+				$resultObj["mb_group_postcode"] = $row["mb_group_postcode"];
+				$resultObj["mb_group_city"] = $row["mb_group_city"];
+				$resultObj["mb_group_logo_path"] = $row["mb_group_logo_path"];
+				$resultObj["mb_group_voicetelephone"] = $row["mb_group_voicetelephone"];
+			}
+		} else {
+			//get current fkey_mb_group_id and the corresponding data
+			$sql = <<<SQL
+	
+SELECT mb_group_name, mb_group_title, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_logo_path, mb_group_voicetelephone FROM mb_group WHERE mb_group_id = $1
+
+SQL;
+			$v = array($resultObj["fkey_mb_group_id"]);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+			$row = array();
+			if ($res) {
+				$row = db_fetch_assoc($res);
+				$resultObj["mb_group_title"] = $row["mb_group_title"];
+				$resultObj["mb_group_address"] = $row["mb_group_address"];
+				$resultObj["mb_group_email"] = $row["mb_group_email"];
+				$resultObj["mb_group_postcode"] = $row["mb_group_postcode"];
+				$resultObj["mb_group_city"] = $row["mb_group_city"];
+				$resultObj["mb_group_logo_path"] = $row["mb_group_logo_path"];
+				$resultObj["mb_group_voicetelephone"] = $row["mb_group_voicetelephone"];
+			}
+			else {
+				$resultObj["fkey_mb_group_id"] = null;
+			}
+		}
 		$ajaxResponse->setResult($resultObj);
 		$ajaxResponse->setSuccess(true);
 
@@ -343,7 +400,8 @@
 			"country", 
 			"contactelectronicmailaddress",
 			"wms_termsofuse",
-			"wms_network_access"
+			"wms_network_access",
+			"fkey_mb_group_id"
 		);
 		foreach ($columns as $c) {
 			$value = $data->wms->$c;
@@ -447,6 +505,33 @@
 		$ajaxResponse->setSuccess(true);		
 		
 		break;
+	case "getContactMetadata" :
+		$mbGroupId = $ajaxResponse->getParameter("id");
+		$sql = <<<SQL
+	
+SELECT mb_group_name, mb_group_title, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_logo_path, mb_group_voicetelephone FROM mb_group WHERE mb_group_id = $1
+
+SQL;
+		$v = array($mbGroupId);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		$row = array();
+		if ($res) {
+			$row = db_fetch_assoc($res);
+			$resultObj["fkey_mb_group_id"] = $mbGroupId;
+			$resultObj["mb_group_name"] = $row["mb_group_name"];
+			$resultObj["mb_group_title"] = $row["mb_group_title"];
+			$resultObj["mb_group_address"] = $row["mb_group_address"];
+			$resultObj["mb_group_email"] = $row["mb_group_email"];
+			$resultObj["mb_group_postcode"] = $row["mb_group_postcode"];
+			$resultObj["mb_group_city"] = $row["mb_group_city"];
+			$resultObj["mb_group_logo_path"] = $row["mb_group_logo_path"];
+			$resultObj["mb_group_voicetelephone"] = $row["mb_group_voicetelephone"];	
+		}
+		$ajaxResponse->setResult($resultObj);
+		$ajaxResponse->setSuccess(true);
+		break;
+
 	default: 
 		$ajaxResponse->setSuccess(false);
 		$ajaxResponse->setMessage(_mb("An unknown error occured."));

Modified: trunk/mapbender/http/plugins/mb_metadata_wfs_edit.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_wfs_edit.js	2011-03-14 08:55:43 UTC (rev 7704)
+++ trunk/mapbender/http/plugins/mb_metadata_wfs_edit.js	2011-03-15 13:27:30 UTC (rev 7705)
@@ -84,6 +84,29 @@
 		req.send();		
 	};
 
+	this.fillMdContact = function(obj) {
+		// get mdContact from server per fkey_mb_group_id
+		var req = new Mapbender.Ajax.Request({
+			url: "../plugins/mb_metadata_server.php",
+			method: "getContactMetadata",
+			parameters: {
+				"id": obj
+			},
+			callback: function (obj, result, message) {
+				if (!result) {
+					return;
+				}
+				//fill form on a not so easy way ;-)
+				for (var key in obj) {
+					if (key == 'mb_group_title' || key == 'mb_group_address' || key == 'mb_group_postcode' || key == 'mb_group_city' || key == 'mb_group_logo_path' || key == 'mb_group_email' || key == 'mb_group_voicetelephone'){
+						document.getElementById(key).value = obj[key];
+					}
+				}
+			}
+		});
+		req.send();
+	}	
+
 	this.fill = function (obj) {
 		$metadataForm.easyform("fill", obj);
 	};

Modified: trunk/mapbender/http/plugins/mb_metadata_wfs_edit.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_wfs_edit.php	2011-03-14 08:55:43 UTC (rev 7704)
+++ trunk/mapbender/http/plugins/mb_metadata_wfs_edit.php	2011-03-15 13:27:30 UTC (rev 7705)
@@ -1,5 +1,6 @@
 <?php
 	require_once dirname(__FILE__) . "/../../core/globalSettings.php";
+	require_once dirname(__FILE__) . "/../classes/class_user.php";
 ?>
 
 <fieldset>
@@ -14,27 +15,27 @@
 	<p>
 		<label for="title"><?php echo _mb("WFS Title (OWS)");?>:</label>
 		<input name="title" id="title" class="required"/>
-		<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+		<img class="metadata_img" title="<?php echo _mb("INSPIRE 1.1: resource title");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 	<p>
     	<label for="summary"><?php echo _mb("WFS Abstract (OWS)");?>:</label>
     	<input name="summary" id="summary"/>
-    	<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+    	<img class="metadata_img" title="<?php echo _mb("INSPIRE 1.2: resource abstract");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 	<p>
 		<label for="wfs_keywords"><?php echo _mb("WFS Keywords (OWS)");?>:</label>
     	<input readonly="readonly" name="wfs_keywords" id="wfs_keywords"/>
-    	<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+    	<img class="metadata_img" title="<?php echo _mb("INSPIRE 3: keyword");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 	<p>
 		<label for="fees"><?php echo _mb("WFS Fees (OWS)");?>:</label>
     	<input name="fees" id="fees"/>
-    	<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+    	<img class="metadata_img" title="<?php echo _mb("INSPIRE 8.1: conditions applying to access and use");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 	<p>
 		<label for="accessconstraints"><?php echo _mb("WFS AccessConstraints (OWS)");?>:</label>
 		<input name="accessconstraints" id="accessconstraints"/>
-    	<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+    	<img class="metadata_img" title="<?php echo _mb("INSPIRE 8.2: limitations on public access");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 <?php
 	$sql = "SELECT termsofuse_id, name FROM termsofuse";
@@ -54,8 +55,12 @@
 	}
 ?>
 		</select>
-    	<img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Auswahl von vordefinierten Lizenzen hinsichtlich Gebühren und Zugriffsbeschränkungen.");?>'}" src="../img/questionmark.png" alt="" />
+    	<img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Selection of predefined licences.");?>'}" src="../img/questionmark.png" alt="" />
 	</p>
+	<p>
+	  	<label for="network_access"><?php echo _mb("Restricted Network Access (Registry)");?>:</label>
+      		<input name="network_access" id="network_access" type="checkbox"/>
+	</p>
 </fieldset>
 <fieldset>
 	<legend><?php echo _mb("WFS Provider Section (OWS)");?></legend>
@@ -78,7 +83,7 @@
 	<p>
 		<label for="providerName"><?php echo _mb("Contact Organisation (WFS)");?>:</label>
     	<input name="providerName" id="providerName"/>
-    	<img  class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+    	<img  class="metadata_img" title="<?php echo _mb("INSPIRE 9.1: responsible party name");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 	<p>
 		<label for="deliveryPoint"><?php echo _mb("Contact Address (WFS)");?>:</label>
@@ -103,20 +108,78 @@
 	<p>
 	  	<label for="electronicMailAddress"><?php echo _mb("Contact Electronic Mail Address (WFS)");?>:</label>
       	<input name="electronicMailAddress" id="electronicMailAddress" class="required email"/>
-     	<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+     	<img class="metadata_img" title="<?php echo _mb("INSPIRE 9.1: responsible party email");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 	<p>
 	  	<label for="wfs_timestamp_create"><?php echo _mb("Date of first registration (Registry)");?>:</label>
       	<input readonly="readonly" name="wfs_timestamp_create" id="wfs_timestamp_create"/>
-      	<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+      	<img class="metadata_img" title="<?php echo _mb("INSPIRE 5.2: date of publication");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
 	<p>
 	  	<label for="wfs_timestamp"><?php echo _mb("Date of last revision (Registry)");?>:</label>
       	<td><input readonly="readonly" name="wfs_timestamp" id="wfs_timestamp"/>
-      	<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+      	<img class="metadata_img" title="<?php echo _mb("INSPIRE 10.2: metadata date");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 	</p>
-<p>
-	  	<label for="wfs_network_access"><?php echo _mb("Restricted Network Access (Registry)");?>:</label>
-      	<input name="wfs_network_access" id="wfs_network_access" type="checkbox"/>
+</fieldset>
+<fieldset>
+	<legend><?php echo _mb("Metadata Point of contact (registry)");?>: <img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Information about the organization which is responsible for contributing the metadata. The information will be automaticcaly generated from the mapbender database mb_group object. The information came from the primary group of the service owner or from a group which has authorized the owner to publish metadata in their name.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+
+<?php
+//selectbox for organizationswhich allows the publishing of metadatasets for the specific user
+	$sql = "SELECT fkey_mb_group_id, mb_group_name FROM (SELECT fkey_mb_group_id FROM mb_user_mb_group WHERE fkey_mb_user_id = $1 AND (mb_user_mb_group_type = 3 OR mb_user_mb_group_type = 2)) AS a LEFT JOIN mb_group ON a.fkey_mb_group_id = mb_group.mb_group_id";
+	$user = new User();
+	$userId = $user->id;
+	$v = array($userId);
+	$t = array('i');
+	$res = db_prep_query($sql,$v,$t);
+	$metadataGroup = array();
+	while ($row = db_fetch_assoc($res)) {
+		$metadataGroup[$row["fkey_mb_group_id"]] = $row["mb_group_name"];
+	}
+?>
+	<p>
+		<label for="mb_group_name"><?php echo _mb("Organization responsible for metadata");?>:</label>
+    	<select name="fkey_mb_group_id" id="fkey_mb_group_id" onChange="var chosenoption=this.options[this.selectedIndex];$('#mb_md_wfs_edit').mapbender().fillMdContact(chosenoption.value);">
+			<option value="0">...</option>
+<?php
+	foreach ($metadataGroup as $key => $value) {
+		echo "<option value='" . $key . "'>" . htmlentities($value, ENT_QUOTES, CHARSET) . "</option>";
+	}
+?>
+		</select>
+    	<img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Selection of different organizations which authorized you to publish metadata in their name.");?>'}" src="../img/questionmark.png" alt="" />
 	</p>
+<!-- end of selection for the different organizations -->
+
+	<p>
+		<label for="mb_group_title"><?php echo _mb("Title");?>:</label>
+		<input readonly="readonly" name="mb_group_title" id="mb_group_title"/>
+		<img class="metadata_img" title="<?php echo _mb("INSPIRE 10.1: metadata point of contact name");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+	</p>
+	<p>
+		<label for="mb_group_address"><?php echo _mb("Address");?>:</label>
+		<input readonly="readonly" name="mb_group_address" id="mb_group_address"/>
+	</p>
+	<p>
+		<label for="mb_group_postcode"><?php echo _mb("Postcode");?>:</label>
+		<input readonly="readonly" name="mb_group_postcode" id="mb_group_postcode"/>
+	</p>
+	<p>
+		<label for="mb_group_city"><?php echo _mb("City");?>:</label>
+		<input readonly="readonly" name="mb_group_city" id="mb_group_city"/>
+	</p>
+	<p>
+		<label for="mb_group_voicetelephone"><?php echo _mb("Telephone");?>:</label>
+		<input readonly="readonly" name="mb_group_voicetelephone" id="mb_group_voicetelephone"/>
+	</p>
+	<p>
+		<label for="mb_group_email"><?php echo _mb("Email");?>:</label>
+		<input readonly="readonly" name="mb_group_email" id="mb_group_email"/>
+		<img class="metadata_img" title="<?php echo _mb("INSPIRE 10.1: metadata point of contact email");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+	</p>
+	<p>
+		<label for="mb_group_logo_path"><?php echo _mb("Logo url");?>:</label>
+		<input readonly="readonly" name="mb_group_logo_path" id="mb_group_logo_path"/>
+	</p>
+
 </fieldset>

Modified: trunk/mapbender/http/plugins/mb_metadata_wfs_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_wfs_server.php	2011-03-14 08:55:43 UTC (rev 7704)
+++ trunk/mapbender/http/plugins/mb_metadata_wfs_server.php	2011-03-15 13:27:30 UTC (rev 7705)
@@ -79,7 +79,7 @@
 individualname, positionname, providername, voice, 
 facsimile, deliverypoint, city, 
 administrativearea, postalcode, country, electronicmailaddress,
-wfs_timestamp, wfs_timestamp_create 
+wfs_timestamp, wfs_timestamp_create, wfs_network_access, fkey_mb_group_id 
 FROM wfs WHERE wfs_id = $wfsId;
 
 SQL;
@@ -104,9 +104,11 @@
 		$resultObj['postalCode'] = $row['postalcode'];
 		$resultObj['country'] = $row['country'];
 		$resultObj['electronicMailAddress'] = $row['electronicmailaddress'];
-		$resultObj['wfs_timestamp'] = $row['wfs_timestamp'] != "" ? date('d.m.Y', $row['wfs_timestamp']) : "";
-		$resultObj['wfs_timestamp_create'] = $row['wfs_timestamp_create'] != "" ? date('d.m.Y', $row['wfs_timestamp_create']) : "";
-		
+		$resultObj['timestamp'] = $row['wfs_timestamp'] != "" ? date('d.m.Y', $row['wfs_timestamp']) : "";
+		$resultObj['timestamp_create'] = $row['wfs_timestamp_create'] != "" ? date('d.m.Y', $row['wfs_timestamp_create']) : "";
+		$resultObj['network_access'] = $row['wfs_network_access'];
+		$resultObj['fkey_mb_group_id'] = $row['fkey_mb_group_id'];
+
 		$keywordSql = <<<SQL
 	
 SELECT DISTINCT keyword FROM keyword, wfs_featuretype_keyword 
@@ -137,8 +139,64 @@
 		else {
 			$resultObj["wfs_termsofuse"] = null;
 		}
-		
 
+		$resultObj['wfs_network_access'] = $resultObj['wfs_network_access'] == 1 ? true : false;
+
+		//get contact information from group relation
+		//check if fkey_mb_group_id has been defined before - in service table
+		if ($resultObj["fkey_mb_group_id"] == "" || !isset($resultObj["fkey_mb_group_id"])){
+			$e = new mb_notice("fkey_mb_group_id is null or empty");
+			//check if primary group is set 
+			$user = new User;
+			$userId = $user->id;
+			$e = new mb_exception("user id:".$userId);
+			$sql = <<<SQL
+	
+SELECT fkey_mb_group_id, mb_group_name, mb_group_title, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_logo_path, mb_group_voicetelephone FROM (SELECT fkey_mb_group_id FROM mb_user_mb_group WHERE fkey_mb_user_id = $1 AND mb_user_mb_group_type = 2) AS a LEFT JOIN mb_group ON a.fkey_mb_group_id = mb_group.mb_group_id
+
+SQL;
+			$v = array($userId);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+			$row = array();
+			if ($res) {
+				$row = db_fetch_assoc($res);
+				$resultObj["fkey_mb_group_id"] = $row["fkey_mb_group_id"];
+				$resultObj["mb_group_title"] = $row["mb_group_title"];
+				$resultObj["mb_group_address"] = $row["mb_group_address"];
+				$resultObj["mb_group_email"] = $row["mb_group_email"];
+				$resultObj["mb_group_postcode"] = $row["mb_group_postcode"];
+				$resultObj["mb_group_city"] = $row["mb_group_city"];
+				$resultObj["mb_group_logo_path"] = $row["mb_group_logo_path"];
+				$resultObj["mb_group_voicetelephone"] = $row["mb_group_voicetelephone"];
+			}
+		} else {
+			//get current fkey_mb_group_id and the corresponding data
+			$sql = <<<SQL
+	
+SELECT mb_group_name, mb_group_title, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_logo_path, mb_group_voicetelephone FROM mb_group WHERE mb_group_id = $1
+
+SQL;
+			$v = array($resultObj["fkey_mb_group_id"]);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+			$row = array();
+			if ($res) {
+				$row = db_fetch_assoc($res);
+				$resultObj["mb_group_title"] = $row["mb_group_title"];
+				$resultObj["mb_group_address"] = $row["mb_group_address"];
+				$resultObj["mb_group_email"] = $row["mb_group_email"];
+				$resultObj["mb_group_postcode"] = $row["mb_group_postcode"];
+				$resultObj["mb_group_city"] = $row["mb_group_city"];
+				$resultObj["mb_group_logo_path"] = $row["mb_group_logo_path"];
+				$resultObj["mb_group_voicetelephone"] = $row["mb_group_voicetelephone"];
+			}
+			else {
+				$resultObj["fkey_mb_group_id"] = null;
+			}
+		}
+
+
 		$ajaxResponse->setResult($resultObj);
 		$ajaxResponse->setSuccess(true);
 
@@ -287,7 +345,7 @@
 		getWfs($wfsId);
 		
 		$wfsFactory = new UniversalWfsFactory();
-		$wfs = $wfsFactory->createFromDb($wfsId);
+		$wfs = $wfsFactory->createFromDb($wfsId, false);
 		if (is_null($wfs)) {
 			$ajaxResponse->setSuccess(false);
 			$ajaxResponse->setMessage(_mb("Invalid WFS ID."));
@@ -310,7 +368,12 @@
 			"postalCode", 
 			"country", 
 			"electronicMailAddress",
-			"wfs_termsofuse"
+			"wfs_termsofuse",
+			"timestamp",
+			"timestamp_create",
+			"network_access",
+			"fkey_mb_group_id",
+			"uuid"
 		);
 		foreach ($columns as $c) {
 			$value = $data->wfs->$c;
@@ -373,7 +436,11 @@
 				}
 			}
 		}
-
+		if ($wfs->network_access == "on") {
+			$wfs->network_access = intval('1');
+		} else {
+			$wfs->network_access = intval('0');
+		}
 		$wfs->update();
 
 		
@@ -388,4 +455,4 @@
 }
 
 $ajaxResponse->send();
-?>
\ No newline at end of file
+?>



More information about the Mapbender_commits mailing list