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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon May 7 10:55:38 EDT 2007


Author: marcjansen
Date: 2007-05-07 10:55:38 -0400 (Mon, 07 May 2007)
New Revision: 1297

Modified:
   trunk/mapbender/http/classes/class_administration.php
Log:
added PHPdoc comments

Modified: trunk/mapbender/http/classes/class_administration.php
===================================================================
--- trunk/mapbender/http/classes/class_administration.php	2007-05-05 11:39:52 UTC (rev 1296)
+++ trunk/mapbender/http/classes/class_administration.php	2007-05-07 14:55:38 UTC (rev 1297)
@@ -132,9 +132,14 @@
 		}
 		return $newpass;
  	}
-
+    
+    /**
+     * returns the name of a mapbender user which owns the GUI identified by the passed over gui_id.
+     * 
+     * @param <string> the gui_id
+     * @return <string> the name of the owner
+     */
  	function getOwnerByGui($gui_id){
-
 		$sql = "(SELECT mb_user.mb_user_name";
 		$sql .= "FROM mb_user ";
 		$sql .= "JOIN gui_mb_user ON mb_user.mb_user_id = gui_mb_user.fkey_mb_user_id ";
@@ -162,14 +167,22 @@
 		}
 		return $owner;
  	}
-
+    
+    /**
+     * returns the content of the field mb_user_email for the given userid.
+     * 
+     * @param <integer> the userid
+     * @return <mixed> the email if one row is found or false if none is foundd
+     */
 	function getEmailByUserId($userid){
 		$sql = "SELECT mb_user_email FROM mb_user ";
 		$sql .= "WHERE mb_user_id = $1 GROUP by mb_user_email";
+        // TODO why do we group, when userid is a primary key?
 		$v = array($userid);
 		$t = array('i');
 		$res = db_prep_query($sql,$v,$t);
-		$count_g = 0;
+		// TODO shall the next two lines be removed? 
+        $count_g = 0;
 		$array = array();
 		$row = db_fetch_array($res);
 		if ($row) {
@@ -179,13 +192,21 @@
 			return false;
 		}
 	}
-
+    
+    /**
+     * returns the name of the user for the given userid.
+     * 
+     * @param <integer> the userid
+     * @return  the name if one row is found or false if none is foundd
+     */
 	function getUserNameByUserId($userid){
 		$sql = "SELECT mb_user_name FROM mb_user ";
 		$sql .= "WHERE mb_user_id = $1 GROUP BY mb_user_name";
+        // TODO why do we group, when userid is a primary key?
 		$v = array($userid);
 		$t = array("i");
 		$res = db_prep_query($sql,$v,$t);
+        // TODO shall the next two lines be removed?
 		$count_g = 0;
 		$array = array();
 		$row = db_fetch_array($res);
@@ -197,6 +218,13 @@
 		}
 	}
 
+    /**
+     * returns one or more userids from the given email or false,
+     * if there is no record in the database matching the given email
+     * 
+     * @param <string> the email
+     * @return <mixed> returns an array of userids or false when no records matches
+     */
  	function getUserIdByEmail($email){
 		$sql = "SELECT  mb_user_id FROM mb_user ";
 		$sql .= "WHERE mb_user_email = $1 GROUP BY mb_user_id";
@@ -217,8 +245,17 @@
 		}
  	}
 
+    /**
+     * returns one or more owners for the given wm_id. First all guis deploying
+     * this wms are selected. Afterwards for each of the guis the owners are
+     * selected and stored within an array.
+     * 
+     * @param <integer> the wms_id
+     * @return <mixed> an array of usernames which use thw wms in their guis (both for persona or group ownership) 
+     */
 	function getOwnerByWms($wms_id){
-		$sql = "SELECT fkey_gui_id FROM gui_wms WHERE fkey_wms_id = $1 GROUP BY fkey_gui_id";
+		// first get guis which deploy this wms.
+        $sql = "SELECT fkey_gui_id FROM gui_wms WHERE fkey_wms_id = $1 GROUP BY fkey_gui_id";
 		$v = array($wms_id);
 		$t = array('i');
 		$count=0;
@@ -229,7 +266,8 @@
 		}
 
 		if ($count > 0) {
-			if(count($gui)>0){
+			// this is not needed! count($gui) is always equal to $count
+            if(count($gui)>0) {
 				$v = array();
 				$t = array();
 				$c = 1;
@@ -269,10 +307,14 @@
 				$user[$cnt] = $row["mb_user_name"];
 				$cnt++;
 			}
-			if ($cnt>0)	return $user;
-			else return false;
-		}
-		else return false;
+			if ($cnt>0)	{
+                return $user;
+            } else {
+                return false;
+            }
+		} else {
+          return false;
+        }
 	}
 
 	function guiExists($id){



More information about the Mapbender_commits mailing list