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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Aug 28 17:27:56 EDT 2007


Author: marcjansen
Date: 2007-08-28 17:27:56 -0400 (Tue, 28 Aug 2007)
New Revision: 1664

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

Modified: trunk/mapbender/http/classes/class_administration.php
===================================================================
--- trunk/mapbender/http/classes/class_administration.php	2007-08-21 08:39:47 UTC (rev 1663)
+++ trunk/mapbender/http/classes/class_administration.php	2007-08-28 21:27:56 UTC (rev 1664)
@@ -529,7 +529,7 @@
 	}
 
     /**
-     * resets the loin count of a given user to 0
+     * resets the login count of a given user to 0
      * @param <integer> the user id
      * @return <boolean> could the login count be reseted?
      */
@@ -548,6 +548,12 @@
 		}
 	}
 
+    /**
+     * returns the user id for a given username
+     *
+     * @param <string> the username of which the id shall be returned
+     * @return <string|boolean> the userid or false if the operation fails
+     */
 	function getUserIdByUserName($username){
 		$sql = "SELECT mb_user_id FROM mb_user ";
 		$sql .= "WHERE mb_user_name = $1 GROUP BY mb_user_id";
@@ -555,9 +561,21 @@
 		$t = array('s');
 		$res = db_prep_query($sql,$v,$t);
 		$row = db_fetch_array($res);
-		if ($row) return $row["mb_user_id"]; else return false;
+		if ($row) {
+			return $row["mb_user_id"];
+		}
+        else {
+        	return false;
+        }
 	}
 
+    /**
+     * sets the given user_id as owner for the passed gui_id
+     *
+     * @param <string> the gui_id to change ownership of
+     * @param <integer> the user_id of the intended new owner
+     * @return <boolean> Could the owner be updated?
+     */
 	function setUserAsGuiOwner($guiId, $userId) {
 		$sql = "UPDATE gui_mb_user SET mb_user_type = 'owner' ";
 		$sql .= "WHERE fkey_gui_id = $1 AND fkey_mb_user_id = $2 ";
@@ -573,8 +591,16 @@
 		}
  	}
 
+    /**
+     * gets and returns gui_ids identified by the passed over gui_name
+     *
+     * @param <string> name of the gui
+     * @return <array|boolean> an array of gui_ids or false when something went wrong
+     */
 	function getGuiIdByGuiName($guiTitle){
-		$sql = "SELECT gui_id FROM gui ";
+		//TODO: check whether the passed variable should be renamed, guiTitle is misleading
+        //TODO: check whether the function should be renamed to "getGuiIdsByGuiName" since it usually returns an array
+        $sql = "SELECT gui_id FROM gui ";
 		$sql .= "WHERE gui_name = $1 GROUP BY gui_id";
 		$v = array($guiTitle);
 		$t = array('s');
@@ -593,15 +619,23 @@
 		}
  	}
 
-	function getGuisByOwner($user_id,$ignore_public)
-	{
-		$sql_guis = "SELECT gui.gui_id FROM gui,gui_mb_user ";
+    /**
+     * returns gui_ids owned by the user with the passed user_id
+     *
+     * @param <integer> user_id of the owner
+     * @param <boolean> shall only public guis be returned? sort of optional... see todo
+     * @return <array> array of gui_ids owned by the user
+     */
+	function getGuisByOwner($user_id,$ignore_public) {
+		//TODO: isn't the name of the second parameter misleading?
+        $sql_guis = "SELECT gui.gui_id FROM gui,gui_mb_user ";
 		$sql_guis .= "WHERE (gui.gui_id = gui_mb_user.fkey_gui_id AND gui_mb_user.fkey_mb_user_id = $1) ";
-		if (!isset($ignore_public) OR $ignore_public == false){
+		//TODO: when using !isset() below should IMO be replaced with a true otional second parameter via a default value
+        if (!isset($ignore_public) OR $ignore_public == false){
 			$sql_guis .= " AND gui.gui_public = 1 ";
 		}
 		$sql_guis .= " AND gui_mb_user.mb_user_type = 'owner' GROUP BY gui.gui_id";
-		$sql_guis .= " ORDER by gui.gui_id";
+		$sql_guis .= " ORDER BY gui.gui_id";
 		$v = array($user_id);
 		$t = array('i');
 		$res_guis = db_prep_query($sql_guis,$v,$t);
@@ -611,9 +645,16 @@
 			$arrayGuis[$count_g] = $row["gui_id"];
 			$count_g++;
 		}
+        //TODO: check: why do we always return an array, when most other comparable functions would return false? This is IMO at least inconsistent.
 		return $arrayGuis;
  	}
 
+    /**
+     * returns wmc_ids owned by the user with the passed user_id
+     *
+     * @param <integer> user_id of the owner
+     * @return <array> array of wmc_ids owned by the user
+     */
  	function getWmcByOwner($user_id){
 		$sql_wmc = "SELECT wmc_id FROM mb_user_wmc ";
 		$sql_wmc .= "WHERE fkey_user_id = $1 GROUP BY wmc_id";
@@ -626,6 +667,7 @@
 			$arrayWmc[$count_g] = $row["wmc_id"];
 			$count_g++;
 		}
+        //TODO: check: why do we always return an array, when most other comparable functions would return false? This is IMO at least inconsistent.
 		return $arrayWmc;
  	}
 
@@ -680,7 +722,7 @@
 		if(count($array_gui_ids)>0){
 			$v = array();
 			$t = array();
-			$sql = "SELECT fkey_wms_id from gui_wms WHERE gui_wms.fkey_gui_id IN(";
+			$sql = "SELECT fkey_wms_id FROM gui_wms WHERE gui_wms.fkey_gui_id IN(";
 			for($i=0; $i<count($array_gui_ids); $i++){
 				if($i>0){ $sql .= ",";}
 				$sql .= "$".strval($i+1);
@@ -839,6 +881,7 @@
 			if($row = db_fetch_array($res)){
 				return true;
 			}
+            //TODO: next three lines should be removable...
 			else{
 				return false;
 			}
@@ -934,15 +977,15 @@
 		|\xF4[\x80-\x8F][\x80-\xBF]{2}    # plane 16
 		)+%xs', $string);
 	}
-	
+
 	function is_utf8_xml($xml) {
 		return preg_match('/<\?xml[^>]+encoding="utf-8"[^>]*\?>/is', $xml);
 	}
-	
+
 	function is_utf8 ($data) {
 		return ($this->is_utf8_xml($data) || $this->is_utf8_string($data));
 	}
-	
+
 	function char_encode($data) {
 		if (CHARSET == "UTF-8") {
 			if (!$this->is_utf8($data)) {
@@ -970,12 +1013,12 @@
 		$e = new mb_notice("no conversion: is " . CHARSET);
 		return $data;
 	}
-	
-	/*
+
+	/**
 	 * identifies the Featureservices where the current user is owner
-	 * 
+	 *
 	 * @param integer userid the user-ID of the current user
-	 * @returen integer[] the IDs of the featureservices
+	 * @return array an array of the IDs as integers of the featureservices
 	 */
 	function getWfsByOwner($userid){
 		$sql = "SELECT wfs_id FROM wfs WHERE wfs_owner = $1";



More information about the Mapbender_commits mailing list