moodle/admin/auth.php

93 lines
2.6 KiB
PHP
Raw Normal View History

<?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');
require_once($CFG->libdir.'/adminlib.php');
2007-02-20 17:09:20 +00:00
require_once($CFG->libdir.'/tablelib.php');
require_admin();
$returnurl = new moodle_url('/admin/settings.php', array('section'=>'manageauths'));
$PAGE->set_url($returnurl);
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
$auth = optional_param('auth', '', PARAM_PLUGIN);
2007-02-20 17:09:20 +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);
}
2007-02-20 17:09:20 +00:00
if (!empty($auth) and !exists_auth_plugin($auth)) {
print_error('pluginnotinstalled', 'auth', $returnurl, $auth);
}
////////////////////////////////////////////////////////////////////////////////
// process actions
2007-01-03 19:24:48 +00:00
if (!confirm_sesskey()) {
redirect($returnurl);
}
2007-02-20 17:09:20 +00:00
switch ($action) {
case 'disable':
// Remove from enabled list.
$class = \core_plugin_manager::resolve_plugininfo_class('auth');
$class::enable_plugin($auth, false);
break;
2007-02-20 17:09:20 +00:00
case 'enable':
// Add to enabled list.
$class = \core_plugin_manager::resolve_plugininfo_class('auth');
$class::enable_plugin($auth, true);
break;
2007-02-20 17:09:20 +00:00
case 'down':
2007-02-20 17:09:20 +00:00
$key = array_search($auth, $authsenabled);
// check auth plugin is valid
if ($key === false) {
print_error('pluginnotenabled', 'auth', $returnurl, $auth);
}
// move down the list
if ($key < (count($authsenabled) - 1)) {
$fsave = $authsenabled[$key];
$authsenabled[$key] = $authsenabled[$key + 1];
$authsenabled[$key + 1] = $fsave;
$value = implode(',', $authsenabled);
add_to_config_log('auth', $CFG->auth, $value, 'core');
set_config('auth', $value);
}
break;
2007-02-20 17:09:20 +00:00
case 'up':
2007-02-20 17:09:20 +00:00
$key = array_search($auth, $authsenabled);
// check auth is valid
if ($key === false) {
print_error('pluginnotenabled', 'auth', $returnurl, $auth);
}
// move up the list
if ($key >= 1) {
$fsave = $authsenabled[$key];
$authsenabled[$key] = $authsenabled[$key - 1];
$authsenabled[$key - 1] = $fsave;
$value = implode(',', $authsenabled);
add_to_config_log('auth', $CFG->auth, $value, 'core');
set_config('auth', $value);
}
break;
default:
break;
}
redirect($returnurl);