MDL-71818 calendar: Fix detection of a click on day link
[moodle.git] / admin / auth.php
blobf501ed7c07acdb93f18e3ec42e159cca1f7491a4
1 <?php
3 /**
4 * Allows admin to edit all auth plugin settings.
6 * JH: copied and Hax0rd from admin/enrol.php and admin/filters.php
8 */
10 require_once('../config.php');
11 require_once($CFG->libdir.'/adminlib.php');
12 require_once($CFG->libdir.'/tablelib.php');
14 require_admin();
16 $returnurl = new moodle_url('/admin/settings.php', array('section'=>'manageauths'));
18 $PAGE->set_url($returnurl);
20 $action = optional_param('action', '', PARAM_ALPHANUMEXT);
21 $auth = optional_param('auth', '', PARAM_PLUGIN);
23 get_enabled_auth_plugins(true); // fix the list of enabled auths
24 if (empty($CFG->auth)) {
25 $authsenabled = array();
26 } else {
27 $authsenabled = explode(',', $CFG->auth);
30 if (!empty($auth) and !exists_auth_plugin($auth)) {
31 print_error('pluginnotinstalled', 'auth', $returnurl, $auth);
34 ////////////////////////////////////////////////////////////////////////////////
35 // process actions
37 if (!confirm_sesskey()) {
38 redirect($returnurl);
41 switch ($action) {
42 case 'disable':
43 // Remove from enabled list.
44 $class = \core_plugin_manager::resolve_plugininfo_class('auth');
45 $class::enable_plugin($auth, false);
46 break;
48 case 'enable':
49 // Add to enabled list.
50 $class = \core_plugin_manager::resolve_plugininfo_class('auth');
51 $class::enable_plugin($auth, true);
52 break;
54 case 'down':
55 $key = array_search($auth, $authsenabled);
56 // check auth plugin is valid
57 if ($key === false) {
58 print_error('pluginnotenabled', 'auth', $returnurl, $auth);
60 // move down the list
61 if ($key < (count($authsenabled) - 1)) {
62 $fsave = $authsenabled[$key];
63 $authsenabled[$key] = $authsenabled[$key + 1];
64 $authsenabled[$key + 1] = $fsave;
65 $value = implode(',', $authsenabled);
66 add_to_config_log('auth', $CFG->auth, $value, 'core');
67 set_config('auth', $value);
69 break;
71 case 'up':
72 $key = array_search($auth, $authsenabled);
73 // check auth is valid
74 if ($key === false) {
75 print_error('pluginnotenabled', 'auth', $returnurl, $auth);
77 // move up the list
78 if ($key >= 1) {
79 $fsave = $authsenabled[$key];
80 $authsenabled[$key] = $authsenabled[$key - 1];
81 $authsenabled[$key - 1] = $fsave;
82 $value = implode(',', $authsenabled);
83 add_to_config_log('auth', $CFG->auth, $value, 'core');
84 set_config('auth', $value);
86 break;
88 default:
89 break;
92 redirect($returnurl);