diff --git a/plugins/ktcore/admin/userManagement.php b/plugins/ktcore/admin/userManagement.php index 42a8e0a..1d50427 100755 --- a/plugins/ktcore/admin/userManagement.php +++ b/plugins/ktcore/admin/userManagement.php @@ -363,17 +363,18 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { function json_getGroups() { - $sFilter = KTUtil::arrayGet($_REQUEST, 'filter', false); - $aGroupList = array('off'=>'-- Please filter --'); - - if($sFilter && trim($sFilter)) { - $aGroups = Group::getList(sprintf('name like "%%%s%%"', $sFilter)); - $aGroupList = array(); - foreach($aGroups as $oGroup) { - $aGroupList[$oGroup->getId()] = $oGroup->getName(); - } - } - return $aGroupList; + $sFilter = KTUtil::arrayGet($_REQUEST, 'filter', false); + $aGroupList = array('off'=>'-- Please filter --'); + + if($sFilter && trim($sFilter)) { + $aGroups = Group::getList(sprintf('name like "%%%s%%"', $sFilter)); + $aGroupList = array(); + foreach($aGroups as $oGroup) { + $aGroupList[$oGroup->getId()] = $oGroup->getName(); + } + } + + return $aGroupList; } @@ -630,49 +631,47 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { - // 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; + // 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(); + } + // admin and anonymous are automatically ignored here. + $iEnabledUsers = User::getNumberEnabledUsers(); + + 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, '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; } - 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++; - } + // 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')); + $this->commitTransaction(); + $this->successRedirectToMain(_kt('Users updated')); - } + } }