[Mapbender-commits] r8934 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jun 25 06:57:31 PDT 2014


Author: hwbllmnn
Date: 2014-06-25 06:57:31 -0700 (Wed, 25 Jun 2014)
New Revision: 8934

Modified:
   trunk/mapbender/http/classes/class_wmc.php
Log:
properly store whether a wmc has local data and its size


Modified: trunk/mapbender/http/classes/class_wmc.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc.php	2014-06-25 11:49:54 UTC (rev 8933)
+++ trunk/mapbender/http/classes/class_wmc.php	2014-06-25 13:57:31 UTC (rev 8934)
@@ -94,6 +94,9 @@
 	var $userId;
 	var $timestamp;
 	var $public;
+    var $local_data_public = 0;
+    var $has_local_data = 0;
+    var $local_data_size = '0';
 
 	// set during parsing
 	var $wmc_version;
@@ -157,7 +160,7 @@
 			return false;
 		}
 		$this->createObjFromWMC_xml($doc);
-		$sql = "SELECT wmc_timestamp, wmc_title, wmc_public, srs, minx, miny, maxx, maxy " .
+		$sql = "SELECT wmc_timestamp, wmc_title, wmc_public, srs, minx, miny, maxx, maxy, wmc_has_local_data, wmc_local_data_size, wmc_local_data_public " .
 			"FROM mb_user_wmc WHERE wmc_serial_id = $1 AND (fkey_user_id = $2 OR wmc_public = 1)";
 		$v = array($wmcId, Mapbender::session()->get("mb_user_id"));
 		$t = array("i", "i");
@@ -174,6 +177,9 @@
 			$this->wmc_extent->miny = $row[5];
 			$this->wmc_extent->maxx = $row[6];
 			$this->wmc_extent->maxy = $row[7];
+            $this->local_data_public = $row[10];
+            $this->local_data_size = $row[9];
+            $this->has_local_data = $row[8];
 			return true;
 		}
 		return false;
@@ -235,6 +241,10 @@
 			}
 		}
 
+        if($mapObject[0]->kmls) {
+            $this->has_local_data = true;
+            $this->local_data_size = strlen(json_encode($mapObject[0]->kmls));
+        }
 
 		// create XML
 		$this->createXml();
@@ -680,10 +690,12 @@
 
 				if($row = db_fetch_row($res)) {
 					$sql = "UPDATE mb_user_wmc SET wmc = $1, wmc_timestamp = $2, abstract = $3, srs = $4, minx = $5, miny = $6,".
-						" maxx = $7, maxy = $8, wmc_title = $9 WHERE fkey_user_id = $10 AND wmc_serial_id=$11 AND wmc_timestamp = $12;";
+						" maxx = $7, maxy = $8, wmc_title = $9 WHERE fkey_user_id = $10 AND wmc_serial_id=$11 AND wmc_timestamp = $12 AND wmc_has_local_data = $13 ".
+                        "AND wmc_local_data_public = $14 AND wmc_local_data_size = $15;";
 					$v = array($this->xml, time(), $this->wmc_abstract, $this->wmc_srs, $this->wmc_extent->minx, $this->wmc_extent->miny,
-						$this->wmc_extent->maxx, $this->wmc_extent->maxy ,administration::convertOutgoingString($this->wmc_title), $this->userId, $this->wmc_id,$row[2]);
-					$t = array("s", "s","s","s","i","i","i","i", "s", "i", "i","s");
+                    $this->wmc_extent->maxx, $this->wmc_extent->maxy ,administration::convertOutgoingString($this->wmc_title), $this->userId, $this->wmc_id,$row[2],
+                    $this->has_local_data, $this->local_data_public, $this->local_data_size);
+					$t = array("s", "s","s","s","i","i","i","i", "s", "i", "i","s", "i", "i", "s");
 					$res = db_prep_query($sql, $v, $t);
 					// need the database Id
 					$wmc_DB_ID = $row[3];
