mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-29538 core_condition: changed the logic in the code so that it works with the new database structure as well as tidying up parts of the code
This commit is contained in:
parent
92fb7dd3a5
commit
cb4492c200
5 changed files with 203 additions and 163 deletions
|
@ -523,10 +523,12 @@ class restore_process_course_modules_availability extends restore_execution_step
|
|||
foreach($rs as $availrec) {
|
||||
$allmatchesok = true;
|
||||
// Get the complete availabilityobject
|
||||
$availability = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'module_availability', $availrec->itemid)->info;
|
||||
$availability = restore_dbops::get_backup_ids_record($this->get_restoreid(),
|
||||
'module_availability', $availrec->itemid)->info;
|
||||
// Map the sourcecmid if needed and possible
|
||||
if (!empty($availability->sourcecmid)) {
|
||||
$newcm = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'course_module', $availability->sourcecmid);
|
||||
$newcm = restore_dbops::get_backup_ids_record($this->get_restoreid(),
|
||||
'course_module', $availability->sourcecmid);
|
||||
if ($newcm) {
|
||||
$availability->sourcecmid = $newcm->newitemid;
|
||||
} else {
|
||||
|
@ -535,7 +537,8 @@ class restore_process_course_modules_availability extends restore_execution_step
|
|||
}
|
||||
// Map the gradeitemid if needed and possible
|
||||
if (!empty($availability->gradeitemid)) {
|
||||
$newgi = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'grade_item', $availability->gradeitemid);
|
||||
$newgi = restore_dbops::get_backup_ids_record($this->get_restoreid(),
|
||||
'grade_item', $availability->gradeitemid);
|
||||
if ($newgi) {
|
||||
$availability->gradeitemid = $newgi->newitemid;
|
||||
} else {
|
||||
|
@ -551,7 +554,8 @@ class restore_process_course_modules_availability extends restore_execution_step
|
|||
$params = array('backupid' => $this->get_restoreid(), 'itemname' => 'module_availability_field');
|
||||
$rs = $DB->get_recordset('backup_ids_temp', $params, '', 'itemid');
|
||||
foreach($rs as $availrec) {
|
||||
$availability = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'module_availability_field', $availrec->itemid)->info;
|
||||
$availability = restore_dbops::get_backup_ids_record($this->get_restoreid(),
|
||||
'module_availability_field', $availrec->itemid)->info;
|
||||
$DB->insert_record('course_modules_avail_fields', $availability);
|
||||
}
|
||||
$rs->close();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue