Commit 2b3a7015d265bbae4593aca397b71228aaa58c0f
1 parent
0ff6c493
Replaced by classes in /lib/groups/ directory
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@417 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
0 additions
and
898 deletions
lib/administration/GroupManager.inc deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id: GroupManager.inc | |
| 4 | - * | |
| 5 | - * Performs group administration tasks- this includes create, remove, update | |
| 6 | - * as well as addGroupToUnit and removeGroupFromUnit ..etc | |
| 7 | - * | |
| 8 | - * @version $Revision: 1.0 | |
| 9 | - * @author Mukhtar Dharsey | |
| 10 | - * @package lib.administration | |
| 11 | - */ | |
| 12 | - | |
| 13 | -// group management | |
| 14 | - class GroupManager | |
| 15 | - { | |
| 16 | - | |
| 17 | - /** | |
| 18 | - * | |
| 19 | - * Adds a new group | |
| 20 | - * | |
| 21 | - * @param name | |
| 22 | - * name of new group | |
| 23 | - * @return boolean | |
| 24 | - * true if the addition was successful, else false. | |
| 25 | - */ | |
| 26 | - | |
| 27 | - function createGroup($name) { | |
| 28 | - global $default; | |
| 29 | - | |
| 30 | - $sql = new Owl_DB; | |
| 31 | - | |
| 32 | - | |
| 33 | - // check that the group name is unique | |
| 34 | - $query = "SELECT name FROM $default->owl_groups_table WHERE name = '" . $name . "'"; | |
| 35 | - $sql->query($query); | |
| 36 | - $rows = $sql->num_rows($sql); | |
| 37 | - | |
| 38 | - if ($rows > 0) | |
| 39 | - { | |
| 40 | - // duplicate username | |
| 41 | - $default->errorMessage = "GroupManager::The Group name " . $name . " is already in use, please choose another one"; | |
| 42 | - $default->log->debug($default->errorMessage); | |
| 43 | - return false; | |
| 44 | - } | |
| 45 | - // insert the user | |
| 46 | - $query = "INSERT INTO $default->owl_groups_table (name) VALUES ('" . $name . "')"; | |
| 47 | - | |
| 48 | - $result = $sql->query($query); | |
| 49 | - | |
| 50 | - if(!'result') | |
| 51 | - { | |
| 52 | - $default->log->debug( "GroupManager::New Group Addition Unsuccessful!<br>"); | |
| 53 | - return false; | |
| 54 | - } | |
| 55 | - else | |
| 56 | - { | |
| 57 | - $default->log->debug ("GroupManager::New Group added Successfully!<br>"); | |
| 58 | - return true; | |
| 59 | - } | |
| 60 | - | |
| 61 | - | |
| 62 | - | |
| 63 | -} | |
| 64 | - | |
| 65 | - /** | |
| 66 | - * Removes a group from the groups table as well as from the groups_units_link table | |
| 67 | - * | |
| 68 | - * @param groupID | |
| 69 | - * The id of the group to be deleted | |
| 70 | - * @return boolean | |
| 71 | - * True if the deletion was successful, else false if not or nonexistant. | |
| 72 | - */ | |
| 73 | - function removeGroup($groupID) | |
| 74 | - { | |
| 75 | - global $default; | |
| 76 | - // create a connection | |
| 77 | - $sql = new Owl_DB; | |
| 78 | - | |
| 79 | - //do validation that userid exists | |
| 80 | - $query = "SELECT * FROM $default->owl_groups_table WHERE id = '" . $groupID ."'"; | |
| 81 | - $result = $sql->query($query); | |
| 82 | - $row = $sql->num_rows($result); | |
| 83 | - | |
| 84 | - // check if result was found..0 if not | |
| 85 | - if($row == 0) | |
| 86 | - { | |
| 87 | - $default->log->debug("GroupManager::Group does not exist in the database<br>"); | |
| 88 | - return false; | |
| 89 | - } | |
| 90 | - | |
| 91 | - //if user id exists delete it from the users table | |
| 92 | - $query = "DELETE FROM $default->owl_groups_table WHERE id = $groupID"; | |
| 93 | - $result = $sql->query($query); | |
| 94 | - | |
| 95 | - if(!'result') | |
| 96 | - { | |
| 97 | - $default->log->debug("GroupManager::Deletion unsuccessful<br>"); | |
| 98 | - return false; | |
| 99 | - } | |
| 100 | - else | |
| 101 | - { | |
| 102 | - $default->log->debug ("GroupManager::Deletion from user table Successful<br>"); | |
| 103 | - //check if belongs to group | |
| 104 | - | |
| 105 | - $result= $this->removeGroupFromUnit($groupID); | |
| 106 | - return true; | |
| 107 | - } | |
| 108 | - | |
| 109 | - | |
| 110 | - | |
| 111 | - } | |
| 112 | - | |
| 113 | - /** | |
| 114 | - * Updates groups details ..ie rename the group | |
| 115 | - * | |
| 116 | - * @param groupID | |
| 117 | - * the group which is to be renamed | |
| 118 | - * @param name | |
| 119 | - * new name of the group | |
| 120 | - * @return boolean | |
| 121 | - * true if the addition was successful, else false. | |
| 122 | - */ | |
| 123 | - function updateGroup($groupID, $name) | |
| 124 | - { | |
| 125 | - global $default; | |
| 126 | - // create a connection | |
| 127 | - $sql = new Owl_DB; | |
| 128 | - | |
| 129 | - //do validation that userid exists | |
| 130 | - $query = "SELECT * FROM $default->owl_groups_table WHERE id = $groupID"; | |
| 131 | - $result = $sql->query($query); | |
| 132 | - $row = $sql->num_rows($result); | |
| 133 | - | |
| 134 | - //if row = 0 ...then no entry was found..so return false | |
| 135 | - if($row == 0) | |
| 136 | - { | |
| 137 | - $default->log->debug("GroupManager::Group does not exist in the database<br>"); | |
| 138 | - return false; | |
| 139 | - } | |
| 140 | - | |
| 141 | - //if user id exists update all info into the users table | |
| 142 | - $query = "UPDATE $default->owl_groups_table SET name = '" . $name . "' WHERE id = $groupID " ; | |
| 143 | - | |
| 144 | - $result = $sql->query($query); | |
| 145 | - | |
| 146 | - | |
| 147 | - // error checking to see if success | |
| 148 | - if(!'result') | |
| 149 | - { | |
| 150 | - $default->log->debug("GroupManager::Not Updated"); | |
| 151 | - return false; | |
| 152 | - } | |
| 153 | - else | |
| 154 | - { | |
| 155 | - $default->log->debug("GroupManager::Update Successful<br>"); | |
| 156 | - return true; | |
| 157 | - } | |
| 158 | - } | |
| 159 | - | |
| 160 | - /** | |
| 161 | - * Returns an array of all the groups | |
| 162 | - * | |
| 163 | - * @return array | |
| 164 | - * An array of groups | |
| 165 | - */ | |
| 166 | - function listGroups() | |
| 167 | - { | |
| 168 | - | |
| 169 | - global $default; | |
| 170 | - $groups = array (); | |
| 171 | - $i = 0; | |
| 172 | - // create a connection | |
| 173 | - $sql = new Owl_DB; | |
| 174 | - | |
| 175 | - //Get list of all the usernames | |
| 176 | - $query = "SELECT name FROM $default->owl_groups_table"; | |
| 177 | - $result = $sql->query($query); | |
| 178 | - $row = $sql->num_rows($result); | |
| 179 | - | |
| 180 | - //error checking | |
| 181 | - if($row == 0) | |
| 182 | - { | |
| 183 | - $default->log->debug("GroupManager::No users in table"); | |
| 184 | - return false; | |
| 185 | - } | |
| 186 | - | |
| 187 | - //store in array | |
| 188 | - while($sql->next_record()) | |
| 189 | - { | |
| 190 | - $groups["$i"] = array("name" => $sql->f("name")); | |
| 191 | - $i++; | |
| 192 | - } | |
| 193 | - | |
| 194 | - //return an array of the groups | |
| 195 | - return $groups; | |
| 196 | - | |
| 197 | - } | |
| 198 | - | |
| 199 | - /** | |
| 200 | - * | |
| 201 | - * Adds a group to a unit NB: Group belongs to 1 unit only | |
| 202 | - * | |
| 203 | - * @param groupID | |
| 204 | - * The ID of the group to add the user to | |
| 205 | - * @param unitID | |
| 206 | - * The Id of the unit to add to | |
| 207 | - * @return boolean | |
| 208 | - * True if the addition was successful, else false if not or nonexistant. | |
| 209 | - */ | |
| 210 | - function addGroupToUnit($groupID,$unitID) | |
| 211 | - { | |
| 212 | - global $default; | |
| 213 | - // create a connection | |
| 214 | - $sql = new Owl_DB; | |
| 215 | - | |
| 216 | - //do validation that groupid exists | |
| 217 | - $query = "SELECT * FROM $default->owl_groups_units_table WHERE group_id = $groupID"; | |
| 218 | - $result = $sql->query($query); | |
| 219 | - $row = $sql->num_rows($result); | |
| 220 | - | |
| 221 | - // if it does exist return false..already there | |
| 222 | - if($row >= 1) | |
| 223 | - { | |
| 224 | - $default->log->debug("GroupManager::Group already belongs to a unit<br>"); | |
| 225 | - return false; | |
| 226 | - } | |
| 227 | - | |
| 228 | - //add user to the table | |
| 229 | - $query = "INSERT INTO $default->owl_groups_units_table (group_id,unit_id) VALUES($groupID,$unitID)"; | |
| 230 | - $result = $sql->query($query); | |
| 231 | - | |
| 232 | - if(!'result') | |
| 233 | - { | |
| 234 | - $default->log->debug("GroupManager::Insertion into groups_units table unsuccessful<br>"); | |
| 235 | - return false; | |
| 236 | - } | |
| 237 | - else | |
| 238 | - { | |
| 239 | - $default->log->debug("GroupManager::Insertion into groups_units table Successful<br>"); | |
| 240 | - return true; | |
| 241 | - } | |
| 242 | - | |
| 243 | - } | |
| 244 | - | |
| 245 | - | |
| 246 | - /** | |
| 247 | - * Removes a group from a unit NB: Group can only belong to 1 unit | |
| 248 | - * | |
| 249 | - * @param groupID | |
| 250 | - * The ID of the group be removed from a unit | |
| 251 | - | |
| 252 | - * @return boolean | |
| 253 | - * True if the deletion was successful, else false if not or nonexistant. | |
| 254 | - */ | |
| 255 | - function removeGroupFromUnit($groupID) | |
| 256 | - { | |
| 257 | - global $default; | |
| 258 | - // create a connection | |
| 259 | - $sql = new Owl_DB; | |
| 260 | - | |
| 261 | - //do validation that groupid exists | |
| 262 | - $query = "SELECT * FROM $default->owl_groups_units_table WHERE group_id = $groupID"; | |
| 263 | - $result = $sql->query($query); | |
| 264 | - $row = $sql->num_rows($result); | |
| 265 | - | |
| 266 | - // check if result was found..0 if not | |
| 267 | - if($row == 0) | |
| 268 | - { | |
| 269 | - $default->log->debug("GroupManager::Group does not exist in the database<br>"); | |
| 270 | - return false; | |
| 271 | - } | |
| 272 | - | |
| 273 | - //if group id exists delete it from the users table | |
| 274 | - $query = "DELETE FROM $default->owl_groups_units_table WHERE group_id = $groupID"; | |
| 275 | - $result = $sql->query($query); | |
| 276 | - | |
| 277 | - if(!'result') | |
| 278 | - { | |
| 279 | - $default->log->debug ("GroupManager::Deletion unsuccessful<br>"); | |
| 280 | - return false; | |
| 281 | - } | |
| 282 | - else | |
| 283 | - { | |
| 284 | - $default->log->debug("GroupManager::Deletion from user_group_link table Successful<br>"); | |
| 285 | - return true; | |
| 286 | - } | |
| 287 | - | |
| 288 | - } | |
| 289 | - /* | |
| 290 | - * | |
| 291 | - * gets the id of a group using its name | |
| 292 | - * | |
| 293 | - * @param $groupName | |
| 294 | - * The GroupName for which we want its ID | |
| 295 | - * @return Integer | |
| 296 | - * The groupname's Id | |
| 297 | - */ | |
| 298 | - | |
| 299 | - function getGroupID($groupName) | |
| 300 | - { | |
| 301 | - global $default; | |
| 302 | - | |
| 303 | - $id = lookupID($default->owl_groups_table, "name", $groupName); | |
| 304 | - | |
| 305 | - return $id; | |
| 306 | - } | |
| 307 | - | |
| 308 | - /* | |
| 309 | - * Function getGroupName($groupID) | |
| 310 | - * | |
| 311 | - * gets the id of a user using their username | |
| 312 | - * | |
| 313 | - * @param $username | |
| 314 | - * The username for which we want its ID | |
| 315 | - * @return char | |
| 316 | - * name of group | |
| 317 | - */ | |
| 318 | - | |
| 319 | - function getGroupName($groupID) | |
| 320 | - { | |
| 321 | - global $default; | |
| 322 | - | |
| 323 | - //call lookup function | |
| 324 | - $name = lookupField($default->owl_groups_table, "name" , "id", $groupID); | |
| 325 | - | |
| 326 | - return $name; | |
| 327 | - } | |
| 328 | - | |
| 329 | - /* | |
| 330 | - * | |
| 331 | - * Gets the unit that the group belongs to | |
| 332 | - * | |
| 333 | - * @param $groupID | |
| 334 | - * The ID of the group | |
| 335 | - * @return Array | |
| 336 | - * array of unitID and name of the unit | |
| 337 | - */ | |
| 338 | - function getUnit($groupID) | |
| 339 | - { | |
| 340 | - global $default; | |
| 341 | - $unitinfo = array(); | |
| 342 | - | |
| 343 | - // call lookup functions | |
| 344 | - $unitID = lookupField($default->owl_groups_units_table, "unit_id" , "group_id", $groupID); | |
| 345 | - $unitName = lookupField($default->owl_units_table, "name" , "id", $unitID); | |
| 346 | - | |
| 347 | - $unitinfo[1] = array("id" => $unitID, "name" => $unitName); | |
| 348 | - | |
| 349 | - // return an array | |
| 350 | - return $unitinfo; | |
| 351 | - | |
| 352 | - } | |
| 353 | - | |
| 354 | - | |
| 355 | - | |
| 356 | - /* | |
| 357 | - * | |
| 358 | - * gets the org details of the org a unit belongs to TODO: move into System/Or Management | |
| 359 | - * | |
| 360 | - * @param orgID | |
| 361 | - * The id of the org who's name we want based on the unit who belongs to it | |
| 362 | - * @return array | |
| 363 | - * if and name of org | |
| 364 | - */ | |
| 365 | - | |
| 366 | - function getOrg($unitID) | |
| 367 | - { | |
| 368 | - | |
| 369 | - global $default; | |
| 370 | - $orginfo = array(); | |
| 371 | - | |
| 372 | - // call lookup functions | |
| 373 | - $orgID = lookupField($default->owl_units_table, "organisation_id" , "id", $unitID); | |
| 374 | - $orgName = lookupField($default->owl_organisations_table, "name" , "id", $orgID); | |
| 375 | - | |
| 376 | - $orginfo[1] = array("id" => $orgID, "name" => $orgName); | |
| 377 | - | |
| 378 | - // return an array | |
| 379 | - return $orginfo; | |
| 380 | - | |
| 381 | - | |
| 382 | - } | |
| 383 | - | |
| 384 | - } | |
| 385 | - | |
| 386 | -?> | |
| 387 | 0 | \ No newline at end of file |
lib/administration/UnitManager.inc deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -require_once("$default->owl_fs_root/lib/class.AuthLdap.php"); | |
| 4 | - | |
| 5 | -/** | |
| 6 | - * $Id$ | |
| 7 | - * | |
| 8 | - * Performs unit administration tasks- this includes user, group and category management, | |
| 9 | - * | |
| 10 | - * @version $Revision$ | |
| 11 | - * @author Mukhtar Dharsey | |
| 12 | - * @package lib.administration | |
| 13 | - */ | |
| 14 | -/*-----------------------------------------------------------------*/ | |
| 15 | -/** | |
| 16 | - * Class Unit Manager | |
| 17 | - * | |
| 18 | - * Performs unit administration tasks- this includes user, group and category management, | |
| 19 | - * | |
| 20 | - * | |
| 21 | - */ | |
| 22 | -/*-----------------------------------------------------------------*/ | |
| 23 | - | |
| 24 | -class UnitManager { | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * Handle to the ldap util class | |
| 28 | - */ | |
| 29 | - var $ldap; | |
| 30 | - | |
| 31 | - // user management | |
| 32 | - | |
| 33 | - /*-----------------------------------------------------------------*/ | |
| 34 | - /* | |
| 35 | - * Function ListLdapUsers($userNameSearch) | |
| 36 | - * | |
| 37 | - * Searches the LDAP directory for users matching the supplied search string. | |
| 38 | - * | |
| 39 | - * @param $userNameSearch | |
| 40 | - * the username to search for | |
| 41 | - * @return | |
| 42 | - * returns an array containing the users found | |
| 43 | - */ | |
| 44 | - /*-----------------------------------------------------------------*/ | |
| 45 | - function listLdapUsers($userNameSearch) { | |
| 46 | - global $default; | |
| 47 | - | |
| 48 | - // user attributes to search for | |
| 49 | - $attributes = array ("dn", "uid", "givenname", "sn", "mail", "mobile"); | |
| 50 | - // initialise the ldap connection | |
| 51 | - $ldap = new AuthLdap(); | |
| 52 | - $server[0] = $default->ldapServer; | |
| 53 | - $ldap->server = $server; | |
| 54 | - $ldap->dn = $default->ldapRootDn; | |
| 55 | - | |
| 56 | - if ( $ldap->connect()) { | |
| 57 | - // search for the users | |
| 58 | - // append and prepend wildcards | |
| 59 | - $userArray = $ldap->getUsers("*" . $userNameSearch . "*", $attributes); | |
| 60 | - if ($userArray) { | |
| 61 | - // return the array | |
| 62 | - return $userArray; | |
| 63 | - } else { | |
| 64 | - // the search failed, bail | |
| 65 | - return false; | |
| 66 | - } | |
| 67 | - } else { | |
| 68 | - // ldap connection failed, bail | |
| 69 | - // TODO: error handling | |
| 70 | - return false; | |
| 71 | - /* | |
| 72 | - echo "There was a problem.<br>"; | |
| 73 | - echo "Error code : " . $ldap->ldapErrorCode . "<br>"; | |
| 74 | - echo "Error text : " . $ldap->ldapErrorText . "<br>"; | |
| 75 | - */ | |
| 76 | - } | |
| 77 | - } | |
| 78 | - | |
| 79 | - | |
| 80 | - //----------------------------------------------------------------- | |
| 81 | - /* | |
| 82 | - * Function addUser($unitID, $userDetails) | |
| 83 | - * | |
| 84 | - * Adds a user to the unit. | |
| 85 | - * | |
| 86 | - * @param unitID | |
| 87 | - * the ID of the unit to add the user to | |
| 88 | - * @param userDetails | |
| 89 | - * an array containing the details of the user | |
| 90 | - * @return | |
| 91 | - * true if the addition was successful, else false. | |
| 92 | - */ | |
| 93 | - //----------------------------------------------------------------- | |
| 94 | - function addUser($unitID, $userDetails) { | |
| 95 | - global $default; | |
| 96 | - | |
| 97 | - $sql = new Owl_DB; | |
| 98 | - | |
| 99 | - // TODO: userDetails validation | |
| 100 | - | |
| 101 | - // check that the username is unique | |
| 102 | - $query = "select username from $default->owl_users_table where username = '" . $userDetails['username'] . "'"; | |
| 103 | - $sql->query($query); | |
| 104 | - $numrows = $sql->num_rows($sql); | |
| 105 | - | |
| 106 | - if ($numrows > 0) { | |
| 107 | - // duplicate username | |
| 108 | - $default->errorMessage = "The username " . $userDetails['username'] . " is already in use, please choose another one"; | |
| 109 | - return false; | |
| 110 | - } | |
| 111 | - // insert the user | |
| 112 | - $query = "insert into $default->owl_users_table (username, name, password, email, mobile, ldap_dn) " . | |
| 113 | - "values ( '" . $userDetails['username'] . "', " . | |
| 114 | - "'" . $userDetails['name'] . "', " . | |
| 115 | - "'', " . | |
| 116 | - "'" . $userDetails['email'] . "', " . | |
| 117 | - "'" . $userDetails['mobile'] . "', " . | |
| 118 | - "'" . $userDetails['ldap_dn'] . "')"; | |
| 119 | - $result = $sql->query($query); | |
| 120 | - if(!'result') { | |
| 121 | - return false; | |
| 122 | - } else { | |
| 123 | - echo "insert into user table worked!<br>"; | |
| 124 | - } | |
| 125 | - | |
| 126 | - // TODO: insert into group table | |
| 127 | - | |
| 128 | - // TODO: must check that username is unique! | |
| 129 | - // retrieve the generated id for insert into the user unit mapping table | |
| 130 | - $query = "select * from $default->owl_users_table where username = '" . $userDetails['username'] . "'"; | |
| 131 | - $sql->query($query); | |
| 132 | - $numrows = $sql->num_rows($sql); | |
| 133 | - | |
| 134 | - if ($numrows == "1") { | |
| 135 | - while($sql->next_record()) { | |
| 136 | - $userID = $sql->f("id"); | |
| 137 | - echo "read userID=$userID from db<br>"; | |
| 138 | - } | |
| 139 | - } else { | |
| 140 | - // select failed, bail | |
| 141 | - // FIXME: need a rollback here | |
| 142 | - echo "id select failed<br>"; | |
| 143 | - return false; | |
| 144 | - } | |
| 145 | - | |
| 146 | - // now insert into the user-unit mapping table | |
| 147 | - $query = "insert into $default->owl_user_unit_table (user_id, unit_id) values ($userID, $unitID)"; | |
| 148 | - $result = $sql->query($query); | |
| 149 | - if (!'result') { | |
| 150 | - // FIXME: rollback! | |
| 151 | - echo "insert into user-unit table failed<br>"; | |
| 152 | - return false; | |
| 153 | - } else { | |
| 154 | - echo "insert into user-unit table worked!<br>"; | |
| 155 | - } | |
| 156 | - | |
| 157 | - return true; | |
| 158 | - } | |
| 159 | - | |
| 160 | - //----------------------------------------------------------------- | |
| 161 | - /* | |
| 162 | - * Function RemoveUser($unitID, $userID) | |
| 163 | - * | |
| 164 | - * Adds a user to the unit. | |
| 165 | - * | |
| 166 | - * @param unitID | |
| 167 | - * The ID of the unit to add the user to | |
| 168 | - * @param userID | |
| 169 | - * The Id of the User that must be deleted | |
| 170 | - * @return | |
| 171 | - * True if the deletion was successful, else false if not or nonexistant. | |
| 172 | - */ | |
| 173 | - //----------------------------------------------------------------- | |
| 174 | - function removeUser($unitID, $userID) | |
| 175 | - { | |
| 176 | - global $default; | |
| 177 | - // create a connection | |
| 178 | - $db = new Owl_DB; | |
| 179 | - | |
| 180 | - //do validation that userid exists | |
| 181 | - $sql = "SELECT * FROM $default->owl_users_table WHERE $id = $userID"; | |
| 182 | - $result = $db->query($sql) | |
| 183 | - if(!'result') | |
| 184 | - { | |
| 185 | - printf"User does not exist in the database") | |
| 186 | - return false | |
| 187 | - } | |
| 188 | - | |
| 189 | - //if user id exists delete it from the users table | |
| 190 | - $sql = "DELETE FROM $default->owl_users_table WHERE id = $userID"; | |
| 191 | - $result = $db->query($sql) | |
| 192 | - if(!'result') | |
| 193 | - { | |
| 194 | - return false; | |
| 195 | - } | |
| 196 | - else | |
| 197 | - { | |
| 198 | - echo "Deletion from user table Successful<br>"; | |
| 199 | - return true; | |
| 200 | - } | |
| 201 | - | |
| 202 | - } | |
| 203 | - | |
| 204 | - //----------------------------------------------------------------- | |
| 205 | - /* | |
| 206 | - * Function updateUser($userID, $userDetails) | |
| 207 | - * | |
| 208 | - * Adds a user to the unit. | |
| 209 | - * | |
| 210 | - * @param userID | |
| 211 | - * the ID of the unit to add the user to | |
| 212 | - * @param userDetails | |
| 213 | - * an array containing the details of the user | |
| 214 | - * @return | |
| 215 | - * true if the addition was successful, else false. | |
| 216 | - */ | |
| 217 | - //----------------------------------------------------------------- | |
| 218 | - function updateUser($userID, $userDetails) | |
| 219 | - { | |
| 220 | - global $default; | |
| 221 | - // create a connection | |
| 222 | - $db = new Owl_DB; | |
| 223 | - | |
| 224 | - //do validation that userid exists | |
| 225 | - $sql = "SELECT * FROM $default->owl_users_table WHERE $id = $userID"; | |
| 226 | - $result = $db->query($sql) | |
| 227 | - if(!'result') | |
| 228 | - { | |
| 229 | - printf"User does not exist in the database") | |
| 230 | - return false | |
| 231 | - } | |
| 232 | - | |
| 233 | - //if user id exists update all info into the users table | |
| 234 | - //TODO group id change?????? | |
| 235 | - $sql = "UPDATE $default->owl_users_table SET " . | |
| 236 | - " username = " . $userDetails['username'] . "," . | |
| 237 | - " name = " . $userDetails['name'] . "," . | |
| 238 | - " password = " . $userDetails['password'] . "," . | |
| 239 | - " quota_max = " . $userDetails['quota_max'] ."," . | |
| 240 | - " quota_current = " . $userDetails['quota_current'] ."," . | |
| 241 | - " name = " . $userDetails['name'] . "," . | |
| 242 | - " email = " . $userDetails['email'] . "," . | |
| 243 | - " mobile = " . $userDetails['mobile'] . "," . | |
| 244 | - " email_notification = " . $userDetails['email_notification'] ."," . | |
| 245 | - " sms_notification = " . $userDetails['sms_notification'] . " | |
| 246 | - " WHERE id = ". $userID ."" ; | |
| 247 | - | |
| 248 | - | |
| 249 | - $result = $db->query($sql) | |
| 250 | - if(!'result') | |
| 251 | - { | |
| 252 | - printf("Not Updated) | |
| 253 | - return false; | |
| 254 | - } | |
| 255 | - else | |
| 256 | - { | |
| 257 | - echo "Deletion from user table Successful<br>"; | |
| 258 | - return true; | |
| 259 | - } | |
| 260 | - } | |
| 261 | - //----------------------------------------------------------------- | |
| 262 | - /* | |
| 263 | - * Function listUser() | |
| 264 | - * | |
| 265 | - * returns an array of all the usernames | |
| 266 | - * | |
| 267 | - * @return | |
| 268 | - * an array of usernames | |
| 269 | - */ | |
| 270 | - //----------------------------------------------------------------- | |
| 271 | - function listUser(){ | |
| 272 | - | |
| 273 | - global $default; | |
| 274 | - // create a connection | |
| 275 | - $db = new Owl_DB; | |
| 276 | - | |
| 277 | - //Get list of all the usernames | |
| 278 | - $sql = "SELECT username FROM $default->owl_users_table"; | |
| 279 | - $result = $db->query($sql) | |
| 280 | - | |
| 281 | - //return an array of the usernames | |
| 282 | - return $result; | |
| 283 | - | |
| 284 | - } | |
| 285 | - | |
| 286 | - //----------------------------------------------------------------- | |
| 287 | - /* | |
| 288 | - * Function GetUserDetails($userID) | |
| 289 | - * | |
| 290 | - * Returns an array of all the details for a specified user. | |
| 291 | - * | |
| 292 | - * @return | |
| 293 | - * an array of usernames | |
| 294 | - */ | |
| 295 | - //----------------------------------------------------------------- | |
| 296 | - function GetUserDetails($userID){ | |
| 297 | - | |
| 298 | - global $default; | |
| 299 | - // create a connection | |
| 300 | - $db = new Owl_DB; | |
| 301 | - | |
| 302 | - //do validation that userid exists | |
| 303 | - $sql = "SELECT * FROM $default->owl_users_table WHERE $id = $userID"; | |
| 304 | - $result = $db->query($sql) | |
| 305 | - if(!'result') | |
| 306 | - { | |
| 307 | - printf"User does not exist in the database") | |
| 308 | - return false | |
| 309 | - } | |
| 310 | - | |
| 311 | - //return an array of the usernames | |
| 312 | - return $result; | |
| 313 | - | |
| 314 | - } | |
| 315 | - | |
| 316 | - // group management | |
| 317 | - | |
| 318 | - //----------------------------------------------------------------- | |
| 319 | - /* | |
| 320 | - * Function addUser($unitID, $userDetails) | |
| 321 | - * | |
| 322 | - * Adds a user to the unit. | |
| 323 | - * | |
| 324 | - * @param unitID | |
| 325 | - * the ID of the unit to add the user to | |
| 326 | - * @param userDetails | |
| 327 | - * an array containing the details of the user | |
| 328 | - * @return | |
| 329 | - * true if the addition was successful, else false. | |
| 330 | - */ | |
| 331 | - //----------------------------------------------------------------- | |
| 332 | - function createGroup($name){ | |
| 333 | - return false; | |
| 334 | - } | |
| 335 | - | |
| 336 | - //----------------------------------------------------------------- | |
| 337 | - /* | |
| 338 | - * Function addUser($unitID, $userDetails) | |
| 339 | - * | |
| 340 | - * Adds a user to the unit. | |
| 341 | - * | |
| 342 | - * @param unitID | |
| 343 | - * the ID of the unit to add the user to | |
| 344 | - * @param userDetails | |
| 345 | - * an array containing the details of the user | |
| 346 | - * @return | |
| 347 | - * true if the addition was successful, else false. | |
| 348 | - */ | |
| 349 | - //----------------------------------------------------------------- | |
| 350 | - function removeGroup($groupID){ | |
| 351 | - return false; | |
| 352 | - } | |
| 353 | - | |
| 354 | - //----------------------------------------------------------------- | |
| 355 | - /* | |
| 356 | - * Function addUser($unitID, $userDetails) | |
| 357 | - * | |
| 358 | - * Adds a user to the unit. | |
| 359 | - * | |
| 360 | - * @param unitID | |
| 361 | - * the ID of the unit to add the user to | |
| 362 | - * @param userDetails | |
| 363 | - * an array containing the details of the user | |
| 364 | - * @return | |
| 365 | - * true if the addition was successful, else false. | |
| 366 | - */ | |
| 367 | - //----------------------------------------------------------------- | |
| 368 | - function updateGroup($groupID, $name){ | |
| 369 | - return false; | |
| 370 | - } | |
| 371 | -//----------------------------------------------------------------- | |
| 372 | - /* | |
| 373 | - * Function addUser($unitID, $userDetails) | |
| 374 | - * | |
| 375 | - * Adds a user to the unit. | |
| 376 | - * | |
| 377 | - * @param unitID | |
| 378 | - * the ID of the unit to add the user to | |
| 379 | - * @param userDetails | |
| 380 | - * an array containing the details of the user | |
| 381 | - * @return | |
| 382 | - * true if the addition was successful, else false. | |
| 383 | - */ | |
| 384 | - //----------------------------------------------------------------- | |
| 385 | - function listGroup(){ | |
| 386 | - //return null; | |
| 387 | - } | |
| 388 | - //----------------------------------------------------------------- | |
| 389 | - /* | |
| 390 | - * Function addUser($unitID, $userDetails) | |
| 391 | - * | |
| 392 | - * Adds a user to the unit. | |
| 393 | - * | |
| 394 | - * @param unitID | |
| 395 | - * the ID of the unit to add the user to | |
| 396 | - * @param userDetails | |
| 397 | - * an array containing the details of the user | |
| 398 | - * @return | |
| 399 | - * true if the addition was successful, else false. | |
| 400 | - */ | |
| 401 | - //----------------------------------------------------------------- | |
| 402 | - /** | |
| 403 | - * @param groupID | |
| 404 | - * @param userID | |
| 405 | - */ | |
| 406 | - function addUserToGroup($groupID, $userID){ | |
| 407 | - return false; | |
| 408 | - } | |
| 409 | -//----------------------------------------------------------------- | |
| 410 | - /* | |
| 411 | - * Function addUser($unitID, $userDetails) | |
| 412 | - * | |
| 413 | - * Adds a user to the unit. | |
| 414 | - * | |
| 415 | - * @param unitID | |
| 416 | - * the ID of the unit to add the user to | |
| 417 | - * @param userDetails | |
| 418 | - * an array containing the details of the user | |
| 419 | - * @return | |
| 420 | - * true if the addition was successful, else false. | |
| 421 | - */ | |
| 422 | - //----------------------------------------------------------------- | |
| 423 | - /** | |
| 424 | - * @param groupID | |
| 425 | - * @param userID | |
| 426 | - */ | |
| 427 | - function removeUserFromGroup($groupID, $userID){ | |
| 428 | - return false; | |
| 429 | - } | |
| 430 | - //----------------------------------------------------------------- | |
| 431 | - /* | |
| 432 | - * Function addUser($unitID, $userDetails) | |
| 433 | - * | |
| 434 | - * Adds a user to the unit. | |
| 435 | - * | |
| 436 | - * @param unitID | |
| 437 | - * the ID of the unit to add the user to | |
| 438 | - * @param userDetails | |
| 439 | - * an array containing the details of the user | |
| 440 | - * @return | |
| 441 | - * true if the addition was successful, else false. | |
| 442 | - */ | |
| 443 | - //----------------------------------------------------------------- | |
| 444 | - // category management | |
| 445 | - | |
| 446 | - /** | |
| 447 | - * @param name | |
| 448 | - */ | |
| 449 | - function createCategory($name){ | |
| 450 | - return false; | |
| 451 | - } | |
| 452 | -//----------------------------------------------------------------- | |
| 453 | - /* | |
| 454 | - * Function addUser($unitID, $userDetails) | |
| 455 | - * | |
| 456 | - * Adds a user to the unit. | |
| 457 | - * | |
| 458 | - * @param unitID | |
| 459 | - * the ID of the unit to add the user to | |
| 460 | - * @param userDetails | |
| 461 | - * an array containing the details of the user | |
| 462 | - * @return | |
| 463 | - * true if the addition was successful, else false. | |
| 464 | - */ | |
| 465 | - //----------------------------------------------------------------- | |
| 466 | - /** | |
| 467 | - * @param categoryID | |
| 468 | - */ | |
| 469 | - function removeCategory($categoryID){ | |
| 470 | - return false; | |
| 471 | - } | |
| 472 | -//----------------------------------------------------------------- | |
| 473 | - /* | |
| 474 | - * Function addUser($unitID, $userDetails) | |
| 475 | - * | |
| 476 | - * Adds a user to the unit. | |
| 477 | - * | |
| 478 | - * @param unitID | |
| 479 | - * the ID of the unit to add the user to | |
| 480 | - * @param userDetails | |
| 481 | - * an array containing the details of the user | |
| 482 | - * @return | |
| 483 | - * true if the addition was successful, else false. | |
| 484 | - */ | |
| 485 | - //----------------------------------------------------------------- | |
| 486 | - /** | |
| 487 | - * @param name | |
| 488 | - * @param categoryID | |
| 489 | - */ | |
| 490 | - function updateCategory($name, $categoryID){ | |
| 491 | - return false; | |
| 492 | - } | |
| 493 | -//----------------------------------------------------------------- | |
| 494 | - /* | |
| 495 | - * Function addUser($unitID, $userDetails) | |
| 496 | - * | |
| 497 | - * Adds a user to the unit. | |
| 498 | - * | |
| 499 | - * @param unitID | |
| 500 | - * the ID of the unit to add the user to | |
| 501 | - * @param userDetails | |
| 502 | - * an array containing the details of the user | |
| 503 | - * @return | |
| 504 | - * true if the addition was successful, else false. | |
| 505 | - */ | |
| 506 | - //----------------------------------------------------------------- | |
| 507 | - function listCategories(){ | |
| 508 | - //return null; | |
| 509 | - } | |
| 510 | - | |
| 511 | -} | |
| 512 | -?> |