|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00010 require_once('../config.php'); 00011 require_once($CFG->libdir.'/adminlib.php'); 00012 require_once($CFG->libdir.'/tablelib.php'); 00013 00014 require_login(); 00015 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); 00016 00017 $returnurl = new moodle_url('/admin/settings.php', array('section'=>'manageauths')); 00018 00019 $PAGE->set_url($returnurl); 00020 00021 $action = optional_param('action', '', PARAM_ACTION); 00022 $auth = optional_param('auth', '', PARAM_PLUGIN); 00023 00024 get_enabled_auth_plugins(true); // fix the list of enabled auths 00025 if (empty($CFG->auth)) { 00026 $authsenabled = array(); 00027 } else { 00028 $authsenabled = explode(',', $CFG->auth); 00029 } 00030 00031 if (!empty($auth) and !exists_auth_plugin($auth)) { 00032 print_error('pluginnotinstalled', 'auth', $returnurl, $auth); 00033 } 00034 00036 // process actions 00037 00038 if (!confirm_sesskey()) { 00039 redirect($returnurl); 00040 } 00041 00042 switch ($action) { 00043 case 'disable': 00044 // remove from enabled list 00045 $key = array_search($auth, $authsenabled); 00046 if ($key !== false) { 00047 unset($authsenabled[$key]); 00048 set_config('auth', implode(',', $authsenabled)); 00049 } 00050 00051 if ($auth == $CFG->registerauth) { 00052 set_config('registerauth', ''); 00053 } 00054 session_gc(); // remove stale sessions 00055 break; 00056 00057 case 'enable': 00058 // add to enabled list 00059 if (!in_array($auth, $authsenabled)) { 00060 $authsenabled[] = $auth; 00061 $authsenabled = array_unique($authsenabled); 00062 set_config('auth', implode(',', $authsenabled)); 00063 } 00064 session_gc(); // remove stale sessions 00065 break; 00066 00067 case 'down': 00068 $key = array_search($auth, $authsenabled); 00069 // check auth plugin is valid 00070 if ($key === false) { 00071 print_error('pluginnotenabled', 'auth', $returnurl, $auth); 00072 } 00073 // move down the list 00074 if ($key < (count($authsenabled) - 1)) { 00075 $fsave = $authsenabled[$key]; 00076 $authsenabled[$key] = $authsenabled[$key + 1]; 00077 $authsenabled[$key + 1] = $fsave; 00078 set_config('auth', implode(',', $authsenabled)); 00079 } 00080 break; 00081 00082 case 'up': 00083 $key = array_search($auth, $authsenabled); 00084 // check auth is valid 00085 if ($key === false) { 00086 print_error('pluginnotenabled', 'auth', $returnurl, $auth); 00087 } 00088 // move up the list 00089 if ($key >= 1) { 00090 $fsave = $authsenabled[$key]; 00091 $authsenabled[$key] = $authsenabled[$key - 1]; 00092 $authsenabled[$key - 1] = $fsave; 00093 set_config('auth', implode(',', $authsenabled)); 00094 } 00095 break; 00096 00097 default: 00098 break; 00099 } 00100 00101 redirect($returnurl); 00102 00103