From 0817451470f2288948d6ff561319fae7e9daab2c Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Wed, 23 Sep 2015 16:00:33 +0800 Subject: [PATCH] MDL-46455 events: Add mapping info to events This commit covers all events outside of /mod/. It adds mapping info for restoring events, or the default implementation which returns false if mapping is not required. --- admin/tool/monitor/classes/event/rule_created.php | 5 +++++ admin/tool/monitor/classes/event/rule_deleted.php | 5 +++++ admin/tool/monitor/classes/event/rule_updated.php | 5 +++++ .../monitor/classes/event/subscription_created.php | 5 +++++ .../classes/event/subscription_criteria_met.php | 5 +++++ .../monitor/classes/event/subscription_deleted.php | 5 +++++ lib/classes/event/assessable_uploaded.php | 4 ++++ lib/classes/event/badge_awarded.php | 4 ++++ lib/classes/event/blog_association_created.php | 10 ++++++++++ lib/classes/event/blog_comment_created.php | 10 ++++++++++ lib/classes/event/blog_comment_deleted.php | 10 ++++++++++ lib/classes/event/blog_entries_viewed.php | 10 ++++++++++ lib/classes/event/blog_entry_created.php | 5 +++++ lib/classes/event/blog_entry_deleted.php | 5 +++++ lib/classes/event/blog_entry_updated.php | 5 +++++ lib/classes/event/calendar_event_created.php | 11 +++++++++++ lib/classes/event/calendar_event_deleted.php | 11 +++++++++++ lib/classes/event/calendar_event_updated.php | 11 +++++++++++ lib/classes/event/cohort_created.php | 5 +++++ lib/classes/event/cohort_deleted.php | 5 +++++ lib/classes/event/cohort_member_added.php | 5 +++++ lib/classes/event/cohort_member_removed.php | 5 +++++ lib/classes/event/cohort_updated.php | 5 +++++ lib/classes/event/comment_created.php | 9 +++++++++ lib/classes/event/comment_deleted.php | 9 +++++++++ lib/classes/event/content_viewed.php | 4 ++++ lib/classes/event/course_category_created.php | 5 +++++ lib/classes/event/course_category_deleted.php | 5 +++++ lib/classes/event/course_category_updated.php | 5 +++++ lib/classes/event/course_completed.php | 11 +++++++++++ lib/classes/event/course_content_deleted.php | 4 ++++ lib/classes/event/course_created.php | 4 ++++ lib/classes/event/course_deleted.php | 4 ++++ .../event/course_module_completion_updated.php | 5 +++++ lib/classes/event/course_module_created.php | 8 ++++++++ lib/classes/event/course_module_deleted.php | 4 ++++ lib/classes/event/course_module_updated.php | 8 ++++++++ lib/classes/event/course_reset_ended.php | 5 +++++ lib/classes/event/course_reset_started.php | 4 ++++ lib/classes/event/course_restored.php | 4 ++++ lib/classes/event/course_section_updated.php | 4 ++++ lib/classes/event/course_updated.php | 4 ++++ lib/classes/event/course_viewed.php | 5 +++++ lib/classes/event/email_failed.php | 4 ++++ lib/classes/event/grade_deleted.php | 4 ++++ lib/classes/event/group_created.php | 4 ++++ lib/classes/event/group_deleted.php | 4 ++++ lib/classes/event/group_member_added.php | 9 +++++++++ lib/classes/event/group_member_removed.php | 5 +++++ lib/classes/event/group_updated.php | 4 ++++ lib/classes/event/grouping_created.php | 4 ++++ lib/classes/event/grouping_deleted.php | 4 ++++ lib/classes/event/grouping_updated.php | 4 ++++ lib/classes/event/message_contact_added.php | 5 +++++ lib/classes/event/message_contact_blocked.php | 5 +++++ lib/classes/event/message_contact_removed.php | 5 +++++ lib/classes/event/message_contact_unblocked.php | 5 +++++ lib/classes/event/message_deleted.php | 5 +++++ lib/classes/event/message_sent.php | 10 ++++++++++ lib/classes/event/message_viewed.php | 10 ++++++++++ lib/classes/event/mnet_access_control_created.php | 10 ++++++++++ lib/classes/event/mnet_access_control_updated.php | 10 ++++++++++ lib/classes/event/note_created.php | 10 ++++++++++ lib/classes/event/note_deleted.php | 10 ++++++++++ lib/classes/event/note_updated.php | 10 ++++++++++ lib/classes/event/notes_viewed.php | 10 ++++++++++ lib/classes/event/question_category_created.php | 4 ++++ lib/classes/event/role_assigned.php | 9 +++++++++ lib/classes/event/role_capabilities_updated.php | 4 ++++ lib/classes/event/role_deleted.php | 4 ++++ lib/classes/event/role_unassigned.php | 8 ++++++++ lib/classes/event/tag_added.php | 10 ++++++++++ lib/classes/event/tag_created.php | 9 +++++++++ lib/classes/event/tag_deleted.php | 9 +++++++++ lib/classes/event/tag_flagged.php | 9 +++++++++ lib/classes/event/tag_removed.php | 10 ++++++++++ lib/classes/event/tag_unflagged.php | 10 ++++++++++ lib/classes/event/tag_updated.php | 10 ++++++++++ lib/classes/event/user_created.php | 4 ++++ lib/classes/event/user_deleted.php | 8 ++++++++ lib/classes/event/user_enrolment_created.php | 9 +++++++++ lib/classes/event/user_enrolment_deleted.php | 9 +++++++++ lib/classes/event/user_enrolment_updated.php | 9 +++++++++ lib/classes/event/user_graded.php | 11 +++++++++++ lib/classes/event/user_list_viewed.php | 8 ++++++++ lib/classes/event/user_loggedin.php | 8 ++++++++ lib/classes/event/user_loggedinas.php | 8 ++++++++ lib/classes/event/user_loggedout.php | 8 ++++++++ lib/classes/event/user_login_failed.php | 3 +++ lib/classes/event/user_password_updated.php | 4 ++++ lib/classes/event/user_profile_viewed.php | 11 +++++++++++ lib/classes/event/user_updated.php | 4 ++++ lib/classes/event/webservice_function_called.php | 4 ++++ lib/classes/event/webservice_login_failed.php | 4 ++++ lib/classes/event/webservice_service_created.php | 9 +++++++++ lib/classes/event/webservice_service_deleted.php | 6 ++++++ lib/classes/event/webservice_service_updated.php | 6 ++++++ lib/classes/event/webservice_service_user_added.php | 6 ++++++ .../event/webservice_service_user_removed.php | 6 ++++++ lib/classes/event/webservice_token_created.php | 9 +++++++++ lib/classes/event/webservice_token_sent.php | 5 +++++ report/log/classes/event/report_viewed.php | 8 ++++++++ report/log/classes/event/user_report_viewed.php | 1 + .../classes/event/activity_report_viewed.php | 1 + report/outline/classes/event/report_viewed.php | 6 ++++++ .../participation/classes/event/report_viewed.php | 13 +++++++++++++ .../classes/event/report_viewed.php | 5 +++++ 107 files changed, 702 insertions(+) diff --git a/admin/tool/monitor/classes/event/rule_created.php b/admin/tool/monitor/classes/event/rule_created.php index 178445b46a3..afc42e892e0 100644 --- a/admin/tool/monitor/classes/event/rule_created.php +++ b/admin/tool/monitor/classes/event/rule_created.php @@ -74,4 +74,9 @@ class rule_created extends \core\event\base { return new \moodle_url('/admin/tool/monitor/edit.php', array('ruleid' => $this->objectid, 'courseid' => $this->courseid)); } + + public static function get_objectid_mapping() { + // No mapping required for this event because event monitor rules are not backed up. + return false; + } } diff --git a/admin/tool/monitor/classes/event/rule_deleted.php b/admin/tool/monitor/classes/event/rule_deleted.php index 50e2d5b6628..45b46cb294f 100644 --- a/admin/tool/monitor/classes/event/rule_deleted.php +++ b/admin/tool/monitor/classes/event/rule_deleted.php @@ -73,4 +73,9 @@ class rule_deleted extends \core\event\base { public function get_url() { return new \moodle_url('/admin/tool/monitor/managerules.php', array('courseid' => $this->courseid)); } + + public static function get_objectid_mapping() { + // No mapping required for this event because event monitor rules are not backed up. + return false; + } } diff --git a/admin/tool/monitor/classes/event/rule_updated.php b/admin/tool/monitor/classes/event/rule_updated.php index 8b262c4f49d..63b247cc1b1 100644 --- a/admin/tool/monitor/classes/event/rule_updated.php +++ b/admin/tool/monitor/classes/event/rule_updated.php @@ -74,4 +74,9 @@ class rule_updated extends \core\event\base { return new \moodle_url('/admin/tool/monitor/edit.php', array('ruleid' => $this->objectid, 'courseid' => $this->courseid)); } + + public static function get_objectid_mapping() { + // No mapping required for this event because event monitor rules are not backed up. + return false; + } } diff --git a/admin/tool/monitor/classes/event/subscription_created.php b/admin/tool/monitor/classes/event/subscription_created.php index e3d2b818da0..3ae76742543 100644 --- a/admin/tool/monitor/classes/event/subscription_created.php +++ b/admin/tool/monitor/classes/event/subscription_created.php @@ -64,4 +64,9 @@ class subscription_created extends \core\event\base { public function get_description() { return "The user with id '$this->userid' created the event monitor subscription with id '$this->objectid'."; } + + public static function get_objectid_mapping() { + // No mapping required for this event because event monitor subscriptions are not backed up. + return false; + } } diff --git a/admin/tool/monitor/classes/event/subscription_criteria_met.php b/admin/tool/monitor/classes/event/subscription_criteria_met.php index 693bcf4049f..aa64be7c95f 100644 --- a/admin/tool/monitor/classes/event/subscription_criteria_met.php +++ b/admin/tool/monitor/classes/event/subscription_criteria_met.php @@ -83,4 +83,9 @@ class subscription_criteria_met extends \core\event\base { throw new \coding_exception('The \'subscriptionid\' value must be set in other.'); } } + + public static function get_other_mapping() { + // No mapping required for this event because event monitor subscriptions are not backed up. + return false; + } } diff --git a/admin/tool/monitor/classes/event/subscription_deleted.php b/admin/tool/monitor/classes/event/subscription_deleted.php index e4b2bc0b422..fc646902b8c 100644 --- a/admin/tool/monitor/classes/event/subscription_deleted.php +++ b/admin/tool/monitor/classes/event/subscription_deleted.php @@ -64,4 +64,9 @@ class subscription_deleted extends \core\event\base { public function get_description() { return "The user with id '$this->userid' deleted the event monitor subscription with id '$this->objectid'."; } + + public static function get_objectid_mapping() { + // No mapping required for this event because event monitor subscriptions are not backed up. + return false; + } } diff --git a/lib/classes/event/assessable_uploaded.php b/lib/classes/event/assessable_uploaded.php index 6c1a50cee9a..39606525af1 100644 --- a/lib/classes/event/assessable_uploaded.php +++ b/lib/classes/event/assessable_uploaded.php @@ -77,4 +77,8 @@ abstract class assessable_uploaded extends base { } } + public static function get_other_mapping() { + // Nothing to map. + return false; + } } diff --git a/lib/classes/event/badge_awarded.php b/lib/classes/event/badge_awarded.php index 4c9e0215eb7..4520d6d3dc4 100644 --- a/lib/classes/event/badge_awarded.php +++ b/lib/classes/event/badge_awarded.php @@ -94,4 +94,8 @@ class badge_awarded extends base { throw new \coding_exception('The \'objectid\' must be set.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'badge', 'restore' => 'badge'); + } } diff --git a/lib/classes/event/blog_association_created.php b/lib/classes/event/blog_association_created.php index 62ae7c9da98..e22322d8b95 100644 --- a/lib/classes/event/blog_association_created.php +++ b/lib/classes/event/blog_association_created.php @@ -125,4 +125,14 @@ class blog_association_created extends base { throw new \coding_exception('The \'subject\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Blogs are not included in backups, so no mapping required. + return false; + } + + public static function get_other_mapping() { + // Blogs are not included in backups, so no mapping required. + return false; + } } diff --git a/lib/classes/event/blog_comment_created.php b/lib/classes/event/blog_comment_created.php index 3c68de270f4..c7889901567 100644 --- a/lib/classes/event/blog_comment_created.php +++ b/lib/classes/event/blog_comment_created.php @@ -52,4 +52,14 @@ class blog_comment_created extends comment_created { public function get_description() { return "The user with id '$this->userid' added the comment to the blog with id '{$this->other['itemid']}'."; } + + public static function get_objectid_mapping() { + // Blogs are not included in backups, so no mapping required. + return false; + } + + public static function get_other_mapping() { + // Blogs are not included in backups, so no mapping required. + return false; + } } diff --git a/lib/classes/event/blog_comment_deleted.php b/lib/classes/event/blog_comment_deleted.php index adf5c092b94..a058c82586d 100644 --- a/lib/classes/event/blog_comment_deleted.php +++ b/lib/classes/event/blog_comment_deleted.php @@ -52,4 +52,14 @@ class blog_comment_deleted extends comment_deleted { public function get_description() { return "The user with id '$this->userid' deleted the comment for the blog with id '{$this->other['itemid']}'."; } + + public static function get_objectid_mapping() { + // Blogs are not included in backups, so no mapping required. + return false; + } + + public static function get_other_mapping() { + // Blogs are not included in backups, so no mapping required. + return false; + } } diff --git a/lib/classes/event/blog_entries_viewed.php b/lib/classes/event/blog_entries_viewed.php index 632b892fcdb..05d61819ff5 100644 --- a/lib/classes/event/blog_entries_viewed.php +++ b/lib/classes/event/blog_entries_viewed.php @@ -106,4 +106,14 @@ class blog_entries_viewed extends base { $url = new \moodle_url('index.php', $params); return array (SITEID, 'blog', 'view', $url->out(), 'view blog entry'); } + + public static function get_other_mapping() { + $othermapped = array(); + $othermapped['userid'] = array('db' => 'user', 'restore' => 'user'); + $othermapped['modid'] = array('db' => 'course_modules', 'restore' => 'course_module'); + $othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group'); + $othermapped['courseid'] = array('db' => 'course', 'restore' => 'course'); + + return $othermapped; + } } diff --git a/lib/classes/event/blog_entry_created.php b/lib/classes/event/blog_entry_created.php index 1f39bed35b6..479d86039b2 100644 --- a/lib/classes/event/blog_entry_created.php +++ b/lib/classes/event/blog_entry_created.php @@ -140,4 +140,9 @@ class blog_entry_created extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Blogs are not backed up, so no mapping required. + return false; + } } diff --git a/lib/classes/event/blog_entry_deleted.php b/lib/classes/event/blog_entry_deleted.php index 2321e42f51b..7282b5e89f9 100644 --- a/lib/classes/event/blog_entry_deleted.php +++ b/lib/classes/event/blog_entry_deleted.php @@ -131,4 +131,9 @@ class blog_entry_deleted extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Blogs are not backed up, so no need for mapping. + return false; + } } diff --git a/lib/classes/event/blog_entry_updated.php b/lib/classes/event/blog_entry_updated.php index 4b9237162e7..6081f76f635 100644 --- a/lib/classes/event/blog_entry_updated.php +++ b/lib/classes/event/blog_entry_updated.php @@ -138,5 +138,10 @@ class blog_entry_updated extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Blogs are not backed up, so no need for mapping. + return false; + } } diff --git a/lib/classes/event/calendar_event_created.php b/lib/classes/event/calendar_event_created.php index 98fa0f4c895..a98c238b922 100644 --- a/lib/classes/event/calendar_event_created.php +++ b/lib/classes/event/calendar_event_created.php @@ -111,4 +111,15 @@ class calendar_event_created extends base { throw new \coding_exception('The \'timestart\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'event', 'restore' => 'event'); + } + + public static function get_other_mapping() { + $othermapped = array(); + $othermapped['repeatid'] = array('db' => 'event', 'restore' => 'event'); + + return $othermapped; + } } diff --git a/lib/classes/event/calendar_event_deleted.php b/lib/classes/event/calendar_event_deleted.php index cdd013bf099..8cb09f64325 100644 --- a/lib/classes/event/calendar_event_deleted.php +++ b/lib/classes/event/calendar_event_deleted.php @@ -92,4 +92,15 @@ class calendar_event_deleted extends base { throw new \coding_exception('The \'timestart\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'event', 'restore' => 'event'); + } + + public static function get_other_mapping() { + $othermapped = array(); + $othermapped['repeatid'] = array('db' => 'event', 'restore' => 'event'); + + return $othermapped; + } } diff --git a/lib/classes/event/calendar_event_updated.php b/lib/classes/event/calendar_event_updated.php index 86971414725..1826f3d0a9f 100644 --- a/lib/classes/event/calendar_event_updated.php +++ b/lib/classes/event/calendar_event_updated.php @@ -110,4 +110,15 @@ class calendar_event_updated extends base { throw new \coding_exception('The \'timestart\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'event', 'restore' => 'event'); + } + + public static function get_other_mapping() { + $othermapped = array(); + $othermapped['repeatid'] = array('db' => 'event', 'restore' => 'event'); + + return $othermapped; + } } diff --git a/lib/classes/event/cohort_created.php b/lib/classes/event/cohort_created.php index 5451a7ab8fd..3fcc3cbf865 100644 --- a/lib/classes/event/cohort_created.php +++ b/lib/classes/event/cohort_created.php @@ -90,4 +90,9 @@ class cohort_created extends base { protected function get_legacy_eventdata() { return $this->get_record_snapshot('cohort', $this->objectid); } + + public static function get_objectid_mapping() { + // Cohorts are not included in backups, so no mapping is needed. + return false; + } } diff --git a/lib/classes/event/cohort_deleted.php b/lib/classes/event/cohort_deleted.php index c5f170cc876..a785d9c4528 100644 --- a/lib/classes/event/cohort_deleted.php +++ b/lib/classes/event/cohort_deleted.php @@ -90,4 +90,9 @@ class cohort_deleted extends base { protected function get_legacy_eventdata() { return $this->get_record_snapshot('cohort', $this->objectid); } + + public static function get_objectid_mapping() { + // Cohorts are not included in backups, so no mapping is needed. + return false; + } } diff --git a/lib/classes/event/cohort_member_added.php b/lib/classes/event/cohort_member_added.php index 018d854ec1f..ccd8cf51b57 100644 --- a/lib/classes/event/cohort_member_added.php +++ b/lib/classes/event/cohort_member_added.php @@ -108,4 +108,9 @@ class cohort_member_added extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Cohorts are not included in backups, so no mapping is needed. + return false; + } } diff --git a/lib/classes/event/cohort_member_removed.php b/lib/classes/event/cohort_member_removed.php index 25c902adf30..b94d4b49f06 100644 --- a/lib/classes/event/cohort_member_removed.php +++ b/lib/classes/event/cohort_member_removed.php @@ -109,4 +109,9 @@ class cohort_member_removed extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Cohorts are not included in backups, so no mapping is needed. + return false; + } } diff --git a/lib/classes/event/cohort_updated.php b/lib/classes/event/cohort_updated.php index 83d05b5de9c..53bc15cc3c2 100644 --- a/lib/classes/event/cohort_updated.php +++ b/lib/classes/event/cohort_updated.php @@ -90,4 +90,9 @@ class cohort_updated extends base { protected function get_legacy_eventdata() { return $this->get_record_snapshot('cohort', $this->objectid); } + + public static function get_objectid_mapping() { + // Cohorts are not included in backups, so no mapping is needed. + return false; + } } diff --git a/lib/classes/event/comment_created.php b/lib/classes/event/comment_created.php index fa4befdb0c4..e37e3ff63f3 100644 --- a/lib/classes/event/comment_created.php +++ b/lib/classes/event/comment_created.php @@ -100,4 +100,13 @@ abstract class comment_created extends base { throw new \coding_exception('The \'itemid\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'comment', 'restore' => 'comment'); + } + + public static function get_other_mapping() { + // We cannot map fields that do not have a 1:1 mapping. + return false; + } } diff --git a/lib/classes/event/comment_deleted.php b/lib/classes/event/comment_deleted.php index 0dbdcab6741..145eb44a8e9 100644 --- a/lib/classes/event/comment_deleted.php +++ b/lib/classes/event/comment_deleted.php @@ -100,4 +100,13 @@ abstract class comment_deleted extends base { throw new \coding_exception('The \'itemid\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'comment', 'restore' => 'comment'); + } + + public static function get_other_mapping() { + // We cannot map fields that do not have a 1:1 mapping. + return false; + } } diff --git a/lib/classes/event/content_viewed.php b/lib/classes/event/content_viewed.php index 18231bf91b8..a1680fa7fde 100644 --- a/lib/classes/event/content_viewed.php +++ b/lib/classes/event/content_viewed.php @@ -126,5 +126,9 @@ abstract class content_viewed extends base { throw new \coding_exception('The \'content\' value must be set in other.'); } } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/course_category_created.php b/lib/classes/event/course_category_created.php index ff48d0a98ab..a710887af4d 100644 --- a/lib/classes/event/course_category_created.php +++ b/lib/classes/event/course_category_created.php @@ -80,4 +80,9 @@ class course_category_created extends base { protected function get_legacy_logdata() { return array(SITEID, 'category', 'add', 'editcategory.php?id=' . $this->objectid, $this->objectid); } + + public static function get_objectid_mapping() { + // Categories are not backed up, so no need to map them. + return false; + } } diff --git a/lib/classes/event/course_category_deleted.php b/lib/classes/event/course_category_deleted.php index 4d80eeea830..45df1cb111d 100644 --- a/lib/classes/event/course_category_deleted.php +++ b/lib/classes/event/course_category_deleted.php @@ -136,4 +136,9 @@ class course_category_deleted extends base { throw new \coding_exception('The \'name\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Categories are not backed up, so no need to map them. + return false; + } } diff --git a/lib/classes/event/course_category_updated.php b/lib/classes/event/course_category_updated.php index d20d487e502..e2a8e375be4 100644 --- a/lib/classes/event/course_category_updated.php +++ b/lib/classes/event/course_category_updated.php @@ -96,4 +96,9 @@ class course_category_updated extends base { return array(SITEID, 'category', 'update', 'editcategory.php?id=' . $this->objectid, $this->objectid); } + + public static function get_objectid_mapping() { + // Categories are not backed up, so no need to map them. + return false; + } } diff --git a/lib/classes/event/course_completed.php b/lib/classes/event/course_completed.php index ed51fa97d3b..8eddac21880 100644 --- a/lib/classes/event/course_completed.php +++ b/lib/classes/event/course_completed.php @@ -134,4 +134,15 @@ class course_completed extends base { throw new \coding_exception('The \'relateduserid\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Sorry - there is no mapping available for completion records. + return false; + } + + public static function get_other_mapping() { + $othermapped = array(); + $othermapped['relateduserid'] = array('db' => 'user', 'restore' => 'user'); + return $othermapped; + } } diff --git a/lib/classes/event/course_content_deleted.php b/lib/classes/event/course_content_deleted.php index dbea00d4d3a..21ad2b5370a 100644 --- a/lib/classes/event/course_content_deleted.php +++ b/lib/classes/event/course_content_deleted.php @@ -104,4 +104,8 @@ class course_content_deleted extends base { throw new \coding_exception('The \'options\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'course', 'restore' => 'course'); + } } diff --git a/lib/classes/event/course_created.php b/lib/classes/event/course_created.php index 699dcc15785..fcb1ec65d9f 100644 --- a/lib/classes/event/course_created.php +++ b/lib/classes/event/course_created.php @@ -119,4 +119,8 @@ class course_created extends base { throw new \coding_exception('The \'fullname\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'course', 'restore' => 'course'); + } } diff --git a/lib/classes/event/course_deleted.php b/lib/classes/event/course_deleted.php index 19641ffef42..661a2384712 100644 --- a/lib/classes/event/course_deleted.php +++ b/lib/classes/event/course_deleted.php @@ -114,4 +114,8 @@ class course_deleted extends base { throw new \coding_exception('The \'fullname\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'course', 'restore' => 'course'); + } } diff --git a/lib/classes/event/course_module_completion_updated.php b/lib/classes/event/course_module_completion_updated.php index b5f2ff2c099..60e2ae7c901 100644 --- a/lib/classes/event/course_module_completion_updated.php +++ b/lib/classes/event/course_module_completion_updated.php @@ -107,4 +107,9 @@ class course_module_completion_updated extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Sorry mapping info is not available for course modules completion records. + return false; + } } diff --git a/lib/classes/event/course_module_created.php b/lib/classes/event/course_module_created.php index 244a1240da4..b8e13317dee 100644 --- a/lib/classes/event/course_module_created.php +++ b/lib/classes/event/course_module_created.php @@ -165,5 +165,13 @@ class course_module_created extends base { throw new \coding_exception('The \'name\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'course_modules', 'restore' => 'course_module'); + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/course_module_deleted.php b/lib/classes/event/course_module_deleted.php index 1bd888b3ec1..bad9fe2eda6 100644 --- a/lib/classes/event/course_module_deleted.php +++ b/lib/classes/event/course_module_deleted.php @@ -119,5 +119,9 @@ class course_module_deleted extends base { throw new \coding_exception('The \'instanceid\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'course_modules', 'restore' => 'course_module'); + } } diff --git a/lib/classes/event/course_module_updated.php b/lib/classes/event/course_module_updated.php index b319df6cc1d..79ed096193c 100644 --- a/lib/classes/event/course_module_updated.php +++ b/lib/classes/event/course_module_updated.php @@ -163,5 +163,13 @@ class course_module_updated extends base { )); return $event; } + + public static function get_objectid_mapping() { + return array('db' => 'course_modules', 'restore' => 'course_module'); + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/course_reset_ended.php b/lib/classes/event/course_reset_ended.php index fcca9611e16..1ff0115d2e7 100644 --- a/lib/classes/event/course_reset_ended.php +++ b/lib/classes/event/course_reset_ended.php @@ -90,4 +90,9 @@ class course_reset_ended extends base { throw new \coding_exception('The \'reset_options\' value must be set in other.'); } } + + public static function get_other_mapping() { + // Nothing to map. + return false; + } } diff --git a/lib/classes/event/course_reset_started.php b/lib/classes/event/course_reset_started.php index 491aacc1d71..d65aadff329 100644 --- a/lib/classes/event/course_reset_started.php +++ b/lib/classes/event/course_reset_started.php @@ -90,4 +90,8 @@ class course_reset_started extends base { throw new \coding_exception('The \'reset_options\' value must be set in other.'); } } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/course_restored.php b/lib/classes/event/course_restored.php index 1d5230c200c..34c1c555b87 100644 --- a/lib/classes/event/course_restored.php +++ b/lib/classes/event/course_restored.php @@ -137,4 +137,8 @@ class course_restored extends base { throw new \coding_exception('The \'samesite\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'course', 'restore' => 'course'); + } } diff --git a/lib/classes/event/course_section_updated.php b/lib/classes/event/course_section_updated.php index 0a458e6dc10..610012e47ad 100644 --- a/lib/classes/event/course_section_updated.php +++ b/lib/classes/event/course_section_updated.php @@ -104,4 +104,8 @@ class course_section_updated extends base { throw new \coding_exception('The \'sectionnum\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'course_sections', 'restore' => 'course_section'); + } } diff --git a/lib/classes/event/course_updated.php b/lib/classes/event/course_updated.php index a49e9c2852e..c272e653cf4 100644 --- a/lib/classes/event/course_updated.php +++ b/lib/classes/event/course_updated.php @@ -117,4 +117,8 @@ class course_updated extends base { protected function get_legacy_logdata() { return $this->legacylogdata; } + + public static function get_objectid_mapping() { + return array('db' => 'course', 'restore' => 'course'); + } } diff --git a/lib/classes/event/course_viewed.php b/lib/classes/event/course_viewed.php index a63e3cea8ff..4f4d9b38f7c 100644 --- a/lib/classes/event/course_viewed.php +++ b/lib/classes/event/course_viewed.php @@ -141,4 +141,9 @@ class course_viewed extends base { throw new \coding_exception('Context level must be CONTEXT_COURSE.'); } } + + public static function get_other_mapping() { + // No mapping required. + return false; + } } diff --git a/lib/classes/event/email_failed.php b/lib/classes/event/email_failed.php index 461f4581c93..1834ef635a4 100644 --- a/lib/classes/event/email_failed.php +++ b/lib/classes/event/email_failed.php @@ -94,4 +94,8 @@ class email_failed extends base { throw new \coding_exception('The \'errorinfo\' value must be set in other.'); } } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/grade_deleted.php b/lib/classes/event/grade_deleted.php index ffb65439517..b82b98d736d 100644 --- a/lib/classes/event/grade_deleted.php +++ b/lib/classes/event/grade_deleted.php @@ -131,4 +131,8 @@ class grade_deleted extends base { throw new \coding_exception('The \'overridden\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'grade_grades', 'restore' => 'grade_grades'); + } } diff --git a/lib/classes/event/group_created.php b/lib/classes/event/group_created.php index 504ba3daedf..71421da72c8 100644 --- a/lib/classes/event/group_created.php +++ b/lib/classes/event/group_created.php @@ -90,4 +90,8 @@ class group_created extends base { $this->data['edulevel'] = self::LEVEL_OTHER; $this->data['objecttable'] = 'groups'; } + + public static function get_objectid_mapping() { + return array('db' => 'groups', 'restore' => 'group'); + } } diff --git a/lib/classes/event/group_deleted.php b/lib/classes/event/group_deleted.php index 22294d15e01..b574cb43abf 100644 --- a/lib/classes/event/group_deleted.php +++ b/lib/classes/event/group_deleted.php @@ -90,4 +90,8 @@ class group_deleted extends base { $this->data['edulevel'] = self::LEVEL_OTHER; $this->data['objecttable'] = 'groups'; } + + public static function get_objectid_mapping() { + return array('db' => 'groups', 'restore' => 'group'); + } } diff --git a/lib/classes/event/group_member_added.php b/lib/classes/event/group_member_added.php index 1da73bca3e2..2718a0725fe 100644 --- a/lib/classes/event/group_member_added.php +++ b/lib/classes/event/group_member_added.php @@ -125,4 +125,13 @@ class group_member_added extends base { throw new \coding_exception('The \'itemid\' value must be set in other, even if empty.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'groups', 'restore' => 'group'); + } + + public static function get_other_mapping() { + // Nothing to map. + return false; + } } diff --git a/lib/classes/event/group_member_removed.php b/lib/classes/event/group_member_removed.php index 1acc7789fb5..938313c65c8 100644 --- a/lib/classes/event/group_member_removed.php +++ b/lib/classes/event/group_member_removed.php @@ -108,4 +108,9 @@ class group_member_removed extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'groups', 'restore' => 'group'); + } + } diff --git a/lib/classes/event/group_updated.php b/lib/classes/event/group_updated.php index 5882b5527a5..e56a5d99dd9 100644 --- a/lib/classes/event/group_updated.php +++ b/lib/classes/event/group_updated.php @@ -90,4 +90,8 @@ class group_updated extends base { $this->data['edulevel'] = self::LEVEL_OTHER; $this->data['objecttable'] = 'groups'; } + + public static function get_objectid_mapping() { + return array('db' => 'groups', 'restore' => 'group'); + } } diff --git a/lib/classes/event/grouping_created.php b/lib/classes/event/grouping_created.php index 7ab5f79bcde..eb58c0d9029 100644 --- a/lib/classes/event/grouping_created.php +++ b/lib/classes/event/grouping_created.php @@ -90,4 +90,8 @@ class grouping_created extends base { $this->data['edulevel'] = self::LEVEL_OTHER; $this->data['objecttable'] = 'groupings'; } + + public static function get_objectid_mapping() { + return array('db' => 'groupings', 'restore' => 'grouping'); + } } diff --git a/lib/classes/event/grouping_deleted.php b/lib/classes/event/grouping_deleted.php index 8a7235ad14b..ac1188ed60b 100644 --- a/lib/classes/event/grouping_deleted.php +++ b/lib/classes/event/grouping_deleted.php @@ -97,4 +97,8 @@ class grouping_deleted extends base { $this->data['edulevel'] = self::LEVEL_OTHER; $this->data['objecttable'] = 'groupings'; } + + public static function get_objectid_mapping() { + return array('db' => 'groupings', 'restore' => 'grouping'); + } } diff --git a/lib/classes/event/grouping_updated.php b/lib/classes/event/grouping_updated.php index 2917da77bff..1892198d7ae 100644 --- a/lib/classes/event/grouping_updated.php +++ b/lib/classes/event/grouping_updated.php @@ -90,4 +90,8 @@ class grouping_updated extends base { $this->data['edulevel'] = self::LEVEL_OTHER; $this->data['objecttable'] = 'groupings'; } + + public static function get_objectid_mapping() { + return array('db' => 'groupings', 'restore' => 'grouping'); + } } diff --git a/lib/classes/event/message_contact_added.php b/lib/classes/event/message_contact_added.php index 6240f6121a2..916f82783d2 100644 --- a/lib/classes/event/message_contact_added.php +++ b/lib/classes/event/message_contact_added.php @@ -94,4 +94,9 @@ class message_contact_added extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Messaging contacts are not backed up, so no need to map them. + return false; + } } diff --git a/lib/classes/event/message_contact_blocked.php b/lib/classes/event/message_contact_blocked.php index 959f3c4ed37..43ec640786c 100644 --- a/lib/classes/event/message_contact_blocked.php +++ b/lib/classes/event/message_contact_blocked.php @@ -94,4 +94,9 @@ class message_contact_blocked extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Messaging contacts are not backed up, so no need to map them. + return false; + } } diff --git a/lib/classes/event/message_contact_removed.php b/lib/classes/event/message_contact_removed.php index c87f837da0d..59979e2cc6a 100644 --- a/lib/classes/event/message_contact_removed.php +++ b/lib/classes/event/message_contact_removed.php @@ -94,4 +94,9 @@ class message_contact_removed extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Messaging contacts are not backed up, so no need to map them. + return false; + } } diff --git a/lib/classes/event/message_contact_unblocked.php b/lib/classes/event/message_contact_unblocked.php index 48f5a07a70e..75d58917ef9 100644 --- a/lib/classes/event/message_contact_unblocked.php +++ b/lib/classes/event/message_contact_unblocked.php @@ -94,4 +94,9 @@ class message_contact_unblocked extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Messaging contacts are not backed up, so no need to map them. + return false; + } } diff --git a/lib/classes/event/message_deleted.php b/lib/classes/event/message_deleted.php index 5d3f71bc419..6ccf2e0d65f 100644 --- a/lib/classes/event/message_deleted.php +++ b/lib/classes/event/message_deleted.php @@ -142,4 +142,9 @@ class message_deleted extends base { throw new \coding_exception('The \'useridto\' value must be set in other.'); } } + + public static function get_other_mapping() { + // Messages are not backed up, so no need to map them. + return false; + } } diff --git a/lib/classes/event/message_sent.php b/lib/classes/event/message_sent.php index 4f11edb63ca..297c6ad8cc8 100644 --- a/lib/classes/event/message_sent.php +++ b/lib/classes/event/message_sent.php @@ -144,4 +144,14 @@ class message_sent extends base { throw new \coding_exception('The \'messageid\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Messages are not backed up, so no need to map them. + return false; + } + + public static function get_other_mapping() { + // Messages are not backed up, so no need to map them. + return false; + } } diff --git a/lib/classes/event/message_viewed.php b/lib/classes/event/message_viewed.php index d5eab52e2a5..a5c815a71cc 100644 --- a/lib/classes/event/message_viewed.php +++ b/lib/classes/event/message_viewed.php @@ -95,4 +95,14 @@ class message_viewed extends base { throw new \coding_exception('The \'messageid\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Messages are not backed up, so no need to map them. + return false; + } + + public static function get_other_mapping() { + // Messages are not backed up, so no need to map them. + return false; + } } diff --git a/lib/classes/event/mnet_access_control_created.php b/lib/classes/event/mnet_access_control_created.php index 1725ddd8222..56fdb7f15eb 100644 --- a/lib/classes/event/mnet_access_control_created.php +++ b/lib/classes/event/mnet_access_control_created.php @@ -113,4 +113,14 @@ class mnet_access_control_created extends base { throw new \coding_exception('The \'accessctrl\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Mnet info is not backed up, so no need to map. + return false; + } + + public static function get_other_mapping() { + // Mnet info is not backed up, so no need to map. + return false; + } } diff --git a/lib/classes/event/mnet_access_control_updated.php b/lib/classes/event/mnet_access_control_updated.php index cc8b8752351..a9737d07707 100644 --- a/lib/classes/event/mnet_access_control_updated.php +++ b/lib/classes/event/mnet_access_control_updated.php @@ -113,4 +113,14 @@ class mnet_access_control_updated extends base { throw new \coding_exception('The \'accessctrl\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Mnet info is not backed up, so no need to map. + return false; + } + + public static function get_other_mapping() { + // Mnet info is not backed up, so no need to map. + return false; + } } diff --git a/lib/classes/event/note_created.php b/lib/classes/event/note_created.php index e6720eb8353..aa407d1e490 100644 --- a/lib/classes/event/note_created.php +++ b/lib/classes/event/note_created.php @@ -106,4 +106,14 @@ class note_created extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Notes are not backed up, so no need to map. + return false; + } + + public static function get_other_mapping() { + // Notes are not backed up, so no need to map. + return false; + } } diff --git a/lib/classes/event/note_deleted.php b/lib/classes/event/note_deleted.php index 0e127cad45f..cce5fb8f4f0 100644 --- a/lib/classes/event/note_deleted.php +++ b/lib/classes/event/note_deleted.php @@ -96,4 +96,14 @@ class note_deleted extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Notes are not backed up, so no need to map. + return false; + } + + public static function get_other_mapping() { + // Notes are not backed up, so no need to map. + return false; + } } diff --git a/lib/classes/event/note_updated.php b/lib/classes/event/note_updated.php index 816816b6fcb..8744e066a75 100644 --- a/lib/classes/event/note_updated.php +++ b/lib/classes/event/note_updated.php @@ -106,4 +106,14 @@ class note_updated extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Notes are not backed up, so no need to map. + return false; + } + + public static function get_other_mapping() { + // Notes are not backed up, so no need to map. + return false; + } } diff --git a/lib/classes/event/notes_viewed.php b/lib/classes/event/notes_viewed.php index ccbbc5d2148..1e38e6d3f7c 100644 --- a/lib/classes/event/notes_viewed.php +++ b/lib/classes/event/notes_viewed.php @@ -86,4 +86,14 @@ class notes_viewed extends base { return array($this->courseid, 'notes', 'view', 'index.php?course=' . $this->courseid.'&user=' . $this->relateduserid, 'view notes'); } + + public static function get_objectid_mapping() { + // Notes are not backed up, so no need to map. + return false; + } + + public static function get_other_mapping() { + // Notes are not backed up, so no need to map. + return false; + } } diff --git a/lib/classes/event/question_category_created.php b/lib/classes/event/question_category_created.php index 99a06fbea5f..dd011eccb83 100644 --- a/lib/classes/event/question_category_created.php +++ b/lib/classes/event/question_category_created.php @@ -96,4 +96,8 @@ class question_category_created extends base { // This is not related to individual quiz at all. return null; } + + public static function get_objectid_mapping() { + return array('db' => 'question_categories', 'restore' => 'question_category'); + } } diff --git a/lib/classes/event/role_assigned.php b/lib/classes/event/role_assigned.php index 78682dad9e8..098ff753255 100644 --- a/lib/classes/event/role_assigned.php +++ b/lib/classes/event/role_assigned.php @@ -131,4 +131,13 @@ class role_assigned extends base { throw new \coding_exception('The \'component\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'role', 'restore' => 'role'); + } + + public static function get_other_mapping() { + // Nothing mappable. + return false; + } } diff --git a/lib/classes/event/role_capabilities_updated.php b/lib/classes/event/role_capabilities_updated.php index 887c8e3a22d..e94e768cb4a 100644 --- a/lib/classes/event/role_capabilities_updated.php +++ b/lib/classes/event/role_capabilities_updated.php @@ -98,4 +98,8 @@ class role_capabilities_updated extends base { protected function get_legacy_logdata() { return $this->legacylogdata; } + + public static function get_objectid_mapping() { + return array('db' => 'role', 'restore' => 'role'); + } } diff --git a/lib/classes/event/role_deleted.php b/lib/classes/event/role_deleted.php index 9b5a2e2bd0f..2c75a8cf696 100644 --- a/lib/classes/event/role_deleted.php +++ b/lib/classes/event/role_deleted.php @@ -102,4 +102,8 @@ class role_deleted extends base { throw new \coding_exception('The \'shortname\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'role', 'restore' => 'role'); + } } diff --git a/lib/classes/event/role_unassigned.php b/lib/classes/event/role_unassigned.php index bb788c2186d..810c2f49f76 100644 --- a/lib/classes/event/role_unassigned.php +++ b/lib/classes/event/role_unassigned.php @@ -128,4 +128,12 @@ class role_unassigned extends base { throw new \coding_exception('The \'component\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'role', 'restore' => 'role'); + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/tag_added.php b/lib/classes/event/tag_added.php index 3c7558c5ce3..be93b086b84 100644 --- a/lib/classes/event/tag_added.php +++ b/lib/classes/event/tag_added.php @@ -117,4 +117,14 @@ class tag_added extends base { throw new \coding_exception('The \'tagrawname\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Tags cannot be mapped by id. + return false; + } + + public static function get_other_mapping() { + return false; + } + } diff --git a/lib/classes/event/tag_created.php b/lib/classes/event/tag_created.php index 858339e840d..e49588a8f4e 100644 --- a/lib/classes/event/tag_created.php +++ b/lib/classes/event/tag_created.php @@ -87,4 +87,13 @@ class tag_created extends base { throw new \coding_exception('The \'rawname\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Tags cannot be mapped by id. + return false; + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/tag_deleted.php b/lib/classes/event/tag_deleted.php index 2598087a149..d1c8f2fbdc5 100644 --- a/lib/classes/event/tag_deleted.php +++ b/lib/classes/event/tag_deleted.php @@ -87,4 +87,13 @@ class tag_deleted extends base { throw new \coding_exception('The \'rawname\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Tags cannot be mapped by id. + return false; + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/tag_flagged.php b/lib/classes/event/tag_flagged.php index 4a675fbd5f1..6ab16e57d5f 100644 --- a/lib/classes/event/tag_flagged.php +++ b/lib/classes/event/tag_flagged.php @@ -96,4 +96,13 @@ class tag_flagged extends base { throw new \coding_exception('The \'rawname\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Tags cannot be mapped by id. + return false; + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/tag_removed.php b/lib/classes/event/tag_removed.php index fe0c1cfaa9e..1b6b6c56f46 100644 --- a/lib/classes/event/tag_removed.php +++ b/lib/classes/event/tag_removed.php @@ -103,4 +103,14 @@ class tag_removed extends base { throw new \coding_exception('The \'tagrawname\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Tags cannot be mapped. + return false; + } + + public static function get_other_mapping() { + return false; + } + } diff --git a/lib/classes/event/tag_unflagged.php b/lib/classes/event/tag_unflagged.php index f9e43782ff5..fc8cb4db8cc 100644 --- a/lib/classes/event/tag_unflagged.php +++ b/lib/classes/event/tag_unflagged.php @@ -87,4 +87,14 @@ class tag_unflagged extends base { throw new \coding_exception('The \'rawname\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Tags cannot be mapped. + return false; + } + + public static function get_other_mapping() { + return false; + } + } diff --git a/lib/classes/event/tag_updated.php b/lib/classes/event/tag_updated.php index 6ec1853e5d4..817baeaf9b0 100644 --- a/lib/classes/event/tag_updated.php +++ b/lib/classes/event/tag_updated.php @@ -112,4 +112,14 @@ class tag_updated extends base { throw new \coding_exception('The \'rawname\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Tags cannot be mapped. + return false; + } + + public static function get_other_mapping() { + return false; + } + } diff --git a/lib/classes/event/user_created.php b/lib/classes/event/user_created.php index d6aa4391e8a..2fb3200de7f 100644 --- a/lib/classes/event/user_created.php +++ b/lib/classes/event/user_created.php @@ -133,4 +133,8 @@ class user_created extends base { $event = self::create($data); return $event; } + + public static function get_objectid_mapping() { + return array('db' => 'user', 'restore' => 'user'); + } } diff --git a/lib/classes/event/user_deleted.php b/lib/classes/event/user_deleted.php index 877ec5a46cd..418f72a0b5f 100644 --- a/lib/classes/event/user_deleted.php +++ b/lib/classes/event/user_deleted.php @@ -141,4 +141,12 @@ class user_deleted extends base { throw new \coding_exception('The \'mnethostid\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'user', 'restore' => 'user'); + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/user_enrolment_created.php b/lib/classes/event/user_enrolment_created.php index 7f84fbc0dd8..17d720cb4c0 100644 --- a/lib/classes/event/user_enrolment_created.php +++ b/lib/classes/event/user_enrolment_created.php @@ -125,4 +125,13 @@ class user_enrolment_created extends base { throw new \coding_exception('The \'enrol\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // User enrolments table is not mappable. + return false; + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/user_enrolment_deleted.php b/lib/classes/event/user_enrolment_deleted.php index 59b60ecc191..0c4f5026547 100644 --- a/lib/classes/event/user_enrolment_deleted.php +++ b/lib/classes/event/user_enrolment_deleted.php @@ -124,4 +124,13 @@ class user_enrolment_deleted extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // User enrolments table is not mappable. + return false; + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/user_enrolment_updated.php b/lib/classes/event/user_enrolment_updated.php index 9d9d2e87808..1219d19cd6f 100644 --- a/lib/classes/event/user_enrolment_updated.php +++ b/lib/classes/event/user_enrolment_updated.php @@ -114,4 +114,13 @@ class user_enrolment_updated extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // User enrolments table is not mappable. + return false; + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/user_graded.php b/lib/classes/event/user_graded.php index 479b4ddd36c..98a6a955589 100644 --- a/lib/classes/event/user_graded.php +++ b/lib/classes/event/user_graded.php @@ -156,4 +156,15 @@ class user_graded extends base { throw new \coding_exception('The \'itemid\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'grade_grades', 'restore' => 'grade_grades'); + } + + public static function get_other_mapping() { + $othermapped = array(); + $othermapped['itemid'] = array('db' => 'grade_items', 'restore' => 'grade_item'); + + return $othermapped; + } } diff --git a/lib/classes/event/user_list_viewed.php b/lib/classes/event/user_list_viewed.php index 002fbfe2084..ff1fec00dcb 100644 --- a/lib/classes/event/user_list_viewed.php +++ b/lib/classes/event/user_list_viewed.php @@ -88,4 +88,12 @@ class user_list_viewed extends base { protected function get_legacy_logdata() { return array($this->courseid, 'user', 'view all', 'index.php?id=' . $this->courseid, ''); } + + public static function get_objectid_mapping() { + return array('db' => 'course', 'restore' => 'course'); + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/user_loggedin.php b/lib/classes/event/user_loggedin.php index 53e3b765093..e199d003116 100644 --- a/lib/classes/event/user_loggedin.php +++ b/lib/classes/event/user_loggedin.php @@ -113,4 +113,12 @@ class user_loggedin extends base { throw new \coding_exception('The \'username\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'user', 'restore' => 'user'); + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/user_loggedinas.php b/lib/classes/event/user_loggedinas.php index 494038fd001..64c1f61e50c 100644 --- a/lib/classes/event/user_loggedinas.php +++ b/lib/classes/event/user_loggedinas.php @@ -112,4 +112,12 @@ class user_loggedinas extends base { throw new \coding_exception('The \'loggedinasusername\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'user', 'restore' => 'user'); + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/user_loggedout.php b/lib/classes/event/user_loggedout.php index 7131a5a38f7..e3831a53687 100644 --- a/lib/classes/event/user_loggedout.php +++ b/lib/classes/event/user_loggedout.php @@ -105,4 +105,12 @@ class user_loggedout extends base { return array(SITEID, 'user', 'logout', 'view.php?id='.$this->objectid.'&course='.SITEID, $this->objectid, 0, $this->objectid); } + + public static function get_objectid_mapping() { + return array('db' => 'user', 'restore' => 'user'); + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/user_login_failed.php b/lib/classes/event/user_login_failed.php index 8c8d20a25bb..1214b49df04 100644 --- a/lib/classes/event/user_login_failed.php +++ b/lib/classes/event/user_login_failed.php @@ -113,4 +113,7 @@ class user_login_failed extends base { } } + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/user_password_updated.php b/lib/classes/event/user_password_updated.php index ef7dbe8b538..72aa3232b21 100644 --- a/lib/classes/event/user_password_updated.php +++ b/lib/classes/event/user_password_updated.php @@ -130,4 +130,8 @@ class user_password_updated extends base { throw new \coding_exception('The \'forgottenreset\' value must be set in other.'); } } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/user_profile_viewed.php b/lib/classes/event/user_profile_viewed.php index d2541955606..bd6bb690cea 100644 --- a/lib/classes/event/user_profile_viewed.php +++ b/lib/classes/event/user_profile_viewed.php @@ -111,4 +111,15 @@ class user_profile_viewed extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + return array('db' => 'user', 'restore' => 'user'); + } + + public static function get_other_mapping() { + $othermapped = array(); + $othermapped['courseid'] = array('db' => 'course', 'restore' => 'course'); + + return $othermapped; + } } diff --git a/lib/classes/event/user_updated.php b/lib/classes/event/user_updated.php index 1e5e27ab623..52827de4037 100644 --- a/lib/classes/event/user_updated.php +++ b/lib/classes/event/user_updated.php @@ -133,4 +133,8 @@ class user_updated extends base { $event = self::create($data); return $event; } + + public static function get_objectid_mapping() { + return array('db' => 'user', 'restore' => 'user'); + } } diff --git a/lib/classes/event/webservice_function_called.php b/lib/classes/event/webservice_function_called.php index b1bde22dbc3..95618487cfd 100644 --- a/lib/classes/event/webservice_function_called.php +++ b/lib/classes/event/webservice_function_called.php @@ -105,4 +105,8 @@ class webservice_function_called extends base { throw new \coding_exception('The \'function\' value must be set in other.'); } } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/webservice_login_failed.php b/lib/classes/event/webservice_login_failed.php index e65e6e1bba6..d372de894b5 100644 --- a/lib/classes/event/webservice_login_failed.php +++ b/lib/classes/event/webservice_login_failed.php @@ -123,4 +123,8 @@ class webservice_login_failed extends base { throw new \coding_exception('The \'token\' value must not be set in other.'); } } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/webservice_service_created.php b/lib/classes/event/webservice_service_created.php index 6a64a6ee1c0..b17ea6fc155 100644 --- a/lib/classes/event/webservice_service_created.php +++ b/lib/classes/event/webservice_service_created.php @@ -91,4 +91,13 @@ class webservice_service_created extends base { $this->data['edulevel'] = self::LEVEL_OTHER; $this->data['objecttable'] = 'external_services'; } + + public static function get_objectid_mapping() { + // Webservices are not included in the backups. + return false; + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/webservice_service_deleted.php b/lib/classes/event/webservice_service_deleted.php index 120dc708a0a..a10c094665d 100644 --- a/lib/classes/event/webservice_service_deleted.php +++ b/lib/classes/event/webservice_service_deleted.php @@ -85,4 +85,10 @@ class webservice_service_deleted extends base { $this->data['edulevel'] = self::LEVEL_OTHER; $this->data['objecttable'] = 'external_services'; } + + public static function get_objectid_mapping() { + // Webservices are not included in backups. + return false; + } + } diff --git a/lib/classes/event/webservice_service_updated.php b/lib/classes/event/webservice_service_updated.php index a84f4fc20b1..c078f92cafe 100644 --- a/lib/classes/event/webservice_service_updated.php +++ b/lib/classes/event/webservice_service_updated.php @@ -85,4 +85,10 @@ class webservice_service_updated extends base { $this->data['edulevel'] = self::LEVEL_OTHER; $this->data['objecttable'] = 'external_services'; } + + public static function get_objectid_mapping() { + // Webservices are not included in backups. + return false; + } + } diff --git a/lib/classes/event/webservice_service_user_added.php b/lib/classes/event/webservice_service_user_added.php index 2d423782ec6..662a2aa0f9d 100644 --- a/lib/classes/event/webservice_service_user_added.php +++ b/lib/classes/event/webservice_service_user_added.php @@ -98,4 +98,10 @@ class webservice_service_user_added extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Webservices are not included in backups. + return false; + } + } diff --git a/lib/classes/event/webservice_service_user_removed.php b/lib/classes/event/webservice_service_user_removed.php index 50ae27c472b..9488fdda9fd 100644 --- a/lib/classes/event/webservice_service_user_removed.php +++ b/lib/classes/event/webservice_service_user_removed.php @@ -98,4 +98,10 @@ class webservice_service_user_removed extends base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_objectid_mapping() { + // Webservices are not included in backups. + return false; + } + } diff --git a/lib/classes/event/webservice_token_created.php b/lib/classes/event/webservice_token_created.php index a816dbead50..a3f375847a3 100644 --- a/lib/classes/event/webservice_token_created.php +++ b/lib/classes/event/webservice_token_created.php @@ -108,4 +108,13 @@ class webservice_token_created extends base { throw new \coding_exception('The \'auto\' value must be set in other.'); } } + + public static function get_objectid_mapping() { + // Webservices are not included in backups. + return false; + } + + public static function get_other_mapping() { + return false; + } } diff --git a/lib/classes/event/webservice_token_sent.php b/lib/classes/event/webservice_token_sent.php index f9d9f21c3e6..527036c50a1 100644 --- a/lib/classes/event/webservice_token_sent.php +++ b/lib/classes/event/webservice_token_sent.php @@ -73,4 +73,9 @@ class webservice_token_sent extends base { $this->data['edulevel'] = self::LEVEL_OTHER; $this->data['objecttable'] = 'external_tokens'; } + + public static function get_objectid_mapping() { + // Webservices are not included in backups. + return false; + } } diff --git a/report/log/classes/event/report_viewed.php b/report/log/classes/event/report_viewed.php index d8ef4b46ec9..eaf24ab0654 100644 --- a/report/log/classes/event/report_viewed.php +++ b/report/log/classes/event/report_viewed.php @@ -123,4 +123,12 @@ class report_viewed extends \core\event\base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_other_mapping() { + $othermapped = array(); + $othermapped['modid'] = array('db' => 'course_modules', 'restore' => 'course_module'); + $othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group'); + + return $othermapped; + } } diff --git a/report/log/classes/event/user_report_viewed.php b/report/log/classes/event/user_report_viewed.php index d553306d0f4..8ac4302a873 100644 --- a/report/log/classes/event/user_report_viewed.php +++ b/report/log/classes/event/user_report_viewed.php @@ -105,4 +105,5 @@ class user_report_viewed extends \core\event\base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + } diff --git a/report/outline/classes/event/activity_report_viewed.php b/report/outline/classes/event/activity_report_viewed.php index 507e8135965..09df8365a53 100644 --- a/report/outline/classes/event/activity_report_viewed.php +++ b/report/outline/classes/event/activity_report_viewed.php @@ -80,4 +80,5 @@ class activity_report_viewed extends \core\event\base { public function get_url() { return new \moodle_url('/report/outline/index.php', array('course' => $this->courseid)); } + } diff --git a/report/outline/classes/event/report_viewed.php b/report/outline/classes/event/report_viewed.php index d9397bd2bbd..820ab9f6a6c 100644 --- a/report/outline/classes/event/report_viewed.php +++ b/report/outline/classes/event/report_viewed.php @@ -105,4 +105,10 @@ class report_viewed extends \core\event\base { throw new \coding_exception('The \'relateduserid\' must be set.'); } } + + public static function get_other_mapping() { + // Nothing to map. + return array(); + } + } diff --git a/report/participation/classes/event/report_viewed.php b/report/participation/classes/event/report_viewed.php index d5b9d8b5159..8a4d8aea4f1 100644 --- a/report/participation/classes/event/report_viewed.php +++ b/report/participation/classes/event/report_viewed.php @@ -120,6 +120,19 @@ class report_viewed extends \core\event\base { if (!isset($this->other['action'])) { throw new \coding_exception('The \'action\' value must be set in other.'); } + + } + + public static function get_other_mapping() { + $othermapped = array(); + // This is a badly named variable - it represents "cm->id" not "cm->instance". + $othermapped['instanceid'] = array('db' => 'course_modules', 'restore' => 'course_module'); + + $othermapped['roleid'] = array('db' => 'role', 'restore' => 'role'); + $othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group'); + + return $othermapped; + } } diff --git a/report/questioninstances/classes/event/report_viewed.php b/report/questioninstances/classes/event/report_viewed.php index 5e79da8f724..682f2fdbb36 100644 --- a/report/questioninstances/classes/event/report_viewed.php +++ b/report/questioninstances/classes/event/report_viewed.php @@ -100,5 +100,10 @@ class report_viewed extends \core\event\base { throw new \coding_exception('The \'requestedqtype\' value must be set in other.'); } } + + public static function get_other_mapping() { + // Nothing to map. + return array(); + } }