mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-47076 badges: Add checks to user fields during badges restoration
Change-Id: Iff6402d1da835ed57dc17d079adf1bbd2e76dd6c
This commit is contained in:
parent
457f818026
commit
927ea484ec
1 changed files with 12 additions and 0 deletions
|
@ -2114,7 +2114,13 @@ class restore_badges_structure_step extends restore_structure_step {
|
||||||
|
|
||||||
$data = (object)$data;
|
$data = (object)$data;
|
||||||
$data->usercreated = $this->get_mappingid('user', $data->usercreated);
|
$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);
|
$data->usermodified = $this->get_mappingid('user', $data->usermodified);
|
||||||
|
if (empty($data->usermodified)) {
|
||||||
|
$data->usermodified = $this->task->get_userid();
|
||||||
|
}
|
||||||
|
|
||||||
// We'll restore the badge image.
|
// We'll restore the badge image.
|
||||||
$restorefiles = true;
|
$restorefiles = true;
|
||||||
|
@ -2211,6 +2217,12 @@ class restore_badges_structure_step extends restore_structure_step {
|
||||||
'issuerrole' => $role,
|
'issuerrole' => $role,
|
||||||
'datemet' => $this->apply_date_offset($data->datemet)
|
'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);
|
$DB->insert_record('badge_manual_award', $award);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue