Skip to content

Commit

Permalink
MDL-46455 events: added more mapping
Browse files Browse the repository at this point in the history
Also fixed a few bugs.
  • Loading branch information
mdjnelson committed Oct 12, 2015
1 parent 3d0fff3 commit 607021c
Show file tree
Hide file tree
Showing 54 changed files with 244 additions and 49 deletions.
5 changes: 5 additions & 0 deletions admin/tool/langimport/classes/event/langpack_imported.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,9 @@ protected function validate_data() {
throw new \coding_exception('The \'langcode\' value must be set to a valid language code');
}
}

public static function get_other_mapping() {
// No mapping required for this event because this event is not backed up.
return false;
}
}
5 changes: 5 additions & 0 deletions admin/tool/langimport/classes/event/langpack_removed.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,9 @@ protected function validate_data() {
throw new \coding_exception('The \'langcode\' value must be set to a valid language code');
}
}

public static function get_other_mapping() {
// No mapping required for this event because this event is not backed up.
return false;
}
}
5 changes: 5 additions & 0 deletions admin/tool/langimport/classes/event/langpack_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,9 @@ protected function validate_data() {
throw new \coding_exception('The \'langcode\' value must be set to a valid language code');
}
}

public static function get_other_mapping() {
// No mapping required for this event because this event is not backed up.
return false;
}
}
7 changes: 7 additions & 0 deletions lib/classes/event/badge_awarded.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,11 @@ protected function validate_data() {
public static function get_objectid_mapping() {
return array('db' => 'badge', 'restore' => 'badge');
}

public static function get_other_mapping() {
$othermapped = array();
$othermapped['badgeissuedid'] = array('db' => 'badge_issued', 'restore' => base::NOT_MAPPED);

return $othermapped;
}
}
2 changes: 2 additions & 0 deletions lib/classes/event/blog_entries_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ protected function get_legacy_logdata() {

public static function get_other_mapping() {
$othermapped = array();
$othermapped['entryid'] = array('db' => 'post', 'restore' => base::NOT_MAPPED);
$othermapped['tagid'] = array('db' => 'tag', 'restore' => base::NOT_MAPPED);
$othermapped['userid'] = array('db' => 'user', 'restore' => 'user');
$othermapped['modid'] = array('db' => 'course_modules', 'restore' => 'course_module');
$othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group');
Expand Down
6 changes: 4 additions & 2 deletions lib/classes/event/comment_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,13 @@ protected function validate_data() {
}

public static function get_objectid_mapping() {
return array('db' => 'comment', 'restore' => 'comment');
return array('db' => 'comments', 'restore' => 'comment');
}

public static function get_other_mapping() {
// We cannot map fields that do not have a 1:1 mapping.
return false;
$othermapped = array();
$othermapped['itemid'] = base::NOT_MAPPED;
return $othermapped;
}
}
6 changes: 4 additions & 2 deletions lib/classes/event/comment_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,13 @@ protected function validate_data() {
}

public static function get_objectid_mapping() {
return array('db' => 'comment', 'restore' => 'comment');
return array('db' => 'comments', 'restore' => 'comment');
}

public static function get_other_mapping() {
// We cannot map fields that do not have a 1:1 mapping.
return false;
$othermapped = array();
$othermapped['itemid'] = base::NOT_MAPPED;
return $othermapped;
}
}
5 changes: 5 additions & 0 deletions lib/classes/event/course_category_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,9 @@ public static function get_objectid_mapping() {
// Categories are not backed up, so no need to map them.
return false;
}

