Skip to content
Browse files

MDL-29538 core_condition: backup and restore now works with the new D…

…B structure and removed unneeded restore process
  • Loading branch information...
1 parent e7b4bd3 commit 5fa220fbf3c5ba6aadf9e011dcd612504e9a66f5 @markn86 markn86 committed May 10, 2012
Showing with 12 additions and 6 deletions.
  1. +1 −1 backup/moodle2/backup_stepslib.php
  2. +11 −5 backup/moodle2/restore_stepslib.php
View
2 backup/moodle2/backup_stepslib.php
@@ -323,7 +323,7 @@ protected function define_structure() {
$availability = new backup_nested_element('availability', array('id'), array(
'sourcecmid', 'requiredcompletion', 'gradeitemid', 'grademin', 'grademax'));
$availability_field = new backup_nested_element('availability_field', array('id'), array(
- 'field', 'operator', 'value'));
+ 'userfield', 'customfieldid', 'operator', 'value'));
// attach format plugin structure to $module element, only one allowed
$this->add_plugin_structure('format', $module, false);
View
16 backup/moodle2/restore_stepslib.php
@@ -2655,12 +2655,18 @@ protected function process_availability($data) {
}
protected function process_availability_fields($data) {
+ global $DB;
+
$data = (object)$data;
- // Simply going to store the whole availability record now, we'll process
- // all them later in the final task (once all activities have been restored)
- // Let's call the low level one to be able to store the whole object
- $data->coursemoduleid = $this->task->get_moduleid(); // Let add the availability cmid
- restore_dbops::set_backup_ids_record($this->get_restoreid(), 'module_availability_field', $data->id, 0, null, $data);
+ // Create the object to insert into the database
+ $avail_field = new stdClass();
+ $avail_field->coursemoduleid = $this->task->get_moduleid(); // Lets add the availability cmid
+ $avail_field->userfield = $data->userfield;
+ $avail_field->customfieldid = $data->customfieldid;
+ $avail_field->operator = $data->operator;
+ $avail_field->value = $data->value;
+ // Insert into the database
+ $DB->insert_record('course_modules_avail_fields', $avail_field);
}
}

0 comments on commit 5fa220f

Please sign in to comment.
Something went wrong with that request. Please try again.