Commit a5ac30f882b33539295921848fad5a6bbdd0e349

Authored by mukhtar
1 parent a1d14e65

added debug stuffs


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@226 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/administration/UserManager.inc
@@ -11,6 +11,7 @@ require_once("$default->owl_fs_root/lib/class.AuthLdap.php"); @@ -11,6 +11,7 @@ require_once("$default->owl_fs_root/lib/class.AuthLdap.php");
11 * @author Mukhtar Dharsey 11 * @author Mukhtar Dharsey
12 * @package dmslib 12 * @package dmslib
13 */ 13 */
  14 +
14 /*-----------------------------------------------------------------*/ 15 /*-----------------------------------------------------------------*/
15 /** 16 /**
16 * Class User Manager 17 * Class User Manager
@@ -70,9 +71,9 @@ class UserManager @@ -70,9 +71,9 @@ class UserManager
70 // TODO: error handling 71 // TODO: error handling
71 return false; 72 return false;
72 /* 73 /*
73 - echo "There was a problem.<br>";  
74 - echo "Error code : " . $ldap->ldapErrorCode . "<br>";  
75 - echo "Error text : " . $ldap->ldapErrorText . "<br>"; 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>";
76 */ 77 */
77 } 78 }
78 } 79 }
@@ -106,8 +107,8 @@ class UserManager @@ -106,8 +107,8 @@ class UserManager
106 if ($rows > 0) 107 if ($rows > 0)
107 { 108 {
108 // duplicate username 109 // duplicate username
109 - $default->errorMessage = "The username " . $userDetails['username'] . " is already in use, please choose another one";  
110 - echo $default->errorMessage; 110 + $default->errorMessage = "UserManager::The username " . $userDetails['username'] . " is already in use, please choose another one";
  111 + $default->log->debug($default->errorMessage);
111 return false; 112 return false;
112 } 113 }
113 // insert the user 114 // insert the user
@@ -130,12 +131,12 @@ class UserManager @@ -130,12 +131,12 @@ class UserManager
130 131
131 if(!'result') 132 if(!'result')
132 { 133 {
133 - echo "Addition Unsuccessful!<br>"; 134 + $default->log->debug( "UserManager::Addition Unsuccessful!<br>");
134 return false; 135 return false;
135 } 136 }
136 else 137 else
137 { 138 {
138 - echo "User added Successfully!<br>"; 139 + $default->log->debug ("UserManager::User added Successfully!<br>");
139 } 140 }
140 return true; 141 return true;
141 142
@@ -152,12 +153,12 @@ class UserManager @@ -152,12 +153,12 @@ class UserManager
152 if ($numrows == "1") { 153 if ($numrows == "1") {
153 while($sql->next_record()) { 154 while($sql->next_record()) {
154 $userID = $sql->f("id"); 155 $userID = $sql->f("id");
155 - echo "read userID=$userID from db<br>"; 156 + $default->log->debug "read userID=$userID from db<br>";
156 } 157 }
157 } else { 158 } else {
158 select failed, bail 159 select failed, bail
159 // FIXME: need a rollback here 160 // FIXME: need a rollback here
160 - echo "id select failed<br>"; 161 + $default->log->debug "id select failed<br>";
161 return false; 162 return false;
162 } 163 }
163 164
@@ -166,12 +167,12 @@ class UserManager @@ -166,12 +167,12 @@ class UserManager
166 $result = $sql->query($query); 167 $result = $sql->query($query);
167 if (!'result') { 168 if (!'result') {
168 // FIXME: rollback! 169 // FIXME: rollback!
169 - echo "insert into user-unit table failed<br>"; 170 + $default->log->debug "insert into user-unit table failed<br>";
170 return false; 171 return false;
171 } 172 }
172 else 173 else
173 { 174 {
174 - echo "insert into user-unit table worked!<br>"; 175 + $default->log->debug "insert into user-unit table worked!<br>";
175 }*/ 176 }*/
176 177
177 178
@@ -206,7 +207,7 @@ class UserManager @@ -206,7 +207,7 @@ class UserManager
206 // check if result was found..0 if not 207 // check if result was found..0 if not
207 if($row == 0) 208 if($row == 0)
208 { 209 {
209 - printf("User does not exist in the database<br>"); 210 + $default->log->debug("UserManager::User does not exist in the database<br>");
210 return false; 211 return false;
211 } 212 }
212 213
@@ -216,12 +217,12 @@ class UserManager @@ -216,12 +217,12 @@ class UserManager
216 217
217 if(!'result') 218 if(!'result')
218 { 219 {
219 - echo "Deletion unsuccessful<br>"; 220 + $default->log->debug("UserManager::Deletion unsuccessful<br>");
220 return false; 221 return false;
221 } 222 }
222 else 223 else
223 { 224 {
224 - echo "Deletion from user table Successful<br>"; 225 + $default->log->debug ("UserManager::Deletion from user table Successful<br>");
225 //check if belongs to group 226 //check if belongs to group
226 $result= $this->removeUserFromAllGroups($userID); 227 $result= $this->removeUserFromAllGroups($userID);
227 return true; 228 return true;
@@ -259,7 +260,7 @@ class UserManager @@ -259,7 +260,7 @@ class UserManager
259 //if row = 0 ...then no entry was found..so return false 260 //if row = 0 ...then no entry was found..so return false
260 if($row == 0) 261 if($row == 0)
261 { 262 {
262 - printf("User does not exist in the database<br>"); 263 + $default->log->debug("UserManager::User does not exist in the database<br>");
263 return false; 264 return false;
264 } 265 }
265 266
@@ -282,12 +283,12 @@ class UserManager @@ -282,12 +283,12 @@ class UserManager
282 // error checking to see if success 283 // error checking to see if success
283 if(!'result') 284 if(!'result')
284 { 285 {
285 - printf("Not Updated"); 286 + $default->log->debug("UserManager::Not Updated");
286 return false; 287 return false;
287 } 288 }
288 else 289 else
289 { 290 {
290 - printf("Update Successful<br>"); 291 + $default->log->debug("UserManager::Update Successful<br>");
291 return true; 292 return true;
292 } 293 }
293 } 294 }
@@ -312,6 +313,13 @@ class UserManager @@ -312,6 +313,13 @@ class UserManager
312 //Get list of all the usernames 313 //Get list of all the usernames
313 $query = "SELECT username FROM $default->owl_users_table"; 314 $query = "SELECT username FROM $default->owl_users_table";
314 $result = $sql->query($query); 315 $result = $sql->query($query);
  316 + $row = $sql->num_rows($result);
  317 +
  318 + if($row == 0)
  319 + {
  320 + $default->log->debug("UserManager::No users in table");
  321 + return false;
  322 + }
