mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Merge branch 'MDL-58822-master' of git://github.com/ryanwyllie/moodle
This commit is contained in:
commit
381db2fe8d
3 changed files with 33 additions and 7 deletions
|
@ -863,8 +863,9 @@ class backup_calendarevents_structure_step extends backup_structure_step {
|
||||||
|
|
||||||
$event = new backup_nested_element('event', array('id'), array(
|
$event = new backup_nested_element('event', array('id'), array(
|
||||||
'name', 'description', 'format', 'courseid', 'groupid', 'userid',
|
'name', 'description', 'format', 'courseid', 'groupid', 'userid',
|
||||||
'repeatid', 'modulename', 'instance', 'eventtype', 'timestart',
|
'repeatid', 'modulename', 'instance', 'type', 'eventtype', 'timestart',
|
||||||
'timeduration', 'visible', 'uuid', 'sequence', 'timemodified'));
|
'timeduration', 'timesort', 'visible', 'uuid', 'sequence', 'timemodified',
|
||||||
|
'priority'));
|
||||||
|
|
||||||
// Build the tree
|
// Build the tree
|
||||||
$events->add_child($event);
|
$events->add_child($event);
|
||||||
|
@ -876,6 +877,14 @@ class backup_calendarevents_structure_step extends backup_structure_step {
|
||||||
AND (eventtype = 'course' OR eventtype = 'group')";
|
AND (eventtype = 'course' OR eventtype = 'group')";
|
||||||
$calendar_items_params = array('courseid'=>backup::VAR_COURSEID);
|
$calendar_items_params = array('courseid'=>backup::VAR_COURSEID);
|
||||||
$event->set_source_sql($calendar_items_sql, $calendar_items_params);
|
$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 {
|
} else {
|
||||||
$event->set_source_table('event', array('courseid' => backup::VAR_COURSEID, 'instance' => backup::VAR_ACTIVITYID, 'modulename' => backup::VAR_MODNAME));
|
$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;
|
$data = (object)$data;
|
||||||
$oldid = $data->id;
|
$oldid = $data->id;
|
||||||
$restorefiles = true; // We'll restore the files
|
$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.
|
// Find the userid and the groupid associated with the event.
|
||||||
$data->userid = $this->get_mappingid('user', $data->userid);
|
$data->userid = $this->get_mappingid('user', $data->userid);
|
||||||
if ($data->userid === false) {
|
if ($data->userid === false) {
|
||||||
|
@ -2688,18 +2698,23 @@ class restore_calendarevents_structure_step extends restore_structure_step {
|
||||||
'name' => $data->name,
|
'name' => $data->name,
|
||||||
'description' => $data->description,
|
'description' => $data->description,
|
||||||
'format' => $data->format,
|
'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,
|
'groupid' => $data->groupid,
|
||||||
'userid' => $data->userid,
|
'userid' => $data->userid,
|
||||||
'repeatid' => $this->get_mappingid('event', $data->repeatid),
|
'repeatid' => $this->get_mappingid('event', $data->repeatid),
|
||||||
'modulename' => $data->modulename,
|
'modulename' => $data->modulename,
|
||||||
|
'type' => $data->type,
|
||||||
'eventtype' => $data->eventtype,
|
'eventtype' => $data->eventtype,
|
||||||
'timestart' => $this->apply_date_offset($data->timestart),
|
'timestart' => $this->apply_date_offset($data->timestart),
|
||||||
'timeduration' => $data->timeduration,
|
'timeduration' => $data->timeduration,
|
||||||
|
'timesort' => $this->apply_date_offset($data->timesort),
|
||||||
'visible' => $data->visible,
|
'visible' => $data->visible,
|
||||||
'uuid' => $data->uuid,
|
'uuid' => $data->uuid,
|
||||||
'sequence' => $data->sequence,
|
'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') {
|
if ($this->name == 'activity_calendar') {
|
||||||
$params['instance'] = $this->task->get_activityid();
|
$params['instance'] = $this->task->get_activityid();
|
||||||
} else {
|
} 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) . "
|
WHERE " . $DB->sql_compare_text('name', 255) . " = " . $DB->sql_compare_text('?', 255) . "
|
||||||
AND courseid = ?
|
AND courseid = ?
|
||||||
AND modulename = ?
|
AND modulename = ?
|
||||||
|
AND instance = ?
|
||||||
AND timestart = ?
|
AND timestart = ?
|
||||||
AND timeduration = ?
|
AND timeduration = ?
|
||||||
AND " . $DB->sql_compare_text('description', 255) . " = " . $DB->sql_compare_text('?', 255);
|
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);
|
$result = $DB->record_exists_sql($sql, $arg);
|
||||||
if (empty($result)) {
|
if (empty($result)) {
|
||||||
$newitemid = $DB->insert_record('event', $params);
|
$newitemid = $DB->insert_record('event', $params);
|
||||||
|
|
|
@ -65,8 +65,9 @@ class restore_assign_activity_structure_step extends restore_activity_structure_
|
||||||
$userflag = new restore_path_element('assign_userflag',
|
$userflag = new restore_path_element('assign_userflag',
|
||||||
'/activity/assign/userflags/userflag');
|
'/activity/assign/userflags/userflag');
|
||||||
$paths[] = $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',
|
$paths[] = new restore_path_element('assign_plugin_config',
|
||||||
'/activity/assign/plugin_configs/plugin_config');
|
'/activity/assign/plugin_configs/plugin_config');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue