Commit 65561c960df115915534da35b77411dbd5e6f968
1 parent
23fa9e11
fixed phpdoc and added ldap method error handling
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@251 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
24 additions
and
76 deletions
lib/administration/UserManager.inc
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | require_once("$default->owl_fs_root/lib/class.AuthLdap.php"); | 3 | require_once("$default->owl_fs_root/lib/class.AuthLdap.php"); |
| 4 | -/*-----------------------------------------------------------------*/ | 4 | + |
| 5 | /** | 5 | /** |
| 6 | * $Id$ | 6 | * $Id$ |
| 7 | * | 7 | * |
| 8 | - * Performs unit administration tasks- this includes user, group and category management, | 8 | + * Performs user administration tasks- this includes create, remove, update |
| 9 | + * as well as addUserToGroup and removeUserFromGroup ..etc | ||
| 9 | * | 10 | * |
| 10 | * @version $Revision$ | 11 | * @version $Revision$ |
| 11 | * @author Mukhtar Dharsey | 12 | * @author Mukhtar Dharsey |
| 12 | - * @package dmslib | ||
| 13 | - */ | ||
| 14 | - | ||
| 15 | -/*-----------------------------------------------------------------*/ | ||
| 16 | -/** | ||
| 17 | - * Class User Manager | ||
| 18 | - * | ||
| 19 | - * Performs user administration tasks- this includes create,remove,update | ||
| 20 | - * as well as addusertogroup and removeuserfromgroup ..etc | ||
| 21 | - * | 13 | + * @package dmslib |
| 22 | */ | 14 | */ |
| 23 | -/*-----------------------------------------------------------------*/ | ||
| 24 | - | ||
| 25 | -class UserManager | ||
| 26 | - { | 15 | +class UserManager { |
| 27 | 16 | ||
| 28 | /** | 17 | /** |
| 29 | * Handle to the ldap util class | 18 | * Handle to the ldap util class |
| @@ -32,10 +21,7 @@ class UserManager | @@ -32,10 +21,7 @@ class UserManager | ||
| 32 | 21 | ||
| 33 | // user management | 22 | // user management |
| 34 | 23 | ||
| 35 | - /*-----------------------------------------------------------------*/ | ||
| 36 | - /* | ||
| 37 | - * Function ListLdapUsers($userNameSearch) | ||
| 38 | - * | 24 | + /** |
| 39 | * Searches the LDAP directory for users matching the supplied search string. | 25 | * Searches the LDAP directory for users matching the supplied search string. |
| 40 | * | 26 | * |
| 41 | * @param $userNameSearch | 27 | * @param $userNameSearch |
| @@ -43,7 +29,6 @@ class UserManager | @@ -43,7 +29,6 @@ class UserManager | ||
| 43 | * @return array | 29 | * @return array |
| 44 | * returns an array containing the users found | 30 | * returns an array containing the users found |
| 45 | */ | 31 | */ |
| 46 | - /*-----------------------------------------------------------------*/ | ||
| 47 | function listLdapUsers($userNameSearch) { | 32 | function listLdapUsers($userNameSearch) { |
| 48 | global $default; | 33 | global $default; |
| 49 | 34 | ||
| @@ -67,21 +52,12 @@ class UserManager | @@ -67,21 +52,12 @@ class UserManager | ||
| 67 | return false; | 52 | return false; |
| 68 | } | 53 | } |
| 69 | } else { | 54 | } else { |
| 70 | - // ldap connection failed, bail | ||
| 71 | - // TODO: error handling | 55 | + $_SESSION["errorMessage"] = "LDAP error: (" . $ldap->ldapErrorCode ") " . $ldap->ldapErrorText; |
| 72 | return false; | 56 | return false; |
| 73 | - /* | ||
| 74 | - $default->log->debug "There was a problem.<br>"; | ||
| 75 | - $default->log->debug "Error code : " . $ldap->ldapErrorCode . "<br>"; | ||
| 76 | - $default->log->debug "Error text : " . $ldap->ldapErrorText . "<br>"; | ||
| 77 | - */ | ||
| 78 | } | 57 | } |
| 79 | } | 58 | } |
| 80 | 59 | ||
| 81 | - | ||
| 82 | - //----------------------------------------------------------------- | ||
| 83 | - /* | ||
| 84 | - * Function createUser($userDetails) | 60 | + /** |
| 85 | * | 61 | * |
| 86 | * Adds a user to the unit. | 62 | * Adds a user to the unit. |
| 87 | * | 63 | * |
| @@ -178,10 +154,7 @@ class UserManager | @@ -178,10 +154,7 @@ class UserManager | ||
| 178 | 154 | ||
| 179 | } | 155 | } |
| 180 | 156 | ||
| 181 | - //----------------------------------------------------------------- | ||
| 182 | - /* | ||
| 183 | - * Function RemoveUser($userID) | ||
| 184 | - * | 157 | + /** |
| 185 | * Removes a user from the users table...since a user does not exist anymore.. | 158 | * Removes a user from the users table...since a user does not exist anymore.. |
| 186 | * deletion from all its groups is also required | 159 | * deletion from all its groups is also required |
| 187 | * | 160 | * |
| @@ -192,9 +165,7 @@ class UserManager | @@ -192,9 +165,7 @@ class UserManager | ||
| 192 | * @return boolean | 165 | * @return boolean |
| 193 | * True if the deletion was successful, else false if not or nonexistant. | 166 | * True if the deletion was successful, else false if not or nonexistant. |
| 194 | */ | 167 | */ |
| 195 | - //----------------------------------------------------------------- | ||
| 196 | - function removeUser($userID) | ||
| 197 | - { | 168 | + function removeUser($userID) { |
| 198 | global $default; | 169 | global $default; |
| 199 | // create a connection | 170 | // create a connection |
| 200 | $sql = new Owl_DB; | 171 | $sql = new Owl_DB; |
| @@ -232,10 +203,7 @@ class UserManager | @@ -232,10 +203,7 @@ class UserManager | ||
| 232 | 203 | ||
| 233 | } | 204 | } |
| 234 | 205 | ||
| 235 | - //----------------------------------------------------------------- | ||
| 236 | - /* | ||
| 237 | - * Function updateUser($userID, $userDetails) | ||
| 238 | - * | 206 | + /** |
| 239 | * Updates a users details | 207 | * Updates a users details |
| 240 | * | 208 | * |
| 241 | * @param userID | 209 | * @param userID |
| @@ -245,7 +213,6 @@ class UserManager | @@ -245,7 +213,6 @@ class UserManager | ||
| 245 | * @return boolean | 213 | * @return boolean |
| 246 | * true if the addition was successful, else false. | 214 | * true if the addition was successful, else false. |
| 247 | */ | 215 | */ |
| 248 | - //----------------------------------------------------------------- | ||
| 249 | function updateUser($userID, $userDetails) | 216 | function updateUser($userID, $userDetails) |
| 250 | { | 217 | { |
| 251 | global $default; | 218 | global $default; |
| @@ -292,16 +259,13 @@ class UserManager | @@ -292,16 +259,13 @@ class UserManager | ||
| 292 | return true; | 259 | return true; |
| 293 | } | 260 | } |
| 294 | } | 261 | } |
| 295 | - //----------------------------------------------------------------- | ||
| 296 | - /* | ||
| 297 | - * Function listUser() | ||
| 298 | - * | ||
| 299 | - * returns an array of all the usernames | 262 | + |
| 263 | + /** | ||
| 264 | + * Returns an array of all the usernames | ||
| 300 | * | 265 | * |
| 301 | * @return array | 266 | * @return array |
| 302 | * An array of usernames | 267 | * An array of usernames |
| 303 | - */ | ||
| 304 | - //----------------------------------------------------------------- | 268 | + */ |
| 305 | function listUsers(){ | 269 | function listUsers(){ |
| 306 | 270 | ||
| 307 | global $default; | 271 | global $default; |
| @@ -331,8 +295,7 @@ class UserManager | @@ -331,8 +295,7 @@ class UserManager | ||
| 331 | 295 | ||
| 332 | } | 296 | } |
| 333 | 297 | ||
| 334 | - //----------------------------------------------------------------- | ||
| 335 | - /* | 298 | + /** |
| 336 | * Function getUserDetails($userID) | 299 | * Function getUserDetails($userID) |
| 337 | * | 300 | * |
| 338 | * Returns an array of all the details for a specified user. | 301 | * Returns an array of all the details for a specified user. |
| @@ -340,7 +303,6 @@ class UserManager | @@ -340,7 +303,6 @@ class UserManager | ||
| 340 | * @return array | 303 | * @return array |
| 341 | * An array of details of a specified user | 304 | * An array of details of a specified user |
| 342 | */ | 305 | */ |
| 343 | - //----------------------------------------------------------------- | ||
| 344 | function getUserDetails($userID) | 306 | function getUserDetails($userID) |
| 345 | { | 307 | { |
| 346 | 308 | ||
| @@ -379,9 +341,7 @@ class UserManager | @@ -379,9 +341,7 @@ class UserManager | ||
| 379 | 341 | ||
| 380 | } | 342 | } |
| 381 | 343 | ||
| 382 | - //----------------------------------------------------------------- | ||
| 383 | - /* | ||
| 384 | - * Function addUserToGroup($groupID, $userID) | 344 | + /** |
| 385 | * | 345 | * |
| 386 | * Adds a user to the group. | 346 | * Adds a user to the group. |
| 387 | * | 347 | * |
| @@ -392,7 +352,6 @@ class UserManager | @@ -392,7 +352,6 @@ class UserManager | ||
| 392 | * @return boolean | 352 | * @return boolean |
| 393 | * True if the addition was successful, else false if not or nonexistant. | 353 | * True if the addition was successful, else false if not or nonexistant. |
| 394 | */ | 354 | */ |
| 395 | - //----------------------------------------------------------------- | ||
| 396 | function addUserToGroup($userID,$groupID) | 355 | function addUserToGroup($userID,$groupID) |
| 397 | { | 356 | { |
| 398 | global $default; | 357 | global $default; |
| @@ -428,11 +387,8 @@ class UserManager | @@ -428,11 +387,8 @@ class UserManager | ||
| 428 | } | 387 | } |
| 429 | 388 | ||
| 430 | 389 | ||
| 431 | - //----------------------------------------------------------------- | ||
| 432 | - /* | ||
| 433 | - * Function removeUserFromGroup($userID, $groupID) | ||
| 434 | - * | ||
| 435 | - * removes a user from a group | 390 | + /** |
| 391 | + * Removes a user from a group | ||
| 436 | * | 392 | * |
| 437 | * @param groupID | 393 | * @param groupID |
| 438 | * The ID of the group to remove the user from | 394 | * The ID of the group to remove the user from |
| @@ -441,7 +397,6 @@ class UserManager | @@ -441,7 +397,6 @@ class UserManager | ||
| 441 | * @return boolean | 397 | * @return boolean |
| 442 | * True if the deletion was successful, else false if not or nonexistant. | 398 | * True if the deletion was successful, else false if not or nonexistant. |
| 443 | */ | 399 | */ |
| 444 | - //----------------------------------------------------------------- | ||
| 445 | function removeUserFromGroup($userID,$groupID) | 400 | function removeUserFromGroup($userID,$groupID) |
| 446 | { | 401 | { |
| 447 | global $default; | 402 | global $default; |
| @@ -477,18 +432,14 @@ class UserManager | @@ -477,18 +432,14 @@ class UserManager | ||
| 477 | 432 | ||
| 478 | } | 433 | } |
| 479 | 434 | ||
| 480 | - //----------------------------------------------------------------- | ||
| 481 | - /* | ||
| 482 | - * Function removeUserFromAllGroups($userID) | ||
| 483 | - * | ||
| 484 | - * removes a user from ALL groups it belongs to | 435 | + /** |
| 436 | + * Removes a user from ALL groups it belongs to | ||
| 485 | * | 437 | * |
| 486 | - * @param userID | 438 | + * @param userID |
| 487 | * The Id of the User that must be removed from the table | 439 | * The Id of the User that must be removed from the table |
| 488 | * @return boolean | 440 | * @return boolean |
| 489 | * True if the deletion was successful, else false if not or nonexistant. | 441 | * True if the deletion was successful, else false if not or nonexistant. |
| 490 | */ | 442 | */ |
| 491 | - //----------------------------------------------------------------- | ||
| 492 | function removeUserFromAllGroups($userID) | 443 | function removeUserFromAllGroups($userID) |
| 493 | { | 444 | { |
| 494 | global $default; | 445 | global $default; |
| @@ -523,10 +474,8 @@ class UserManager | @@ -523,10 +474,8 @@ class UserManager | ||
| 523 | } | 474 | } |
| 524 | 475 | ||
| 525 | } | 476 | } |
| 526 | - //----------------------------------------------------------------- | ||
| 527 | - /* | ||
| 528 | - * Function getUserID($username) | ||
| 529 | - * | 477 | + |
| 478 | + /** | ||
| 530 | * Adds a user to the unit. | 479 | * Adds a user to the unit. |
| 531 | * | 480 | * |
| 532 | * @param $username | 481 | * @param $username |
| @@ -534,7 +483,6 @@ class UserManager | @@ -534,7 +483,6 @@ class UserManager | ||
| 534 | * @return Integer | 483 | * @return Integer |
| 535 | * The username's Id | 484 | * The username's Id |
| 536 | */ | 485 | */ |
| 537 | - //----------------------------------------------------------------- | ||
| 538 | function getUserID($username) | 486 | function getUserID($username) |
| 539 | { | 487 | { |
| 540 | global $default; | 488 | global $default; |