Differences Between: [Versions 311 and 402] [Versions 311 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 * Abstract event for content viewing. 18 * 19 * This class has been deprecated, please extend base event or other relevent abstract class. 20 * 21 * @package core 22 * @copyright 2013 Ankit Agarwal 23 * @deprecated since Moodle 2.7 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 namespace core\event; 28 29 defined('MOODLE_INTERNAL') || die(); 30 31 debugging('core\event\content_viewed has been deprecated. Please extend base event or other relevant abstract class.', 32 DEBUG_DEVELOPER); 33 34 /** 35 * Class content_viewed. 36 * 37 * This class has been deprecated, please extend base event or other relevent abstract class. 38 * 39 * @property-read array $other { 40 * Extra information about the event. 41 * 42 * - string content: name of the content viewed. 43 * } 44 * 45 * @package core 46 * @since Moodle 2.6 47 * @copyright 2013 Ankit Agarwal 48 * @deprecated since Moodle 2.7 49 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 50 */ 51 abstract class content_viewed extends base { 52 53 /** @var null|array $legacylogdata Legacy log data */ 54 protected $legacylogdata = null; 55 56 /** 57 * Set basic properties of the event. 58 */ 59 protected function init() { 60 global $PAGE; 61 62 $this->data['crud'] = 'r'; 63 $this->data['edulevel'] = self::LEVEL_OTHER; 64 $this->context = $PAGE->context; 65 } 66 67 /** 68 * Set basic page properties. 69 */ 70 public function set_page_detail() { 71 global $PAGE; 72 if (!isset($this->data['other'])) { 73 $this->data['other'] = array(); 74 } 75 $this->data['other'] = array_merge(array('url' => $PAGE->url->out_as_local_url(false), 76 'heading' => $PAGE->heading, 77 'title' => $PAGE->title), $this->data['other']); 78 } 79 80 /** 81 * Returns localised general event name. 82 * 83 * @return string 84 */ 85 public static function get_name() { 86 return get_string('eventcontentviewed', 'moodle'); 87 } 88 89 /** 90 * Returns non-localised description of what happened. 91 * 92 * @return string 93 */ 94 public function get_description() { 95 return "The user with id '$this->userid' viewed content."; 96 } 97 98 /** 99 * Set legacy logdata. 100 * 101 * @param array $legacydata legacy logdata. 102 */ 103 public function set_legacy_logdata(array $legacydata) { 104 $this->legacylogdata = $legacydata; 105 } 106 107 /** 108 * Get legacy logdata. 109 * 110 * @return null|array legacy log data. 111 */ 112 protected function get_legacy_logdata() { 113 return $this->legacylogdata; 114 } 115 116 /** 117 * Custom validation. 118 * 119 * @throws \coding_exception when validation does not pass. 120 * @return void 121 */ 122 protected function validate_data() { 123 parent::validate_data(); 124 // Make sure this class is never used without a content identifier. 125 if (empty($this->other['content'])) { 126 throw new \coding_exception('The \'content\' value must be set in other.'); 127 } 128 } 129 130 public static function get_other_mapping() { 131 return false; 132 } 133 134 /** 135 * This event has been deprected. 136 * 137 * @return boolean 138 */ 139 public static function is_deprecated() { 140 return true; 141 } 142 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body