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.

Differences Between: [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   * 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          $ADMIN = $adminroot; // May be used in settings.php.
  58          $plugininfo = $this; // Also can be used inside settings.php.
  59  
  60          if (!$this->is_installed_and_upgraded()) {
  61              return;
  62          }
  63  
  64          if (!$hassiteconfig or !file_exists($this->full_path('settings.php'))) {
  65              return;
  66          }
  67  
  68          $section = $this->get_settings_section_name();
  69          $settings = new \admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false);
  70          include($this->full_path('settings.php')); // This may also set $settings to null.
  71  
  72          if ($settings) {
  73              $ADMIN->add($parentnodename, $settings);
  74          }
  75      }
  76  
  77      /**
  78       * Get the settings section name.
  79       * It's used to get the setting links in the Atto sub-plugins table.
  80       *
  81       * @return null|string the settings section name.
  82       */
  83      public function get_settings_section_name() {
  84          return 'atto_' . $this->name . '_settings';
  85      }
  86  }