MDL-22624 help string thanks to Davo Smith for suggested wording
[moodle.git] / admin / editors.php
blob476df6cd5f8bb171ece75d56af108bd511d53cb5
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 require_login();
12 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
14 $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors";
16 $action = optional_param('action', '', PARAM_ACTION);
17 $editor = optional_param('editor', '', PARAM_SAFEDIR);
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 ////////////////////////////////////////////////////////////////////////////////
33 // process actions
35 if (!confirm_sesskey()) {
36 redirect($returnurl);
40 $return = true;
41 switch ($action) {
42 case 'disable':
43 // remove from enabled list
44 $key = array_search($editor, $active_editors);
45 unset($active_editors[$key]);
46 break;
48 case 'enable':
49 // add to enabled list
50 if (!in_array($editor, $active_editors)) {
51 $active_editors[] = $editor;
52 $active_editors = array_unique($active_editors);
54 break;
56 case 'down':
57 $key = array_search($editor, $active_editors);
58 // check auth plugin is valid
59 if ($key !== false) {
60 // move down the list
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;
67 break;
69 case 'up':
70 $key = array_search($editor, $active_editors);
71 // check auth is valid
72 if ($key !== false) {
73 // move up the list
74 if ($key >= 1) {
75 $fsave = $active_editors[$key];
76 $active_editors[$key] = $active_editors[$key - 1];
77 $active_editors[$key - 1] = $fsave;
80 break;
81 default:
82 break;
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));
92 if ($return) {
93 redirect ($returnurl);