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/ -> media.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  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Enrol config manipulation script.
  19   *
  20   * @package    core
  21   * @subpackage media
  22   * @copyright  2016 Marina Glancy
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  define('NO_OUTPUT_BUFFERING', true);
  27  
  28  require_once('../config.php');
  29  require_once($CFG->libdir.'/adminlib.php');
  30  
  31  $action  = required_param('action', PARAM_ALPHANUMEXT);
  32  $media   = required_param('media', PARAM_PLUGIN);
  33  $confirm = optional_param('confirm', 0, PARAM_BOOL);
  34  
  35  $PAGE->set_url('/admin/media.php');
  36  $PAGE->set_context(context_system::instance());
  37  
  38  require_admin();
  39  require_sesskey();
  40  
  41  $plugins = core_plugin_manager::instance()->get_plugins_of_type('media');
  42  $sortorder = array_values(\core\plugininfo\media::get_enabled_plugins());
  43  
  44  $return = new moodle_url('/admin/settings.php', array('section' => 'managemediaplayers'));
  45  
  46  if (!array_key_exists($media, $plugins)) {
  47      redirect($return);
  48  }
  49  
  50  switch ($action) {
  51      case 'disable':
  52          $class = \core_plugin_manager::resolve_plugininfo_class('media');
  53          $class::enable_plugin($media, false);
  54          break;
  55  
  56      case 'enable':
  57          $class = \core_plugin_manager::resolve_plugininfo_class('media');
  58          $class::enable_plugin($media, true);
  59          break;
  60  
  61      case 'up':
  62          if (($pos = array_search($media, $sortorder)) > 0) {
  63              $tmp = $sortorder[$pos - 1];
  64              $sortorder[$pos - 1] = $sortorder[$pos];
  65              $sortorder[$pos] = $tmp;
  66              \core\plugininfo\media::set_enabled_plugins($sortorder);
  67          }
  68          break;
  69  
  70      case 'down':
  71          if ((($pos = array_search($media, $sortorder)) !== false) && ($pos < count($sortorder) - 1)) {
  72              $tmp = $sortorder[$pos + 1];
  73              $sortorder[$pos + 1] = $sortorder[$pos];
  74              $sortorder[$pos] = $tmp;
  75              \core\plugininfo\media::set_enabled_plugins($sortorder);
  76          }
  77          break;
  78  }
  79  
  80  redirect($return);