From 610629d7cc4e212c4185bdb181a174fcf1500dba Mon Sep 17 00:00:00 2001
From: bryndivey
Date: Tue, 12 Sep 2006 11:27:31 +0000
Subject: [PATCH] Added enable/disable features to user management
---
lib/users/User.inc | 2 ++
plugins/ktcore/admin/userManagement.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++
templates/ktcore/principals/useradmin.smarty | 35 +++++++++++++++++++++++++++++++----
3 files changed, 79 insertions(+), 4 deletions(-)
diff --git a/lib/users/User.inc b/lib/users/User.inc
index b9d58f0..96364d4 100644
--- a/lib/users/User.inc
+++ b/lib/users/User.inc
@@ -31,6 +31,8 @@
require_once(KT_LIB_DIR . '/database/dbutil.inc');
require_once(KT_LIB_DIR . '/ktentity.inc');
+
+define('ADMIN_USER_ID', 1);
class User extends KTEntity {
/** user's login name */
diff --git a/plugins/ktcore/admin/userManagement.php b/plugins/ktcore/admin/userManagement.php
index 4e9475c..42a8e0a 100755
--- a/plugins/ktcore/admin/userManagement.php
+++ b/plugins/ktcore/admin/userManagement.php
@@ -628,6 +628,52 @@ class KTUserAdminDispatcher extends KTAdminDispatcher {
return implode(', ', $aGroupNames);
}
+
+
+ // change enabled / disabled status of users
+ function do_change_enabled() {
+ $this->startTransaction();
+
+ $iLicenses = 0;
+ if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
+ require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php');
+ $iLicenses = BaobabKeyUtil::getLicenseCount();
+ }
+
+ // "-2" to account for admin/anonymous
+ $iEnabledUsers = User::getNumberEnabledUsers() - 2;
+
+ foreach(KTUtil::arrayGet($_REQUEST, 'disable_user', array()) as $sUserId => $v) {
+ $oUser = User::get((int)$sUserId);
+ if(PEAR::isError($oUser)) { $this->errorRedirectToMain(_kt('Error getting user object')); }
+ $oUser->setDisabled(True);
+ $res = $oUser->update();
+ if(PEAR::isError($res)) { $this->errorRedirectToMain(_kt('Error updating user')); }
+ $iEnabledUsers--;
+ }
+
+ foreach(KTUtil::arrayGet($_REQUEST, 'enable_user', array()) as $sUserId => $v) {
+ // check that we haven't hit max user limit
+ if($iLicenses !== 0 && $iEnabledUsers >= $iLicenses) {
+ // if so, add to error messages, but commit transaction (break this loop)
+ $_SESSION['KTErrorMessage'][] = _kt('You may only have ') . $iLicenses . _kt(' users enabled at one time.');
+ break;
+ }
+
+ // else enable user
+ $oUser = User::get((int)$sUserId);
+ if(PEAR::isError($oUser)) { $this->errorRedirectToMain(_kt('Error getting user object')); }
+ $oUser->setDisabled(False);
+ $res = $oUser->update();
+ if(PEAR::isError($res)) { $this->errorRedirectToMain(_kt('Error updating user')); }
+ $iEnabledUsers++;
+ }
+
+ $this->commitTransaction();
+ $this->successRedirectToMain(_kt('Users updated'));
+
+ }
+
}
?>
diff --git a/templates/ktcore/principals/useradmin.smarty b/templates/ktcore/principals/useradmin.smarty
index 39232d6..fa7992e 100644
--- a/templates/ktcore/principals/useradmin.smarty
+++ b/templates/ktcore/principals/useradmin.smarty
@@ -54,7 +54,7 @@ very slow if you have many users).{/i18n}
{/foreach}
-
+
@@ -62,13 +62,18 @@ very slow if you have many users).{/i18n}
{if ($no_search === true)}
{else}
{if (!empty($search_results))}
+
+
+
{else}
{i18n}No results for your search.{/i18n}
--
libgit2 0.21.4