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
|
|
|
|
2019-06-05 14:07:28 +10:00
|
|
|
require_admin();
|
2007-12-19 17:35:20 +00:00
|
|
|
|
2010-09-07 19:47:08 +00:00
|
|
|
$returnurl = new moodle_url('/admin/settings.php', array('section'=>'manageauths'));
|
2007-01-04 03:19:49 +00:00
|
|
|
|
2009-10-15 02:19:51 +00:00
|
|
|
$PAGE->set_url($returnurl);
|
|
|
|
|
2012-05-11 13:42:27 +08:00
|
|
|
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
2011-09-24 15:07:27 +02:00
|
|
|
$auth = optional_param('auth', '', PARAM_PLUGIN);
|
2007-02-20 17:09:20 +00:00
|
|
|
|
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)) {
|
2010-09-07 19:47:08 +00:00
|
|
|
print_error('pluginnotinstalled', 'auth', $returnurl, $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':
|
2021-10-01 11:28:37 +02:00
|
|
|
// Remove from enabled list.
|
|
|
|
$class = \core_plugin_manager::resolve_plugininfo_class('auth');
|
|
|
|
$class::enable_plugin($auth, false);
|
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':
|
2021-10-01 11:28:37 +02:00
|
|
|
// Add to enabled list.
|
|
|
|
$class = \core_plugin_manager::resolve_plugininfo_class('auth');
|
|
|
|
$class::enable_plugin($auth, true);
|
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) {
|
2010-09-07 19:47:08 +00:00
|
|
|
print_error('pluginnotenabled', 'auth', $returnurl, $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;
|
2021-02-02 12:41:18 +11:00
|
|
|
$value = implode(',', $authsenabled);
|
|
|
|
add_to_config_log('auth', $CFG->auth, $value, 'core');
|
|
|
|
set_config('auth', $value);
|
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) {
|
2010-09-07 19:47:08 +00:00
|
|
|
print_error('pluginnotenabled', 'auth', $returnurl, $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;
|
2021-02-02 12:41:18 +11:00
|
|
|
$value = implode(',', $authsenabled);
|
|
|
|
add_to_config_log('auth', $CFG->auth, $value, 'core');
|
|
|
|
set_config('auth', $value);
|
2007-01-04 03:19:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2002-11-22 08:43:35 +00:00
|
|
|
|
2010-09-07 19:47:08 +00:00
|
|
|
redirect($returnurl);
|