[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
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 * The mod_feedback response submitted event. 19 * 20 * @package mod_feedback 21 * @copyright 2013 Ankit Agarwal 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. 23 */ 24 25 namespace mod_feedback\event; 26 defined('MOODLE_INTERNAL') || die(); 27 28 /** 29 * The mod_feedback response submitted event class. 30 * 31 * This event is triggered when a feedback response is submitted. 32 * 33 * @property-read array $other { 34 * Extra information about event. 35 * 36 * - int anonymous: if feedback is anonymous. 37 * - int cmid: course module id. 38 * - int instanceid: id of instance. 39 * } 40 * 41 * @package mod_feedback 42 * @since Moodle 2.6 43 * @copyright 2013 Ankit Agarwal 44 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. 45 */ 46 class response_submitted extends \core\event\base { 47 48 /** 49 * Set basic properties for the event. 50 */ 51 protected function init() { 52 global $CFG; 53 54 require_once($CFG->dirroot.'/mod/feedback/lib.php'); 55 $this->data['objecttable'] = 'feedback_completed'; 56 $this->data['crud'] = 'c'; 57 $this->data['edulevel'] = self::LEVEL_PARTICIPATING; 58 } 59 60 /** 61 * Returns localised general event name. 62 * 63 * @return string 64 */ 65 public static function get_name() { 66 return get_string('eventresponsesubmitted', 'mod_feedback'); 67 } 68 69 /** 70 * Returns non-localised event description with id's for admin use only. 71 * 72 * @return string 73 */ 74 public function get_description() { 75 return "The user with id '$this->userid' created feedback for the user with id '$this->relateduserid' " . 76 "for the feedback activity with course module id '$this->contextinstanceid'."; 77 } 78 79 /** 80 * Returns relevant URL based on the anonymous mode of the response. 81 * @return \moodle_url 82 */ 83 public function get_url() { 84 if ($this->other['anonymous'] == FEEDBACK_ANONYMOUS_YES) { 85 return new \moodle_url('/mod/feedback/show_entries.php' , array('id' => $this->other['cmid'], 86 'do_show' => 'showoneentry' , 'userid' => $this->relateduserid)); 87 } else { 88 return new \moodle_url('/mod/feedback/show_entries_anonym.php', array('id' => $this->other['cmid'], 89 'do_show' => 'showoneentry', 'showall' => 1, 'showcompleted' => $this->objectid)); 90 } 91 } 92 93 /** 94 * Replace add_to_log() statement. Do this only for the case when anonymous mode is off, 95 * since this is what was happening before. 96 * 97 * @return array of parameters to be passed to legacy add_to_log() function. 98 */ 99 protected function get_legacy_logdata() { 100 if ($this->anonymous) { 101 return null; 102 } else { 103 return array($this->courseid, 'feedback', 'submit', 'view.php?id=' . $this->other['cmid'], 104 $this->other['instanceid'], $this->other['cmid'], $this->relateduserid); 105 } 106 } 107 108 /** 109 * Define whether a user can view the event or not. Make sure no one except admin can see details of an anonymous response. 110 * 111 * @deprecated since 2.7 112 * 113 * @param int|\stdClass $userorid ID of the user. 114 * @return bool True if the user can view the event, false otherwise. 115 */ 116 public function can_view($userorid = null) { 117 global $USER; 118 debugging('can_view() method is deprecated, use anonymous flag instead if necessary.', DEBUG_DEVELOPER); 119 120 if (empty($userorid)) { 121 $userorid = $USER; 122 } 123 if ($this->anonymous) { 124 return is_siteadmin($userorid); 125 } else { 126 return has_capability('mod/feedback:viewreports', $this->context, $userorid); 127 } 128 } 129 130 /** 131 * Custom validations. 132 * 133 * @throws \coding_exception in case of any problems. 134 */ 135 protected function validate_data() { 136 parent::validate_data(); 137 138 if (!isset($this->relateduserid)) { 139 throw new \coding_exception('The \'relateduserid\' must be set.'); 140 } 141 if (!isset($this->other['anonymous'])) { 142 throw new \coding_exception('The \'anonymous\' value must be set in other.'); 143 } 144 if (!isset($this->other['cmid'])) { 145 throw new \coding_exception('The \'cmid\' value must be set in other.'); 146 } 147 if (!isset($this->other['instanceid'])) { 148 throw new \coding_exception('The \'instanceid\' value must be set in other.'); 149 } 150 } 151 } 152
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |