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 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | require_once("$default->owl_fs_root/lib/class.AuthLdap.php"); |
| 4 | -/*-----------------------------------------------------------------*/ | |
| 4 | + | |
| 5 | 5 | /** |
| 6 | 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 | 11 | * @version $Revision$ |
| 11 | 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 | 18 | * Handle to the ldap util class |
| ... | ... | @@ -32,10 +21,7 @@ class UserManager |
| 32 | 21 | |
| 33 | 22 | // user management |
| 34 | 23 | |
| 35 | - /*-----------------------------------------------------------------*/ | |
| 36 | - /* | |
| 37 | - * Function ListLdapUsers($userNameSearch) | |
| 38 | - * | |
| 24 | + /** | |
| 39 | 25 | * Searches the LDAP directory for users matching the supplied search string. |
| 40 | 26 | * |
| 41 | 27 | * @param $userNameSearch |
| ... | ... | @@ -43,7 +29,6 @@ class UserManager |
| 43 | 29 | * @return array |
| 44 | 30 | * returns an array containing the users found |
| 45 | 31 | */ |
| 46 | - /*-----------------------------------------------------------------*/ | |
| 47 | 32 | function listLdapUsers($userNameSearch) { |
| 48 | 33 | global $default; |
| 49 | 34 | |
| ... | ... | @@ -67,21 +52,12 @@ class UserManager |
| 67 | 52 | return false; |
| 68 | 53 | } |
| 69 | 54 | } else { |
| 70 | - // ldap connection failed, bail | |
| 71 | - // TODO: error handling | |
| 55 | + $_SESSION["errorMessage"] = "LDAP error: (" . $ldap->ldapErrorCode ") " . $ldap->ldapErrorText; | |
| 72 | 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 | 62 | * Adds a user to the unit. |
| 87 | 63 | * |
| ... | ... | @@ -178,10 +154,7 @@ class UserManager |
| 178 | 154 | |
| 179 | 155 | } |
| 180 | 156 | |
| 181 | - //----------------------------------------------------------------- | |
| 182 | - /* | |
| 183 | - * Function RemoveUser($userID) | |
| 184 | - * | |
| 157 | + /** | |
| 185 | 158 | * Removes a user from the users table...since a user does not exist anymore.. |
| 186 | 159 | * deletion from all its groups is also required |
| 187 | 160 | * |
| ... | ... | @@ -192,9 +165,7 @@ class UserManager |
| 192 | 165 | * @return boolean |
| 193 | 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 | 169 | global $default; |
| 199 | 170 | // create a connection |
| 200 | 171 | $sql = new Owl_DB; |
| ... | ... | @@ -232,10 +203,7 @@ class UserManager |
| 232 | 203 | |
| 233 | 204 | } |
| 234 | 205 | |
| 235 | - //----------------------------------------------------------------- | |
| 236 | - /* | |
| 237 | - * Function updateUser($userID, $userDetails) | |
| 238 | - * | |
| 206 | + /** | |
| 239 | 207 | * Updates a users details |
| 240 | 208 | * |
| 241 | 209 | * @param userID |
| ... | ... | @@ -245,7 +213,6 @@ class UserManager |
| 245 | 213 | * @return boolean |
| 246 | 214 | * true if the addition was successful, else false. |
| 247 | 215 | */ |
| 248 | - //----------------------------------------------------------------- | |
| 249 | 216 | function updateUser($userID, $userDetails) |
| 250 | 217 | { |
| 251 | 218 | global $default; |
| ... | ... | @@ -292,16 +259,13 @@ class UserManager |
| 292 | 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 | 266 | * @return array |
| 302 | 267 | * An array of usernames |
| 303 | - */ | |
| 304 | - //----------------------------------------------------------------- | |
| 268 | + */ | |
| 305 | 269 | function listUsers(){ |
| 306 | 270 | |
| 307 | 271 | global $default; |
| ... | ... | @@ -331,8 +295,7 @@ class UserManager |
| 331 | 295 | |
| 332 | 296 | } |
| 333 | 297 | |
| 334 | - //----------------------------------------------------------------- | |
| 335 | - /* | |
| 298 | + /** | |
| 336 | 299 | * Function getUserDetails($userID) |
| 337 | 300 | * |
| 338 | 301 | * Returns an array of all the details for a specified user. |
| ... | ... | @@ -340,7 +303,6 @@ class UserManager |
| 340 | 303 | * @return array |
| 341 | 304 | * An array of details of a specified user |
| 342 | 305 | */ |
| 343 | - //----------------------------------------------------------------- | |
| 344 | 306 | function getUserDetails($userID) |
| 345 | 307 | { |
| 346 | 308 | |
| ... | ... | @@ -379,9 +341,7 @@ class UserManager |
| 379 | 341 | |
| 380 | 342 | } |
| 381 | 343 | |
| 382 | - //----------------------------------------------------------------- | |
| 383 | - /* | |
| 384 | - * Function addUserToGroup($groupID, $userID) | |
| 344 | + /** | |
| 385 | 345 | * |
| 386 | 346 | * Adds a user to the group. |
| 387 | 347 | * |
| ... | ... | @@ -392,7 +352,6 @@ class UserManager |
| 392 | 352 | * @return boolean |
| 393 | 353 | * True if the addition was successful, else false if not or nonexistant. |
| 394 | 354 | */ |
| 395 | - //----------------------------------------------------------------- | |
| 396 | 355 | function addUserToGroup($userID,$groupID) |
| 397 | 356 | { |
| 398 | 357 | global $default; |
| ... | ... | @@ -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 | 393 | * @param groupID |
| 438 | 394 | * The ID of the group to remove the user from |
| ... | ... | @@ -441,7 +397,6 @@ class UserManager |
| 441 | 397 | * @return boolean |
| 442 | 398 | * True if the deletion was successful, else false if not or nonexistant. |
| 443 | 399 | */ |
| 444 | - //----------------------------------------------------------------- | |
| 445 | 400 | function removeUserFromGroup($userID,$groupID) |
| 446 | 401 | { |
| 447 | 402 | global $default; |
| ... | ... | @@ -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 | 439 | * The Id of the User that must be removed from the table |
| 488 | 440 | * @return boolean |
| 489 | 441 | * True if the deletion was successful, else false if not or nonexistant. |
| 490 | 442 | */ |
| 491 | - //----------------------------------------------------------------- | |
| 492 | 443 | function removeUserFromAllGroups($userID) |
| 493 | 444 | { |
| 494 | 445 | global $default; |
| ... | ... | @@ -523,10 +474,8 @@ class UserManager |
| 523 | 474 | } |
| 524 | 475 | |
| 525 | 476 | } |
| 526 | - //----------------------------------------------------------------- | |
| 527 | - /* | |
| 528 | - * Function getUserID($username) | |
| 529 | - * | |
| 477 | + | |
| 478 | + /** | |
| 530 | 479 | * Adds a user to the unit. |
| 531 | 480 | * |
| 532 | 481 | * @param $username |
| ... | ... | @@ -534,7 +483,6 @@ class UserManager |
| 534 | 483 | * @return Integer |
| 535 | 484 | * The username's Id |
| 536 | 485 | */ |
| 537 | - //----------------------------------------------------------------- | |
| 538 | 486 | function getUserID($username) |
| 539 | 487 | { |
| 540 | 488 | global $default; | ... | ... |