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 14 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");
15 15 require_once("addUserUI.inc");
16 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 19 require_once("$default->fileSystemRoot/lib/security/permission.inc");
18 20 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
19 21 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
... ... @@ -30,9 +32,9 @@ if (checkSession()) {
30 32 $bLdap = false;
31 33 } else {
32 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 36 if ($default->ldapServerType == "ActiveDirectory") {
35   - $aAttributes = array ("dn", "samaccountname", "givenname", "sn", "mail", "telephonenumber");
  37 + $aAttributes = array ("dn", "samaccountname", "givenname", "sn", "userPrincipalName", "telephonenumber");
36 38 } else {
37 39 $aAttributes = array ("dn", "uid", "givenname", "sn", "mail", "mobile");
38 40 }
... ... @@ -59,7 +61,7 @@ if (checkSession()) {
59 61 if($bLdap) {
60 62 $oPatternCustom->setHtml(getDetailsLDAPPage($sSearch,$aResults, $oAuth->oLdap->getUserIdentifier()));
61 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 66 $main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1");
65 67 } else {
... ... @@ -81,7 +83,7 @@ if (checkSession()) {
81 83 if ($bLdap) {
82 84 $oPatternCustom->setHtml(getDetailsLDAPPage($fName,$aResult, $oAuth->oLdap->getUserIdentifier()));
83 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 88 $main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1");
87 89 } else {
... ... @@ -93,13 +95,19 @@ if (checkSession()) {
93 95 // if db authentication
94 96 if(isset($fFromDb)) {
95 97 $oUser = new User($fUsername,$fName,$fPassword,0,$fEmail,$fMobile,$fEmailNotification,$fSmsNotification,0,1,0);
96   -
97 98 } else {
98 99 $oUser = new User($fUsername,$fName,0,0,$fEmail,$fMobile,$fEmailNotification,$fSmsNotification,$fLdap,1,0);
99 100 }
100 101  
101 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 111 } else {
104 112 $oPatternCustom->setHtml(getPageFail());
105 113 }
... ... @@ -116,6 +124,7 @@ if (checkSession()) {
116 124 }
117 125  
118 126 $main->setCentralPayload($oPatternCustom);
  127 + $main->setHasRequiredFields(true);
119 128 $main->render();
120 129 }
121 130 ?>
122 131 \ No newline at end of file
... ...