Commit fc26a2e8d1377ef2ac3a430a0f0b0ef9f24d7220

Authored by Brad Shuttleworth
1 parent 650cfd59

merge in 5980:5982 from RELEASE_3_1_BRANCH


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5983 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/users/User.inc
... ... @@ -315,10 +315,20 @@ class User extends KTEntity {
315 315 $this->update();
316 316 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
317 317 require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php');
318   - BaobabKeyUtil::deallocate($this);
  318 + BaobabKeyUtil::deallocateUser($this);
319 319 }
320 320 return;
321 321 }
  322 +
  323 + function enable() {
  324 + $this->setDisabled(false);
  325 + $this->update();
  326 + if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
  327 + require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php');
  328 + BaobabKeyUtil::allocateUser($this);
  329 + }
  330 + return;
  331 + }
322 332  
323 333 function create() {
324 334 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
... ...
plugins/ktcore/admin/userManagement.php
... ... @@ -635,9 +635,11 @@ class KTUserAdminDispatcher extends KTAdminDispatcher {
635 635 function do_change_enabled() {
636 636 $this->startTransaction();
637 637 $iLicenses = 0;
  638 + $bRequireLicenses = false;
638 639 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
639 640 require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php');
640 641 $iLicenses = BaobabKeyUtil::getLicenseCount();
  642 + $bRequireLicenses = true;
641 643 }
642 644 // admin and anonymous are automatically ignored here.
643 645 $iEnabledUsers = User::getNumberEnabledUsers();
... ... @@ -645,7 +647,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher {
645 647 foreach(KTUtil::arrayGet($_REQUEST, 'disable_user', array()) as $sUserId => $v) {
646 648 $oUser = User::get((int)$sUserId);
647 649 if(PEAR::isError($oUser)) { $this->errorRedirectToMain(_kt('Error getting user object')); }
648   - $oUser->setDisabled(True);
  650 + $oUser->disable();
649 651 $res = $oUser->update();
650 652 if(PEAR::isError($res)) { $this->errorRedirectToMain(_kt('Error updating user')); }
651 653 $iEnabledUsers--;
... ... @@ -653,7 +655,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher {
653 655  
654 656 foreach(KTUtil::arrayGet($_REQUEST, 'enable_user', array()) as $sUserId => $v) {
655 657 // check that we haven't hit max user limit
656   - if($iLicenses !== 0 && $iEnabledUsers >= $iLicenses) {
  658 + if($bRequireLicenses && $iEnabledUsers >= $iLicenses) {
657 659 // if so, add to error messages, but commit transaction (break this loop)
658 660 $_SESSION['KTErrorMessage'][] = _kt('You may only have ') . $iLicenses . _kt(' users enabled at one time.');
659 661 break;
... ... @@ -662,7 +664,7 @@ class KTUserAdminDispatcher extends KTAdminDispatcher {
662 664 // else enable user
663 665 $oUser = User::get((int)$sUserId);
664 666 if(PEAR::isError($oUser)) { $this->errorRedirectToMain(_kt('Error getting user object')); }
665   - $oUser->setDisabled(False);
  667 + $oUser->enable();
666 668 $res = $oUser->update();
667 669 if(PEAR::isError($res)) { $this->errorRedirectToMain(_kt('Error updating user')); }
668 670 $iEnabledUsers++;
... ...