2007-01-04 03:19:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allows admin to edit all auth plugin settings.
|
|
|
|
*
|
|
|
|
* JH: copied and Hax0rd from admin/enrol.php and admin/filters.php
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-02-20 17:09:20 +00:00
|
|
|
require_once('../config.php');
|
2007-01-04 03:19:49 +00:00
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
2007-02-20 17:09:20 +00:00
|
|
|
require_once($CFG->libdir.'/tablelib.php');
|
2007-01-04 03:19:49 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
require_login();
|
|
|
|
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
|
|
|
|
|
|
|
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageauths";
|
2007-01-04 03:19:49 +00:00
|
|
|
|
2007-02-20 17:09:20 +00:00
|
|
|
$action = optional_param('action', '', PARAM_ACTION);
|
|
|
|
$auth = optional_param('auth', '', PARAM_SAFEDIR);
|
|
|
|
|
2007-03-27 20:26:05 +00:00
|
|
|
get_enabled_auth_plugins(true); // fix the list of enabled auths
|
2007-02-20 17:09:20 +00:00
|
|
|
if (empty($CFG->auth)) {
|
|
|
|
$authsenabled = array();
|
|
|
|
} else {
|
|
|
|
$authsenabled = explode(',', $CFG->auth);
|
|
|
|
}
|
2005-09-22 15:12:31 +00:00
|
|
|
|
2007-02-20 17:09:20 +00:00
|
|
|
if (!empty($auth) and !exists_auth_plugin($auth)) {
|
2008-06-25 17:31:23 +00:00
|
|
|
print_error('pluginnotinstalled', 'auth', $url, $auth);
|
2007-01-04 03:19:49 +00:00
|
|
|
}
|
2002-11-19 08:51:33 +00:00
|
|
|
|
2007-01-04 03:19:49 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// process actions
|
2007-01-03 19:24:48 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
if (!confirm_sesskey()) {
|
|
|
|
redirect($returnurl);
|
|
|
|
}
|
2007-02-20 17:09:20 +00:00
|
|
|
|
|
|
|
switch ($action) {
|
2007-01-04 03:19:49 +00:00
|
|
|
case 'disable':
|
2007-02-20 17:09:20 +00:00
|
|
|
// remove from enabled list
|
|
|
|
$key = array_search($auth, $authsenabled);
|
|
|
|
if ($key !== false) {
|
2007-01-04 03:19:49 +00:00
|
|
|
unset($authsenabled[$key]);
|
2007-02-20 17:09:20 +00:00
|
|
|
set_config('auth', implode(',', $authsenabled));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($auth == $CFG->registerauth) {
|
|
|
|
set_config('registerauth', '');
|
2007-01-04 03:19:49 +00:00
|
|
|
}
|
2009-01-18 18:00:44 +00:00
|
|
|
session_gc(); // remove stale sessions
|
2007-01-04 03:19:49 +00:00
|
|
|
break;
|
2007-02-20 17:09:20 +00:00
|
|
|
|
2007-01-04 03:19:49 +00:00
|
|
|
case 'enable':
|
|
|
|
// add to enabled list
|
2007-02-20 17:09:20 +00:00
|
|
|
if (!in_array($auth, $authsenabled)) {
|
|
|
|
$authsenabled[] = $auth;
|
2007-01-04 03:19:49 +00:00
|
|
|
$authsenabled = array_unique($authsenabled);
|
2007-02-20 17:09:20 +00:00
|
|
|
set_config('auth', implode(',', $authsenabled));
|
2007-01-04 03:19:49 +00:00
|
|
|
}
|
2009-01-18 18:00:44 +00:00
|
|
|
session_gc(); // remove stale sessions
|
2007-01-04 03:19:49 +00:00
|
|
|
break;
|
2007-02-20 17:09:20 +00:00
|
|
|
|
2007-01-04 03:19:49 +00:00
|
|
|
case 'down':
|
2007-02-20 17:09:20 +00:00
|
|
|
$key = array_search($auth, $authsenabled);
|
2007-01-04 03:19:49 +00:00
|
|
|
// check auth plugin is valid
|
|
|
|
if ($key === false) {
|
2008-06-25 17:31:23 +00:00
|
|
|
print_error('pluginnotenabled', 'auth', $url, $auth);
|
2007-01-04 03:19:49 +00:00
|
|
|
}
|
|
|
|
// move down the list
|
|
|
|
if ($key < (count($authsenabled) - 1)) {
|
|
|
|
$fsave = $authsenabled[$key];
|
|
|
|
$authsenabled[$key] = $authsenabled[$key + 1];
|
|
|
|
$authsenabled[$key + 1] = $fsave;
|
2007-02-20 17:09:20 +00:00
|
|
|
set_config('auth', implode(',', $authsenabled));
|
2007-01-04 03:19:49 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-02-20 17:09:20 +00:00
|
|
|
|
2007-01-04 03:19:49 +00:00
|
|
|
case 'up':
|
2007-02-20 17:09:20 +00:00
|
|
|
$key = array_search($auth, $authsenabled);
|
2007-01-04 03:19:49 +00:00
|
|
|
// check auth is valid
|
|
|
|
if ($key === false) {
|
2008-06-25 17:31:23 +00:00
|
|
|
print_error('pluginnotenabled', 'auth', $url, $auth);
|
2007-01-04 03:19:49 +00:00
|
|
|
}
|
|
|
|
// move up the list
|
|
|
|
if ($key >= 1) {
|
|
|
|
$fsave = $authsenabled[$key];
|
|
|
|
$authsenabled[$key] = $authsenabled[$key - 1];
|
|
|
|
$authsenabled[$key - 1] = $fsave;
|
2007-02-20 17:09:20 +00:00
|
|
|
set_config('auth', implode(',', $authsenabled));
|
2007-01-04 03:19:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2002-11-22 08:43:35 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
redirect ($returnurl);
|
2002-11-19 08:51:33 +00:00
|
|
|
|
|
|
|
?>
|