[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/availability/classes/ -> info_section.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   * Class handles conditional availability information for a section.
  19   *
  20   * @package core_availability
  21   * @copyright 2014 The Open University
  22   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace core_availability;
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  /**
  30   * Class handles conditional availability information for a section.
  31   *
  32   * @package core_availability
  33   * @copyright 2014 The Open University
  34   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  35   */
  36  class info_section extends info {
  37      /** @var \section_info Section. */
  38      protected $section;
  39  
  40      /**
  41       * Constructs with item details.
  42       *
  43       * @param \section_info $section Section object
  44       */
  45      public function __construct(\section_info $section) {
  46          parent::__construct($section->modinfo->get_course(), $section->visible,
  47                  $section->availability);
  48          $this->section = $section;
  49      }
  50  
  51      protected function get_thing_name() {
  52          return get_section_name($this->section->course, $this->section->section);
  53      }
  54  
  55      public function get_context() {
  56          return \context_course::instance($this->get_course()->id);
  57      }
  58  
  59      protected function get_view_hidden_capability() {
  60          return 'moodle/course:viewhiddensections';
  61      }
  62  
  63      protected function set_in_database($availability) {
  64          global $DB;
  65          $DB->set_field('course_sections', 'availability', $availability,
  66                  array('id' => $this->section->id));
  67      }
  68  
  69      /**
  70       * Gets the section object. Intended for use by conditions.
  71       *
  72       * @return \section_info Section
  73       */
  74      public function get_section() {
  75          return $this->section;
  76      }
  77  
  78  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1