Merge branch 'w14_MDL-44715_m27_eventval' of git://github.com/skodak/moodle

This commit is contained in:
Marina Glancy 2014-04-01 13:45:59 +08:00
commit 0b1afc71bb
72 changed files with 100 additions and 36 deletions

View File

@ -59,6 +59,7 @@ abstract class assessable_submitted extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context passed must be module context.');
}

View File

@ -66,6 +66,7 @@ abstract class assessable_uploaded extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context passed must be module context.');
} else if (!isset($this->other['pathnamehashes']) || !is_array($this->other['pathnamehashes'])) {

View File

@ -103,6 +103,7 @@ class blog_association_created extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->other['associatetype']) || ($this->other['associatetype'] !== 'course'
&& $this->other['associatetype'] !== 'coursemodule')) {
throw new \coding_exception('Invalid associatetype in event blog_association_created.');

View File

@ -94,6 +94,7 @@ abstract class comment_created extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['itemid'])) {
throw new \coding_exception('The itemid needs to be set in $other');
}

View File

@ -94,6 +94,7 @@ abstract class comment_deleted extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['itemid'])) {
throw new \coding_exception('The itemid needs to be set in $other');
}

View File

@ -113,11 +113,10 @@ abstract class content_viewed extends base {
* @return void
*/
protected function validate_data() {
if (debugging('', DEBUG_DEVELOPER)) {
// Make sure this class is never used without a content identifier.
if (empty($this->other['content'])) {
throw new \coding_exception('content_viewed event must define content identifier.');
}
parent::validate_data();
// Make sure this class is never used without a content identifier.
if (empty($this->other['content'])) {
throw new \coding_exception('content_viewed event must define content identifier.');
}
}
}

View File

@ -87,6 +87,7 @@ class course_module_completion_updated extends base {
* @throws \coding_exception in case of a problem.
*/
protected function validate_data() {
parent::validate_data();
// Make sure the context level is set to module.
if ($this->contextlevel !== CONTEXT_MODULE) {
throw new \coding_exception('Context passed must be module context.');

View File

@ -120,6 +120,7 @@ class course_module_created extends base {
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['modulename'])) {
throw new \coding_exception("Field other['modulename'] cannot be empty");
}

View File

@ -110,6 +110,7 @@ class course_module_deleted extends base {
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['modulename'])) {
throw new \coding_exception("Field other['modulename'] cannot be empty");
}

View File

@ -105,6 +105,7 @@ abstract class course_module_instance_list_viewed extends base{
* @return void
*/
protected function validate_data() {
parent::validate_data();
if ($this->contextlevel != CONTEXT_COURSE) {
throw new \coding_exception('Context passed must be course context.');
}

View File

@ -120,6 +120,7 @@ class course_module_updated extends base {
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['modulename'])) {
throw new \coding_exception("Field other['modulename'] cannot be empty");
}

View File

@ -92,6 +92,7 @@ abstract class course_module_viewed extends base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
// Make sure this class is never used without proper object details.
if (empty($this->objectid) || empty($this->objecttable)) {
throw new \coding_exception('course_module_viewed event must define objectid and object table.');

View File

@ -84,6 +84,7 @@ class course_reset_ended extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['reset_options'])) {
throw new \coding_exception('The key reset_options must be set in $other.');
}

View File

@ -84,6 +84,7 @@ class course_reset_started extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['reset_options'])) {
throw new \coding_exception('The key reset_options must be set in $other.');
}

View File

@ -69,6 +69,7 @@ class email_failed extends base {
* @throws \coding_exception
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['subject'])) {
throw new \coding_exception('The subject needs to be set in $other');
}

View File

@ -112,6 +112,7 @@ class group_member_added extends \core\event\base {
if (!isset($this->other['component']) || !isset($this->other['itemid'])) {
throw new \coding_exception('The component and itemid need to be set in $other, even if empty.');
}
parent::validate_data();
}
}

View File

