function do_change_enabled()
 {
     $this->startTransaction();
     $iLicenses = 0;
     $bRequireLicenses = false;
     if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
         $path = KTPluginUtil::getPluginPath('ktdms.wintools');
         require_once $path . 'baobabkeyutil.inc.php';
         $iLicenses = BaobabKeyUtil::getLicenseCount();
         $bRequireLicenses = true;
     }
     // admin and anonymous are automatically ignored here.
     $iEnabledUsers = User::getNumberEnabledUsers();
     if ($_REQUEST['update_value'] == 'enable') {
         foreach (KTUtil::arrayGet($_REQUEST, 'edit_user', array()) as $sUserId => $v) {
             // check that we haven't hit max user limit
             if ($bRequireLicenses && $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->enable();
             $res = $oUser->update();
             if (PEAR::isError($res)) {
                 $this->errorRedirectToMain(_kt('Error updating user'));
             }
             $iEnabledUsers++;
         }
     }
     if ($_REQUEST['update_value'] == 'disable') {
         //echo 'got into disable';
         //exit;
         foreach (KTUtil::arrayGet($_REQUEST, 'edit_user', array()) as $sUserId => $v) {
             $oUser = User::get((int) $sUserId);
             if (PEAR::isError($oUser)) {
                 $this->errorRedirectToMain(_kt('Error getting user object'));
             }
             $oUser->disable();
             $res = $oUser->update();
             if (PEAR::isError($res)) {
                 $this->errorRedirectToMain(_kt('Error updating user'));
             }
             $iEnabledUsers--;
         }
     }
     if ($_REQUEST['update_value'] == 'delete') {
         //echo 'Delete called';
         foreach (KTUtil::arrayGet($_REQUEST, 'edit_user', array()) as $sUserId => $v) {
             $oUser = User::get((int) $sUserId);
             if (PEAR::isError($oUser)) {
                 $this->errorRedirectToMain(_kt('Error getting user object'));
             }
             $oUser->delete();
             $res = $oUser->update();
             if (PEAR::isError($res)) {
                 $this->errorRedirectToMain(_kt('Error updating user'));
             }
             $iEnabledUsers--;
         }
     }
     $this->commitTransaction();
     $this->successRedirectToMain(_kt('Users updated'));
 }
Beispiel #2
0
 /**
  * Method to check whether electronic signatures are enabled
  *
  * @author KnowledgeTree Team
  * @access public
  * @return bool $enabled true or false
  */
 public function electronic_sig_enabled()
 {
     // Check that the wintools plugin is active and available, return false if not.
     if (!KTPluginUtil::pluginIsActive('ktdms.wintools')) {
         return false;
     }
     // Check config for api signatures enabled
     $oConfig =& KTConfig::getSingleton();
     $enabled = $oConfig->get('e_signatures/enableApiSignatures', false);
     // Check that the license is valid
     $enabled = BaobabKeyUtil::getLicenseCount() >= MIN_LICENSES & $enabled;
     return $enabled;
 }