@@ -715,11 +727,12 @@
 
 					$sql = "INSERT INTO mb_user_wmc (" .
 						"wmc_id, fkey_user_id, wmc, wmc_title, wmc_public, wmc_timestamp, wmc_timestamp_create, " .
-						"abstract, srs, minx, miny, maxx, maxy, wmc_serial_id".
-						") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14);";
+						"abstract, srs, minx, miny, maxx, maxy, wmc_serial_id, wmc_has_local_data, wmc_local_data_public, wmc_local_data_size".
+						") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17);";
 					$v = array(time(), $this->userId, $this->xml, administration::convertOutgoingString($this->wmc_title), $this->isPublic()?1:0,time(),time(),
-						$this->wmc_abstract, $this->wmc_srs, $this->wmc_extent->minx,  $this->wmc_extent->miny, $this->wmc_extent->maxx, $this->wmc_extent->maxy, $wmc_DB_ID_new);
-					$t = array("s", "i", "s", "s", "i", "s","s", "s","s","i","i","i", "i", "i");
+                    $this->wmc_abstract, $this->wmc_srs, $this->wmc_extent->minx,  $this->wmc_extent->miny, $this->wmc_extent->maxx, $this->wmc_extent->maxy, $wmc_DB_ID_new,
+                    $this->has_local_data, $this->local_data_public, $this->local_data_size);
+					$t = array("s", "i", "s", "s", "i", "s","s", "s","s","i","i","i", "i", "i", "i", "i", "s");
 					$res = db_prep_query($sql, $v, $t);
 
 					//$sql = "SELECT max(wmc_serial_id) AS i FROM mb_user_wmc";
@@ -737,12 +750,13 @@
 
 				$sql = "INSERT INTO mb_user_wmc (" .
 					"wmc_id, fkey_user_id, wmc, wmc_title, wmc_public, wmc_timestamp, wmc_timestamp_create, " .
-					"abstract, srs, minx, miny, maxx, maxy, wmc_serial_id".
-					") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14);";
+					"abstract, srs, minx, miny, maxx, maxy, wmc_serial_id, wmc_has_local_data, wmc_local_data_public, wmc_local_data_size".
+					") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17);";
 				//$e = new mb_exception($sql);
 				$v = array(time(), $this->userId, $this->xml, administration::convertOutgoingString($this->wmc_title), $this->isPublic()?1:0, time(),time(),
-					$this->wmc_abstract, $this->wmc_srs, $this->wmc_extent->minx,  $this->wmc_extent->miny, $this->wmc_extent->maxx, $this->wmc_extent->maxy, $wmc_DB_ID_new);
-				$t = array("s", "i", "s", "s", "i", "s","s", "s","s","i","i","i", "i", "i");
+                $this->wmc_abstract, $this->wmc_srs, $this->wmc_extent->minx,  $this->wmc_extent->miny, $this->wmc_extent->maxx, $this->wmc_extent->maxy, $wmc_DB_ID_new,
+                $this->has_local_data, $this->local_data_public, $this->local_data_size);
+				$t = array("s", "i", "s", "s", "i", "s","s", "s","s","i","i","i", "i", "i", "i", "i", "s");
 				$res = db_prep_query($sql, $v, $t);
 
 
@@ -1032,7 +1046,33 @@
 		return $noIdArray;
 	}
 
+    public function hasLocalData() {
+        return $this->has_local_data;
+    }
 
+    public function isLocalDataPublic() {
+        return $this->local_data_public;
+    }
+
+    public function getLocalDataSize() {
+        return $this->local_data_size;
+    }
+
+    public function setHasLocalData($has_local_data) {
+        $this->has_local_data = $has_local_data;
+        return $this;
+    }
+
+    public function setLocalDataPublic($local_data_public) {
+        $this->local_data_public = $local_data_public;
+        return $this;
+    }
+
+    public function setLocalDataSize($local_data_size) {
+        $this->local_data_size = $local_data_size;
+        return $this;
+    }
+
 	// ---------------------------------------------------------------------------
 	// OUTPUT FUNCTIONS
 	// ---------------------------------------------------------------------------



More information about the Mapbender_commits mailing list