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');
12 require_capability('moodle/site:config', context_system
::instance());
14 $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors";
16 $action = optional_param('action', '', PARAM_ALPHANUMEXT
);
17 $editor = optional_param('editor', '', PARAM_PLUGIN
);
19 // get currently installed and enabled auth plugins
20 $available_editors = editors_get_available();
21 if (!empty($editor) and empty($available_editors[$editor])) {
22 redirect ($returnurl);
25 $active_editors = explode(',', $CFG->texteditors
);
26 foreach ($active_editors as $key=>$active) {
27 if (empty($available_editors[$active])) {
28 unset($active_editors[$key]);
32 ////////////////////////////////////////////////////////////////////////////////
35 if (!confirm_sesskey()) {
43 // remove from enabled list
44 $key = array_search($editor, $active_editors);
45 unset($active_editors[$key]);
49 // add to enabled list
50 if (!in_array($editor, $active_editors)) {
51 $active_editors[] = $editor;
52 $active_editors = array_unique($active_editors);
57 $key = array_search($editor, $active_editors);
58 // check auth plugin is valid
61 if ($key < (count($active_editors) - 1)) {
62 $fsave = $active_editors[$key];
63 $active_editors[$key] = $active_editors[$key +
1];
64 $active_editors[$key +
1] = $fsave;
70 $key = array_search($editor, $active_editors);
71 // check auth is valid
75 $fsave = $active_editors[$key];
76 $active_editors[$key] = $active_editors[$key - 1];
77 $active_editors[$key - 1] = $fsave;
85 // at least one editor must be active
86 if (empty($active_editors)) {
87 $active_editors = array('textarea');
90 set_config('texteditors', implode(',', $active_editors));
93 redirect ($returnurl);