Merge branch 'MDL-45445_master' of https://github.com/markn86/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2014-06-24 21:54:58 +02:00
commit c45754d840
85 changed files with 631 additions and 100 deletions

View File

@ -326,6 +326,7 @@ class core_bloglib_testcase extends advanced_testcase {
\core\event\blog_association_created::create(array(
'contextid' => 1,
'objectid' => 3,
'relateduserid' => 2,
'other' => array('associateid' => 2 , 'blogid' => 3, 'subject' => 'blog subject')));
} catch (coding_exception $e) {
$this->assertContains('The \'associatetype\' value must be set in other and be a valid type.', $e->getMessage());
@ -334,6 +335,7 @@ class core_bloglib_testcase extends advanced_testcase {
\core\event\blog_association_created::create(array(
'contextid' => 1,
'objectid' => 3,
'relateduserid' => 2,
'other' => array('associateid' => 2 , 'blogid' => 3, 'associatetype' => 'random', 'subject' => 'blog subject')));
} catch (coding_exception $e) {
$this->assertContains('The \'associatetype\' value must be set in other and be a valid type.', $e->getMessage());
@ -343,6 +345,7 @@ class core_bloglib_testcase extends advanced_testcase {
\core\event\blog_association_created::create(array(
'contextid' => 1,
'objectid' => 3,
'relateduserid' => 2,
'other' => array('blogid' => 3, 'associatetype' => 'course', 'subject' => 'blog subject')));
} catch (coding_exception $e) {
$this->assertContains('The \'associateid\' value must be set in other.', $e->getMessage());
@ -352,6 +355,7 @@ class core_bloglib_testcase extends advanced_testcase {
\core\event\blog_association_created::create(array(
'contextid' => 1,
'objectid' => 3,
'relateduserid' => 2,
'other' => array('associateid' => 3, 'associatetype' => 'course', 'subject' => 'blog subject')));
} catch (coding_exception $e) {
$this->assertContains('The \'blogid\' value must be set in other.', $e->getMessage());
@ -361,6 +365,7 @@ class core_bloglib_testcase extends advanced_testcase {
\core\event\blog_association_created::create(array(
'contextid' => 1,
'objectid' => 3,
'relateduserid' => 2,
'other' => array('blogid' => 3, 'associateid' => 3, 'associatetype' => 'course')));
} catch (coding_exception $e) {
$this->assertContains('The \'subject\' value must be set in other.', $e->getMessage());

View File

@ -104,14 +104,24 @@ class blog_association_created extends base {
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (empty($this->other['associatetype']) || ($this->other['associatetype'] !== 'course'
&& $this->other['associatetype'] !== 'coursemodule')) {
throw new \coding_exception('The \'associatetype\' value must be set in other and be a valid type.');
} else if (!isset($this->other['blogid'])) {
}
if (!isset($this->other['blogid'])) {
throw new \coding_exception('The \'blogid\' value must be set in other.');
} else if (!isset($this->other['associateid'])) {
}
if (!isset($this->other['associateid'])) {
throw new \coding_exception('The \'associateid\' value must be set in other.');
} else if (!isset($this->other['subject'])) {
}
if (!isset($this->other['subject'])) {
throw new \coding_exception('The \'subject\' value must be set in other.');
}
}

View File

@ -30,7 +30,14 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - int courseid: id of associated course.
* - int entryid: (optional) id of the entry.
* - int tagid: (optional) id of the tag.
* - int userid: (optional) id of the user.
* - int modid: (optional) id of the mod.
* - int groupid: (optional) id of the group.
* - int courseid: (optional) id of associated course.
* - string search: (optional) the string used to search.
* - int fromstart: (optional) the time to search from.
* }
*
* @package core

View File

@ -126,4 +126,18 @@ class blog_entry_created extends base {
return array (SITEID, 'blog', 'add', 'index.php?userid=' . $this->relateduserid . '&entryid=' . $this->objectid,
$this->blogentry->subject);
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -117,4 +117,18 @@ class blog_entry_deleted extends base {
return array (SITEID, 'blog', 'delete', 'index.php?userid=' . $this->relateduserid, 'deleted blog entry with entry id# '.
$this->objectid);
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -124,5 +124,19 @@ class blog_entry_updated extends base {
return array(SITEID, 'blog', 'update', 'index.php?userid=' . $this->relateduserid . '&entryid=' . $this->objectid,
$this->blogentry->subject);
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -94,4 +94,18 @@ class cohort_member_added extends base {
$data->userid = $this->relateduserid;
return $data;
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -95,4 +95,18 @@ class cohort_member_removed extends base {
$data->userid = $this->relateduserid;
return $data;
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -36,6 +36,12 @@ debugging('core\event\content_viewed has been deprecated. Please extend base eve
*
* This class has been deprecated, please extend base event or other relevent abstract class.
*
* @property-read array $other {
* Extra information about the event.
*
* - string content: name of the content viewed.
* }
*
* @package core
* @since Moodle 2.6
* @copyright 2013 Ankit Agarwal

View File

@ -122,4 +122,18 @@ class course_category_deleted extends base {
protected function get_legacy_logdata() {
return array(SITEID, 'category', 'delete', 'index.php', $this->other['name'] . '(ID ' . $this->objectid . ')');
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['name'])) {
throw new \coding_exception('The \'name\' value must be set in other.');
}
}
}

View File

@ -124,6 +124,14 @@ class course_completed extends base {
protected function validate_data() {
parent::validate_data();
// TODO: MDL-45445 add validation of relateduserid and other['relateduserid'].
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
// Check that the 'relateduserid' value is set in other as well. This is because we introduced this in 2.6
// and some observers may be relying on this value to be present.
if (!isset($this->other['relateduserid'])) {
throw new \coding_exception('The \'relateduserid\' value must be set in other.');
}
}
}

View File

@ -90,4 +90,18 @@ class course_content_deleted extends base {
return $course;
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['options'])) {
throw new \coding_exception('The \'options\' value must be set in other.');
}
}
}

View File

@ -32,8 +32,8 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string shortname: shortname of course.
* - string fullname: fullname of course.
* - string shortname: (optional) shortname of course.
* }
*
* @package core
@ -105,4 +105,18 @@ class course_created extends base {
protected function get_legacy_logdata() {
return array(SITEID, 'course', 'new', 'view.php?id=' . $this->objectid, $this->other['fullname'] . ' (ID ' . $this->objectid . ')');
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['fullname'])) {
throw new \coding_exception('The \'fullname\' value must be set in other.');
}
}
}

View File

@ -32,9 +32,9 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string shortname: shortname of course.
* - string fullname: fullname of course.
* - string idnumber: id number of course.
* - string shortname: (optional) shortname of course.
* - string idnumber: (optional) id number of course.
* }
*
* @package core
@ -100,4 +100,18 @@ class course_deleted extends base {
protected function get_legacy_logdata() {
return array(SITEID, 'course', 'delete', 'view.php?id=' . $this->objectid, $this->other['fullname'] . '(ID ' . $this->objectid . ')');
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['fullname'])) {
throw new \coding_exception('The \'fullname\' value must be set in other.');
}
}
}

View File

@ -107,4 +107,34 @@ class course_restored extends base {
'samesite' => $this->other['samesite'],
);
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['type'])) {
throw new \coding_exception('The \'type\' value must be set in other.');
}
if (!isset($this->other['target'])) {
throw new \coding_exception('The \'target\' value must be set in other.');
}
if (!isset($this->other['mode'])) {
throw new \coding_exception('The \'mode\' value must be set in other.');
}
if (!isset($this->other['operation'])) {
throw new \coding_exception('The \'operation\' value must be set in other.');
}
if (!isset($this->other['samesite'])) {
throw new \coding_exception('The \'samesite\' value must be set in other.');
}
}
}

View File

@ -32,8 +32,8 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string shortname: shortname of course.
* - string fullname: fullname of course.
* - string shortname: (optional) shortname of course.
* - string fullname: (optional) fullname of course.
* }
*
* @package core

View File

@ -41,7 +41,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2014 Adrian Greeve <adrian@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_user_report_viewed extends \core\event\base {
class course_user_report_viewed extends base {
/**
* Init method.

View File

@ -41,7 +41,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2014 Adrian Greeve <adrian@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_viewed extends \core\event\base {
class course_viewed extends base {
/**
* Init method.

View File

@ -80,6 +80,10 @@ class email_failed extends base {
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['subject'])) {
throw new \coding_exception('The \'subject\' value must be set in other.');
}

View File

@ -113,6 +113,10 @@ class group_member_added extends base {
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['component'])) {
throw new \coding_exception('The \'component\' value must be set in other, even if empty.');
}

View File

@ -94,4 +94,18 @@ class group_member_removed extends base {
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'groups';
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -30,6 +30,14 @@ defined('MOODLE_INTERNAL') || die();
/**
* Mnet access control created event class.
*
* @property-read array $other {
* Extra information about event.
*
* - string username: the username of the user.
* - string hostname: the name of the host the user came from.
* - string accessctrl: the access control value.
* }
*
* @package core
* @since Moodle 2.7
* @copyright 2013 Mark Nelson <markn@moodle.com>

View File

@ -30,6 +30,14 @@ defined('MOODLE_INTERNAL') || die();
/**
* Mnet access control updated event class.
*
* @property-read array $other {
* Extra information about event.
*
* - string username: the username of the user.
* - string hostname: the name of the host the user came from.
* - string accessctrl: the access control value.
* }
*
* @package core
* @since Moodle 2.7
* @copyright 2013 Mark Nelson <markn@moodle.com>

View File

@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string publishstate: the publish state.
* - string publishstate: (optional) the publish state.
* }
*
* @package core
@ -92,4 +92,18 @@ class note_created extends base {
$logurl->set_anchor('note-' . $this->objectid);
return array($this->courseid, 'notes', 'add', $logurl, 'add note');
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string publishstate: the publish state.
* - string publishstate: (optional) the publish state.
* }
*
* @package core
@ -82,4 +82,18 @@ class note_deleted extends base {
$logurl->set_anchor('note-' . $this->objectid);
return array($this->courseid, 'notes', 'delete', $logurl, 'delete note');
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string publishstate: the publish state.
* - string publishstate: (optional) the publish state.
* }
*
* @package core
@ -92,4 +92,18 @@ class note_updated extends base {
$logurl->set_anchor('note-' . $this->objectid);
return array($this->courseid, 'notes', 'update', $logurl, 'update note');
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -70,6 +70,7 @@ class notes_viewed extends base {
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {

View File

@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2014 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class recent_activity_viewed extends \core\event\base {
class recent_activity_viewed extends base {
/**
* Init method.

View File

@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
*
* - int id: role assigned id.
* - string component: name of component.
* - int itemid: id of the item.
* - int itemid: (optional) id of the item.
* }
*
* @package core
@ -109,4 +109,26 @@ class role_assigned extends base {
return array($this->courseid, 'role', 'assign', 'admin/roles/assign.php?contextid='.$this->contextid.'&roleid='.$this->objectid,
$rolenames[$this->objectid], '', $this->userid);
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['id'])) {
throw new \coding_exception('The \'id\' value must be set in other.');
}
if (!isset($this->other['component'])) {
throw new \coding_exception('The \'component\' value must be set in other.');
}
}
}

View File

@ -33,8 +33,8 @@ defined('MOODLE_INTERNAL') || die();
* Extra information about event.
*
* - string shortname: shortname of role.
* - string description: role description.
* - string archetype: role type.
* - string description: (optional) role description.
* - string archetype: (optional) role type.
* }
*
* @package core
@ -88,4 +88,18 @@ class role_deleted extends base {
return array(SITEID, 'role', 'delete', 'admin/roles/manage.php?action=delete&roleid=' . $this->objectid,
$this->other['shortname'], '');
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['shortname'])) {
throw new \coding_exception('The \'shortname\' value must be set in other.');
}
}
}

View File

@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die();
*
* - int id: role assigned id.
* - string component: name of component.
* - int itemid: id of item.
* - int itemid: (optional) id of item.
* }
*
* @package core
@ -106,4 +106,26 @@ class role_unassigned extends base {
return array($this->courseid, 'role', 'unassign', 'admin/roles/assign.php?contextid='.$this->contextid.'&roleid='.$this->objectid,
$rolenames[$this->objectid], '', $this->userid);
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['id'])) {
throw new \coding_exception('The \'id\' value must be set in other.');
}
if (!isset($this->other['component'])) {
throw new \coding_exception('The \'component\' value must be set in other.');
}
}
}

View File

@ -36,8 +36,8 @@ defined('MOODLE_INTERNAL') || die();
* Extra information about the event.
*
* - int itemid: grade item id.
* - bool overridden: Is this grade override?
* - float finalgrade: the final grade value.
* - bool overridden: (optional) Is this grade override?
* - float finalgrade: (optional) the final grade value.
* }
*
* @package core
@ -72,6 +72,7 @@ class user_graded extends base {
/**
* Get grade object.
*
* @throws \coding_exception
* @return \grade_grade
*/
public function get_grade() {
@ -137,4 +138,22 @@ class user_graded extends base {
return array($this->courseid, 'grade', 'update', $url, $info);
}
/**
* Custom validation.
*
* @throws \coding_exception when validation does not pass.
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['itemid'])) {
throw new \coding_exception('The \'itemid\' value must be set in other.');
}
}
}

View File

@ -32,8 +32,8 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string courseshortname: the short name of course.
* - string coursefullname: the full name of course.
* - string courseshortname: (optional) the short name of course.
* - string coursefullname: (optional) the full name of course.
* }
*
* @package core

View File

@ -90,4 +90,26 @@ class user_loggedinas extends base {
public function get_url() {
return new \moodle_url('/user/view.php', array('id' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception when validation does not pass.
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['originalusername'])) {
throw new \coding_exception('The \'originalusername\' value must be set in other.');
}
if (!isset($this->other['loggedinasusername'])) {
throw new \coding_exception('The \'loggedinasusername\' value must be set in other.');
}
}
}

View File

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string sessionid: session id.
* - string sessionid: (optional) session id.
* }
*
* @package core

View File

@ -32,8 +32,8 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string username name of user.
* - int reason failure reason.
* - string username: name of user.
* - int reason: failure reason.
* }
*
* @package core

View File

@ -32,9 +32,9 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - int courseid: id of course.
* - string courseshortname: short name of course.
* - string coursefullname: fullname of course.
* - int courseid: (optional) id of course.
* - string courseshortname: (optional) shortname of course.
* - string coursefullname: (optional) fullname of course.
* }
*
* @package core
@ -97,4 +97,18 @@ class user_profile_viewed extends base {
}
return null;
}
/**
* Custom validation.
*
* @throws \coding_exception when validation does not pass.
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -105,5 +105,4 @@ class webservice_function_called extends base {
throw new \coding_exception('The \'function\' value must be set in other.');
}
}
}

View File

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string: sessionid session id.
* - string sessionid: (optional) session id.
* }
*
* @package core
@ -91,5 +91,4 @@ class webservice_service_created extends base {
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'external_services';
}
}

View File

@ -85,5 +85,4 @@ class webservice_service_deleted extends base {
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'external_services';
}
}

View File

@ -85,14 +85,4 @@ class webservice_service_updated extends base {
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'external_services';
}
/**
* Set the legacy event log data.
*
* @return void
*/
public function set_legacy_logdata($legacylogdata) {
$this->legacylogdata = $legacylogdata;
}
}

View File

@ -98,5 +98,4 @@ class webservice_service_user_added extends base {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -98,5 +98,4 @@ class webservice_service_user_removed extends base {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -103,5 +103,9 @@ class webservice_token_created extends base {
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['auto'])) {
throw new \coding_exception('The \'auto\' value must be set in other.');
}
}
}

View File

@ -73,5 +73,4 @@ class webservice_token_sent extends base {
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'external_tokens';
}
}

