Skip to content

Commit

Permalink
MDL-14055, change to human-readable strings from hard-coded integer, …
Browse files Browse the repository at this point in the history
…thanks for Matt's patch.
  • Loading branch information
dongsheng committed Mar 26, 2008
1 parent d169515 commit 6f87ef5
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 25 deletions.
8 changes: 4 additions & 4 deletions auth/cas/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function process_config($config) {
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');
Expand Down Expand Up @@ -708,13 +708,13 @@ function sync_users ($bulk_insert_records = 1000, $do_updates = true) {
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';
Expand All @@ -731,7 +731,7 @@ function sync_users ($bulk_insert_records = 1000, $do_updates = true) {
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
Expand Down
10 changes: 5 additions & 5 deletions auth/cas/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@

if (!isset($config->removeuser))

{$config->removeuser = 0; }
{$config->removeuser = AUTH_REMOVEUSER_KEEP; }



Expand Down Expand Up @@ -782,11 +782,11 @@ <h4><?php print_string('auth_sync_script', 'auth') ?> </h4>

$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, '');

Expand Down Expand Up @@ -825,4 +825,4 @@ <h4><?php print_string('auth_sync_script', 'auth') ?> </h4>


?>
</table>
</table>
6 changes: 3 additions & 3 deletions auth/db/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ function sync_users($do_updates=false) {
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';
Expand Down Expand Up @@ -666,7 +666,7 @@ function process_config($config) {
$config->debugauthdb = 0;
}
if (!isset($config->removeuser)) {
$config->removeuser = 0;
$config->removeuser = AUTH_REMOVEUSER_KEEP;
}
if (!isset($config->changepasswordurl)) {
$config->changepasswordurl = '';
Expand Down
8 changes: 4 additions & 4 deletions auth/db/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -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') );
Expand Down Expand Up @@ -256,9 +256,9 @@ <h4><?php print_string('auth_sync_script', 'auth') ?> </h4>
<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>
Expand Down
8 changes: 4 additions & 4 deletions auth/ldap/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -655,13 +655,13 @@ function sync_users ($bulk_insert_records = 1000, $do_updates = true) {
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';
Expand All @@ -679,7 +679,7 @@ function sync_users ($bulk_insert_records = 1000, $do_updates = true) {
}

/// 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
Expand Down Expand Up @@ -1971,7 +1971,7 @@ function process_config($config) {
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))
Expand Down
8 changes: 4 additions & 4 deletions auth/ldap/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -432,9 +432,9 @@ <h4><?php print_string('auth_sync_script', 'auth') ?> </h4>
<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>
Expand Down
5 changes: 4 additions & 1 deletion lib/authlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
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.
Expand Down

0 comments on commit 6f87ef5

Please sign in to comment.