@ -113,29 +113,26 @@ class user_deleted extends base {
* @return void
*/
protected function validate_data() {
global $CFG;
parent::validate_data();
if ($CFG->debugdeveloper) {
parent::validate_data();
if (!isset($this->other['username'])) {
throw new \coding_exception('username must be set in $other.');
}
if (!isset($this->other['username'])) {
throw new \coding_exception('username must be set in $other.');
}
if (!isset($this->other['email'])) {
throw new \coding_exception('email must be set in $other.');
}
if (!isset($this->other['email'])) {
throw new \coding_exception('email must be set in $other.');
}
if (!isset($this->other['idnumber'])) {
throw new \coding_exception('idnumber must be set in $other.');
}
if (!isset($this->other['idnumber'])) {
throw new \coding_exception('idnumber must be set in $other.');
}
if (!isset($this->other['picture'])) {
throw new \coding_exception('picture must be set in $other.');
}
if (!isset($this->other['picture'])) {
throw new \coding_exception('picture must be set in $other.');
}
if (!isset($this->other['mnethostid'])) {
throw new \coding_exception('mnethostid must be set in $other.');
}
if (!isset($this->other['mnethostid'])) {
throw new \coding_exception('mnethostid must be set in $other.');
}
}
}

View File

@ -106,11 +106,11 @@ class user_loggedin extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->data['objectid'])) {
throw new \coding_exception("objectid has to be specified.");
} else if (!isset($this->data['other']['username'])) {
throw new \coding_exception("other['username'] has to be specified.");
}
}
}

View File

@ -99,6 +99,7 @@ class user_login_failed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['reason'])) {
throw new \coding_exception("other['reason'] has to be specified.");
} else if (!isset($this->other['username'])) {

View File

@ -99,6 +99,7 @@ class webservice_function_called extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['function'])) {
throw new \coding_exception('The key \'function\' needs to be set in $other.');
}

View File

@ -113,6 +113,7 @@ class webservice_login_failed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['reason'])) {
throw new \coding_exception('The key \'reason\' needs to be set in $other.');
} else if (!isset($this->other['method'])) {

View File

@ -90,6 +90,7 @@ class webservice_service_user_added extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The relateduserid must be set.');
}

View File

@ -90,6 +90,7 @@ class webservice_service_user_removed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The relateduserid must be set.');
}

View File

@ -98,6 +98,7 @@ class webservice_token_created extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The property \'relateduserid\' must be set.');
}

View File

@ -205,6 +205,7 @@ class problematic_event3 extends \core\event\base {
}
protected function validate_data() {
parent::validate_data();
if (empty($this->data['other'])) {
debugging('other is missing');
}

View File

@ -92,7 +92,7 @@ class extension_granted extends \core\event\base {
/**
* Sets the legacy event log data.
*
* @param stdClass $legacylogdata legacy log data.
* @param \stdClass $legacylogdata legacy log data.
* @return void
*/
public function set_legacy_logdata($legacylogdata) {
@ -106,6 +106,7 @@ class extension_granted extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('relateduserid is a mandatory property.');
}

View File

@ -98,7 +98,7 @@ class marker_updated extends \core\event\base {
/**
* Sets the legacy event log data.
*
* @param stdClass $legacylogdata legacy log data.
* @param \stdClass $legacylogdata legacy log data.
* @return void
*/
public function set_legacy_logdata($legacylogdata) {
@ -112,6 +112,7 @@ class marker_updated extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['markerid'])) {
throw new \coding_exception('markerid must be set in $other.');
} else if (!isset($this->relateduserid)) {

View File

@ -92,7 +92,7 @@ class statement_accepted extends \core\event\base {
/**
* Sets the legacy event log data.
*
* @param stdClass $legacylogdata legacy log data.
* @param \stdClass $legacylogdata legacy log data.
* @return void
*/
public function set_legacy_logdata($legacylogdata) {

View File

@ -74,6 +74,7 @@ abstract class submission_created extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['submissionid'])) {
throw new \coding_exception('Other must contain the key submissionid.');
}

View File

@ -92,7 +92,7 @@ class submission_graded extends \core\event\base {
/**
* Sets the legacy event log data.
*
* @param stdClass $legacylogdata legacy log data.
* @param \stdClass $legacylogdata legacy log data.
* @return void
*/
public function set_legacy_logdata($legacylogdata) {
@ -106,6 +106,7 @@ class submission_graded extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('relateduserid is a mandatory property.');
}

View File

@ -92,7 +92,7 @@ class submission_locked extends \core\event\base {
/**
* Sets the legacy event log data.
*
* @param stdClass $legacylogdata legacy log data.
* @param \stdClass $legacylogdata legacy log data.
* @return void
*/
public function set_legacy_logdata($legacylogdata) {
@ -106,6 +106,7 @@ class submission_locked extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('relateduserid is a mandatory property.');
}

View File

@ -112,6 +112,7 @@ class submission_status_updated extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['newstatus'])) {
throw new \coding_exception('newstatus must be set in $other.');
}

View File

@ -106,6 +106,7 @@ class submission_unlocked extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('relateduserid is a mandatory property.');
}

View File

@ -74,6 +74,7 @@ abstract class submission_updated extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['submissionid'])) {
throw new \coding_exception('Other must contain the key submissionid.');
}

