MDL-45445 events: added missing 'other' validation
authorMark Nelson <markn@moodle.com>
Thu, 8 May 2014 02:12:06 +0000 (19:12 -0700)
committerMark Nelson <markn@moodle.com>
Fri, 13 Jun 2014 03:46:58 +0000 (20:46 -0700)
17 files changed:
lib/classes/event/course_category_deleted.php
lib/classes/event/course_content_deleted.php
lib/classes/event/course_created.php
lib/classes/event/course_deleted.php
lib/classes/event/course_restored.php
lib/classes/event/role_assigned.php
lib/classes/event/role_deleted.php
lib/classes/event/role_unassigned.php
lib/classes/event/user_graded.php
lib/classes/event/user_loggedinas.php
lib/classes/event/webservice_token_created.php
mod/scorm/classes/event/report_viewed.php
mod/workshop/classes/event/assessment_evaluations_reset.php
mod/workshop/classes/event/assessments_reset.php
mod/workshop/classes/event/phase_switched.php
mod/workshop/classes/event/submission_assessed.php
mod/workshop/classes/event/submission_reassessed.php

index 5c6bbee..4d80eee 100644 (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.');
+        }
+    }
 }
index 42161dd..dbea00d 100644 (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.');
+        }
+    }
 }
index 56a6d61..0836ccb 100644 (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.');
+        }
+    }
 }
index ca27280..d89aa19 100644 (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.');
+        }
+    }
 }
index 8ccfc26..1d5230c 100644 (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.');
+        }
+    }
 }
index 85c6051..6722959 100644 (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.');
+        }
     }
 }
index a259419..f80003d 100644 (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.');
+        }
+    }
 }
index f0888be..79928c3 100644 (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.');
+        }
     }
 }
index 61c8980..9af099f 100644 (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.');
+        }
     }
 }
index 0e32b29..494038f 100644 (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.');
+        }
     }
 }
index 65da1bb..a816dbe 100644 (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.');
+        }
     }
 }
index 37d0c2a..edd61f3 100644 (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.');
         }
index 6a68335..68145df 100644 (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.');
+        }
+    }
 }
index c3b8992..2e1a32b 100644 (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.');
+        }
+    }
 }
index 0d4d3b3..faefe75 100644 (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.');
+        }
+    }
 }
index 7c7e4dc..57ccf64 100644 (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.');
+        }
     }
 }
index eb05f03..c66a8fc 100644 (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.');
+        }
     }
 }