Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.
   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  namespace mod_bigbluebuttonbn\local\plugins;
  18  
  19  defined('MOODLE_INTERNAL') || die();
  20  global $CFG;
  21  require_once($CFG->libdir . '/adminlib.php');
  22  
  23  use admin_externalpage;
  24  use core_component;
  25  use core_text;
  26  use mod_bigbluebuttonbn\extension;
  27  use moodle_url;
  28  
  29  /**
  30   * Admin external page that displays a list of the installed extension plugins.
  31   *
  32   * @package   mod_bigbluebuttonbn
  33   * @copyright 2023 onwards, Blindside Networks Inc
  34   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  35   * @author    Laurent David (laurent@call-learning.fr)
  36   */
  37  class admin_page_manage_extensions extends admin_externalpage {
  38      /**
  39       * Global URL for page.
  40       */
  41      const ADMIN_PAGE_URL = '/mod/bigbluebuttonbn/adminmanageplugins.php';
  42  
  43      /**
  44       * The constructor - calls parent constructor
  45       *
  46       */
  47      public function __construct() {
  48          $url = new moodle_url(self::ADMIN_PAGE_URL);
  49          $managepagename = 'manage' . extension::BBB_EXTENSION_PLUGIN_NAME . 'plugins';
  50          parent::__construct(
  51              $managepagename,
  52              get_string($managepagename, 'mod_bigbluebuttonbn'),
  53              $url
  54          );
  55      }
  56  
  57      /**
  58       * Search plugins for the specified string
  59       *
  60       * @param string $query The string to search for
  61       * @return array
  62       */
  63      public function search($query): array {
  64          if ($result = parent::search($query)) {
  65              return $result;
  66          }
  67          foreach (core_component::get_plugin_list(extension::BBB_EXTENSION_PLUGIN_NAME ) as $name => $notused) {
  68              $pluginname = core_text::strtolower(
  69                  get_string('pluginname', extension::BBB_EXTENSION_PLUGIN_NAME . '_' . $name)
  70              );
  71              if (str_contains($pluginname, $query) !== false) {
  72                  $result = (object)[
  73                      'page' => $this,
  74                      'settings' => [],
  75                  ];
  76                  return [$this->name => $result];
  77              }
  78          }
  79          return [];
  80      }
  81  }