From 2c839beb2d7e0c3f208f1505d174820fdb18c6e9 Mon Sep 17 00:00:00 2001
From: bryndivey
Date: Wed, 24 May 2006 10:16:17 +0000
Subject: [PATCH] Fixes from 24/05/2006
---
config/config.ini | 4 ++++
lib/templating/kt3template.inc.php | 99 +++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------
plugins/ktcore/admin/userManagement.php | 9 +++++----
preferences.php | 23 ++++++++++++++---------
templates/kt3/standard_page.smarty | 2 +-
templates/ktcore/principals/adduser.smarty | 32 ++++++--------------------------
templates/ktcore/principals/useradmin.smarty | 45 +++++++++++++++++++++++++++++++++++----------
templates/ktstandard/action/email.smarty | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
8 files changed, 179 insertions(+), 113 deletions(-)
diff --git a/config/config.ini b/config/config.ini
index 7f6d3e2..3363d97 100644
--- a/config/config.ini
+++ b/config/config.ini
@@ -179,6 +179,10 @@ passwordLength = 6
; default is set to "false" meaning that admins can create users with shorter passwords.
restrictAdminPasswords = default
+; restrict users from accessing their preferences menus?
+restrictPreferences = true
+
+
; This is configuration for the built-in authentication provider
[builtinauth]
;
diff --git a/lib/templating/kt3template.inc.php b/lib/templating/kt3template.inc.php
index 741524a..297a8d6 100644
--- a/lib/templating/kt3template.inc.php
+++ b/lib/templating/kt3template.inc.php
@@ -268,7 +268,9 @@ class KTPage {
/* final render call. */
function render() {
- global $default;
+ global $default;
+ $oConfig = KTConfig::getSingleton();
+
if (empty($this->contents)) {
$this->contents = "";
}
@@ -278,63 +280,60 @@ class KTPage {
$this->contents = "";
}
- if (!is_string($this->contents)) {
- $this->contents = $this->contents->render();
- }
-
- // if we have no portlets, make the ui a tad nicer.
- if (empty($this->portlets)) {
- $this->show_portlets = false;
- }
+ if (!is_string($this->contents)) {
+ $this->contents = $this->contents->render();
+ }
- if (empty($this->title)) {
- if (!empty($this->breadcrumbDetails)) {
- $this->title = $this->breadcrumbDetails;
- } else if (!empty($this->breadcrumbs)) {
- $this->title = array_slice($this->breadcrumbs, -1);
- $this->title = $this->title[0]['label'];
- } else if (!empty($this->breadcrumbSection)) {
- $this->title = $this->breadcrumbSection['label'];
- } else {
- $this->title = $this->componentLabel;
- }
- }
+ // if we have no portlets, make the ui a tad nicer.
+ if (empty($this->portlets)) {
+ $this->show_portlets = false;
+ }
- $this->userMenu = array();
- if (!(PEAR::isError($this->user) || is_null($this->user) || $this->user->isAnonymous())) {
- $this->userMenu = array(
- "preferences" => $this->_actionHelper(array("name" => _kt("Preferences"), "action" => "preferences", "active" => 0)),
- "logout" => $this->_actionHelper(array("name" => _kt("Logout"), "action" => "logout", "active" => 0)),
- );
- } else {
- $this->userMenu = array(
- "login" => $this->_actionHelper(array("name" => _kt("Login"), "action" => "login")),
- );
- }
+ if (empty($this->title)) {
+ if (!empty($this->breadcrumbDetails)) {
+ $this->title = $this->breadcrumbDetails;
+ } else if (!empty($this->breadcrumbs)) {
+ $this->title = array_slice($this->breadcrumbs, -1);
+ $this->title = $this->title[0]['label'];
+ } else if (!empty($this->breadcrumbSection)) {
+ $this->title = $this->breadcrumbSection['label'];
+ } else {
+ $this->title = $this->componentLabel;
+ }
+ }
- // FIXME we need a more complete solution to navigation restriction
- if (!is_null($this->menu['administration']) && !is_null($this->user)) {
- if (!Permission::userIsSystemAdministrator($this->user->getId())) {
- unset($this->menu['administration']);
- }
- }
+ $this->userMenu = array();
+ if (!(PEAR::isError($this->user) || is_null($this->user) || $this->user->isAnonymous())) {
+ if ($oConfig->get("user_prefs/restrictPreferences", false) && !Permission::userIsSystemAdministrator($this->user->getId())) {
+ $this->userMenu = array("logout" => $this->_actionHelper(array("name" => _kt("Logout"), "action" => "logout", "active" => 0)),);
+ } else {
+ $this->userMenu = array("preferences" => $this->_actionHelper(array("name" => _kt("Preferences"), "action" => "preferences", "active" => 0)),
+ "logout" => $this->_actionHelper(array("name" => _kt("Logout"), "action" => "logout", "active" => 0)),);
+ }
+ } else {
+ $this->userMenu = array("login" => $this->_actionHelper(array("name" => _kt("Login"), "action" => "login")),);
+ }
- $sContentType = 'Content-type: ' . $this->contentType;
- if(!empty($this->charset)) {
- $sContentType .= '; charset=' . $this->charset;
- };
+ // FIXME we need a more complete solution to navigation restriction
+ if (!is_null($this->menu['administration']) && !is_null($this->user)) {
+ if (!Permission::userIsSystemAdministrator($this->user->getId())) {
+ unset($this->menu['administration']);
+ }
+ }
+
+ $sContentType = 'Content-type: ' . $this->contentType;
+ if(!empty($this->charset)) {
+ $sContentType .= '; charset=' . $this->charset;
+ };
- header($sContentType);
+ header($sContentType);
$oTemplating =& KTTemplating::getSingleton();
$oTemplate = $oTemplating->loadTemplate($this->template);
- $aTemplateData = array(
- "page" => $this,
- "systemversion" => $default->systemVersion,
- "versionname" => $default->versionName,
- );
- $oConfig = KTConfig::getSingleton();
+ $aTemplateData = array("page" => $this,
+ "systemversion" => $default->systemVersion,
+ "versionname" => $default->versionName,);
if ($oConfig->get("ui/automaticRefresh", false)) {
$aTemplateData['refreshTimeout'] = (int)$oConfig->get("session/sessionTimeout") + 3;
}
@@ -342,7 +341,7 @@ class KTPage {
// unlike the rest of KT, we use echo here.
echo $oTemplate->render($aTemplateData);
}
-
+
/** heler functions */
// returns an array ("url", "label")
diff --git a/plugins/ktcore/admin/userManagement.php b/plugins/ktcore/admin/userManagement.php
index c78fc2f..09eca54 100755
--- a/plugins/ktcore/admin/userManagement.php
+++ b/plugins/ktcore/admin/userManagement.php
@@ -75,13 +75,17 @@ var $sHelpPage = 'ktcore/admin/manage users.html';
$no_search = false;
}
+
+ $aAuthenticationSources =& KTAuthenticationSource::getList();
+
$oTemplating =& KTTemplating::getSingleton();
$oTemplate = $oTemplating->loadTemplate("ktcore/principals/useradmin");
$aTemplateData = array(
"context" => $this,
"search_fields" => $search_fields,
"search_results" => $search_results,
- 'no_search' => $no_search,
+ "no_search" => $no_search,
+ "authentication_sources" => $aAuthenticationSources,
);
return $oTemplate->render($aTemplateData);
}
@@ -121,14 +125,11 @@ var $sHelpPage = 'ktcore/admin/manage users.html';
$add_fields[] = new KTStringWidget(_kt('Mobile Number'), _kt("The mobile phone number of the user. e.g. 999 9999 999"), 'mobile_number', null, $this->oPage, false, null, null, $aOptions);
$add_fields[] = new KTStringWidget(_kt('Maximum Sessions'), _kt('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, null, null, $aOptions);
- $aAuthenticationSources =& KTAuthenticationSource::getList();
-
$oTemplating =& KTTemplating::getSingleton();
$oTemplate = $oTemplating->loadTemplate("ktcore/principals/adduser");
$aTemplateData = array(
"context" => &$this,
"add_fields" => $add_fields,
- "authentication_sources" => $aAuthenticationSources,
);
return $oTemplate->render($aTemplateData);
}
diff --git a/preferences.php b/preferences.php
index 4fe478c..6b30987 100644
--- a/preferences.php
+++ b/preferences.php
@@ -39,10 +39,15 @@ require_once(KT_LIB_DIR . '/widgets/fieldWidgets.php');
class PreferencesDispatcher extends KTStandardDispatcher {
var $sSection = 'preferences';
- function check() {
- if ($this->oUser->getId() == -2) { return false; }
- return parent::check();
- }
+ function check() {
+ $oConfig =& KTConfig::getSingleton();
+ if ($this->oUser->getId() == -2 ||
+ ($oConfig->get('user_prefs/restrictPreferences', false) && !Permission::userIsSystemAdministrator($this->oUser->getId()))) {
+ return false;
+ }
+
+ return parent::check();
+ }
function PreferencesDispatcher() {
$this->aBreadcrumbs = array(
@@ -52,15 +57,15 @@ class PreferencesDispatcher extends KTStandardDispatcher {
}
function do_main() {
- $this->oPage->setBreadcrumbDetails(_kt("Your Preferences"));
- $this->oPage->title = _kt("Dashboard");
+ $this->oPage->setBreadcrumbDetails(_kt("Your Preferences"));
+ $this->oPage->title = _kt("Dashboard");
- $oUser =& $this->oUser;
+ $oUser =& $this->oUser;
- $aOptions = array('autocomplete' => false);
+ $aOptions = array('autocomplete' => false);
- $edit_fields = array();
+ $edit_fields = array();
$edit_fields[] = new KTStringWidget(_kt('Name'), _kt('Your full name. This is shown in reports and listings. e.g. John Smith'), 'name', $oUser->getName(), $this->oPage, true, null, null, $aOptions);
$edit_fields[] = new KTStringWidget(_kt('Email Address'), _kt('Your email address. Notifications and alerts are mailed to this address if email notifications is set below. e.g. jsmith@acme.com'), 'email_address', $oUser->getEmail(), $this->oPage, false, null, null, $aOptions);
$edit_fields[] = new KTCheckboxWidget(_kt('Email Notifications'), _kt('If this is specified then the you will receive certain notifications. If it is not set, then you will only see notifications on the Dashboard'), 'email_notifications', $oUser->getEmailNotification(), $this->oPage, false, null, null, $aOptions);
diff --git a/templates/kt3/standard_page.smarty b/templates/kt3/standard_page.smarty
index 32772f0..b063928 100644
--- a/templates/kt3/standard_page.smarty
+++ b/templates/kt3/standard_page.smarty
@@ -76,7 +76,7 @@
{foreach item=aMenuItem from=$page->userMenu name=prefmenu}
{if ($aMenuItem.active == 1)}
- {$aMenuItem.label}
+ {$aMenuItem.label}
{else}
{$aMenuItem.label}
{/if}
diff --git a/templates/ktcore/principals/adduser.smarty b/templates/ktcore/principals/adduser.smarty
index 6d6fef4..b008582 100644
--- a/templates/ktcore/principals/adduser.smarty
+++ b/templates/ktcore/principals/adduser.smarty
@@ -1,31 +1,11 @@
{i18n}Add a user{/i18n}
-{i18n}Please complete the form below to add a new user. Fields marked with a red square are required. By default, users are created using KnowledgeTree's builtin authentication provider. Should you wish to use an external authentication provider such as LDAP, please ensure that the provider's plugin is registered and enabled.{/i18n}
-
-{if $authentication_sources}
-
-
-
-{i18n}Alternatively, you can manually create a user
-within KnowledgeTree below.{/i18n}
-{/if}
+{i18n}Please complete the form below to add
+a new user. Fields marked with a red square are required. By default,
+users are created using KnowledgeTree's builtin authentication
+provider. Should you wish to use an external authentication provider
+such as LDAP, please ensure that the provider's plugin is registered
+and use the form on the User Management page.{/i18n}