Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.
/admin/ -> media.php (source)

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

   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  require_once('../config.php');
  27  require_once("{$CFG->libdir}/adminlib.php");
  28  
  29  $action = required_param('action', PARAM_ALPHANUMEXT);
  30  $plugin = required_param('plugin', PARAM_PLUGIN);
  31  
  32  $PAGE->set_url('/admin/media.php');
  33  $PAGE->set_context(context_system::instance());
  34  
  35  require_admin();
  36  require_sesskey();
  37  
  38  $return = new moodle_url('/admin/settings.php', [
  39      'section' => 'managemediaplayers',
  40  ]);
  41  
  42  $displayname = get_string('pluginname', "media_{$plugin}");
  43  switch ($action) {
  44      case 'disable':
  45          $class = \core_plugin_manager::resolve_plugininfo_class('media');
  46          if ($class::enable_plugin($plugin, false)) {
  47              \core\notification::add(
  48                  get_string('plugin_disabled', 'core_admin', $displayname),
  49                  \core\notification::SUCCESS
  50              );
  51          }
  52          break;
  53  
  54      case 'enable':
  55          $class = \core_plugin_manager::resolve_plugininfo_class('media');
  56          if ($class::enable_plugin($plugin, true)) {
  57              \core\notification::add(
  58                  get_string('plugin_enabled', 'core_admin', $displayname),
  59                  \core\notification::SUCCESS
  60              );
  61          }
  62          break;
  63  
  64      case 'up':
  65          $class::change_plugin_order($plugin, $class::MOVE_UP);
  66          break;
  67  
  68      case 'down':
  69          $class::change_plugin_order($plugin, $class::MOVE_DOWN);
  70          break;
  71  }
  72  
  73  redirect($return);