addUserBL.php
3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* BL information for adding a unit
*
* @author Mukhtar Dharsey
* @date 5 February 2003
* @package presentation.lookAndFeel.knowledgeTree.
*
*/
require_once("../../../../../config/dmsDefaults.php");
if (checkSession()) {
require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");
require_once("addUserUI.inc");
require_once("$default->fileSystemRoot/lib/users/User.inc");
require_once("$default->fileSystemRoot/lib/security/permission.inc");
require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
require_once("$default->fileSystemRoot/presentation/Html.inc");
$oPatternCustom = & new PatternCustom();
//create db object
$oDbAuth = new $default->authenticationClass;
if (isset($fSearch)) {
//get user name
$sSearch = $fName;
// user attributes to search for
if ($default->authenticationClass == "DBAuthenticator") {
$aAttributes = array ("username", "name", "email", "mobile", "email_notification", "sms_notification");
$aResults = $oDbAuth->searchUsers($sSearch, $aAttributes);
$bLdap = false;
} else {
//if its using LDAP get these attributes
$aAttributes = array ("dn", "uid", "givenname", "sn", "mail", "mobile");
$aResults = $oDbAuth->searchUsers($sSearch, $aAttributes);
$bLdap = true;
}
//post array to page
if(isset($aResults)) {
if(count($aResults) == 0) {
$oPatternCustom->setHtml(getPageUsernameNotFound());
} else {
if (count($aResults) > 1) {
// display results in a listbox
$oPatternCustom->setHtml(getSelectUserPage($aResults));
$main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1&fFromDb=1&fSearch=1");
} else {
if($bLdap == false) {
$oPatternCustom->setHtml(getDetailsDBPage($sSearch,$aResults));
$main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1&fFromDb=1");
} else {
$oPatternCustom->setHtml(getDetailsLDAPPage($sSearch,$aResults));
$main->setFormAction($_SERVER["PHP_SELF"]. "?fAddToDb=1");
}
}
}
} else {
$oPatternCustom->setHtml(getAddPageFail());
$main->setFormAction($_SERVER["PHP_SELF"]);
}
} else if(isset($fAddToDb)) { //if db authentication
if(isset($fFromDb)) {
//User($sNewUserName, $sNewName, $sNewPassword, $iNewQuotaMax, $sNewEmail, $sNewMobile, $bNewEmailNotification, $bNewSmsNotification, $sNewLdapDn, $iNewMaxSessions, $iNewLanguageID)
$oUser = new User($fUsername,$fName,0,0,$fEmail,$fMobile,$fEmailNotification,$fSmsNotification,0,1,0);
} else {
$oUser = new User($fUsername,$fName,0,0,$fEmail,$fMobile,1,0,$fLdap,1,0);
}
if($oUser->create()) {
$oPatternCustom->setHtml(getPageSuccess());
} else {
$oPatternCustom->setHtml(getPageFail());
}
} else {
// if nothing happens...just reload edit page
$oPatternCustom->setHtml(getAddPage(null));
$main->setFormAction($_SERVER["PHP_SELF"]. "?fSearch=1");
}
//$main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/create.php?fRedirectURL=".urlencode("$default->rootUrl/control.php?action=addUnitSuccess&fUnit"));
$main->setCentralPayload($oPatternCustom);
$main->render();
}
?>