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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue May 29 08:35:13 PDT 2012


Author: armin11
Date: 2012-05-29 08:35:12 -0700 (Tue, 29 May 2012)
New Revision: 8366

Modified:
   trunk/mapbender/http/classes/class_wfsToDb.php
   trunk/mapbender/http/classes/class_wfs_factory.php
   trunk/mapbender/http/php/mod_deleteWFS.php
   trunk/mapbender/http/plugins/mb_metadata_wfs_server.php
Log:
Handling of MetadataURL for WFS featuretypes

Modified: trunk/mapbender/http/classes/class_wfsToDb.php
===================================================================
--- trunk/mapbender/http/classes/class_wfsToDb.php	2012-05-25 12:52:15 UTC (rev 8365)
+++ trunk/mapbender/http/classes/class_wfsToDb.php	2012-05-29 15:35:12 UTC (rev 8366)
@@ -266,7 +266,8 @@
 	 */
 	public static function delete ($aWfs) {
 		//first delete coupled metadata, cause there is no contraints in the database to do so
-		$this->deleteFeatureTypeMetadataUrls($aWfs->id);
+		$e = new mb_notice("Deleting MetadataURLs");
+		WfsToDb::deleteFeatureTypeMetadataUrls($aWfs->id);
 		//then delete wfs itself
 		$sql = "DELETE FROM wfs WHERE wfs_id = $1";
 		$v = array($aWfs->id);
@@ -897,8 +898,9 @@
 	 * @param $wfsId integer
 	 */
 	private static function deleteFeatureTypeMetadataUrls ($wfsId) {
+	
+		$e = new mb_notice("Deleting coupled WFS MetadataURLs from database.");
 
-
 		$sql = "DELETE FROM mb_metadata INNER JOIN (select * from ows_relation_metadata where (internal is NULL OR internal != 1) and fkey_featuretype_id in ";
 		$sql .= "(select fkey_featuretype_id from wfs_featuretype where fkey_wfs_id = $1)) as relation on ";
 		$sql .= "mb_metadata.metadata_id = relation.fkey_metadata_id where mb_metadata.origin = 'capabilities'";

Modified: trunk/mapbender/http/classes/class_wfs_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_factory.php	2012-05-25 12:52:15 UTC (rev 8365)
+++ trunk/mapbender/http/classes/class_wfs_factory.php	2012-05-29 15:35:12 UTC (rev 8366)
@@ -58,14 +58,14 @@
 	 * @param $id Integer
 	 * @param $aWfs Wfs is being created by the subclass
 	 */
-	public function createFromDb ($id, $withProxyUrls = true) {
+	public function createFromDb ($id) {
 		if (func_num_args() == 2) {
-			$aWfs = func_get_arg(1);
+			$aWfs = func_get_arg(1);//set object to use given wfs object to be extented
 		}
 		else {
 			return null;
 		}
-
+		$withProxyUrls = true;
 		// WFS
 		$sql = "SELECT * FROM wfs WHERE wfs_id = $1;";
 		$v = array($id);

Modified: trunk/mapbender/http/php/mod_deleteWFS.php
===================================================================
--- trunk/mapbender/http/php/mod_deleteWFS.php	2012-05-25 12:52:15 UTC (rev 8365)
+++ trunk/mapbender/http/php/mod_deleteWFS.php	2012-05-29 15:35:12 UTC (rev 8366)
@@ -17,7 +17,10 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
 require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs.php");
+require_once(dirname(__FILE__)."/../classes/class_universal_wfs_factory.php");
 
 $e_id="deleteWFS";
 $gui_id = Mapbender::session()->get("mb_user_gui");
@@ -48,7 +51,7 @@
 <?php
 echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
 ?>
-<title>Delete WFS - All Users</title>
+<title>Delete own WFS</title>
 <?php
 include '../include/dyn_css.php';
 ?>
@@ -66,10 +69,6 @@
 }
 
 
-
-
-
-
 function sel(){
 	var ind = document.form1.wfsList.selectedIndex;
 	var wfsData = document.form1.wfsList.options[ind].value.split("###");
@@ -129,16 +128,33 @@
 <?php
 $logged_user_name=Mapbender::session()->get("mb_user_name");
 $logged_user_id=Mapbender::session()->get("mb_user_id");
+###delete if del is set thru GET Parameter
 
-###delete
-
-if($del!='-1'){
-	 $sql = "DELETE FROM wfs WHERE wfs_id = '".$del."'";
-	 $res = db_query($sql);
+//$del = intval($del);
+if (isset($del) && $del != '') {
+	//parse as integer
+	$del = intval($del);
+	if(is_int($del)){
+		$myWfsFactory = new UniversalWfsFactory();
+		$myWfs = $myWfsFactory->createFromDb($del);
+		if ($myWfs->exists()) {
+			if ($myWfs->owner == $logged_user_id) {
+				$e = new mb_exception("User with id ".$logged_user_id." delete wfs with id ".$myWfs->id);
+				$myWfs->delete();
+			} else {
+				$e = new mb_exception("User with id ".$logged_user_id." is not allowed to delete wfs with id ".$myWfs->id);
+			}
+		} else {
+			$e = new mb_exception("Wfs with id ".$myWfs->id." does not exists in mapbender database!");
+		}
+	} else {
+	echo "GET Value for wfs to delete is no integer: ".$del;
+	}
+} else {
+	echo "GET Value for wfs to delete is not set or empty<br>";
 }
+//echo "user logged in: ".$logged_user_id;
 
-
-
 //adopted for owned wfs and not all!!!!!!
 
 $sql_wfs = "SELECT * FROM wfs ";

Modified: trunk/mapbender/http/plugins/mb_metadata_wfs_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_wfs_server.php	2012-05-25 12:52:15 UTC (rev 8365)
+++ trunk/mapbender/http/plugins/mb_metadata_wfs_server.php	2012-05-29 15:35:12 UTC (rev 8366)
@@ -1050,7 +1050,7 @@
 		
 		$wfsFactory = new UniversalWfsFactory();
 		
-		$wfs = $wfsFactory->createFromDb($wfsId, false);
+		$wfs = $wfsFactory->createFromDb($wfsId);
 		
 
 		if (is_null($wfs)) {



More information about the Mapbender_commits mailing list