From 2970590761b8b68ec088f4b7b1a12bfb311702eb Mon Sep 17 00:00:00 2001 From: mukhtar Date: Mon, 13 Jan 2003 15:07:29 +0000 Subject: [PATCH] added - remove - update - listall - getuserdetails functions --- lib/administration/UnitManager.inc | 354 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------- 1 file changed, 316 insertions(+), 38 deletions(-) diff --git a/lib/administration/UnitManager.inc b/lib/administration/UnitManager.inc index cd3044b..e35bf4f 100644 --- a/lib/administration/UnitManager.inc +++ b/lib/administration/UnitManager.inc @@ -8,9 +8,19 @@ require_once("$default->owl_fs_root/lib/class.AuthLdap.php"); * Performs unit administration tasks- this includes user, group and category management, * * @version $Revision$ - * @author owl_users_table WHERE $id = $userID"; + $result = $db->query($sql) + if(!'result') + { + printf"User does not exist in the database") + return false + } + + //if user id exists delete it from the users table + $sql = "DELETE FROM $default->owl_users_table WHERE id = $userID"; + $result = $db->query($sql) + if(!'result') + { + return false; + } + else + { + echo "Deletion from user table Successful
"; + return true; + } + + } - /** - * @param userID - * @param userDetails - */ - function updateUser($userID, $userDetails){ - return false; + //----------------------------------------------------------------- + /* + * Function updateUser($userID, $userDetails) + * + * Adds a user to the unit. + * + * @param userID + * the ID of the unit to add the user to + * @param userDetails + * an array containing the details of the user + * @return + * true if the addition was successful, else false. + */ + //----------------------------------------------------------------- + function updateUser($userID, $userDetails) + { + global $default; + // create a connection + $db = new Owl_DB; + + //do validation that userid exists + $sql = "SELECT * FROM $default->owl_users_table WHERE $id = $userID"; + $result = $db->query($sql) + if(!'result') + { + printf"User does not exist in the database") + return false + } + + //if user id exists update all info into the users table + //TODO group id change?????? + $sql = "UPDATE $default->owl_users_table SET " . + " username = " . $userDetails['username'] . "," . + " name = " . $userDetails['name'] . "," . + " password = " . $userDetails['password'] . "," . + " quota_max = " . $userDetails['quota_max'] ."," . + " quota_current = " . $userDetails['quota_current'] ."," . + " name = " . $userDetails['name'] . "," . + " email = " . $userDetails['email'] . "," . + " mobile = " . $userDetails['mobile'] . "," . + " email_notification = " . $userDetails['email_notification'] ."," . + " sms_notification = " . $userDetails['sms_notification'] . " + " WHERE id = ". $userID ."" ; + + + $result = $db->query($sql) + if(!'result') + { + printf("Not Updated) + return false; + } + else + { + echo "Deletion from user table Successful
"; + return true; + } } - + //----------------------------------------------------------------- + /* + * Function listUser() + * + * returns an array of all the usernames + * + * @Return + * an array of usernames + */ + //----------------------------------------------------------------- function listUser(){ - //return null; + + global $default; + // create a connection + $db = new Owl_DB; + + //Get list of all the usernames + $sql = "SELECT username FROM $default->owl_users_table"; + $result = $db->query($sql) + + //return an array of the usernames + return $result; + + } + + //----------------------------------------------------------------- + /* + * Function GetUserDetails($userID) + * + * Returns an array of all the details for a specified user. + * + * @Return + * an array of usernames + */ + //----------------------------------------------------------------- + function GetUserDetails($userID){ + + global $default; + // create a connection + $db = new Owl_DB; + + //do validation that userid exists + $sql = "SELECT * FROM $default->owl_users_table WHERE $id = $userID"; + $result = $db->query($sql) + if(!'result') + { + printf"User does not exist in the database") + return false + } + + //return an array of the usernames + return $result; + } // group management - /** - * @param name - */ + //----------------------------------------------------------------- + /* + * Function addUser($unitID, $userDetails) + * + * Adds a user to the unit. + * + * @param unitID + * the ID of the unit to add the user to + * @param userDetails + * an array containing the details of the user + * @return + * true if the addition was successful, else false. + */ + //----------------------------------------------------------------- function createGroup($name){ return false; } - /** - * @param groupID - */ + //----------------------------------------------------------------- + /* + * Function addUser($unitID, $userDetails) + * + * Adds a user to the unit. + * + * @param unitID + * the ID of the unit to add the user to + * @param userDetails + * an array containing the details of the user + * @return + * true if the addition was successful, else false. + */ + //----------------------------------------------------------------- function removeGroup($groupID){ return false; } - /** - * @param groupID - * @param name - */ + //----------------------------------------------------------------- + /* + * Function addUser($unitID, $userDetails) + * + * Adds a user to the unit. + * + * @param unitID + * the ID of the unit to add the user to + * @param userDetails + * an array containing the details of the user + * @return + * true if the addition was successful, else false. + */ + //----------------------------------------------------------------- function updateGroup($groupID, $name){ return false; } - +//----------------------------------------------------------------- + /* + * Function addUser($unitID, $userDetails) + * + * Adds a user to the unit. + * + * @param unitID + * the ID of the unit to add the user to + * @param userDetails + * an array containing the details of the user + * @return + * true if the addition was successful, else false. + */ + //----------------------------------------------------------------- function listGroup(){ //return null; } - + //----------------------------------------------------------------- + /* + * Function addUser($unitID, $userDetails) + * + * Adds a user to the unit. + * + * @param unitID + * the ID of the unit to add the user to + * @param userDetails + * an array containing the details of the user + * @return + * true if the addition was successful, else false. + */ + //----------------------------------------------------------------- /** * @param groupID * @param userID @@ -193,7 +406,20 @@ class UnitManager { function addUserToGroup($groupID, $userID){ return false; } - +//----------------------------------------------------------------- + /* + * Function addUser($unitID, $userDetails) + * + * Adds a user to the unit. + * + * @param unitID + * the ID of the unit to add the user to + * @param userDetails + * an array containing the details of the user + * @return + * true if the addition was successful, else false. + */ + //----------------------------------------------------------------- /** * @param groupID * @param userID @@ -201,7 +427,20 @@ class UnitManager { function removeUserFromGroup($groupID, $userID){ return false; } - + //----------------------------------------------------------------- + /* + * Function addUser($unitID, $userDetails) + * + * Adds a user to the unit. + * + * @param unitID + * the ID of the unit to add the user to + * @param userDetails + * an array containing the details of the user + * @return + * true if the addition was successful, else false. + */ + //----------------------------------------------------------------- // category management /** @@ -210,14 +449,40 @@ class UnitManager { function createCategory($name){ return false; } - +//----------------------------------------------------------------- + /* + * Function addUser($unitID, $userDetails) + * + * Adds a user to the unit. + * + * @param unitID + * the ID of the unit to add the user to + * @param userDetails + * an array containing the details of the user + * @return + * true if the addition was successful, else false. + */ + //----------------------------------------------------------------- /** * @param categoryID */ function removeCategory($categoryID){ return false; } - +//----------------------------------------------------------------- + /* + * Function addUser($unitID, $userDetails) + * + * Adds a user to the unit. + * + * @param unitID + * the ID of the unit to add the user to + * @param userDetails + * an array containing the details of the user + * @return + * true if the addition was successful, else false. + */ + //----------------------------------------------------------------- /** * @param name * @param categoryID @@ -225,7 +490,20 @@ class UnitManager { function updateCategory($name, $categoryID){ return false; } - +//----------------------------------------------------------------- + /* + * Function addUser($unitID, $userDetails) + * + * Adds a user to the unit. + * + * @param unitID + * the ID of the unit to add the user to + * @param userDetails + * an array containing the details of the user + * @return + * true if the addition was successful, else false. + */ + //----------------------------------------------------------------- function listCategories(){ //return null; } -- libgit2 0.21.4