Commit 5bd1075014c1881e63bd4e40b895bbacfe8a6ee0

Authored by nbm
1 parent 847acbe2

Pass the authentication provider and source into the edit template,

allowing for authentication information to be displayed and ultimately
editing through the user management system.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4190 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/administration/usermanagement/userManagement.php
@@ -11,10 +11,14 @@ require_once(KT_LIB_DIR . "/dispatcher.inc.php"); @@ -11,10 +11,14 @@ require_once(KT_LIB_DIR . "/dispatcher.inc.php");
11 require_once(KT_LIB_DIR . "/templating/kt3template.inc.php"); 11 require_once(KT_LIB_DIR . "/templating/kt3template.inc.php");
12 require_once(KT_LIB_DIR . "/widgets/fieldWidgets.php"); 12 require_once(KT_LIB_DIR . "/widgets/fieldWidgets.php");
13 13
  14 +require_once(KT_LIB_DIR . "/authentication/authenticationsource.inc.php");
  15 +require_once(KT_LIB_DIR . "/authentication/authenticationproviderregistry.inc.php");
  16 +require_once(KT_LIB_DIR . "/authentication/builtinauthenticationprovider.inc.php");
  17 +
14 class KTUserAdminDispatcher extends KTAdminDispatcher { 18 class KTUserAdminDispatcher extends KTAdminDispatcher {
15 // Breadcrumbs base - added to in methods 19 // Breadcrumbs base - added to in methods
16 var $aBreadcrumbs = array( 20 var $aBreadcrumbs = array(
17 - array('action' => 'administration', 'name' => 'Administration'), 21 + array('action' => 'administration', 'name' => 'Administration'),
18 ); 22 );
19 23
20 function do_main() { 24 function do_main() {
@@ -71,13 +75,6 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { @@ -71,13 +75,6 @@ class KTUserAdminDispatcher extends KTAdminDispatcher {
71 // nice, easy bits. 75 // nice, easy bits.
72 $add_fields[] = new KTStringWidget('Mobile Number','The mobile phone number of the user. If the system is configured to send notifications to cellphones, then this number will be SMS\'d with notifications. e.g. <strong>999 9999 999</strong>', 'mobile_number', null, $this->oPage, false); 76 $add_fields[] = new KTStringWidget('Mobile Number','The mobile phone number of the user. If the system is configured to send notifications to cellphones, then this number will be SMS\'d with notifications. e.g. <strong>999 9999 999</strong>', 'mobile_number', null, $this->oPage, false);
73 $add_fields[] = new KTStringWidget('Maximum Sessions','As a safety precaution, it is useful to limit the number of times a given account can log in, before logging out. This prevents a single account being used by many different people.', 'max_sessions', '3', $this->oPage, true); 77 $add_fields[] = new KTStringWidget('Maximum Sessions','As a safety precaution, it is useful to limit the number of times a given account can log in, before logging out. This prevents a single account being used by many different people.', 'max_sessions', '3', $this->oPage, true);
74 - // FIXME handle group search stuff.  
75 - $search_results = null;  
76 - if (!empty($name)) {  
77 - $search_results =& User::getList('WHERE username LIKE "%' . DBUtil::escapeSimple($name) . '%"');  
78 - } else if ($show_all !== false) {  
79 - $search_results =& User::getList();  
80 - }  
81 78
82 $oTemplating = new KTTemplating; 79 $oTemplating = new KTTemplating;
83 $oTemplate = $oTemplating->loadTemplate("ktcore/principals/adduser"); 80 $oTemplate = $oTemplating->loadTemplate("ktcore/principals/adduser");
@@ -91,50 +88,53 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { @@ -91,50 +88,53 @@ class KTUserAdminDispatcher extends KTAdminDispatcher {
91 88
92 89
93 function do_editUser() { 90 function do_editUser() {
94 - $this->aBreadcrumbs[] = array('action' => 'userManagement', 'name' => 'User Management');  
95 - $this->oPage->setBreadcrumbDetails('modify user details');  
96 - $this->oPage->setTitle("Modify User Details");  
97 -  
98 - $name = KTUtil::arrayGet($_REQUEST, 'name');  
99 - $show_all = KTUtil::arrayGet($_REQUEST, 'show_all', false);  
100 - $add_user = KTUtil::arrayGet($_REQUEST, 'add_user', false);  
101 - if ($add_user !== false) { $add_user = true; }  
102 - $edit_user = KTUtil::arrayGet($_REQUEST, 'edit_user', false);  
103 - $user_id = KTUtil::arrayGet($_REQUEST, 'user_id');  
104 -  
105 - $oUser =& User::get($user_id);  
106 -  
107 - if (PEAR::isError($oUser) || $oUser == false) {  
108 - $this->errorRedirectToMain('Please select a user first.');  
109 - exit(0);  
110 - }  
111 -  
112 - $this->aBreadcrumbs[] = array('name' => $oUser->getName());  
113 -  
114 - $edit_fields = array();  
115 - $edit_fields[] = new KTStringWidget('Username','The username the user will enter to gain access to the KnowledgeTree. e.g. <strong>jsmith</strong>', 'username', $oUser->getUsername(), $this->oPage, true);  
116 - $edit_fields[] = new KTStringWidget('Name','The full name of the user. This is shown in reports and listings. e.g. <strong>John Smith</strong>', 'name', $oUser->getName(), $this->oPage, true);  
117 - $edit_fields[] = new KTStringWidget('Email Address','The email address of the user. Notifications and alerts are mailed to this address if <strong>email notifications</strong> is set below. e.g. <strong>jsmith@acme.com</strong>', 'email_address', $oUser->getEmail(), $this->oPage, false);  
118 - $edit_fields[] = new KTCheckboxWidget('Email Notifications','If this is specified then the user will have notifications sent to the email address entered above. If it isn\'t set, then the user will only see notifications on the <strong>Dashboard</strong>', 'email_notifications', $oUser->getEmailNotification(), $this->oPage, false);  
119 - $edit_fields[] = new KTStringWidget('Mobile Number','The mobile phone number of the user. If the system is configured to send notifications to cellphones, then this number will be SMS\'d with notifications. e.g. <strong>999 9999 999</strong>', 'mobile_number', $oUser->getMobile(), $this->oPage, false);  
120 - $edit_fields[] = new KTStringWidget('Maximum Sessions','As a safety precaution, it is useful to limit the number of times a given account can log in, before logging out. This prevents a single account being used by many different people.', 'max_sessions', $oUser->getMaxSessions(), $this->oPage, true);  
121 -  
122 - // FIXME handle group search stuff.  
123 - $search_results = null;  
124 - if (!empty($name)) {  
125 - $search_results =& User::getList('WHERE username LIKE "%' . DBUtil::escapeSimple($name) . '%"');  
126 - } else if ($show_all !== false) {  
127 - $search_results =& User::getList();  
128 - }  
129 -  
130 - $oTemplating = new KTTemplating;  
131 - $oTemplate = $oTemplating->loadTemplate("ktcore/principals/edituser");  
132 - $aTemplateData = array(  
133 - "context" => $this,  
134 - "edit_fields" => $edit_fields,  
135 - "edit_user" => $oUser,  
136 - );  
137 - return $oTemplate->render($aTemplateData); 91 + $this->aBreadcrumbs[] = array('action' => 'userManagement', 'name' => 'User Management');
  92 + $this->oPage->setBreadcrumbDetails('modify user details');
  93 + $this->oPage->setTitle("Modify User Details");
  94 +
  95 + $name = KTUtil::arrayGet($_REQUEST, 'name');
  96 + $show_all = KTUtil::arrayGet($_REQUEST, 'show_all', false);
  97 + $add_user = KTUtil::arrayGet($_REQUEST, 'add_user', false);
  98 + if ($add_user !== false) { $add_user = true; }
  99 + $edit_user = KTUtil::arrayGet($_REQUEST, 'edit_user', false);
  100 + $user_id = KTUtil::arrayGet($_REQUEST, 'user_id');
  101 +
  102 + $oUser =& User::get($user_id);
  103 +
  104 + if (PEAR::isError($oUser) || $oUser == false) {
  105 + $this->errorRedirectToMain('Please select a user first.');
  106 + exit(0);
  107 + }
  108 +
  109 + $this->aBreadcrumbs[] = array('name' => $oUser->getName());
  110 +
  111 + $edit_fields = array();
  112 + $edit_fields[] = new KTStringWidget('Username','The username the user will enter to gain access to the KnowledgeTree. e.g. <strong>jsmith</strong>', 'username', $oUser->getUsername(), $this->oPage, true);
  113 + $edit_fields[] = new KTStringWidget('Name','The full name of the user. This is shown in reports and listings. e.g. <strong>John Smith</strong>', 'name', $oUser->getName(), $this->oPage, true);
  114 + $edit_fields[] = new KTStringWidget('Email Address','The email address of the user. Notifications and alerts are mailed to this address if <strong>email notifications</strong> is set below. e.g. <strong>jsmith@acme.com</strong>', 'email_address', $oUser->getEmail(), $this->oPage, false);
  115 + $edit_fields[] = new KTCheckboxWidget('Email Notifications','If this is specified then the user will have notifications sent to the email address entered above. If it isn\'t set, then the user will only see notifications on the <strong>Dashboard</strong>', 'email_notifications', $oUser->getEmailNotification(), $this->oPage, false);
  116 + $edit_fields[] = new KTStringWidget('Mobile Number','The mobile phone number of the user. If the system is configured to send notifications to cellphones, then this number will be SMS\'d with notifications. e.g. <strong>999 9999 999</strong>', 'mobile_number', $oUser->getMobile(), $this->oPage, false);
  117 + $edit_fields[] = new KTStringWidget('Maximum Sessions','As a safety precaution, it is useful to limit the number of times a given account can log in, before logging out. This prevents a single account being used by many different people.', 'max_sessions', $oUser->getMaxSessions(), $this->oPage, true);
  118 +
  119 + $oAuthenticationSource = KTAuthenticationSource::getForUser($oUser);
  120 + if (is_null($oAuthenticationSource)) {
  121 + $oProvider =& new KTBuiltinAuthenticationProvider;
  122 + } else {
  123 + $sProvider = $oAuthenticationSource->getAuthenticationProvider();
  124 + $oRegistry =& KTAuthenticationProviderRegistry::getSingleton();
  125 + $oProvider = $oRegistry->getAuthenticationProvider($sProvider);
  126 + }
  127 +
  128 + $oTemplating = new KTTemplating;
  129 + $oTemplate = $oTemplating->loadTemplate("ktcore/principals/edituser");
  130 + $aTemplateData = array(
  131 + "context" => $this,
  132 + "edit_fields" => $edit_fields,
  133 + "edit_user" => $oUser,
  134 + "provider" => $oProvider,
  135 + "source" => $oAuthenticationSource,
  136 + );
  137 + return $oTemplate->render($aTemplateData);
138 } 138 }
139 139
140 function do_editgroups() { 140 function do_editgroups() {
@@ -292,7 +292,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { @@ -292,7 +292,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher {
292 $oUser = User::get($user_id); 292 $oUser = User::get($user_id);
293 if ((PEAR::isError($oUser)) || ($oUser === false)) { 293 if ((PEAR::isError($oUser)) || ($oUser === false)) {
294 $this->errorRedirectToMain('Please select a user first.'); 294 $this->errorRedirectToMain('Please select a user first.');
295 - } 295 + }
296 $groupAdded = KTUtil::arrayGet($_REQUEST, 'groupAdded',''); 296 $groupAdded = KTUtil::arrayGet($_REQUEST, 'groupAdded','');
297 $groupRemoved = KTUtil::arrayGet($_REQUEST, 'groupRemoved',''); 297 $groupRemoved = KTUtil::arrayGet($_REQUEST, 'groupRemoved','');
298 298
@@ -324,7 +324,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { @@ -324,7 +324,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher {
324 $oGroup = Group::get($iGroupID); 324 $oGroup = Group::get($iGroupID);
325 $res = $oGroup->removeMember($oUser); 325 $res = $oGroup->removeMember($oUser);
326 if (PEAR::isError($res) || $res == false) { 326 if (PEAR::isError($res) || $res == false) {
327 - $this->errorRedirectToMain('Unable to remove user from "' . $oGroup->getName() . '"'); 327 + $this->errorRedirectToMain('Unable to remove user from "' . $oGroup->getName() . '"');
328 } else { $groupsRemoved[] = $oGroup->getName(); } 328 } else { $groupsRemoved[] = $oGroup->getName(); }
329 } 329 }
330 } 330 }