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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Feb 18 02:58:34 EST 2011


Author: armin11
Date: 2011-02-17 23:58:34 -0800 (Thu, 17 Feb 2011)
New Revision: 7623

Modified:
   trunk/mapbender/http/classes/class_wmc.php
Log:
bugfixing

Modified: trunk/mapbender/http/classes/class_wmc.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc.php	2011-02-17 17:12:09 UTC (rev 7622)
+++ trunk/mapbender/http/classes/class_wmc.php	2011-02-18 07:58:34 UTC (rev 7623)
@@ -670,7 +670,7 @@
 						"wmc_id, fkey_user_id, wmc, wmc_title, wmc_public, wmc_timestamp, wmc_timestamp_create, " .
 						"abstract, srs, minx, miny, maxx, maxy ".
 						") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13);";
-					$v = array(time(), $this->userId, $this->xml, administration::convertOutgoingString($this->wmc_title), $user->isPublic()?1:0,time(),time(),
+					$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);
 					$t = array("s", "i", "s", "s", "i", "s","s", "s","s","i","i","i", "i");
 					$res = db_prep_query($sql, $v, $t);
@@ -681,20 +681,24 @@
 					$wmc_DB_ID = intval($row["i"]);
 				}
 			}
+			//if overwrite = false
 			else {
+				$sql = "SELECT max(wmc_serial_id) AS i FROM mb_user_wmc";
+				$res = db_query($sql);
+				$row = db_fetch_assoc($res);
+				$wmc_DB_ID_new = intval($row["i"])+1;
+
 				$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 ".
-					") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13);";
-				$v = array(time(), $this->userId, $this->xml, administration::convertOutgoingString($this->wmc_title), $user->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);
-				$t = array("s", "i", "s", "s", "i", "s","s", "s","s","i","i","i", "i");
+					"abstract, srs, minx, miny, maxx, maxy, wmc_serial_id".
+					") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14);";
+				$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");
 				$res = db_prep_query($sql, $v, $t);
 				
-				$sql = "SELECT max(wmc_serial_id) AS i FROM mb_user_wmc";
-				$res = db_query($sql);
-				$row = db_fetch_assoc($res);
-				$wmc_DB_ID = intval($row["i"]);
+				
 			}
 
 			if (db_error()) {
@@ -707,7 +711,7 @@
 			// because the wmc id is created each time a wmc is instantiated $this->wmc_id has nothing to do with the database wmc_id
 			// this is some duct tape to fix it :-(
 			// see also above where wmc_DB_ID is defined if we need to update
-				if(!isset($wmc_DB_ID)) { $wmc_DB_ID = $this->wmc_id; }
+				if(!isset($wmc_DB_ID_new)) { $wmc_DB_ID_new = $this->wmc_id; }
 
 				// update keywords
 				foreach($this->wmc_keyword as $keyword) {
@@ -731,7 +735,7 @@
 		SELECT fkey_keyword_id FROM wmc_keyword WHERE fkey_wmc_serial_id = $3
 	)
 SQL;
-					$v = array($wmc_DB_ID, $keyword,$wmc_DB_ID);
+					$v = array($wmc_DB_ID_new, $keyword,$wmc_DB_ID_new);
 					$t = array("s","s","s");
 					$res = db_prep_query($keywordsql, $v, $t);
 					if($a = db_error()) {
@@ -743,7 +747,7 @@
 				foreach($this->isoTopicCats as $catId) {
 
 					$catSql = "INSERT INTO wmc_md_topic_category (fkey_wmc_serial_id, fkey_md_topic_category_id) VALUES ($1,$2)";
-					$v = array($wmc_DB_ID, $catId);
+					$v = array($wmc_DB_ID_new, $catId);
 					$t = array("s","s");
 					$res = db_prep_query($catSql, $v, $t);
 
@@ -754,7 +758,7 @@
 				foreach($this->inspireCats as $catId) {
 
 					$catSql = "INSERT INTO wmc_inspire_category (fkey_wmc_serial_id, fkey_inspire_category_id) VALUES ($1,$2)";
-					$v = array($wmc_DB_ID, $catId);
+					$v = array($wmc_DB_ID_new, $catId);
 					$t = array("s","s");
 					$res = db_prep_query($catSql, $v, $t);
 
@@ -765,7 +769,7 @@
 				foreach($this->customCats as $catId) {
 
 					$catSql = "INSERT INTO wmc_custom_category (fkey_wmc_serial_id, fkey_custom_category_id) VALUES ($1,$2)";
-					$v = array($wmc_DB_ID, $catId);
+					$v = array($wmc_DB_ID_new, $catId);
 					$t = array("s","s");
 					$res = db_prep_query($catSql, $v, $t);
 



More information about the Mapbender_commits mailing list