View File

@ -112,6 +112,7 @@ class workflow_state_updated extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['newstate'])) {
throw new \coding_exception('newstate must be set in $other.');
} else if (!isset($this->relateduserid)) {

View File

@ -89,6 +89,7 @@ class message_sent extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The property relateduserid must be set.');
}

View File

@ -93,6 +93,7 @@ class sessions_viewed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->data['other']['start'])) {
throw new \coding_exception('The property start must be set in other.');
}

View File

@ -103,6 +103,7 @@ class answer_submitted extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['choiceid'])) {
throw new \coding_exception('choiceid must be set in $other.');
}

View File

@ -103,6 +103,7 @@ class answer_updated extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['choiceid'])) {
throw new \coding_exception('choiceid must be set in $other.');
}

View File

@ -88,6 +88,7 @@ class category_created extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
// Make sure this class is never used without proper object details.
if (!$this->contextlevel === CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');

View File

@ -88,6 +88,7 @@ class category_deleted extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
// Make sure this class is never used without proper object details.
if (!$this->contextlevel === CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');

View File

@ -88,6 +88,7 @@ class category_updated extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
// Make sure this class is never used without proper object details.
if (!$this->contextlevel === CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');

View File

@ -90,6 +90,7 @@ class entry_approved extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
// Make sure this class is never used without proper object details.
if (!$this->contextlevel === CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');

View File

@ -96,6 +96,7 @@ class entry_created extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
// Make sure this class is never used without proper object details.
if (!$this->contextlevel === CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');

View File

@ -110,6 +110,7 @@ class entry_deleted extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
// Make sure this class is never used without proper object details.
if (!$this->contextlevel === CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');

View File

@ -90,6 +90,7 @@ class entry_disapproved extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
// Make sure this class is never used without proper object details.
if (!$this->contextlevel === CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');

View File

@ -96,6 +96,7 @@ class entry_updated extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
// Make sure this class is never used without proper object details.
if (!$this->contextlevel === CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');

View File

@ -90,6 +90,7 @@ class entry_viewed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
// Make sure this class is never used without proper object details.
if (!$this->contextlevel === CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');

View File

@ -99,6 +99,7 @@ class essay_assessed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('relateduserid is a mandatory property.');
}

View File

@ -111,6 +111,7 @@ class attempt_abandoned extends \core\event\base {
* Custom validation.
*/
protected function validate_data() {
parent::validate_data();
if (!array_key_exists('submitterid', $this->other)) {
throw new \coding_exception('Other must contain the key submitterid');
} else if (!isset($this->relateduserid)) {

View File

@ -88,10 +88,10 @@ class attempt_becameoverdue extends \core\event\base {
return new \moodle_url('/mod/quiz/review.php', array('attempt' => $this->objectid));
}
/**
/**
* Legacy event data if get_legacy_eventname() is not empty.
*
* @return stdClass
* @return \stdClass
*/
protected function get_legacy_eventdata() {
$attempt = $this->get_record_snapshot('quiz_attempts', $this->objectid);
@ -112,10 +112,11 @@ class attempt_becameoverdue extends \core\event\base {
/**
* Custom validation.
*
* @throws coding_exception
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!array_key_exists('submitterid', $this->other)) {
throw new \coding_exception('Other must contain the key submitterid');
} else if (!isset($this->relateduserid)) {

View File

@ -82,7 +82,7 @@ class attempt_started extends \core\event\base {
/**
* Legacy event data if get_legacy_eventname() is not empty.
*
* @return stdClass
* @return \stdClass
*/
protected function get_legacy_eventdata() {
$attempt = $this->get_record_snapshot('quiz_attempts', $this->objectid);
@ -103,10 +103,11 @@ class attempt_started extends \core\event\base {
/**
* Custom validation.
*
* @throws coding_exception
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('relateduserid must be set');
}

View File

@ -88,7 +88,7 @@ class attempt_submitted extends \core\event\base {
/**
* Legacy event data if get_legacy_eventname() is not empty.
*
* @return stdClass
* @return \stdClass
*/
protected function get_legacy_eventdata() {
$attempt = $this->get_record_snapshot('quiz_attempts', $this->objectid);
@ -110,10 +110,11 @@ class attempt_submitted extends \core\event\base {
/**
* Custom validation.
*
* @throws coding_exception
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!array_key_exists('submitterid', $this->other)) {
throw new \coding_exception('Other must contain the key submitterid');
} else if (!isset($this->relateduserid)) {

View File

@ -98,6 +98,7 @@ class interactions_viewed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->other['attemptid'])) {
throw new \coding_exception('The \\mod_scorm\\event\\interactions_viewed must specify attemptid.');
}

View File

@ -93,6 +93,7 @@ class report_viewed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->other['mode'])) {
throw new \coding_exception('The event must specify mode to define which report was viewed.');
}

View File

@ -94,6 +94,7 @@ class sco_launched extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->other['loadedcontent'])) {
throw new \coding_exception('The event mod_scorm\\event\\sco_launched must specify loadedcontent.');
}

View File

@ -98,6 +98,7 @@ class user_report_viewed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->other['attemptid'])) {
throw new \coding_exception('The \\mod_scorm\\event\\user_report_viewed must specify attemptid.');
}

View File

@ -54,6 +54,7 @@ class course_module_viewed extends \core\event\course_module_viewed {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->other['viewed'])) {
throw new \coding_exception('Other must contain the key viewed.');
}

View File

@ -88,6 +88,7 @@ class report_downloaded extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->other['type'])) {
throw new \coding_exception('Other must contain the key type.');
}

View File

@ -84,6 +84,7 @@ class response_submitted extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->other['surveyid'])) {
throw new \coding_exception('Other must contain the key surveyid.');
}

View File

@ -80,6 +80,7 @@ class comments_viewed extends \core\event\comments_viewed {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->objectid) || empty($this->objecttable)) {
throw new \coding_exception('The objectid and objecttable need to be set in $other');
}

View File

@ -100,6 +100,7 @@ class page_diff_viewed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['comparewith']) || !isset($this->other['compare'])) {
throw new \coding_exception('The comparewith and compare need to be set in $other');
}

View File

@ -94,6 +94,7 @@ class page_map_viewed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['option'])) {
throw new \coding_exception('The option need to be set in $other, even if 0.');
}

View File

@ -95,6 +95,7 @@ class page_version_deleted extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['pageid'])) {
throw new \coding_exception('The pageid need to be set in $other');
}

View File

@ -95,6 +95,7 @@ class page_version_restored extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['pageid'])) {
throw new \coding_exception('The pageid needs to be set in $other');
}

View File

@ -97,6 +97,7 @@ class page_version_viewed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['versionid'])) {
throw new \coding_exception('The versionid need to be set in $other');
}

View File

@ -92,6 +92,7 @@ class report_viewed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->data['other']['groupid'])) {
throw new \coding_exception('The property groupid must be set in other.');
}

View File

@ -90,6 +90,7 @@ class user_report_viewed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->data['other']['mode'])) {
throw new \coding_exception('The property mode must be set in other.');
}

View File

@ -91,6 +91,7 @@ class outline_viewed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->data['other']['mode'])) {
throw new \coding_exception('The property mode must be set in other.');
}

View File

@ -94,6 +94,7 @@ class report_viewed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->data['other']['instanceid'])) {
throw new \coding_exception('The property instanceid must be set in other.');
}

View File

@ -91,6 +91,7 @@ class report_viewed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->data['other']['report'])) {
throw new \coding_exception('The property report must be set in other.');
}

View File

@ -86,6 +86,7 @@ class user_report_viewed extends \core\event\base {
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->data['relateduserid'])) {
throw new \coding_exception('The property relateduserid must be set.');
}