View File

@ -14,8 +14,32 @@ Events and Logging:
* Significant changes in Logging API. For upgrading existing events_trigger() and
add_to_log() see http://docs.moodle.org/dev/Migrating_logging_calls_in_plugins
For accessing logs from plugins see http://docs.moodle.org/dev/Migrating_log_access_in_reports
* The validation of the following events is now stricter:
- \core\event\course_section_updated
* The validation of the following events is now stricter (see MDL-45445):
- \core\event\blog_entry_created
- \core\event\blog_entry_deleted
- \core\event\blog_entry_updated
- \core\event\cohort_member_added
- \core\event\cohort_member_removed
- \core\event\course_category_deleted
- \core\event\course_completed
- \core\event\course_content_deleted
- \core\event\course_created
- \core\event\course_deleted
- \core\event\course_restored
- \core\event\course_section_updated (see MDL-45229)
- \core\event\email_failed
- \core\event\group_member_added
- \core\event\group_member_removed
- \core\event\note_created
- \core\event\note_deleted
- \core\event\note_updated
- \core\event\role_assigned
- \core\event\role_deleted
- \core\event\role_unassigned
- \core\event\user_graded
- \core\event\user_loggedinas
- \core\event\user_profile_viewed
- \core\event\webservice_token_created
DEPRECATIONS:
* $module uses in mod/xxx/version.php files is now deprecated. Please use $plugin instead. It will be removed in Moodle 2.10.

View File

@ -119,7 +119,7 @@ class reveal_identities_confirmation_page_viewed extends base {
parent::validate_data();
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' must be set in other.');
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
}

View File

@ -120,7 +120,7 @@ class submission_confirmation_form_viewed extends base {
parent::validate_data();
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' must be set in other.');
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
}

View File

@ -121,7 +121,7 @@ class submission_status_viewed extends base {
parent::validate_data();
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' must be set in other.');
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
}

View File

@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string newstatus: status of submission.
* - string newstate: state of submission.
* }
*
* @package mod_assign

View File

@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string format: content format.
* - string format: (optional) content format.
* }
*
* @package assignsubmission_onlinetext

View File

@ -77,7 +77,7 @@ class submission_updated extends \mod_assign\event\submission_updated {
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['onlinetextwordcount'])) {
throw new \coding_exception('Other must contain the key onlinetextwordcount.');
throw new \coding_exception('The \'onlinetextwordcount\' value must be set in other.');
}
}
}

View File

@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die();
* Extra information about event.
*
* - int choiceid: id of choice.
* - int optionid: id of option.
* - int optionid: (optional) id of option.
* }
*
* @package mod_choice

View File

@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die();
* Extra information about event.
*
* - int choiceid: id of choice.
* - int optionid: id of option.
* - int optionid: (optional) id of option.
* }
*
* @package mod_choice