public static function get_other_mapping() {
// Categories are not backed up, so no need to map them.
return false;
}
}
2 changes: 1 addition & 1 deletion lib/classes/event/course_completed.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected function validate_data() {

public static function get_objectid_mapping() {
// Sorry - there is no mapping available for completion records.
return false;
return array('db' => 'course_completions', 'restore' => base::NOT_MAPPED);
}

public static function get_other_mapping() {
Expand Down
5 changes: 5 additions & 0 deletions lib/classes/event/course_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,9 @@ protected function validate_data() {
public static function get_objectid_mapping() {
return array('db' => 'course', 'restore' => 'course');
}

public static function get_other_mapping() {
// Nothing to map.
return false;
}
}
5 changes: 5 additions & 0 deletions lib/classes/event/course_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,9 @@ protected function validate_data() {
public static function get_objectid_mapping() {
return array('db' => 'course', 'restore' => 'course');
}

public static function get_other_mapping() {
// Nothing to map.
return false;
}
}
15 changes: 14 additions & 1 deletion lib/classes/event/course_module_completion_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
/**
* Course module completion event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int relateduserid: (optional) the related user id.
* }
*
* @package core
* @since Moodle 2.6
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
Expand Down Expand Up @@ -110,6 +116,13 @@ protected function validate_data() {

public static function get_objectid_mapping() {
// Sorry mapping info is not available for course modules completion records.
return false;
return array('db' => 'course_modules_completions', 'restore' => base::NOT_MAPPED);
}

public static function get_other_mapping() {
$othermapped = array();
$othermapped['relateduserid'] = array('db' => 'user', 'restore' => 'user');

return $othermapped;
}
}
5 changes: 4 additions & 1 deletion lib/classes/event/course_module_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ public static function get_objectid_mapping() {
}

public static function get_other_mapping() {
return false;
$othermapped = array();
$othermapped['instanceid'] = base::NOT_MAPPED;

return $othermapped;
}
}

7 changes: 7 additions & 0 deletions lib/classes/event/course_module_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,12 @@ protected function validate_data() {
public static function get_objectid_mapping() {
return array('db' => 'course_modules', 'restore' => 'course_module');
}

public static function get_other_mapping() {
$othermapped = array();
$othermapped['instanceid'] = base::NOT_MAPPED;

return $othermapped;
}
}

5 changes: 4 additions & 1 deletion lib/classes/event/course_module_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ public static function get_objectid_mapping() {
}

public static function get_other_mapping() {
return false;
$othermapping = array();
$othermapping['instanceid'] = base::NOT_MAPPED;

return $othermapping;
}
}

5 changes: 5 additions & 0 deletions lib/classes/event/course_restored.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,9 @@ protected function validate_data() {
public static function get_objectid_mapping() {
return array('db' => 'course', 'restore' => 'course');
}

public static function get_other_mapping() {
// No need to map anything.
return false;
}
}
5 changes: 5 additions & 0 deletions lib/classes/event/course_section_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,9 @@ protected function validate_data() {
public static function get_objectid_mapping() {
return array('db' => 'course_sections', 'restore' => 'course_section');
}

public static function get_other_mapping() {
// Nothing to map.
return false;
}
}
5 changes: 5 additions & 0 deletions lib/classes/event/course_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,9 @@ protected function get_legacy_logdata() {
public static function get_objectid_mapping() {
return array('db' => 'course', 'restore' => 'course');
}

public static function get_other_mapping() {
// Nothing to map.
return false;
}
}
5 changes: 5 additions & 0 deletions lib/classes/event/course_user_report_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,9 @@ protected function validate_data() {
throw new \coding_exception('The \'mode\' value must be set in other.');
}
}

public static function get_other_mapping() {
// Nothing to map.
return false;
}
}
8 changes: 8 additions & 0 deletions lib/classes/event/email_failed.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
/**
* Email failed event class.
*
* @property-read array $other {
* Extra information about event.
*
* - string subject: the message subject.
* - string message: the message text.
* - string errorinfo: the error info.
* }
*
* @package core
* @since Moodle 2.7
* @copyright 2013 Mark Nelson <markn@moodle.com>
Expand Down
9 changes: 9 additions & 0 deletions lib/classes/event/enrol_instance_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,13 @@ protected function validate_data() {
throw new \coding_exception('The \'enrol\' value must be set in other.');
}
}

public static function get_objectid_mapping() {
return array('db' => 'enrol', 'restore' => 'enrol');
}

public static function get_other_mapping() {
// Nothing to map.
return false;
}
}
9 changes: 9 additions & 0 deletions lib/classes/event/enrol_instance_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,13 @@ protected function validate_data() {
throw new \coding_exception('The \'enrol\' value must be set in other.');
}
}

public static function get_objectid_mapping() {
return array('db' => 'enrol', 'restore' => 'enrol');
}

public static function get_other_mapping() {
// Nothing to map.
return false;
}
}
9 changes: 9 additions & 0 deletions lib/classes/event/enrol_instance_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,13 @@ protected function validate_data() {
throw new \coding_exception('The \'enrol\' value must be set in other.');
}
}

public static function get_objectid_mapping() {
return array('db' => 'enrol', 'restore' => 'enrol');
}

public static function get_other_mapping() {
// Nothing to map.
return false;
}
}
7 changes: 7 additions & 0 deletions lib/classes/event/grade_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,11 @@ protected function validate_data() {
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;
}
}
6 changes: 4 additions & 2 deletions lib/classes/event/group_member_added.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ public static function get_objectid_mapping() {
}

public static function get_other_mapping() {
// Nothing to map.
return false;
$othermapped = array();
$othermapped['itemid'] = base::NOT_MAPPED;

return $othermapped;
}
}
10 changes: 0 additions & 10 deletions lib/classes/event/notes_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,4 @@ protected function get_legacy_logdata() {
return array($this->courseid, 'notes', 'view', 'index.php?course=' . $this->courseid.'&amp;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;
}
}
7 changes: 5 additions & 2 deletions lib/classes/event/role_assigned.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ public static function get_objectid_mapping() {
}

public static function get_other_mapping() {
// Nothing mappable.
return false;
$othermapped = array();
$othermapped['id'] = array('db' => 'role_assignments', 'restore' => base::NOT_MAPPED);
$othermapped['itemid'] = base::NOT_MAPPED;

return $othermapped;
}
}
5 changes: 5 additions & 0 deletions lib/classes/event/role_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,9 @@ protected function validate_data() {
public static function get_objectid_mapping() {
return array('db' => 'role', 'restore' => 'role');
}

public static function get_other_mapping() {
// Nothing to map.
return false;
}
}
6 changes: 5 additions & 1 deletion lib/classes/event/role_unassigned.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ public static function get_objectid_mapping() {
}

public static function get_other_mapping() {
return false;
$othermapped = array();
$othermapped['id'] = array('db' => 'role_assignments', 'restore' => base::NOT_MAPPED);
$othermapped['itemid'] = base::NOT_MAPPED;

return $othermapped;
}
}
11 changes: 7 additions & 4 deletions lib/classes/event/tag_added.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,15 @@ protected function validate_data() {
}

public static function get_objectid_mapping() {
// Tags cannot be mapped by id.
return false;
// Tags cannot be mapped.
return array('db' => 'tag_instance', 'restore' => base::NOT_MAPPED);
}

public static function get_other_mapping() {
return false;
}
$othermapped = array();
$othermapped['tagid'] = array('db' => 'tag', 'restore' => base::NOT_MAPPED);
$othermapped['itemid'] = base::NOT_MAPPED;

return $othermapped;
}
}
4 changes: 2 additions & 2 deletions lib/classes/event/tag_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ protected function validate_data() {
}

public static function get_objectid_mapping() {
// Tags cannot be mapped by id.
return false;
// Tags cannot be mapped.
return array('db' => 'tag', 'restore' => base::NOT_MAPPED);
}

public static function get_other_mapping() {
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/event/tag_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ protected function validate_data() {
}

public static function get_objectid_mapping() {
// Tags cannot be mapped by id.
return false;
// Tags cannot be mapped.
return array('db' => 'tag', 'restore' => base::NOT_MAPPED);
}

public static function get_other_mapping() {
Expand Down
Loading

0 comments on commit 607021c

Please sign in to comment.