Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]
1 <?php 2 3 /** 4 * Allows admin to configure editors. 5 */ 6 7 require_once('../config.php'); 8 require_once($CFG->libdir.'/adminlib.php'); 9 require_once($CFG->libdir.'/tablelib.php'); 10 11 $action = required_param('action', PARAM_ALPHANUMEXT); 12 $editor = required_param('editor', PARAM_PLUGIN); 13 $confirm = optional_param('confirm', 0, PARAM_BOOL); 14 15 $PAGE->set_url('/admin/editors.php', array('action'=>$action, 'editor'=>$editor)); 16 $PAGE->set_context(context_system::instance()); 17 18 require_admin(); 19 20 $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors"; 21 22 // get currently installed and enabled auth plugins 23 $available_editors = editors_get_available(); 24 if (!empty($editor) and empty($available_editors[$editor])) { 25 redirect ($returnurl); 26 } 27 28 $active_editors = explode(',', $CFG->texteditors); 29 foreach ($active_editors as $key=>$active) { 30 if (empty($available_editors[$active])) { 31 unset($active_editors[$key]); 32 } 33 } 34 35 //////////////////////////////////////////////////////////////////////////////// 36 // process actions 37 38 if (!confirm_sesskey()) { 39 redirect($returnurl); 40 } 41 42 43 $return = true; 44 switch ($action) { 45 case 'disable': 46 // remove from enabled list 47 $key = array_search($editor, $active_editors); 48 unset($active_editors[$key]); 49 add_to_config_log('editor_visibility', '1', '0', $editor); 50 break; 51 52 case 'enable': 53 // add to enabled list 54 if (!in_array($editor, $active_editors)) { 55 $active_editors[] = $editor; 56 $active_editors = array_unique($active_editors); 57 add_to_config_log('editor_visibility', '0', '1', $editor); 58 } 59 break; 60 61 case 'down': 62 $key = array_search($editor, $active_editors); 63 // check auth plugin is valid 64 if ($key !== false) { 65 // move down the list 66 if ($key < (count($active_editors) - 1)) { 67 $fsave = $active_editors[$key]; 68 $active_editors[$key] = $active_editors[$key + 1]; 69 $active_editors[$key + 1] = $fsave; 70 add_to_config_log('editor_position', $key, $key + 1, $editor); 71 } 72 } 73 break; 74 75 case 'up': 76 $key = array_search($editor, $active_editors); 77 // check auth is valid 78 if ($key !== false) { 79 // move up the list 80 if ($key >= 1) { 81 $fsave = $active_editors[$key]; 82 $active_editors[$key] = $active_editors[$key - 1]; 83 $active_editors[$key - 1] = $fsave; 84 add_to_config_log('editor_position', $key, $key - 1, $editor); 85 } 86 } 87 break; 88 89 default: 90 break; 91 } 92 93 // at least one editor must be active 94 if (empty($active_editors)) { 95 $active_editors = array('textarea'); 96 } 97 98 set_config('texteditors', implode(',', $active_editors)); 99 core_plugin_manager::reset_caches(); 100 101 if ($return) { 102 redirect ($returnurl); 103 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body