MDL-46455 events: added more mapping

Also fixed a few bugs.
This commit is contained in:
Mark Nelson 2015-10-06 16:44:18 -07:00
parent 3d0fff3a83
commit 607021c14b
54 changed files with 244 additions and 49 deletions

View File

@ -112,4 +112,9 @@ class langpack_imported extends \core\event\base {
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;
}
}

View File

@ -113,4 +113,9 @@ class langpack_removed extends \core\event\base {
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;
}
}

View File

@ -112,4 +112,9 @@ class langpack_updated extends \core\event\base {
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;
}
}

View File

@ -98,4 +98,11 @@ class badge_awarded extends base {
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;
}
}

View File

@ -109,6 +109,8 @@ class blog_entries_viewed extends base {
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');

View File

@ -102,11 +102,13 @@ abstract class comment_created extends base {
}
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;
}
}

View File

@ -102,11 +102,13 @@ abstract class comment_deleted extends base {
}
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;
}
}

View File

@ -141,4 +141,9 @@ class course_category_deleted extends base {
// 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;
}
}

View File

@ -137,7 +137,7 @@ class course_completed extends base {
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() {

View File

@ -123,4 +123,9 @@ class course_created extends base {
public static function get_objectid_mapping() {
return array('db' => 'course', 'restore' => 'course');
}
public static function get_other_mapping() {
// Nothing to map.
return false;
}
}

View File

@ -118,4 +118,9 @@ class course_deleted extends base {
public static function get_objectid_mapping() {
return array('db' => 'course', 'restore' => 'course');
}
public static function get_other_mapping() {
// Nothing to map.
return false;
}
}

View File

@ -29,6 +29,12 @@ defined('MOODLE_INTERNAL') || die();
/**
* 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>
@ -110,6 +116,13 @@ class course_module_completion_updated extends base {
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;
}
}

View File

@ -171,7 +171,10 @@ class course_module_created extends base {
}
public static function get_other_mapping() {
return false;
$othermapped = array();
$othermapped['instanceid'] = base::NOT_MAPPED;
return $othermapped;
}
}

View File

@ -123,5 +123,12 @@ class course_module_deleted extends base {
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;
}
}

View File

@ -169,7 +169,10 @@ class course_module_updated extends base {
}
public static function get_other_mapping() {
return false;
$othermapping = array();
$othermapping['instanceid'] = base::NOT_MAPPED;
return $othermapping;
}
}

View File

@ -141,4 +141,9 @@ class course_restored extends base {
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;
}
}

View File

@ -108,4 +108,9 @@ class course_section_updated extends base {
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;
}
}

View File

@ -121,4 +121,9 @@ class course_updated extends base {
public static function get_objectid_mapping() {
return array('db' => 'course', 'restore' => 'course');
}
public static function get_other_mapping() {
// Nothing to map.
return false;
}
}

View File

@ -114,4 +114,9 @@ class course_user_report_viewed extends base {
throw new \coding_exception('The \'mode\' value must be set in other.');
}
}
public static function get_other_mapping() {
// Nothing to map.
return false;
}
}

View File

@ -30,6 +30,14 @@ defined('MOODLE_INTERNAL') || die();
/**
* 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>

View File

@ -106,4 +106,13 @@ class enrol_instance_created extends base {
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;
}
}

View File

@ -107,4 +107,13 @@ class enrol_instance_deleted extends base {
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;
}
}

View File

@ -107,4 +107,13 @@ class enrol_instance_updated extends base {
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;
}
}

View File

@ -135,4 +135,11 @@ class grade_deleted extends base {
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;
}
}

View File

@ -131,7 +131,9 @@ class group_member_added extends base {
}
public static function get_other_mapping() {
// Nothing to map.
return false;
$othermapped = array();
$othermapped['itemid'] = base::NOT_MAPPED;
return $othermapped;
}
}

View File

@ -86,14 +86,4 @@ class notes_viewed extends base {
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;
}
}

View File

@ -137,7 +137,10 @@ class role_assigned extends base {
}
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;
}
}

View File

@ -106,4 +106,9 @@ class role_deleted extends base {
public static function get_objectid_mapping() {
return array('db' => 'role', 'restore' => 'role');
}
public static function get_other_mapping() {
// Nothing to map.
return false;
}
}

View File

@ -134,6 +134,10 @@ class role_unassigned extends base {
}
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;
}
}

View File

@ -119,12 +119,15 @@ class tag_added extends base {
}
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;
}
}

View File

@ -89,8 +89,8 @@ class tag_created extends base {
}
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() {

View File

@ -89,8 +89,8 @@ class tag_deleted extends base {
}
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() {

View File

@ -98,8 +98,8 @@ class tag_flagged extends base {
}
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() {

View File

@ -106,11 +106,15 @@ class tag_removed extends base {
public static function get_objectid_mapping() {
// Tags cannot be mapped.
return false;
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;
}
}

View File

@ -90,7 +90,7 @@ class tag_unflagged extends base {
public static function get_objectid_mapping() {
// Tags cannot be mapped.
return false;
return array('db' => 'tag', 'restore' => base::NOT_MAPPED);
}
public static function get_other_mapping() {

View File

@ -115,7 +115,7 @@ class tag_updated extends base {
public static function get_objectid_mapping() {
// Tags cannot be mapped.
return false;
return array('db' => 'tag', 'restore' => base::NOT_MAPPED);
}
public static function get_other_mapping() {

View File

@ -128,7 +128,7 @@ class user_enrolment_created extends base {
public static function get_objectid_mapping() {
// User enrolments table is not mappable.
return false;
return array('db' => 'user_enrolments', 'restore' => base::NOT_MAPPED);
}
public static function get_other_mapping() {

View File

@ -127,7 +127,7 @@ class user_enrolment_deleted extends base {
public static function get_objectid_mapping() {
// User enrolments table is not mappable.
return false;
return array('db' => 'user_enrolments', 'restore' => base::NOT_MAPPED);
}
public static function get_other_mapping() {

View File

@ -117,7 +117,7 @@ class user_enrolment_updated extends base {
public static function get_objectid_mapping() {
// User enrolments table is not mappable.
return false;
return array('db' => 'user_enrolments', 'restore' => base::NOT_MAPPED);
}
public static function get_other_mapping() {

View File

@ -83,6 +83,6 @@ class submission_created extends \mod_assign\event\submission_created {
public static function get_objectid_mapping() {
// No mapping available for 'assignsubmission_file'.
return false;
return array('db' => 'assignsubmission_file', 'restore' => \core\event\base::NOT_MAPPED);
}
}

View File

@ -83,6 +83,6 @@ class submission_updated extends \mod_assign\event\submission_updated {
public static function get_objectid_mapping() {
// No mapping available for 'assignsubmission_file'.
return false;
return array('db' => 'assignsubmission_file', 'restore' => \core\event\base::NOT_MAPPED);
}
}

View File

@ -83,6 +83,6 @@ class submission_created extends \mod_assign\event\submission_created {
public static function get_objectid_mapping() {
// No mapping available for 'assignsubmission_onlinetext'.
return false;
return array('db' => 'assignsubmission_onlinetext', 'restore' => \core\event\base::NOT_MAPPED);
}
}

View File

@ -83,6 +83,6 @@ class submission_updated extends \mod_assign\event\submission_updated {
public static function get_objectid_mapping() {
// No mapping available for 'assignsubmission_onlinetext'.
return false;
return array('db' => 'assignsubmission_onlinetext', 'restore' => \core\event\base::NOT_MAPPED);
}
}

View File

@ -129,7 +129,7 @@ class answer_submitted extends \core\event\base {
// multiple choices, so the value is converted to an array, which is then passed
// to the event. Ideally this event should be triggered every time we insert to the
// 'choice_answers' table so this will only be an int.
// $othermapped['optionid'] = array('db' => 'choice_options', 'restore' => 'choice_option');
$othermapped['optionid'] = \core\event\base::NOT_MAPPED;
return $othermapped;
}

View File

@ -129,7 +129,7 @@ class answer_updated extends \core\event\base {
// multiple choices, so the value is converted to an array, which is then passed
// to the event. Ideally this event should be triggered every time we update the
// 'choice_answers' table so this will only be an int.
// $othermapped['optionid'] = array('db' => 'choice_options', 'restore' => 'choice_option');
$othermapped['optionid'] = \core\event\base::NOT_MAPPED;
return $othermapped;
}

View File

@ -28,6 +28,12 @@ defined('MOODLE_INTERNAL') || die();
/**
* The mod_choice report viewed event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - string content: (optional) The content we are viewing.
* }
*
* @package mod_choice
* @since Moodle 2.6
* @copyright 2013 Adrian Greeve
@ -84,4 +90,9 @@ class report_viewed extends \core\event\base {
public static function get_objectid_mapping() {
return array('db' => 'choice', 'restore' => 'choice');
}
public static function get_other_mapping() {
// No need to map the 'content' value.
return false;
}
}

View File

@ -102,5 +102,10 @@ class course_module_viewed extends \core\event\course_module_viewed {
public static function get_objectid_mapping() {
return array('db' => 'feedback', 'restore' => 'feedback');
}
public static function get_other_mapping() {
// No need to map the 'anonymous' flag.
return false;
}
}

View File

@ -102,7 +102,7 @@ class attempt_deleted extends \core\event\base {
}
public static function get_other_mapping() {
// Can't map the 'attemptid' value.
// Nothing to map.
return false;
}
}

View File

@ -29,6 +29,12 @@ defined('MOODLE_INTERNAL') || die();
/**
* The mod_survery course module viewed event.
*
* @property-read array $other {
* Extra information about the event.
*
* - string viewed: what was viewed
* }
*
* @package mod_survey
* @since Moodle 2.7
* @copyright 2014 Rajesh Taneja <rajesh@moodle.com>
@ -71,4 +77,9 @@ class course_module_viewed extends \core\event\course_module_viewed {
public static function get_objectid_mapping() {
return array('db' => 'survey', 'restore' => 'survey');
}
public static function get_other_mapping() {
// No need to map 'viewed'.
return false;
}
}

View File

@ -28,6 +28,15 @@ defined('MOODLE_INTERNAL') || die();
/**
* The mod_wiki page viewed event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - string title: (optional) the wiki title
* - int wid: (optional) the wiki id
* - int group: (optional) the group id
* - string groupanduser: (optional) the groupid-userid
* }
*
* @package mod_wiki
* @since Moodle 2.7
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
@ -106,4 +115,12 @@ class page_viewed extends \core\event\base {
public static function get_objectid_mapping() {
return array('db' => 'wiki_pages', 'restore' => 'wiki_page');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['wid'] = array('db' => 'wiki', 'restore' => 'wiki');
$othermapped['group'] = array('db' => 'groups', 'restore' => 'group');
return $othermapped;
}
}

View File

@ -106,4 +106,8 @@ class user_report_viewed extends \core\event\base {
}
}
public static function get_other_mapping() {
// Nothing to map.
return false;
}
}

View File

@ -108,7 +108,7 @@ class report_viewed extends \core\event\base {
public static function get_other_mapping() {
// Nothing to map.
return array();
return false;
}
}

View File

@ -103,7 +103,7 @@ class report_viewed extends \core\event\base {
public static function get_other_mapping() {
// Nothing to map.
return array();
return false;
}
}

View File

@ -114,5 +114,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();
}
}