[Mapbender-commits] r1903 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Dec 7 04:04:55 EST 2007
Author: christoph
Date: 2007-12-07 04:04:52 -0500 (Fri, 07 Dec 2007)
New Revision: 1903
Modified:
trunk/mapbender/http/classes/class_administration.php
Log:
new comments
some functions return ids, no longer names
Modified: trunk/mapbender/http/classes/class_administration.php
===================================================================
--- trunk/mapbender/http/classes/class_administration.php 2007-12-07 09:03:30 UTC (rev 1902)
+++ trunk/mapbender/http/classes/class_administration.php 2007-12-07 09:04:52 UTC (rev 1903)
@@ -138,32 +138,32 @@
* 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
+ * @return <integer> the user id of the owner
*/
function getOwnerByGui($gui_id){
- $sql = "(SELECT mb_user.mb_user_name";
+ $sql = "(SELECT mb_user.mb_user_id";
$sql .= "FROM mb_user ";
$sql .= "JOIN gui_mb_user ON mb_user.mb_user_id = gui_mb_user.fkey_mb_user_id ";
$sql .= "WHERE gui_mb_user.mb_user_type = 'owner' ";
$sql .= "AND gui_mb_user.fkey_gui_id = $1 ";
- $sql .= "GROUP BY mb_user.mb_user_name ";
+ $sql .= "GROUP BY mb_user.mb_user_id ";
$sql .= ") ";
$sql .= "UNION ( ";
- $sql .= "SELECT mb_user.mb_user_name ";
+ $sql .= "SELECT mb_user.mb_user_id ";
$sql .= "FROM gui_mb_group ";
$sql .= "JOIN mb_user_mb_group ON mb_user_mb_group.fkey_mb_group_id = gui_mb_group.fkey_mb_group_id ";
$sql .= "JOIN mb_user ON mb_user.mb_user_id = mb_user_mb_group.fkey_mb_user_id ";
$sql .= "JOIN gui_mb_user ON mb_user.mb_user_id = gui_mb_user.fkey_mb_user_id ";
$sql .= "WHERE gui_mb_group.mb_group_type = 'owner' ";
$sql .= "AND gui_mb_group.fkey_gui_id = $2 ";
- $sql .= "GROUP BY mb_user.mb_user_name)";
+ $sql .= "GROUP BY mb_user.mb_user_id)";
$owner = array();
$v = array($gui_id,$gui_id);
$t = array('s','s');
$res = db_prep_query($sql,$v,$t);
$cnt = 0;
while($row = db_fetch_array($res)){
- $owner[$cnt] = $row["mb_user_name"];
+ $owner[$cnt] = $row["mb_user_id"];
$cnt++;
}
return $owner;
@@ -172,8 +172,8 @@
/**
* 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
+ * @param integer userid the id of the current user
+ * @return string the email if one row is found or false if none is found
*/
function getEmailByUserId($userid){
$sql = "SELECT mb_user_email FROM mb_user ";
@@ -252,7 +252,7 @@
* 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)
+ * @return <mixed> an array of user ids which use the wms in their guis (both for persona or group ownership)
*/
function getOwnerByWms($wms_id){
// first get guis which deploy this wms.
@@ -272,7 +272,7 @@
$v = array();
$t = array();
$c = 1;
- $sql = "(SELECT mb_user.mb_user_name FROM mb_user JOIN gui_mb_user ";
+ $sql = "(SELECT mb_user.mb_user_id FROM mb_user JOIN gui_mb_user ";
$sql .= "ON mb_user.mb_user_id = gui_mb_user.fkey_mb_user_id ";
$sql .= " WHERE gui_mb_user.mb_user_type = 'owner'";
$sql .= " AND gui_mb_user.fkey_gui_id IN (";
@@ -283,9 +283,9 @@
array_push($v, $gui[$i]);
array_push($t, 's');
}
- $sql .= ") GROUP BY mb_user.mb_user_name";
+ $sql .= ") GROUP BY mb_user.mb_user_id";
$sql .= ") UNION (";
- $sql .= "SELECT mb_user.mb_user_name FROM gui_mb_group JOIN mb_user_mb_group ON mb_user_mb_group.fkey_mb_group_id = gui_mb_group.fkey_mb_group_id JOIN mb_user ";
+ $sql .= "SELECT mb_user.mb_user_id FROM gui_mb_group JOIN mb_user_mb_group ON mb_user_mb_group.fkey_mb_group_id = gui_mb_group.fkey_mb_group_id JOIN mb_user ";
$sql .= "ON mb_user.mb_user_id = mb_user_mb_group.fkey_mb_user_id ";
$sql .= " WHERE gui_mb_group.mb_group_type = 'owner'";
$sql .= " AND gui_mb_group.fkey_gui_id IN (";
@@ -297,7 +297,7 @@
array_push($v, $gui[$i]);
array_push($t, 's');
}
- $sql .= ") GROUP BY mb_user.mb_user_name)";
+ $sql .= ") GROUP BY mb_user.mb_user_id)";
$user = array();
$res = db_prep_query($sql,$v,$t);
@@ -305,7 +305,7 @@
$cnt = 0;
while($row = db_fetch_array($res)){
- $user[$cnt] = $row["mb_user_name"];
+ $user[$cnt] = $row["mb_user_id"];
$cnt++;
}
if ($cnt>0) {
@@ -445,7 +445,7 @@
$v = array();
$t = array();
if(count($gui)>0){
- $sql = "(SELECT mb_user.mb_user_name FROM mb_user JOIN gui_mb_user ";
+ $sql = "(SELECT mb_user.mb_user_id FROM mb_user JOIN gui_mb_user ";
$sql .= "ON mb_user.mb_user_id = gui_mb_user.fkey_mb_user_id ";
$sql .= " WHERE gui_mb_user.fkey_gui_id IN (";
for($i=0; $i<count($gui); $i++){
@@ -455,8 +455,8 @@
array_push($t, 's');
$c++;
}
- $sql .= ") GROUP BY mb_user.mb_user_name) UNION";
- $sql .= "(SELECT mb_user.mb_user_name FROM gui_mb_group JOIN mb_user_mb_group ON mb_user_mb_group.fkey_mb_group_id = gui_mb_group.fkey_mb_group_id JOIN mb_user ";
+ $sql .= ") GROUP BY mb_user.mb_user_id) UNION";
+ $sql .= "(SELECT mb_user.mb_user_id FROM gui_mb_group JOIN mb_user_mb_group ON mb_user_mb_group.fkey_mb_group_id = gui_mb_group.fkey_mb_group_id JOIN mb_user ";
$sql .= "ON mb_user.mb_user_id = mb_user_mb_group.fkey_mb_user_id ";
$sql .= " WHERE gui_mb_group.fkey_gui_id IN (";
for($i=0; $i<count($gui); $i++){
@@ -466,12 +466,12 @@
array_push($t, 's');
$c++;
}
- $sql .= ") GROUP BY mb_user.mb_user_name )";
+ $sql .= ") GROUP BY mb_user.mb_user_id )";
$user = array();
$res = db_prep_query($sql,$v,$t);
$cnt = 0;
while($row = db_fetch_array($res)){
- $user[$cnt] = $row["mb_user_name"];
+ $user[$cnt] = $row["mb_user_id"];
$cnt++;
}
}
@@ -548,12 +548,6 @@
}
}
- /**
- * 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";
@@ -561,21 +555,9 @@
$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 ";
@@ -591,16 +573,8 @@
}
}
- /**
- * 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){
- //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 = "SELECT gui_id FROM gui ";
$sql .= "WHERE gui_name = $1 GROUP BY gui_id";
$v = array($guiTitle);
$t = array('s');
@@ -619,23 +593,15 @@
}
}
- /**
- * 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 ";
+ function getGuisByOwner($user_id,$ignore_public)
+ {
+ $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) ";
- //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){
+ 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);
@@ -645,16 +611,9 @@
$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";
@@ -667,11 +626,10 @@
$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;
}
- function getGuisByPermission($mb_user_id,$ignore_public){
+ function getGuisByPermission($mb_user_id,$ignoreublic){
$arrayGuis = array();
$mb_user_groups = array();
$sql_groups = "SELECT fkey_mb_group_id FROM mb_user_mb_group WHERE fkey_mb_user_id = $1 ";
@@ -722,7 +680,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);
@@ -740,7 +698,7 @@
}
return $ownguis;
}
-
+
function getLayerByWms($wms_id){
$sql = "SELECT layer_id from layer WHERE fkey_wms_id = $1 AND layer_pos NOT IN ('0') GROUP BY layer_id, layer_title ORDER BY layer_title";
$v = array($wms_id);
@@ -766,7 +724,7 @@
$v = array();
$t = array();
if(count($gui)>0){
- $sql = "SELECT mb_user.mb_user_name FROM mb_user JOIN gui_mb_user ";
+ $sql = "SELECT mb_user.mb_user_id FROM mb_user JOIN gui_mb_user ";
$sql .= "ON mb_user.mb_user_id = gui_mb_user.fkey_mb_user_id WHERE";
$sql .= " gui_mb_user.fkey_gui_id IN (";
for($i=0; $i<count($gui); $i++){
@@ -776,12 +734,12 @@
array_push($t,'s');
}
$sql .= ")";
- $sql .= " AND gui_mb_user.mb_user_type = 'owner' GROUP BY mb_user.mb_user_name";
+ $sql .= " AND gui_mb_user.mb_user_type = 'owner' GROUP BY mb_user.mb_user_id";
$res = db_prep_query($sql,$v,$t);
$i=0;
$wmsowner = array();
while($row = db_fetch_array($res)){
- $wmsowner[$i]=$row['mb_user_name'];
+ $wmsowner[$i]=$row['mb_user_id'];
$i++;
}
}
@@ -926,7 +884,6 @@
if($row = db_fetch_array($res)){
return true;
}
- //TODO: next three lines should be removable...
else{
return false;
}
@@ -1061,12 +1018,12 @@
/**
* identifies the Featureservices where the current user is owner
- *
+ *
* @param integer userid the user-ID of the current user
- * @return array an array of the IDs as integers of the featureservices
+ * @return integer[] the IDs of the featureservices
*/
- function getWfsByOwner($userid){
- $sql = "SELECT wfs_id FROM wfs WHERE wfs_owner = $1";
+ function getWfsByOwner($userid){
+ $sql = "SELECT wfs_id FROM wfs WHERE wfs_owner = $1";
$v = array($userid);
$t = array('i');
$res = db_prep_query($sql,$v,$t);
@@ -1077,10 +1034,10 @@
return $r;
}
- /* identifies the Conf-FeatureServices where the current user is owner
+ /** identifies the Conf-FeatureServices where the current user is owner
*
* @param integer userid the user-ID of the current user
- * @returen integer[] the IDs of the wfs_conf-table
+ * @return integer[] the IDs of the wfs_conf-table
*/
function getWfsConfByPermission($userid){
More information about the Mapbender_commits
mailing list