Permalink
Browse files

MDL-47076 badges: Add checks to user fields during badges restoration

Change-Id: Iff6402d1da835ed57dc17d079adf1bbd2e76dd6c
  • Loading branch information...
DavidCurry committed Sep 3, 2014
1 parent 457f818 commit 927ea484ecfd453b0ed34e36dab832727bdd03d4
Showing with 12 additions and 0 deletions.
  1. +12 −0 backup/moodle2/restore_stepslib.php
@@ -2114,7 +2114,13 @@ public function process_badge($data) {
$data = (object)$data;
$data->usercreated = $this->get_mappingid('user', $data->usercreated);
if (empty($data->usercreated)) {
$data->usercreated = $this->task->get_userid();
}
$data->usermodified = $this->get_mappingid('user', $data->usermodified);
if (empty($data->usermodified)) {
$data->usermodified = $this->task->get_userid();
}
// We'll restore the badge image.
$restorefiles = true;
@@ -2211,6 +2217,12 @@ public function process_manual_award($data) {
'issuerrole' => $role,
'datemet' => $this->apply_date_offset($data->datemet)
);
// Skip the manual award if recipient or issuer can not be mapped to.
if (empty($award['recipientid']) || empty($award['issuerid'])) {
return;
}
$DB->insert_record('badge_manual_award', $award);
}
}

0 comments on commit 927ea48

Please sign in to comment.