MDL-60058 calendar: fix event context issue in month_detailed
[moodle.git] / admin / editors.php
blob5d8a50ce768f81633fe221b293d9eecd18661e71
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_login();
19 require_capability('moodle/site:config', context_system::instance());
21 $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors";
23 // get currently installed and enabled auth plugins
24 $available_editors = editors_get_available();
25 if (!empty($editor) and empty($available_editors[$editor])) {
26 redirect ($returnurl);
29 $active_editors = explode(',', $CFG->texteditors);
30 foreach ($active_editors as $key=>$active) {
31 if (empty($available_editors[$active])) {
32 unset($active_editors[$key]);
36 ////////////////////////////////////////////////////////////////////////////////
37 // process actions
39 if (!confirm_sesskey()) {
40 redirect($returnurl);
44 $return = true;
45 switch ($action) {
46 case 'disable':
47 // remove from enabled list
48 $key = array_search($editor, $active_editors);
49 unset($active_editors[$key]);
50 add_to_config_log('editor_visibility', '1', '0', $editor);
51 break;
53 case 'enable':
54 // add to enabled list
55 if (!in_array($editor, $active_editors)) {
56 $active_editors[] = $editor;
57 $active_editors = array_unique($active_editors);
58 add_to_config_log('editor_visibility', '0', '1', $editor);
60 break;
62 case 'down':
63 $key = array_search($editor, $active_editors);
64 // check auth plugin is valid
65 if ($key !== false) {
66 // move down the list
67 if ($key < (count($active_editors) - 1)) {
68 $fsave = $active_editors[$key];
69 $active_editors[$key] = $active_editors[$key + 1];
70 $active_editors[$key + 1] = $fsave;
71 add_to_config_log('editor_position', $key, $key + 1, $editor);
74 break;
76 case 'up':
77 $key = array_search($editor, $active_editors);
78 // check auth is valid
79 if ($key !== false) {
80 // move up the list
81 if ($key >= 1) {
82 $fsave = $active_editors[$key];
83 $active_editors[$key] = $active_editors[$key - 1];
84 $active_editors[$key - 1] = $fsave;
85 add_to_config_log('editor_position', $key, $key - 1, $editor);
88 break;
90 default:
91 break;
94 // at least one editor must be active
95 if (empty($active_editors)) {
96 $active_editors = array('textarea');
99 set_config('texteditors', implode(',', $active_editors));
100 core_plugin_manager::reset_caches();
102 if ($return) {
103 redirect ($returnurl);