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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jul 13 07:53:15 EDT 2010


Author: christoph
Date: 2010-07-13 11:53:15 +0000 (Tue, 13 Jul 2010)
New Revision: 6594

Modified:
   trunk/mapbender/http/classes/class_user.php
Log:
refactoring, code conventions

Modified: trunk/mapbender/http/classes/class_user.php
===================================================================
--- trunk/mapbender/http/classes/class_user.php	2010-07-13 11:46:37 UTC (rev 6593)
+++ trunk/mapbender/http/classes/class_user.php	2010-07-13 11:53:15 UTC (rev 6594)
@@ -150,35 +150,34 @@
 	}
 
 	public function create() {
-		if($this->name == ""){ $e = new Exception("Can' t create user without name");}
+		if ($this->name === "") { 
+			$e = new Exception("Can' t create user without name");
+		}
 		
-		$sql_user_create = "INSERT INTO mb_user (mb_user_name) VALUES ('". $this->name ."');";
+		$sql_user_create = "INSERT INTO mb_user (mb_user_name) VALUES ('" . 
+			$this->name ."');";
 		$v = array($this->name);
 		$t = array("s");
 	
 		db_begin();
 		
 		$insert_result = db_query($sql_user_create);
-		if($insert_result == false)
-		{
+		if($insert_result == false)	{
 			db_rollback();
 			throw new Exception("Could not insert new user");
 		}
 
 		$id = db_insertid($insert_result,'mb_user','mb_user_id');
-		if($id != 0)
-		{
+		if ($id != 0) {
 			$this->id = $id;
 		}
 	
 		$commit_result = $this->commit();
-		if($commit_result == false)
-		{
+		if($commit_result == false)	{
 			try {
 				db_rollback();
 			}
-			catch(Exception $E)
-			{
+			catch(Exception $E)	{
 				throw new Exception("Could not set inital values of new user");
 			}
 		}
@@ -192,8 +191,7 @@
 	*/
 	public function change($changes) {
         //FIXME: validate input
-        if($changes->owner)
-        {
+        if($changes->owner) {
           $owner = User::byName($changes->owner);
         }
 		$this->name = $changes->name ? $changes->name : $this->name;
@@ -325,8 +323,8 @@
 		$v = array($this->id);
 		$t = array("i");
 		$res_user = db_prep_query($sql_user,$v,$t);
-		if($row = db_fetch_array($res_user)){
 
+		if ($row = db_fetch_array($res_user)) {
 			$this->name = $row['mb_user_name'];
 			$this->owner = $row['mb_user_owner'];
 			$this->description	= $row['mb_user_description'];
@@ -358,6 +356,7 @@
 		}
 		else {
 			 throw new Exception("no such User");
+			 return false;
 		}
 		return true;
 	}
@@ -381,6 +380,7 @@
 		}
 		else {
 			throw new Exception("Database error validating user ticket.");
+			return false;
 		}
 		return true;
 	}
@@ -399,6 +399,7 @@
 
 		if (!$update_result)	{
 			throw new Exception("Database error updating user password");
+			return false;
 		}
 		return true;
 	}



More information about the Mapbender_commits mailing list