[Mapbender-commits] r4260 - branches/kmq_dev/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Sun Jun 28 17:05:35 EDT 2009


Author: kmq
Date: 2009-06-28 17:05:35 -0400 (Sun, 28 Jun 2009)
New Revision: 4260

Modified:
   branches/kmq_dev/http/classes/class_user.php
Log:
User object mostly finished

Modified: branches/kmq_dev/http/classes/class_user.php
===================================================================
--- branches/kmq_dev/http/classes/class_user.php	2009-06-27 06:32:51 UTC (rev 4259)
+++ branches/kmq_dev/http/classes/class_user.php	2009-06-28 21:05:35 UTC (rev 4260)
@@ -63,6 +63,7 @@
 		}
 
 	}	
+
 	
 	/**
 	 * @return String the ID of this user
@@ -79,7 +80,7 @@
 	{
 			
 		$result = '{"name":"'. 				$this->name .'",'
-							.'"password":				"*************",'
+							.'"password": "*************",'
 							.'"owner":"'. 			$this->owner .'",'
 							.'"descr":"'. 			$this->descr .'",'
 							.'"loginCount":"'.	$this->loginCount .'",'
@@ -146,6 +147,35 @@
 
 	}
 
+
+	/*
+	*	@param	$changes JSON  keys and their values of what to change in the object
+	*/
+	public function change($changes)
+	{
+
+		$this->name = $changes->name ? $changes->name : $this->name;
+        print "MY NAME IS $changes->name";
+		$this->owner = $changes->owner ? $changes->owner : $this->owner;
+		$this->description = $changes->description ? $changes->description : $this->description;
+		$this->email = $changes->email ? $changes->email : $this->email;
+		$this->phone = $changes->phone ? $changes->phone : $this->phone;
+		$this->department = $changes->department ? $changes->department : $this->department;
+		$this->resolution = $changes->resolution ? $changes->resolution : $this->resolution;
+		$this->organization = $changes->organization ? $changes->organization : $this->organization;
+		$this->position = $changes->position ? $changes->position : $this->position;
+		$this->phone1 = $changes->phone1 ? $changes->phone1 : $this->phone1;
+		$this->facsimile = $changes->facsimile ? $changes->facsimile : $this->facsimile;
+		$this->deliveryPoint = $changes->deliveryPoint ? $changes->deliveryPoint : $this->deliveryPoint;
+		$this->city = $changes->city ? $changes->city : $this->city;
+		$this->postalCode = $changes->postalCode ? $changes->postalCode : $this->postalCode;
+		$this->country = $changes->country ? $changes->country : $this->country;
+		$this->url = $changes->url ? $changes->url : $this->url;
+		$this->id = $changes->id ? $changes->id : $this->id;
+
+        return true;
+	}
+
 	public function commit()
 	{
 
@@ -198,8 +228,6 @@
 		return true;
 	}
 
-
-
 	public function remove()
 	{
 
@@ -253,8 +281,51 @@
 		//
 		return false;
 	}
+  
+    /*
+    * @return Array of Users
+    * @param $filter UNUSED! string that must be contained in the username
+    */
+    public static function getList($filter)
+    {
+      $users = Array();
+      $sql_userlist = "SELECT mb_user_id FROM mb_user";
+      $res_users = db_query($sql_userlist);
+
+      while($row = db_fetch_array($res_users))
+      {
+        try{
+          $users[] = new User($row['mb_user_id']);
+        }
+        catch(Exception $E)
+        {
+          continue;
+          //FIXME: should catch some errors here
+        }
+      }
+      return $users;
+      
+    }
+
+    /*
+    * tries to initialize a userobject by Name
+    * @return A user Object
+    * @param $name the name of the user to find
+    */
+
+    public static function byName($name)
+    {
+      $sql_user = "SELECT mb_user_id FROM mb_user WHERE mb_user_name = '$name'";
+      $res_user = db_query($sql_user);
+      if($row = db_fetch_array($res_user))
+      {
+        return  new User($row['mb_user_id']);
+      }
+      return null;
+
+    }
 	
-	/**
+		/**
 	 * Returns an array of application IDs that the user is allowed to access.
 	 * 
 	 * @return Array an array of application IDs



More information about the Mapbender_commits mailing list