Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
/admin/ -> editors.php (source)

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 and 403]

   1  <?php
   2  
   3  /**
   4   * Allows admin to configure editors.
   5   */
   6  
   7  require_once('../config.php');
   8  require_once($CFG->libdir.'/adminlib.php');
   9  require_once($CFG->libdir.'/tablelib.php');
  10  
  11  $action  = required_param('action', PARAM_ALPHANUMEXT);
  12  $editor  = required_param('editor', PARAM_PLUGIN);
  13  $confirm = optional_param('confirm', 0, PARAM_BOOL);
  14  
  15  $PAGE->set_url('/admin/editors.php', array('action'=>$action, 'editor'=>$editor));
  16  $PAGE->set_context(context_system::instance());
  17  
  18  require_admin();
  19  
  20  $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors";
  21  
  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);
  26  }
  27  
  28  $active_editors = explode(',', $CFG->texteditors);
  29  foreach ($active_editors as $key=>$active) {
  30      if (empty($available_editors[$active])) {
  31          unset($active_editors[$key]);
  32      }
  33  }
  34  
  35  ////////////////////////////////////////////////////////////////////////////////
  36  // process actions
  37  
  38  if (!confirm_sesskey()) {
  39      redirect($returnurl);
  40  }
  41  
  42  $return = true;
  43  switch ($action) {
  44      case 'disable':
  45          // Remove from enabled list.
  46          $class = \core_plugin_manager::resolve_plugininfo_class('editor');
  47          $class::enable_plugin($editor, false);
  48          break;
  49  
  50      case 'enable':
  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);
  55          }
  56          break;
  57  
  58      case 'down':
  59          $key = array_search($editor, $active_editors);
  60          // check auth plugin is valid
  61          if ($key !== false) {
  62              // move down the list
  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();
  70              }
  71          }
  72          break;
  73  
  74      case 'up':
  75          $key = array_search($editor, $active_editors);
  76          // check auth is valid
  77          if ($key !== false) {
  78              // move up the list
  79              if ($key >= 1) {
  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();
  86              }
  87          }
  88          break;
  89  
  90      default:
  91          break;
  92  }
  93  
  94  if ($return) {
  95      redirect ($returnurl);
  96  }