[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/classes/plugininfo/ -> calendartype.php (source)

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


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1