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());
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 ////////////////////////////////////////////////////////////////////////////////
39 if (!confirm_sesskey()) {
47 // remove from enabled list
48 $key = array_search($editor, $active_editors);
49 unset($active_editors[$key]);
53 // add to enabled list
54 if (!in_array($editor, $active_editors)) {
55 $active_editors[] = $editor;
56 $active_editors = array_unique($active_editors);
61 $key = array_search($editor, $active_editors);
62 // check auth plugin is valid
65 if ($key < (count($active_editors) - 1)) {
66 $fsave = $active_editors[$key];
67 $active_editors[$key] = $active_editors[$key +
1];
68 $active_editors[$key +
1] = $fsave;
74 $key = array_search($editor, $active_editors);
75 // check auth is valid
79 $fsave = $active_editors[$key];
80 $active_editors[$key] = $active_editors[$key - 1];
81 $active_editors[$key - 1] = $fsave;
87 if ($editor === 'textarea') {
90 if (get_string_manager()->string_exists('pluginname', 'editor_'.$editor)) {
91 $strplugin = get_string('pluginname', 'editor_'.$editor);
96 $PAGE->set_title($strplugin);
97 echo $OUTPUT->header();
100 echo $OUTPUT->heading(get_string('editors', 'core_editor'));
102 $deleteurl = new moodle_url('/admin/editors.php', array('action'=>'uninstall', 'editor'=>$editor, 'sesskey'=>sesskey(), 'confirm'=>1));
104 echo $OUTPUT->confirm(get_string('editordeleteconfirm', 'core_editor', $strplugin),
105 $deleteurl, $returnurl);
106 echo $OUTPUT->footer();
110 // Remove from enabled list.
111 $key = array_search($editor, $active_editors);
112 unset($active_editors[$key]);
113 set_config('texteditors', implode(',', $active_editors));
115 // Delete everything!!
116 uninstall_plugin('editor', $editor);
119 $a->name
= $strplugin;
120 $a->directory
= "$CFG->dirroot/lib/editor/$editor";
121 echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
122 echo $OUTPUT->continue_button($returnurl);
123 echo $OUTPUT->footer();
131 // at least one editor must be active
132 if (empty($active_editors)) {
133 $active_editors = array('textarea');
136 set_config('texteditors', implode(',', $active_editors));
139 redirect ($returnurl);