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.

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

   1  <?php
   2  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19   * Provides an overview of installed local plugins
  20   *
  21   * Displays the list of found local plugins, their version (if found) and
  22   * a link to delete the local plugin.
  23   *
  24   * @see       https://moodledev.io/docs/apis/plugintypes/local
  25   * @package   admin
  26   * @copyright 2010 David Mudrak <david.mudrak@gmail.com>
  27   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  28   */
  29  
  30  require_once(__DIR__ . '/../config.php');
  31  require_once($CFG->libdir.'/adminlib.php');
  32  require_once($CFG->libdir.'/tablelib.php');
  33  
  34  admin_externalpage_setup('managelocalplugins');
  35  
  36  echo $OUTPUT->header();
  37  echo $OUTPUT->heading(get_string('localplugins'));
  38  
  39  /// Print the table of all installed local plugins
  40  
  41  $table = new flexible_table('localplugins_administration_table');
  42  $table->define_columns(array('name', 'version', 'uninstall'));
  43  $table->define_headers(array(get_string('plugin'), get_string('version'), get_string('uninstallplugin', 'core_admin')));
  44  $table->define_baseurl($PAGE->url);
  45  $table->set_attribute('id', 'localplugins');
  46  $table->set_attribute('class', 'admintable generaltable');
  47  $table->setup();
  48  
  49  $plugins = array();
  50  foreach (core_component::get_plugin_list('local') as $plugin => $plugindir) {
  51      if (get_string_manager()->string_exists('pluginname', 'local_' . $plugin)) {
  52          $strpluginname = get_string('pluginname', 'local_' . $plugin);
  53      } else {
  54          $strpluginname = $plugin;
  55      }
  56      $plugins[$plugin] = $strpluginname;
  57  }
  58  core_collator::asort($plugins);
  59  
  60  foreach ($plugins as $plugin => $name) {
  61      $uninstall = '';
  62      if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('local_'.$plugin, 'manage')) {
  63          $uninstall = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'));
  64      }
  65  
  66      $version = get_config('local_' . $plugin);
  67      if (!empty($version->version)) {
  68          $version = $version->version;
  69      } else {
  70          $version = '?';
  71      }
  72  
  73      $table->add_data(array($name, $version, $uninstall));
  74  }
  75  
  76  $table->print_html();
  77  
  78  echo $OUTPUT->footer();