MDL-73507 course: make current activity highlight darker
[moodle.git] / admin / editors.php
blobaa4e91b4fa7cef3dc455b94d3ad0613bf34b5263
1 <?php
3 /**
4 * Allows admin to configure editors.
5 */
7 require_once('../config.php');
8 require_once($CFG->libdir.'/adminlib.php');
9 require_once($CFG->libdir.'/tablelib.php');
11 $action = required_param('action', PARAM_ALPHANUMEXT);
12 $editor = required_param('editor', PARAM_PLUGIN);
13 $confirm = optional_param('confirm', 0, PARAM_BOOL);
15 $PAGE->set_url('/admin/editors.php', array('action'=>$action, 'editor'=>$editor));
16 $PAGE->set_context(context_system::instance());
18 require_admin();
20 $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors";
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);
28 $active_editors = explode(',', $CFG->texteditors);
29 foreach ($active_editors as $key=>$active) {
30 if (empty($available_editors[$active])) {
31 unset($active_editors[$key]);
35 ////////////////////////////////////////////////////////////////////////////////
36 // process actions
38 if (!confirm_sesskey()) {
39 redirect($returnurl);
42 $return = true;
43 switch ($action) {
44 case 'disable':
45 // Remove from enabled list.
46 $class = \core_plugin_manager::resolve_plugininfo_class('editor');
47 $class::enable_plugin($editor, false);
48 break;
50 case 'enable':
51 // Add to enabled list.
52 if (!in_array($editor, $active_editors)) {
53 $class = \core_plugin_manager::resolve_plugininfo_class('editor');
54 $class::enable_plugin($editor, true);
56 break;
58 case 'down':
59 $key = array_search($editor, $active_editors);
60 // check auth plugin is valid
61 if ($key !== false) {
62 // move down the list
63 if ($key < (count($active_editors) - 1)) {
64 $fsave = $active_editors[$key];
65 $active_editors[$key] = $active_editors[$key + 1];
66 $active_editors[$key + 1] = $fsave;
67 add_to_config_log('editor_position', $key, $key + 1, $editor);
68 set_config('texteditors', implode(',', $active_editors));
69 core_plugin_manager::reset_caches();
72 break;
74 case 'up':
75 $key = array_search($editor, $active_editors);
76 // check auth is valid
77 if ($key !== false) {
78 // move up the list
79 if ($key >= 1) {
80 $fsave = $active_editors[$key];
81 $active_editors[$key] = $active_editors[$key - 1];
82 $active_editors[$key - 1] = $fsave;
83 add_to_config_log('editor_position', $key, $key - 1, $editor);
84 set_config('texteditors', implode(',', $active_editors));
85 core_plugin_manager::reset_caches();
88 break;
90 default:
91 break;
94 if ($return) {
95 redirect ($returnurl);