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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Oct 29 05:20:13 EDT 2009


Author: kmq
Date: 2009-10-29 05:20:12 -0400 (Thu, 29 Oct 2009)
New Revision: 4877

Modified:
   trunk/mapbender/http/classes/class_wmc.php
   trunk/mapbender/http/php/mod_loadwmc_server.php
Log:
small bugfix to allow WMC deletion; Diasllow Public user from overwriting, disallow Public user from deleteing

Modified: trunk/mapbender/http/classes/class_wmc.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc.php	2009-10-28 17:01:53 UTC (rev 4876)
+++ trunk/mapbender/http/classes/class_wmc.php	2009-10-29 09:20:12 UTC (rev 4877)
@@ -25,6 +25,7 @@
 require_once(dirname(__FILE__) . "/../classes/class_map.php");
 require_once(dirname(__FILE__) . "/../classes/class_administration.php");
 require_once(dirname(__FILE__) . "/../classes/class_wmcToXml.php");
+require_once(dirname(__FILE__) . "/../classes/class_user.php");
 
 /**
  * Implementation of a Web Map Context Document, WMC 1.1.0
@@ -215,8 +216,20 @@
 	 */
 	public function insert ($overwrite) {
 		$result = array();
+        
         if ($this->userId && $this->xml && $this->wmc_title) {
-        
+          try {
+            $user = new user($this->userId);
+          } catch (Exception $E) {
+            $errMsg = "Error while saving WMC document " . $this->wmc_title . "': Invalud UserId";
+            $result["success"] = false;
+            $result["message"] = $errMsg;
+            $e = new mb_exception("mod_insertWMCIntoDB: " . $errMsg);
+            return $result;
+          }
+         
+          $overwrite  = ($user->isPublic())? false: $overwrite;
+          
           db_begin();
 
           if($overwrite)
@@ -296,7 +309,18 @@
 		if (!isset($userId) || $userId === null) {
 			$userId = Mapbender::session()->get("mb_user_id");
 		}
-		
+
+        try {
+          $user = new user($userId);
+        } catch (Exception $E) {
+          return $false;
+        }
+        
+        if($user->isPublic())
+        {
+            return $false;
+        }
+
 		$sql = "DELETE FROM mb_user_wmc ";
 		$sql .= "WHERE fkey_user_id = $1 AND wmc_id = $2";
 		$v = array($userId, $wmcId);

Modified: trunk/mapbender/http/php/mod_loadwmc_server.php
===================================================================
--- trunk/mapbender/http/php/mod_loadwmc_server.php	2009-10-28 17:01:53 UTC (rev 4876)
+++ trunk/mapbender/http/php/mod_loadwmc_server.php	2009-10-29 09:20:12 UTC (rev 4877)
@@ -98,7 +98,7 @@
 	// deletes a WMC
 	case 'deleteWmc':
 		$wmcId = $queryObj->parameters->id;
-		if ($wmc->delete($wmcId)) {
+		if ($wmc->delete($wmcId,$userId)) {
 			$resultObj["success"] = "WMC has been deleted from the database.";
 		}
 		else {



More information about the Mapbender_commits mailing list