[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/admin/ -> editors.php (source)

   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_login();
  19  require_capability('moodle/site:config', context_system::instance());
  20  
  21  $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors";
  22  
  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);
  27  }
  28  
  29  $active_editors = explode(',', $CFG->texteditors);
  30  foreach ($active_editors as $key=>$active) {
  31      if (empty($available_editors[$active])) {
  32          unset($active_editors[$key]);
  33      }
  34  }
  35  
  36  ////////////////////////////////////////////////////////////////////////////////
  37  // process actions
  38  
  39  if (!confirm_sesskey()) {
  40      redirect($returnurl);
  41  }
  42  
  43  
  44  $return = true;
  45  switch ($action) {
  46      case 'disable':
  47          // remove from enabled list
  48          $key = array_search($editor, $active_editors);
  49          unset($active_editors[$key]);
  50          break;
  51  
  52      case 'enable':
  53          // add to enabled list
  54          if (!in_array($editor, $active_editors)) {
  55              $active_editors[] = $editor;
  56              $active_editors = array_unique($active_editors);
  57          }
  58          break;
  59  
  60      case 'down':
  61          $key = array_search($editor, $active_editors);
  62          // check auth plugin is valid
  63          if ($key !== false) {
  64              // move down the list
  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;
  69              }
  70          }
  71          break;
  72  
  73      case 'up':
  74          $key = array_search($editor, $active_editors);
  75          // check auth is valid
  76          if ($key !== false) {
  77              // move up the list
  78              if ($key >= 1) {
  79                  $fsave = $active_editors[$key];
  80                  $active_editors[$key] = $active_editors[$key - 1];
  81                  $active_editors[$key - 1] = $fsave;
  82              }
  83          }
  84          break;
  85  
  86      default:
  87          break;
  88  }
  89  
  90  // at least one editor must be active
  91  if (empty($active_editors)) {
  92      $active_editors = array('textarea');
  93  }
  94  
  95  set_config('texteditors', implode(',', $active_editors));
  96  core_plugin_manager::reset_caches();
  97  
  98  if ($return) {
  99      redirect ($returnurl);
 100  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1