|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00007 require_once('../config.php'); 00008 require_once($CFG->libdir.'/adminlib.php'); 00009 require_once($CFG->libdir.'/tablelib.php'); 00010 00011 require_login(); 00012 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); 00013 00014 $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors"; 00015 00016 $action = optional_param('action', '', PARAM_ACTION); 00017 $editor = optional_param('editor', '', PARAM_PLUGIN); 00018 00019 // get currently installed and enabled auth plugins 00020 $available_editors = editors_get_available(); 00021 if (!empty($editor) and empty($available_editors[$editor])) { 00022 redirect ($returnurl); 00023 } 00024 00025 $active_editors = explode(',', $CFG->texteditors); 00026 foreach ($active_editors as $key=>$active) { 00027 if (empty($available_editors[$active])) { 00028 unset($active_editors[$key]); 00029 } 00030 } 00031 00033 // process actions 00034 00035 if (!confirm_sesskey()) { 00036 redirect($returnurl); 00037 } 00038 00039 00040 $return = true; 00041 switch ($action) { 00042 case 'disable': 00043 // remove from enabled list 00044 $key = array_search($editor, $active_editors); 00045 unset($active_editors[$key]); 00046 break; 00047 00048 case 'enable': 00049 // add to enabled list 00050 if (!in_array($editor, $active_editors)) { 00051 $active_editors[] = $editor; 00052 $active_editors = array_unique($active_editors); 00053 } 00054 break; 00055 00056 case 'down': 00057 $key = array_search($editor, $active_editors); 00058 // check auth plugin is valid 00059 if ($key !== false) { 00060 // move down the list 00061 if ($key < (count($active_editors) - 1)) { 00062 $fsave = $active_editors[$key]; 00063 $active_editors[$key] = $active_editors[$key + 1]; 00064 $active_editors[$key + 1] = $fsave; 00065 } 00066 } 00067 break; 00068 00069 case 'up': 00070 $key = array_search($editor, $active_editors); 00071 // check auth is valid 00072 if ($key !== false) { 00073 // move up the list 00074 if ($key >= 1) { 00075 $fsave = $active_editors[$key]; 00076 $active_editors[$key] = $active_editors[$key - 1]; 00077 $active_editors[$key - 1] = $fsave; 00078 } 00079 } 00080 break; 00081 default: 00082 break; 00083 } 00084 00085 // at least one editor must be active 00086 if (empty($active_editors)) { 00087 $active_editors = array('textarea'); 00088 } 00089 00090 set_config('texteditors', implode(',', $active_editors)); 00091 00092 if ($return) { 00093 redirect ($returnurl); 00094 }