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   * Defines classes used for plugin info.
  19   *
  20   * @package    core
  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 core\plugininfo;
  25  
  26  use part_of_admin_tree, admin_settingpage;
  27  
  28  defined('MOODLE_INTERNAL') || die();
  29  
  30  /**
  31   * Class for calendar type plugins.
  32   */
  33  class calendartype extends base {
  34  
  35      public function is_uninstall_allowed() {
  36          // We can delete all calendar types, except Gregorian. Gregorian comes with core and was the calendar
  37          // type used before the calendar types were introduced as plugins in Moodle. If all calendar types were
  38          // deleted then Moodle would break completely wherever any dates are displayed.
  39          if ($this->name !== 'gregorian') {
  40              return true;
  41          }
  42  
  43          return false;
  44      }
  45  
  46      public function get_settings_section_name() {
  47          return 'calendartype_' . $this->name . '_settings';
  48      }
  49  
  50      public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
  51          global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them.
  52          /** @var \admin_root $ADMIN */
  53          $ADMIN = $adminroot; // May be used in settings.php.
  54          $plugininfo = $this; // Also can be used inside settings.php.
  55          $qtype = $this;      // Also can be used inside settings.php.
  56  
  57          if (!$this->is_installed_and_upgraded()) {
  58              return;
  59          }
  60  
  61          $section = $this->get_settings_section_name();
  62  
  63          $settings = null;
  64          $systemcontext = \context_system::instance();
  65          if (($hassiteconfig) &&
  66              file_exists($this->full_path('settings.php'))) {
  67              $settings = new admin_settingpage($section, $this->displayname,
  68                  'moodle/site:config', $this->is_enabled() === false);
  69              include($this->full_path('settings.php')); // This may also set $settings to null.
  70          }
  71          if ($settings) {
  72              $ADMIN->add($parentnodename, $settings);
  73          }
  74      }
  75  }