Commit d2c0bb581c15920c442eaef326206db5a044a960

Authored by Michael Joseph
1 parent 376eadbf

corrected ldap searching / selecting bug


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1509 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/administration/usermanagement/addUserBL.php
@@ -13,6 +13,7 @@ if (checkSession()) { @@ -13,6 +13,7 @@ if (checkSession()) {
13 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); 13 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
14 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc"); 14 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");
15 require_once("addUserUI.inc"); 15 require_once("addUserUI.inc");
  16 + require_once("../adminUI.inc");
16 require_once("$default->fileSystemRoot/lib/users/User.inc"); 17 require_once("$default->fileSystemRoot/lib/users/User.inc");
17 require_once("$default->fileSystemRoot/lib/security/permission.inc"); 18 require_once("$default->fileSystemRoot/lib/security/permission.inc");
18 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 19 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
@@ -23,23 +24,24 @@ if (checkSession()) { @@ -23,23 +24,24 @@ if (checkSession()) {
23 24
24 $oPatternCustom = & new PatternCustom(); 25 $oPatternCustom = & new PatternCustom();
25 //create db object 26 //create db object
26 - $oDbAuth = new $default->authenticationClass;  
27 - 27 + $oAuth = new $default->authenticationClass;
  28 + // user attributes to search for
  29 + if ($default->authenticationClass == "DBAuthenticator") {
  30 + $aAttributes = array ("username", "name", "email", "mobile", "email_notification", "sms_notification");
  31 + $bLdap = false;
  32 + } else {
  33 + //if its using LDAP get these attributes
  34 + $aAttributes = array ("dn", "uid", "givenname", "sn", "mail", "mobile");
  35 + $bLdap = true;
  36 + }
  37 +
28 if (isset($fSearch)) { 38 if (isset($fSearch)) {
29 //get user name 39 //get user name
30 $sSearch = $fName; 40 $sSearch = $fName;
31 41
32 - // user attributes to search for  
33 - if ($default->authenticationClass == "DBAuthenticator") {  
34 - $aAttributes = array ("username", "name", "email", "mobile", "email_notification", "sms_notification");  
35 - $aResults = $oDbAuth->searchUsers($sSearch, $aAttributes);  
36 - $bLdap = false;  
37 - } else {  
38 - //if its using LDAP get these attributes  
39 - $aAttributes = array ("dn", "uid", "givenname", "sn", "mail", "mobile");  
40 - $aResults = $oDbAuth->searchUsers($sSearch, $aAttributes);  
41 - $bLdap = true;  
42 - } 42 + // search for users
  43 + $aResults = $oAuth->searchUsers($sSearch, $aAttributes);
  44 +
43 //post array to page 45 //post array to page
44 if(isset($aResults)) { 46 if(isset($aResults)) {
45 if(count($aResults) == 0) { 47 if(count($aResults) == 0) {
@@ -48,14 +50,14 @@ if (checkSession()) { @@ -48,14 +50,14 @@ if (checkSession()) {
48 if (count($aResults) > 1) { 50 if (count($aResults) > 1) {
49 // display results in a listbox 51 // display results in a listbox
50 $oPatternCustom->setHtml(getSelectUserPage($aResults)); 52 $oPatternCustom->setHtml(getSelectUserPage($aResults));
51 - $main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1&fFromDb=1&fSearch=1"); 53 + $main->setFormAction($_SERVER["PHP_SELF"]. "?fSelectedUser=1");
52 } else { 54 } else {
53 - if($bLdap == false) {  
54 - $oPatternCustom->setHtml(getDetailsDBPage($sSearch,$aResults));  
55 - $main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1&fFromDb=1");  
56 - } else { 55 + if($bLdap) {
57 $oPatternCustom->setHtml(getDetailsLDAPPage($sSearch,$aResults)); 56 $oPatternCustom->setHtml(getDetailsLDAPPage($sSearch,$aResults));
58 $main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1"); 57 $main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1");
  58 + } else {
  59 + $oPatternCustom->setHtml(getDetailsDBPage($sSearch,$aResults));
  60 + $main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1&fFromDb=1");
59 } 61 }
60 } 62 }
61 } 63 }
@@ -64,14 +66,29 @@ if (checkSession()) { @@ -64,14 +66,29 @@ if (checkSession()) {
64 $oPatternCustom->setHtml(getAddPageFail()); 66 $oPatternCustom->setHtml(getAddPageFail());
65 $main->setFormAction($_SERVER["PHP_SELF"]); 67 $main->setFormAction($_SERVER["PHP_SELF"]);
66 } 68 }
67 - } else if(isset($fAddToDb)) { //if db authentication 69 + } else if (isset($fSelectedUser)) {
  70 + // user has been selected
  71 +
  72 + // retrieve user details
  73 + $aResult = $oAuth->getUser($fName, $aAttributes);
  74 + // display details page
  75 + if ($bLdap) {
  76 + $oPatternCustom->setHtml(getDetailsLDAPPage($fName,$aResult));
  77 + $main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1");
  78 + } else {
  79 + $oPatternCustom->setHtml(getDetailsDBPage($fName,$aResult));
  80 + $main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1&fFromDb=1");
  81 + }
  82 +
  83 + } else if(isset($fAddToDb)) {
  84 + // if db authentication
68 if(isset($fFromDb)) { 85 if(isset($fFromDb)) {
69 86
70 //User($sNewUserName, $sNewName, $sNewPassword, $iNewQuotaMax, $sNewEmail, $sNewMobile, $bNewEmailNotification, $bNewSmsNotification, $sNewLdapDn, $iNewMaxSessions, $iNewLanguageID) 87 //User($sNewUserName, $sNewName, $sNewPassword, $iNewQuotaMax, $sNewEmail, $sNewMobile, $bNewEmailNotification, $bNewSmsNotification, $sNewLdapDn, $iNewMaxSessions, $iNewLanguageID)
71 $oUser = new User($fUsername,$fName,0,0,$fEmail,$fMobile,$fEmailNotification,$fSmsNotification,0,1,0); 88 $oUser = new User($fUsername,$fName,0,0,$fEmail,$fMobile,$fEmailNotification,$fSmsNotification,0,1,0);
72 89
73 } else { 90 } else {
74 - $oUser = new User($fUsername,$fName,0,0,$fEmail,$fMobile,1,0,$fLdap,1,0); 91 + $oUser = new User($fUsername,$fName,0,0,$fEmail,$fMobile,$fEmailNotification,$fSmsNotification,$fLdap,1,0);
75 } 92 }
76 93
77 if($oUser->create()) { 94 if($oUser->create()) {