mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-58822-master' of git://github.com/ryanwyllie/moodle
This commit is contained in:
commit
381db2fe8d
@ -863,8 +863,9 @@ class backup_calendarevents_structure_step extends backup_structure_step {
|
||||
|
||||
$event = new backup_nested_element('event', array('id'), array(
|
||||
'name', 'description', 'format', 'courseid', 'groupid', 'userid',
|
||||
'repeatid', 'modulename', 'instance', 'eventtype', 'timestart',
|
||||
'timeduration', 'visible', 'uuid', 'sequence', 'timemodified'));
|
||||
'repeatid', 'modulename', 'instance', 'type', 'eventtype', 'timestart',
|
||||
'timeduration', 'timesort', 'visible', 'uuid', 'sequence', 'timemodified',
|
||||
'priority'));
|
||||
|
||||
// Build the tree
|
||||
$events->add_child($event);
|
||||
@ -876,6 +877,14 @@ class backup_calendarevents_structure_step extends backup_structure_step {
|
||||
AND (eventtype = 'course' OR eventtype = 'group')";
|
||||
$calendar_items_params = array('courseid'=>backup::VAR_COURSEID);
|
||||
$event->set_source_sql($calendar_items_sql, $calendar_items_params);
|
||||
} else if ($this->name == 'activity_calendar') {
|
||||
$params = array('instance' => backup::VAR_ACTIVITYID, 'modulename' => backup::VAR_MODNAME);
|
||||
// If we don't want to include the userinfo in the backup then setting the courseid
|
||||
// will filter out all of the user override events (which have a course id of zero).
|
||||
if (!$this->get_setting_value('userinfo')) {
|
||||
$params['courseid'] = backup::VAR_COURSEID;
|
||||
}
|
||||
$event->set_source_table('event', $params);
|
||||
} else {
|
||||
$event->set_source_table('event', array('courseid' => backup::VAR_COURSEID, 'instance' => backup::VAR_ACTIVITYID, 'modulename' => backup::VAR_MODNAME));
|
||||
}
|
||||
|
@ -2653,6 +2653,16 @@ class restore_calendarevents_structure_step extends restore_structure_step {
|
||||
$data = (object)$data;
|
||||
$oldid = $data->id;
|
||||
$restorefiles = true; // We'll restore the files
|
||||
// User overrides for activities are identified by having a courseid of zero with
|
||||
// both a modulename and instance value set.
|
||||
$isuseroverride = !$data->courseid && $data->modulename && $data->instance;
|
||||
|
||||
// If we don't want to include user data and this record is a user override event
|
||||
// for an activity then we should not create it.
|
||||
if (!$this->task->get_setting_value('userinfo') && $isuseroverride) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the userid and the groupid associated with the event.
|
||||
$data->userid = $this->get_mappingid('user', $data->userid);
|
||||
if ($data->userid === false) {
|
||||
@ -2688,18 +2698,23 @@ class restore_calendarevents_structure_step extends restore_structure_step {
|
||||
'name' => $data->name,
|
||||
'description' => $data->description,
|
||||
'format' => $data->format,
|
||||
'courseid' => $this->get_courseid(),
|
||||
// User overrides in activities use a course id of zero. All other event types
|
||||
// must use the mapped course id.
|
||||
'courseid' => $data->courseid ? $this->get_courseid() : 0,
|
||||
'groupid' => $data->groupid,
|
||||
'userid' => $data->userid,
|
||||
'repeatid' => $this->get_mappingid('event', $data->repeatid),
|
||||
'modulename' => $data->modulename,
|
||||
'type' => $data->type,
|
||||
'eventtype' => $data->eventtype,
|
||||
'timestart' => $this->apply_date_offset($data->timestart),
|
||||
'timeduration' => $data->timeduration,
|
||||
'timesort' => $this->apply_date_offset($data->timesort),
|
||||
'visible' => $data->visible,
|
||||
'uuid' => $data->uuid,
|
||||
'sequence' => $data->sequence,
|
||||
'timemodified' => $this->apply_date_offset($data->timemodified));
|
||||
'timemodified' => $this->apply_date_offset($data->timemodified),
|
||||
'priority' => $data->priority);
|
||||
if ($this->name == 'activity_calendar') {
|
||||
$params['instance'] = $this->task->get_activityid();
|
||||
} else {
|
||||
@ -2710,10 +2725,11 @@ class restore_calendarevents_structure_step extends restore_structure_step {
|
||||
WHERE " . $DB->sql_compare_text('name', 255) . " = " . $DB->sql_compare_text('?', 255) . "
|
||||
AND courseid = ?
|
||||
AND modulename = ?
|
||||
AND instance = ?
|
||||
AND timestart = ?
|
||||
AND timeduration = ?
|
||||
AND " . $DB->sql_compare_text('description', 255) . " = " . $DB->sql_compare_text('?', 255);
|
||||
$arg = array ($params['name'], $params['courseid'], $params['modulename'], $params['timestart'], $params['timeduration'], $params['description']);
|
||||
$arg = array ($params['name'], $params['courseid'], $params['modulename'], $params['instance'], $params['timestart'], $params['timeduration'], $params['description']);
|
||||
$result = $DB->record_exists_sql($sql, $arg);
|
||||
if (empty($result)) {
|
||||
$newitemid = $DB->insert_record('event', $params);
|
||||
@ -5512,4 +5528,4 @@ class restore_completion_defaults_structure_step extends restore_structure_step
|
||||
// Save id mapping for restoring associated events.
|
||||
$this->set_mapping('course_completion_defaults', $oldid, $newid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,8 +65,9 @@ class restore_assign_activity_structure_step extends restore_activity_structure_
|
||||
$userflag = new restore_path_element('assign_userflag',
|
||||
'/activity/assign/userflags/userflag');
|
||||
$paths[] = $userflag;
|
||||
$paths[] = new restore_path_element('assign_override', '/activity/assign/overrides/override');
|
||||
}
|
||||
|
||||
$paths[] = new restore_path_element('assign_override', '/activity/assign/overrides/override');
|
||||
$paths[] = new restore_path_element('assign_plugin_config',
|
||||
'/activity/assign/plugin_configs/plugin_config');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user