315 323
316 while($sql->next_record()) 324 while($sql->next_record())
317 { 325 {
@@ -348,7 +356,7 @@ class UserManager @@ -348,7 +356,7 @@ class UserManager
348 356
349 if($row == 0) 357 if($row == 0)
350 { 358 {
351 - printf("User does not exist in the database<br>"); 359 + $default->log->debug("UserManager::User does not exist in the database<br>");
352 return false; 360 return false;
353 } 361 }
354 362
@@ -398,7 +406,7 @@ class UserManager @@ -398,7 +406,7 @@ class UserManager
398 406
399 if($row >= 1) 407 if($row >= 1)
400 { 408 {
401 - printf("User already belongs to group<br>"); 409 + $default->log->debug("UserManager::User already belongs to group<br>");
402 return false; 410 return false;
403 } 411 }
404 412
@@ -408,12 +416,12 @@ class UserManager @@ -408,12 +416,12 @@ class UserManager
408 416
409 if(!'result') 417 if(!'result')
410 { 418 {
411 - echo "Insertion into user_group table unsuccessful<br>"; 419 + $default->log->debug("UserManager::Insertion into user_group table unsuccessful<br>");
412 return false; 420 return false;
413 } 421 }
414 else 422 else
415 { 423 {
416 - printf("Insertion into user_group table Successful<br>"); 424 + $default->log->debug("UserManager::Insertion into user_group table Successful<br>");
417 return true; 425 return true;
418 } 426 }
419 427
@@ -448,7 +456,7 @@ class UserManager @@ -448,7 +456,7 @@ class UserManager
448 // check if result was found..0 if not 456 // check if result was found..0 if not
449 if($row == 0) 457 if($row == 0)
450 { 458 {
451 - printf("User does not exist in the database<br>"); 459 + $default->log->debug("UserManager::User does not exist in the database<br>");
452 return false; 460 return false;
453 } 461 }
454 462
@@ -458,12 +466,12 @@ class UserManager @@ -458,12 +466,12 @@ class UserManager
458 466
459 if(!'result') 467 if(!'result')
460 { 468 {
461 - echo "Deletion unsuccessful<br>"; 469 + $default->log->debug ("UserManager::Deletion unsuccessful<br>");
462 return false; 470 return false;
463 } 471 }
464 else 472 else
465 { 473 {
466 - echo "Deletion from user_group_link table Successful<br>"; 474 + $default->log->debug("UserManager::Deletion from user_group_link table Successful<br>");
467 return true; 475 return true;
468 } 476 }
469 477
@@ -495,7 +503,7 @@ class UserManager @@ -495,7 +503,7 @@ class UserManager
495 // check if result was found..0 if not 503 // check if result was found..0 if not
496 if($row == 0) 504 if($row == 0)
497 { 505 {
498 - printf("User does not exist in the database<br>"); 506 + $default->log->debug("UserManager::User does not exist in the database<br>");
499 return false; 507 return false;
500 } 508 }
501 509
@@ -505,12 +513,12 @@ class UserManager @@ -505,12 +513,12 @@ class UserManager
505 513
506 if(!'result') 514 if(!'result')
507 { 515 {
508 - echo "Deletion unsuccessful<br>"; 516 + $default->log->debug ("UserManager::Deletion unsuccessful<br>");
509 return false; 517 return false;
510 } 518 }
511 else 519 else
512 { 520 {
513 - echo "Deletion from user_group_link table Successful<br>"; 521 + $default->log->debug ("UserManager::Deletion from user_group_link table Successful<br>");
514 return true; 522 return true;
515 } 523 }
516 524
@@ -548,8 +556,8 @@ class UserManager @@ -548,8 +556,8 @@ class UserManager
548 if ($rows == 0) 556 if ($rows == 0)
549 { 557 {
550 // duplicate username 558 // duplicate username
551 - $default->errorMessage = "The username " . $username . " does not exist<br>";  
552 - echo $default->errorMessage; 559 + $default->errorMessage = "UserManagerThe username " . $username . " does not exist<br>";
  560 + $default->log->debug($default->errorMessage);
553 return false; 561 return false;
554 } 562 }
555 else 563 else