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] [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   * Subplugin info class.
  19   *
  20   * @package   editor_atto
  21   * @copyright 2013 Petr Skoda {@link http://skodak.org}
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  namespace editor_atto\plugininfo;
  25  
  26  use core\plugininfo\base;
  27  
  28  defined('MOODLE_INTERNAL') || die();
  29  
  30  
  31  class atto extends base {
  32  
  33      /**
  34       * Yes you can uninstall these plugins if you want.
  35       * @return \moodle_url
  36       */
  37      public function is_uninstall_allowed() {
  38          return true;
  39      }
  40  
  41      /**
  42       * Return URL used for management of plugins of this type.
  43       * @return \moodle_url
  44       */
  45      public static function get_manage_url() {
  46          return new \moodle_url('/admin/settings.php', array('section'=>'editorsettingsatto'));
  47      }
  48  
  49      /**
  50       * Include the settings.php file from sub plugins if they provide it.
  51       * This is a copy of very similar implementations from various other subplugin areas.
  52       *
  53       * @return \moodle_url
  54       */
  55      public function load_settings(\part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
  56          global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them.
  57          /** @var \admin_root $ADMIN */
  58          $ADMIN = $adminroot; // May be used in settings.php.
  59          $plugininfo = $this; // Also can be used inside settings.php.
  60  
  61          if (!$this->is_installed_and_upgraded()) {
  62              return;
  63          }
  64  
  65          if (!$hassiteconfig or !file_exists($this->full_path('settings.php'))) {
  66              return;
  67          }
  68  
  69          $section = $this->get_settings_section_name();
  70          $settings = new \admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false);
  71          include($this->full_path('settings.php')); // This may also set $settings to null.
  72  
  73          if ($settings) {
  74              $ADMIN->add($parentnodename, $settings);
  75          }
  76      }
  77  
  78      /**
  79       * Get the settings section name.
  80       * It's used to get the setting links in the Atto sub-plugins table.
  81       *
  82       * @return null|string the settings section name.
  83       */
  84      public function get_settings_section_name() {
  85          return 'atto_' . $this->name . '_settings';
  86      }
  87  }