Commit dbf332e73e96b7c41d2a621d2ecaa545a5270c17

Authored by michael
1 parent 5014a4c0

(#2746) added code to map user to a group on addition


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2458 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/administration/usermanagement/addUserBL.php
@@ -14,6 +14,8 @@ if (checkSession()) { @@ -14,6 +14,8 @@ if (checkSession()) {
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("$default->fileSystemRoot/lib/users/User.inc"); 16 require_once("$default->fileSystemRoot/lib/users/User.inc");
  17 + require_once("$default->fileSystemRoot/lib/groups/Group.inc");
  18 + require_once("$default->fileSystemRoot/lib/groups/GroupUserLink.inc");
17 require_once("$default->fileSystemRoot/lib/security/permission.inc"); 19 require_once("$default->fileSystemRoot/lib/security/permission.inc");
18 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 20 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
19 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); 21 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
@@ -30,9 +32,9 @@ if (checkSession()) { @@ -30,9 +32,9 @@ if (checkSession()) {
30 $bLdap = false; 32 $bLdap = false;
31 } else { 33 } else {
32 //if its using LDAP get these attributes 34 //if its using LDAP get these attributes
33 - // TODO: make these user defined 35 + // FIXME: move these to $default(ldapSettings.inc) and map them to DN, username, display name, email, mobile
34 if ($default->ldapServerType == "ActiveDirectory") { 36 if ($default->ldapServerType == "ActiveDirectory") {
35 - $aAttributes = array ("dn", "samaccountname", "givenname", "sn", "mail", "telephonenumber"); 37 + $aAttributes = array ("dn", "samaccountname", "givenname", "sn", "userPrincipalName", "telephonenumber");
36 } else { 38 } else {
37 $aAttributes = array ("dn", "uid", "givenname", "sn", "mail", "mobile"); 39 $aAttributes = array ("dn", "uid", "givenname", "sn", "mail", "mobile");
38 } 40 }
@@ -59,7 +61,7 @@ if (checkSession()) { @@ -59,7 +61,7 @@ if (checkSession()) {
59 if($bLdap) { 61 if($bLdap) {
60 $oPatternCustom->setHtml(getDetailsLDAPPage($sSearch,$aResults, $oAuth->oLdap->getUserIdentifier())); 62 $oPatternCustom->setHtml(getDetailsLDAPPage($sSearch,$aResults, $oAuth->oLdap->getUserIdentifier()));
61 if ($default->bNN4) { 63 if ($default->bNN4) {
62 - $main->setOnLoadJavaScript("disable(document.MainForm.fLdap)"); 64 + $main->setOnLoadJavaScript("disable(document.MainForm.fLdap);disable(document.MainForm.fUsername)");
63 } 65 }
64 $main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1"); 66 $main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1");
65 } else { 67 } else {
@@ -81,7 +83,7 @@ if (checkSession()) { @@ -81,7 +83,7 @@ if (checkSession()) {
81 if ($bLdap) { 83 if ($bLdap) {
82 $oPatternCustom->setHtml(getDetailsLDAPPage($fName,$aResult, $oAuth->oLdap->getUserIdentifier())); 84 $oPatternCustom->setHtml(getDetailsLDAPPage($fName,$aResult, $oAuth->oLdap->getUserIdentifier()));
83 if ($default->bNN4) { 85 if ($default->bNN4) {
84 - $main->setOnLoadJavaScript("disable(document.MainForm.fLdap)"); 86 + $main->setOnLoadJavaScript("disable(document.MainForm.fLdap);disable(document.MainForm.fUsername)");
85 } 87 }
86 $main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1"); 88 $main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1");
87 } else { 89 } else {
@@ -93,13 +95,19 @@ if (checkSession()) { @@ -93,13 +95,19 @@ if (checkSession()) {
93 // if db authentication 95 // if db authentication
94 if(isset($fFromDb)) { 96 if(isset($fFromDb)) {
95 $oUser = new User($fUsername,$fName,$fPassword,0,$fEmail,$fMobile,$fEmailNotification,$fSmsNotification,0,1,0); 97 $oUser = new User($fUsername,$fName,$fPassword,0,$fEmail,$fMobile,$fEmailNotification,$fSmsNotification,0,1,0);
96 -  
97 } else { 98 } else {
98 $oUser = new User($fUsername,$fName,0,0,$fEmail,$fMobile,$fEmailNotification,$fSmsNotification,$fLdap,1,0); 99 $oUser = new User($fUsername,$fName,0,0,$fEmail,$fMobile,$fEmailNotification,$fSmsNotification,$fLdap,1,0);
99 } 100 }
100 101
101 if($oUser->create()) { 102 if($oUser->create()) {
102 - $oPatternCustom->setHtml(getPageSuccess()); 103 + // now add the user to the initial group
  104 + $default->log->info("adding user id " . $oUser->getID() . " to group id $fGroupID");
  105 + $oUserGroup = new GroupUserLink($fGroupID,$oUser->getID());
  106 + if ($oUserGroup->create()) {
  107 + $oPatternCustom->setHtml(getPageSuccess());
  108 + } else {
  109 + $oPatternCustom->setHtml(getPageGroupFail());
  110 + }
103 } else { 111 } else {
104 $oPatternCustom->setHtml(getPageFail()); 112 $oPatternCustom->setHtml(getPageFail());
105 } 113 }
@@ -116,6 +124,7 @@ if (checkSession()) { @@ -116,6 +124,7 @@ if (checkSession()) {
116 } 124 }
117 125
118 $main->setCentralPayload($oPatternCustom); 126 $main->setCentralPayload($oPatternCustom);
  127 + $main->setHasRequiredFields(true);
119 $main->render(); 128 $main->render();
120 } 129 }
121 ?> 130 ?>
122 \ No newline at end of file 131 \ No newline at end of file