Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [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   * Event for when a template is deleted.
  19   *
  20   * @package    quizaccess_seb
  21   * @author     Nicholas Hoobin <nicholashoobin@catalyst-au.net>
  22   * @copyright  2020 Catalyst IT
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  namespace quizaccess_seb\event;
  27  
  28  use context_system;
  29  use core\event\base;
  30  
  31  defined('MOODLE_INTERNAL') || die();
  32  
  33  /**
  34   * Event for when a template is deleted.
  35   *
  36   * @copyright  2020 Catalyst IT
  37   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  38   */
  39  class template_deleted extends base {
  40  
  41      /**
  42       * Create event with strict parameters.
  43       *
  44       * Define strict parameters to create event with instead of relying on internal validation of array. Better code practice.
  45       * Easier for consumers of this class to know what data must be supplied and observers can have more trust in event data.
  46       *
  47       * @param string $id The id of the template
  48       * @param context_system $context Context system.
  49       * @return base
  50       */
  51      public static function create_strict(string $id, context_system $context) : base {
  52          global $USER;
  53  
  54          return self::create([
  55              'userid' => $USER->id,
  56              'objectid' => $id,
  57              'context' => $context,
  58          ]);
  59      }
  60  
  61      /**
  62       * Initialize the event data.
  63       */
  64      protected function init() {
  65          $this->data['objecttable'] = 'quizaccess_seb_template';
  66          $this->data['crud'] = 'd';
  67          $this->data['edulevel'] = self::LEVEL_PARTICIPATING;
  68      }
  69  
  70      /**
  71       * Get the name of the event.
  72       *
  73       * @return string Name of event.
  74       */
  75      public static function get_name() {
  76          return get_string('event:templatedeleted', 'quizaccess_seb');
  77      }
  78  
  79      /**
  80       * Returns relevant URL.
  81       * @return \moodle_url
  82       */
  83      public function get_url() {
  84          return new \moodle_url('/mod/quiz/accessrule/seb/template.php');
  85      }
  86  
  87      /**
  88       * Returns non-localised event description with id's for admin use only.
  89       *
  90       * @return string Description.
  91       */
  92      public function get_description() {
  93          return "The user with id '$this->userid' has deleted a template with id '$this->objectid'.";
  94      }
  95  
  96      /**
  97       * This is used when restoring course logs where it is required that we
  98       * map the objectid to it's new value in the new course.
  99       *
 100       * @return array Mapping of object id.
 101       */
 102      public static function get_objectid_mapping() : array {
 103          return ['db' => 'quizaccess_seb_template', 'restore' => 'quizaccess_seb_template'];
 104      }
 105  
 106      /**
 107       * This is used when restoring course logs where it is required that we
 108       * map the information in 'other' to it's new value in the new course.
 109       *
 110       * @return array List of mapping of other ids.
 111       */
 112      public static function get_other_mapping() : array {
 113          return [];
 114      }
 115  }