4 * Allows admin to edit all auth plugin settings.
6 * JH: copied and Hax0rd from admin/enrol.php and admin/filters.php
10 require_once('../config.php');
11 require_once($CFG->libdir
.'/adminlib.php');
12 require_once($CFG->libdir
.'/tablelib.php');
15 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM
));
17 $returnurl = new moodle_url('/admin/settings.php', array('section'=>'manageauths'));
19 $PAGE->set_url($returnurl);
21 $action = optional_param('action', '', PARAM_ACTION
);
22 $auth = optional_param('auth', '', PARAM_PLUGIN
);
24 get_enabled_auth_plugins(true); // fix the list of enabled auths
25 if (empty($CFG->auth
)) {
26 $authsenabled = array();
28 $authsenabled = explode(',', $CFG->auth
);
31 if (!empty($auth) and !exists_auth_plugin($auth)) {
32 print_error('pluginnotinstalled', 'auth', $returnurl, $auth);
35 ////////////////////////////////////////////////////////////////////////////////
38 if (!confirm_sesskey()) {
44 // remove from enabled list
45 $key = array_search($auth, $authsenabled);
47 unset($authsenabled[$key]);
48 set_config('auth', implode(',', $authsenabled));
51 if ($auth == $CFG->registerauth
) {
52 set_config('registerauth', '');
54 session_gc(); // remove stale sessions
58 // add to enabled list
59 if (!in_array($auth, $authsenabled)) {
60 $authsenabled[] = $auth;
61 $authsenabled = array_unique($authsenabled);
62 set_config('auth', implode(',', $authsenabled));
64 session_gc(); // remove stale sessions
68 $key = array_search($auth, $authsenabled);
69 // check auth plugin is valid
71 print_error('pluginnotenabled', 'auth', $returnurl, $auth);
74 if ($key < (count($authsenabled) - 1)) {
75 $fsave = $authsenabled[$key];
76 $authsenabled[$key] = $authsenabled[$key +
1];
77 $authsenabled[$key +
1] = $fsave;
78 set_config('auth', implode(',', $authsenabled));
83 $key = array_search($auth, $authsenabled);
84 // check auth is valid
86 print_error('pluginnotenabled', 'auth', $returnurl, $auth);
90 $fsave = $authsenabled[$key];
91 $authsenabled[$key] = $authsenabled[$key - 1];
92 $authsenabled[$key - 1] = $fsave;
93 set_config('auth', implode(',', $authsenabled));
101 redirect($returnurl);