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 = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageauths";
19 $action = optional_param('action', '', PARAM_ACTION
);
20 $auth = optional_param('auth', '', PARAM_SAFEDIR
);
22 // get currently installed and enabled auth plugins
23 $authsavailable = get_list_of_plugins('auth');
25 get_enabled_auth_plugins(true); // fix the list of enabled auths
26 if (empty($CFG->auth
)) {
27 $authsenabled = array();
29 $authsenabled = explode(',', $CFG->auth
);
32 if (!empty($auth) and !exists_auth_plugin($auth)) {
33 print_error('pluginnotinstalled', 'auth', $url, $auth);
36 ////////////////////////////////////////////////////////////////////////////////
39 if (!confirm_sesskey()) {
45 // remove from enabled list
46 $key = array_search($auth, $authsenabled);
48 unset($authsenabled[$key]);
49 set_config('auth', implode(',', $authsenabled));
52 if ($auth == $CFG->registerauth
) {
53 set_config('registerauth', '');
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));
67 $key = array_search($auth, $authsenabled);
68 // check auth plugin is valid
70 print_error('pluginnotenabled', 'auth', $url, $auth);
73 if ($key < (count($authsenabled) - 1)) {
74 $fsave = $authsenabled[$key];
75 $authsenabled[$key] = $authsenabled[$key +
1];
76 $authsenabled[$key +
1] = $fsave;
77 set_config('auth', implode(',', $authsenabled));
82 $key = array_search($auth, $authsenabled);
83 // check auth is valid
85 print_error('pluginnotenabled', 'auth', $url, $auth);
89 $fsave = $authsenabled[$key];
90 $authsenabled[$key] = $authsenabled[$key - 1];
91 $authsenabled[$key - 1] = $fsave;
92 set_config('auth', implode(',', $authsenabled));
100 redirect ($returnurl);