View File

@ -113,6 +113,9 @@ class response_deleted extends \core\event\base {
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['anonymous'])) {
throw new \coding_exception('The \'anonymous\' value must be set in other.');
}

View File

@ -135,6 +135,9 @@ class response_submitted extends \core\event\base {
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['anonymous'])) {
throw new \coding_exception('The \'anonymous\' value must be set in other.');
}

View File

@ -184,7 +184,8 @@ class mod_feedback_events_testcase extends advanced_testcase {
try {
\mod_feedback\event\response_submitted::create(array(
'context' => $context,
'objectid' => $this->eventfeedbackcompleted->id
'objectid' => $this->eventfeedbackcompleted->id,
'relateduserid' => 2,
));
$this->fail("Event validation should not allow \\mod_feedback\\event\\response_deleted to be triggered without
other['anonymous']");
@ -289,6 +290,7 @@ class mod_feedback_events_testcase extends advanced_testcase {
\mod_feedback\event\response_submitted::create(array(
'context' => $context,
'objectid' => $this->eventfeedbackcompleted->id,
'relateduserid' => 2,
'anonymous' => 0,
'other' => array('cmid' => $this->eventcm->id, 'anonymous' => 2)
));
@ -303,6 +305,7 @@ class mod_feedback_events_testcase extends advanced_testcase {
\mod_feedback\event\response_submitted::create(array(
'context' => $context,
'objectid' => $this->eventfeedbackcompleted->id,
'relateduserid' => 2,
'anonymous' => 0,
'other' => array('instanceid' => $this->eventfeedback->id, 'anonymous' => 2)
));
@ -317,6 +320,7 @@ class mod_feedback_events_testcase extends advanced_testcase {
\mod_feedback\event\response_submitted::create(array(
'context' => $context,
'objectid' => $this->eventfeedbackcompleted->id,
'relateduserid' => 2,
'other' => array('cmid' => $this->eventcm->id, 'instanceid' => $this->eventfeedback->id)
));
$this->fail("Event validation should not allow \\mod_feedback\\event\\response_deleted to be triggered without

5
mod/feedback/upgrade.txt Normal file
View File

@ -0,0 +1,5 @@
=== 2.7 ===
* The validation of the following events is now stricter (see MDL-45445):
- \mod_feedback\event\response_deleted
- \mod_feedback\event\response_submitted

View File

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string concept: the concept of created entry.
* - string concept: (optional) the concept of created entry.
* }
*
* @package mod_glossary

View File

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string concept: the concept of deleted entry.
* - string concept: (optional) the concept of deleted entry.
* - string mode: (optional) view mode user was in before deleting entry.
* - int|string hook: (optional) hook parameter in the previous view mode.
* }

View File

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string concept: the concept of updated entry (after update).
* - string concept: (optional) the concept of updated entry (after update).
* }
*
* @package mod_glossary

View File

@ -83,4 +83,18 @@ class essay_attempt_viewed extends \core\event\base {
return array($this->courseid, 'lesson', 'view grade', 'essay.php?id=' . $this->contextinstanceid . '&mode=grade&attemptid='
. $this->objectid, get_string('manualgrading', 'lesson'), $this->contextinstanceid);
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* Extra information about event.
*
* - int submitterid: id of submitter (null when trigged by CLI script).
* - int quizid: id of the quiz.
* - int quizid: (optional) id of the quiz.
* }
*
* @package mod_quiz

View File

@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
* Extra information about event.
*
* - int submitterid: id of submitter (null when trigged by CLI script).
* - int quizid: the id of the quiz.
* - int quizid: (optional) the id of the quiz.
* }
*
* @package mod_quiz

View File

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* Extra information about event.
*
* - int submitterid: id of submitter (null when trigged by CLI script).
* - int quizid: the id of the quiz.
* - int quizid: (optional) the id of the quiz.
* }
*
* @package mod_quiz

View File

@ -103,6 +103,10 @@ class interactions_viewed extends \core\event\base {
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (empty($this->other['attemptid'])) {
throw new \coding_exception('The \'attemptid\' must be set in other.');
}

View File

@ -97,6 +97,10 @@ class report_viewed extends \core\event\base {
protected function validate_data() {
parent::validate_data();
if (empty($this->other['scormid'])) {
throw new \coding_exception('The \'scormid\' value must be set in other.');
}
if (empty($this->other['mode'])) {
throw new \coding_exception('The \'mode\' value must be set in other.');
}

View File

@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
* Extra information about event properties.
*
* - string loadedcontent: A reference to the content loaded.
* - int instanceid: Instance id of the scorm activity.
* - int instanceid: (optional) Instance id of the scorm activity.
* }
*
* @package mod_scorm

View File

@ -105,6 +105,9 @@ class tracks_viewed extends \core\event\base {
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (empty($this->other['attemptid'])) {
throw new \coding_exception('The \'attemptid\' value must be set in other.');
}

View File

@ -101,6 +101,10 @@ class user_report_viewed extends \core\event\base {
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (empty($this->other['attemptid'])) {
throw new \coding_exception('The \'attemptid\' value must be set in other.');
}

View File

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - int section: section id.
* - int section: (optional) section id.
* }
*
* @package mod_wiki

View File

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about event.
*
* - string newcontent: updated content.
* - string newcontent: (optional) updated content.
* }
*
* @package mod_wiki

View File

@ -29,13 +29,6 @@ defined('MOODLE_INTERNAL') || die();
/**
* The mod_workshop assessable uploaded event class.
*
* @property-read array $other {
* Extra information about event.
*
* - array pathnamehashes: uploaded files path name hashes.
* - string content: string.
* }
*
* @package mod_workshop
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart

View File

@ -29,10 +29,10 @@ defined('MOODLE_INTERNAL') || die();
* The mod_workshop assessment evaluated event class.
*
* @property-read array $other {
* Extra information about the event.
* Extra information about the event.
*
* - string currentgrade: (could be null) current saved grade.
* - string finalgrade: (could be null) final grade.
* - string currentgrade: (may be null) current saved grade.
* - string finalgrade: (may be null) final grade.
* }
*
* @package mod_workshop

View File

@ -30,9 +30,9 @@ defined('MOODLE_INTERNAL') || die();
* The mod_workshop assessment_evaluations reset event class.
*
* @property-read array $other {
* Extra information about the event.
* Extra information about the event.
*
* - int workshopid: the ID of the workshop.
* - int workshopid: the ID of the workshop.
* }
*
* @package mod_workshop
@ -89,4 +89,18 @@ class assessment_evaluations_reset extends \core\event\base {
public function get_url() {
return new \moodle_url('/mod/workshop/view.php', array('id' => $this->contextinstanceid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['workshopid'])) {
throw new \coding_exception('The \'workshopid\' value must be set in other.');
}
}
}

View File

@ -29,10 +29,10 @@ defined('MOODLE_INTERNAL') || die();
* The mod_workshop assessment_reevaluated event class.
*
* @property-read array $other {
* Extra information about the event.
* Extra information about the event.
*
* - float currentgrade: (may be null) current saved grade.
* - float finalgrade: (may be null) final grade.
* - float currentgrade: (may be null) current saved grade.
* - float finalgrade: (may be null) final grade.
* }
*
* @package mod_workshop

View File

@ -29,9 +29,9 @@ defined('MOODLE_INTERNAL') || die();
* The mod_workshop submission assessments reset event class.
*
* @property-read array $other {
* Extra information about the event.
* Extra information about the event.
*
* - int workshopid: the ID of the workshop.
* - int workshopid: the ID of the workshop.
* }
*
* @package mod_workshop
@ -88,4 +88,18 @@ class assessments_reset extends \core\event\base {
public function get_url() {
return new \moodle_url('/mod/workshop/view.php', array('id' => $this->contextinstanceid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['workshopid'])) {
throw new \coding_exception('The \'workshopid\' value must be set in other.');
}
}
}

View File

@ -29,9 +29,9 @@ defined('MOODLE_INTERNAL') || die();
* The mod_workshop phase switched event class.
*
* @property-read array $other {
* Extra information about the event.
* Extra information about the event.
*
* - int workshopphase: Workshop phase.
* - int workshopphase: Workshop phase.
* }
*
* @package mod_workshop
@ -89,4 +89,18 @@ class phase_switched extends \core\event\base {
public function get_url() {
return new \moodle_url('/mod/workshop/view.php', array('id' => $this->contextinstanceid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['workshopphase'])) {
throw new \coding_exception('The \'workshopphase\' value must be set in other.');
}
}
}

View File

@ -29,10 +29,10 @@ defined('MOODLE_INTERNAL') || die();
* The mod_workshop submission assessed event class.
*
* @property-read array $other {
* Extra information about the event.
* Extra information about the event.
*
* - int workshopid: Workshop ID.
* - int submissionid: Submission ID.
* - int submissionid: Submission ID.
* - int workshopid: (optional) Workshop ID.
* }
*
* @package mod_workshop
@ -90,4 +90,22 @@ class submission_assessed extends \core\event\base {
public function get_url() {
return new \moodle_url('/mod/workshop/assessment.php', array('asid' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['submissionid'])) {
throw new \coding_exception('The \'submissionid\' value must be set in other.');
}
}
}

View File

@ -29,9 +29,9 @@ defined('MOODLE_INTERNAL') || die();
* The mod_workshop submission created event class.
*
* @property-read array $other {
* Extra information about the event.
* Extra information about the event.
*
* - string submissiontitle: Submission title.
* - string submissiontitle: (optional) Submission title.
* }
*
* @package mod_workshop

View File

@ -29,11 +29,11 @@ defined('MOODLE_INTERNAL') || die();
* The mod_workshop submission reassessed event class.
*
* @property-read array $other {
* Extra information about the event.
* Extra information about the event.
*
* - int workshopid: Workshop ID.
* - int submissionid: Submission ID.
* - float grade: Assessment grade.
* - int submissionid: Submission ID.
* - int workshopid: (optional) Workshop ID.
* - float grade: (optional) Assessment grade.
* }
*
* @package mod_workshop
@ -91,4 +91,22 @@ class submission_reassessed extends \core\event\base {
public function get_url() {
return new \moodle_url('/mod/workshop/assessment.php?', array('asid' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['submissionid'])) {
throw new \coding_exception('The \'submissionid\' value must be set in other.');
}
}
}

View File

@ -29,9 +29,9 @@ defined('MOODLE_INTERNAL') || die();
* The mod_workshop submission updated event class.
*
* @property-read array $other {
* Extra information about the event.
* Extra information about the event.
*
* - string submissiontitle: Submission title.
* - string submissiontitle: (optional) Submission title.
* }
*
* @package mod_workshop

View File

@ -29,9 +29,9 @@ defined('MOODLE_INTERNAL') || die();
* The mod_workshop submission viewed event class.
*
* @property-read array $other {
* Extra information about the event.
* Extra information about the event.
*
* - int workshopid: workshop ID.
* - int workshopid: (optional) workshop ID.
* }
*
* @package mod_workshop
@ -88,4 +88,18 @@ class submission_viewed extends \core\event\base {
'submission.php?cmid=' . $this->contextinstanceid . '&id=' . $this->objectid,
$this->objectid, $this->contextinstanceid);
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -94,5 +94,9 @@ class user_report_viewed extends \core\event\base {
if ($this->contextlevel != CONTEXT_COURSE) {
throw new \coding_exception('Context level must be CONTEXT_COURSE.');
}
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
}

View File

@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
* @property-read array $other {
* Extra information about the event.
*
* -string requestedqtype: Requested question type.
* - string requestedqtype: Requested question type.
* }
*
* @package report_questioninstances