MDL-45445 events: added missing 'other' validation

This commit is contained in:
Mark Nelson 2014-05-07 19:12:06 -07:00
parent 943c61051f
commit d0c65a411f
17 changed files with 186 additions and 0 deletions

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

@ -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

@ -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

@ -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

@ -122,5 +122,13 @@ class role_assigned extends base {
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

@ -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

@ -119,5 +119,13 @@ class role_unassigned extends base {
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

@ -151,5 +151,9 @@ class user_graded extends base {
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

@ -103,5 +103,13 @@ class user_loggedinas extends base {
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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -103,5 +103,9 @@ class submission_assessed extends \core\event\base {
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

@ -104,5 +104,9 @@ class submission_reassessed extends \core\event\base {
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.');
}
}
}