4 * Allows admin to configure editors.
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());
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 ////////////////////////////////////////////////////////////////////////////////
38 if (!confirm_sesskey()) {
45 // Remove from enabled list.
46 $class = \core_plugin_manager
::resolve_plugininfo_class('editor');
47 $class::enable_plugin($editor, false);
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);
59 $key = array_search($editor, $active_editors);
60 // check auth plugin is valid
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();
75 $key = array_search($editor, $active_editors);
76 // check auth is valid
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();
95 redirect ($returnurl);