]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14055, change to human-readable strings from hard-coded integer, thanks for Matt...
authordongsheng <dongsheng>
Wed, 26 Mar 2008 01:35:04 +0000 (01:35 +0000)
committerdongsheng <dongsheng>
Wed, 26 Mar 2008 01:35:04 +0000 (01:35 +0000)
auth/cas/auth.php
auth/cas/config.html
auth/db/auth.php
auth/db/config.html
auth/ldap/auth.php
auth/ldap/config.html
lib/authlib.php

index ff01fa9a3925808216a2ed3eaa1c2563d2057e21..f3d05e46e4ce2fc0a7f549d9601a8c0c899a2cf0 100644 (file)
@@ -269,7 +269,7 @@ if ( !is_object($PHPCAS_CLIENT) ) {
         if (!isset($config->groupecreators))
             {$config->groupecreators = ''; }
         if (!isset($config->removeuser))
-            {$config->removeuser = 0; }
+            {$config->removeuser = AUTH_REMOVEUSER_KEEP; }
         // save CAS settings
         set_config('hostname',    $config->hostname,    'auth/cas');
         set_config('port',        $config->port,        'auth/cas');
@@ -708,13 +708,13 @@ if ( !is_object($PHPCAS_CLIENT) ) {
             if (!empty($remove_users)) {
                 print "User entries to remove: ". count($remove_users) . "\n";
                 foreach ($remove_users as $user) {
-                    if ($this->config->removeuser == 2) {
+                    if ($this->config->removeuser == AUTH_REMOVEUSER_FULLDELETE) {
                         if (delete_user($user)) {
                             echo "\t"; print_string('auth_dbdeleteuser', 'auth', array($user->username, $user->id)); echo "\n";
                         } else {
                             echo "\t"; print_string('auth_dbdeleteusererror', 'auth', $user->username); echo "\n";
                         }
-                    } else if ($this->config->removeuser == 1) {
+                    } else if ($this->config->removeuser == AUTH_REMOVEUSER_SUSPEND) {
                         $updateuser = new object();
                         $updateuser->id = $user->id;
                         $updateuser->auth = 'nologin';
@@ -731,7 +731,7 @@ if ( !is_object($PHPCAS_CLIENT) ) {
             unset($remove_users); // free mem!
         }
 /// Revive suspended users
-        if (!empty($this->config->removeuser) and $this->config->removeuser == 1) {
+        if (!empty($this->config->removeuser) and $this->config->removeuser == AUTH_REMOVEUSER_SUSPEND) {
             $sql = "SELECT u.id, u.username
                     FROM $temptable e, {$CFG->prefix}user u
                     WHERE e.username=u.username
index 22cd7a00d03e6422ef84524371c69bfbcf2e1fac..23f9137deb9acac34db86937d705e369a5b6eac5 100644 (file)
 
      if (!isset($config->removeuser))
 
-        {$config->removeuser = 0; }
+        {$config->removeuser = AUTH_REMOVEUSER_KEEP; }
 
 
 
@@ -782,11 +782,11 @@ if (!function_exists('ldap_connect')) { // Is php4-ldap really there?
 
        $deleteopt = array();
 
-       $deleteopt['0'] = get_string('auth_remove_keep','auth');
+       $deleteopt[AUTH_REMOVEUSER_KEEP] = get_string('auth_remove_keep','auth');
 
-       $deleteopt['1'] = get_string('auth_remove_suspend','auth');
+       $deleteopt[AUTH_REMOVEUSER_SUSPEND] = get_string('auth_remove_suspend','auth');
 
-       $deleteopt['2'] = get_string('auth_remove_delete','auth');
+       $deleteopt[AUTH_REMOVEUSER_FULLDELETE] = get_string('auth_remove_delete','auth');
 
        choose_from_menu($deleteopt, 'removeuser', $config->removeuser, '');
 
@@ -825,4 +825,4 @@ print_auth_lock_options('cas', $user_fields, $help, true, true);
 
 
 ?>
-</table>
\ No newline at end of file
+</table>
index 239df97e147b8ec605d47c7a17c3aaaac8bf8a67..32f2df1e3c73f143761686a6d9efb515f02ea05b 100644 (file)
@@ -255,13 +255,13 @@ class auth_plugin_db extends auth_plugin_base {
                 print_string('auth_dbuserstoremove','auth', count($remove_users)); echo "\n";
 
                 foreach ($remove_users as $user) {
-                    if ($this->config->removeuser == 2) {
+                    if ($this->config->removeuser == AUTH_REMOVEUSER_FULLDELETE) {
                         if (delete_user($user)) {
                             echo "\t"; print_string('auth_dbdeleteuser', 'auth', array($user->username, $user->id)); echo "\n";
                         } else {
                             echo "\t"; print_string('auth_dbdeleteusererror', 'auth', $user->username); echo "\n";
                         }
-                    } else if ($this->config->removeuser == 1) {
+                    } else if ($this->config->removeuser == AUTH_REMOVEUSER_SUSPEND) {
                         $updateuser = new object();
                         $updateuser->id   = $user->id;
                         $updateuser->auth = 'nologin';
@@ -666,7 +666,7 @@ class auth_plugin_db extends auth_plugin_base {
             $config->debugauthdb = 0;
         }
         if (!isset($config->removeuser)) {
-            $config->removeuser = 0;
+            $config->removeuser = AUTH_REMOVEUSER_KEEP;
         }
         if (!isset($config->changepasswordurl)) {
             $config->changepasswordurl = '';
index e4ccbe3bf920697facca8fae2781b9d93d40c17b..d7aea3f814e8758144eecb339d336aa4a5009ddd 100644 (file)
@@ -44,7 +44,7 @@
         $config->setupsql = '';
     }
     if (!isset($config->removeuser)) {
-        $config->removeuser = 0;
+        $config->removeuser = AUTH_REMOVEUSER_KEEP;
     }
 
     $yesno = array( get_string('no'), get_string('yes') );
     <td>
     <?php
        $deleteopt = array();
-       $deleteopt['0'] = get_string('auth_remove_keep','auth');
-       $deleteopt['1'] = get_string('auth_remove_suspend','auth');
-       $deleteopt['2'] = get_string('auth_remove_delete','auth');
+       $deleteopt[AUTH_REMOVEUSER_KEEP] = get_string('auth_remove_keep','auth');
+       $deleteopt[AUTH_REMOVEUSER_SUSPEND] = get_string('auth_remove_suspend','auth');
+       $deleteopt[AUTH_REMOVEUSER_FULLDELETE] = get_string('auth_remove_delete','auth');
        choose_from_menu($deleteopt, 'removeuser', $config->removeuser, '');
     ?>
     </td>
index 5ae7085b5cf0c4c099636122e25d3aeb3272d080..868d950316efe8df1ef79815dc48ab412c901921 100644 (file)
@@ -655,13 +655,13 @@ class auth_plugin_ldap extends auth_plugin_base {
                 print "User entries to remove: ". count($remove_users) . "\n";
 
                 foreach ($remove_users as $user) {
-                    if ($this->config->removeuser == 2) {
+                    if ($this->config->removeuser == AUTH_REMOVEUSER_FULLDELETE) {
                         if (delete_user($user)) {
                             echo "\t"; print_string('auth_dbdeleteuser', 'auth', array($user->username, $user->id)); echo "\n";
                         } else {
                             echo "\t"; print_string('auth_dbdeleteusererror', 'auth', $user->username); echo "\n";
                         }
-                    } else if ($this->config->removeuser == 1) {
+                    } else if ($this->config->removeuser == AUTH_REMOVEUSER_SUSPEND) {
                         $updateuser = new object();
                         $updateuser->id = $user->id;
                         $updateuser->auth = 'nologin';
@@ -679,7 +679,7 @@ class auth_plugin_ldap extends auth_plugin_base {
         }
 
 /// Revive suspended users
-        if (!empty($this->config->removeuser) and $this->config->removeuser == 1) {
+        if (!empty($this->config->removeuser) and $this->config->removeuser == AUTH_REMOVEUSER_SUSPEND) {
             $sql = "SELECT u.id, u.username
                     FROM $temptable e, {$CFG->prefix}user u
                     WHERE e.username=u.username
@@ -1971,7 +1971,7 @@ class auth_plugin_ldap extends auth_plugin_base {
         if (!isset($config->changepasswordurl))
             {$config->changepasswordurl = ''; }
         if (!isset($config->removeuser))
-            {$config->removeuser = 0; }
+            {$config->removeuser = AUTH_REMOVEUSER_KEEP; }
         if (!isset($config->ntlmsso_enabled))
             {$config->ntlmsso_enabled = 0; }
         if (!isset($config->ntlmsso_subnet))
index 55fe2debd0db178ff4d0ce36bf842ba40175dbfc..e7f4aeaa78a6e302bbb4ffac6991b95127347297 100644 (file)
@@ -54,7 +54,7 @@
     if (!isset($config->changepasswordurl))
         {$config->changepasswordurl = ''; }
     if (!isset($config->removeuser))
-        {$config->removeuser = 0; }
+        {$config->removeuser = AUTH_REMOVEUSER_KEEP; }
     if (!isset($config->ntlmsso_enabled))
         {$config->ntlmsso_enabled = 0; }
     if (!isset($config->ntlmsso_subnet))
@@ -432,9 +432,9 @@ if (!function_exists('ldap_connect')) { // Is php4-ldap really there?
     <td>
     <?php
        $deleteopt = array();
-       $deleteopt['0'] = get_string('auth_remove_keep','auth');
-       $deleteopt['1'] = get_string('auth_remove_suspend','auth');
-       $deleteopt['2'] = get_string('auth_remove_delete','auth');
+       $deleteopt[AUTH_REMOVEUSER_KEEP] = get_string('auth_remove_keep','auth');
+       $deleteopt[AUTH_REMOVEUSER_SUSPEND] = get_string('auth_remove_suspend','auth');
+       $deleteopt[AUTH_REMOVEUSER_FULLDELETE] = get_string('auth_remove_delete','auth');
        choose_from_menu($deleteopt, 'removeuser', $config->removeuser, '');
     ?>
     </td>
index 2cbdda31d13dcab55eda177329465dc74ee70502..835e6afd68e709b2472bd332f3e084199a49fd2c 100644 (file)
@@ -38,7 +38,10 @@ define('AUTH_CONFIRM_OK', 1);
 define('AUTH_CONFIRM_ALREADY', 2);
 define('AUTH_CONFIRM_ERROR', 3);
 
-
+# MDL-14055
+define('AUTH_REMOVEUSER_KEEP', 0);
+define('AUTH_REMOVEUSER_SUSPEND', 1);
+define('AUTH_REMOVEUSER_FULLDELETE', 2);
 
 /**
  * Abstract authentication plugin.