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 310 and 401] [Versions 39 and 401]

   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   * Calendar event class.
  19   *
  20   * @package    core_calendar
  21   * @copyright  2017 Cameron Ball <cameron@cameron1729.xyz>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace core_calendar\local\event\entities;
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  use core_calendar\local\event\proxies\proxy_interface;
  30  use core_calendar\local\event\value_objects\description_interface;
  31  use core_calendar\local\event\value_objects\times_interface;
  32  
  33  /**
  34   * Class representing a calendar event.
  35   *
  36   * @copyright 2017 Cameron Ball <cameron@cameron1729.xyz>
  37   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  38   */
  39  class event implements event_interface {
  40      /**
  41       * @var int $id The event's id in the database.
  42       */
  43      protected $id;
  44  
  45      /**
  46       * @var string $name The name of this event.
  47       */
  48      protected $name;
  49  
  50      /**
  51       * @var description_interface $description Description for this event.
  52       */
  53      protected $description;
  54  
  55      /**
  56       * @var string $location Location of this event.
  57       */
  58      protected $location;
  59  
  60      /**
  61       * @var proxy_interface $category Category for this event.
  62       */
  63      protected $category;
  64  
  65      /**
  66       * @var proxy_interface $course Course for this event.
  67       */
  68      protected $course;
  69  
  70      /**
  71       * @var proxy_interface $group Group for this event.
  72       */
  73      protected $group;
  74  
  75      /**
  76       * @var proxy_interface $user User for this event.
  77       */
  78      protected $user;
  79  
  80      /**
  81       * @var event_collection_interface $repeats Collection of repeat events.
  82       */
  83      protected $repeats;
  84  
  85      /**
  86       * @var proxy_interface $coursemodule The course module that created this event.
  87       */
  88      protected $coursemodule;
  89  
  90      /**
  91       * @var string type The type of this event.
  92       */
  93      protected $type;
  94  
  95      /**
  96       * @var times_interface $times The times for this event.
  97       */
  98      protected $times;
  99  
 100      /**
 101       * @var bool $visible The visibility of this event.
 102       */
 103      protected $visible;
 104  
 105      /**
 106       * @var string $component
 107       */
 108      protected $component;
 109  
 110      /**
 111       * @var proxy_interface $subscription Subscription for this event.
 112       */
 113      protected $subscription;
 114  
 115      /**
 116       * Constructor.
 117       *
 118       * @param int                        $id             The event's ID in the database.
 119       * @param string                     $name           The event's name.
 120       * @param description_interface      $description    The event's description.
 121       * @param proxy_interface|null       $category       The category associated with the event.
 122       * @param proxy_interface|null       $course         The course associated with the event.
 123       * @param proxy_interface|null       $group          The group associated with the event.
 124       * @param proxy_interface|null       $user           The user associated with the event.
 125       * @param event_collection_interface|null $repeats   Collection of repeat events.
 126       * @param proxy_interface|null       $coursemodule   The course module that created the event.
 127       * @param string                     $type           The event's type.
 128       * @param times_interface            $times          The times associated with the event.
 129       * @param bool                       $visible        The event's visibility. True for visible, false for invisible.
 130       * @param proxy_interface|null       $subscription   The event's subscription.
 131       * @param string                     $location       The event's location.
 132       * @param string                     $component      The event's component.
 133       */
 134      public function __construct(
 135          $id,
 136          $name,
 137          description_interface $description,
 138          ?proxy_interface $category,
 139          ?proxy_interface $course,
 140          ?proxy_interface $group,
 141          ?proxy_interface $user,
 142          ?event_collection_interface $repeats,
 143          ?proxy_interface $coursemodule,
 144          $type,
 145          times_interface $times,
 146          $visible,
 147          proxy_interface $subscription = null,
 148          $location = null,
 149          $component = null
 150      ) {
 151          $this->id = $id;
 152          $this->name = $name;
 153          $this->description = $description;
 154          $this->location = $location;
 155          $this->category = $category;
 156          $this->course = $course;
 157          $this->group = $group;
 158          $this->user = $user;
 159          $this->repeats = $repeats;
 160          $this->coursemodule = $coursemodule;
 161          $this->type = $type;
 162          $this->times = $times;
 163          $this->visible = $visible;
 164          $this->subscription = $subscription;
 165          $this->component = $component;
 166      }
 167  
 168      public function get_id() {
 169          return $this->id;
 170      }
 171  
 172      public function get_name() {
 173          return $this->name;
 174      }
 175  
 176      public function get_description() {
 177          return $this->description;
 178      }
 179  
 180      public function get_location() {
 181          return $this->location;
 182      }
 183  
 184      public function get_category() {
 185          return $this->category;
 186      }
 187  
 188      public function get_course() {
 189          return $this->course;
 190      }
 191  
 192      public function get_course_module() {
 193          return $this->coursemodule;
 194      }
 195  
 196      public function get_group() {
 197          return $this->group;
 198      }
 199  
 200      public function get_user() {
 201          return $this->user;
 202      }
 203  
 204      public function get_type() {
 205          return $this->type;
 206      }
 207  
 208      public function get_times() {
 209          return $this->times;
 210      }
 211  
 212      public function get_repeats() {
 213          return $this->repeats;
 214      }
 215  
 216      public function get_subscription() {
 217          return $this->subscription;
 218      }
 219  
 220      public function is_visible() {
 221          return $this->visible;
 222      }
 223  
 224      /**
 225       * Resolved event component (frankenstyle name of activity module or the component)
 226       * @return string|null
 227       */
 228      public function get_component() {
 229          return $this->get_course_module() ? 'mod_' . $this->get_course_module()->get('modname') : $this->component;
 230      }
 231  }