diff --git a/backup/restore_form.html b/backup/restore_form.html
index d1eaae7b7c9f2..028d6709616ab 100644
--- a/backup/restore_form.html
+++ b/backup/restore_form.html
@@ -435,7 +435,7 @@
$group_options[RESTORE_GROUPS_NONE] = get_string('no');
$group_options[RESTORE_GROUPS_ONLY] = get_string('yes');
} else {
- echo ''.$helplink;
+ echo ''.$helplink;
echo "
";
$group_options[RESTORE_GROUPS_NONE] = get_string('none');
$group_options[RESTORE_GROUPS_ONLY] = get_string('groups');
diff --git a/backup/restorelib.php b/backup/restorelib.php
index 8a618d5606bc6..b726b36e8f44d 100644
--- a/backup/restorelib.php
+++ b/backup/restorelib.php
@@ -480,17 +480,6 @@ function restore_print_info ($info) {
$tab[$elem][0] = "".get_string("users").":";
$tab[$elem][1] = get_string($info->backup_users);
$elem++;
- //Groups info
- if (empty($CFG->enablegroupings)) {
- $tab[$elem][0] = "".get_string('groups').":";
- } else {
- $tab[$elem][0] = "".get_string('groupsgroupings','group').":";
- }
- if (!isset($info->backup_groups)) { //Backwards compatibility.
- $info->backup_groups = 'course';
- }
- $tab[$elem][1] = get_string($info->backup_groups);
- $elem++;
//Logs info
$tab[$elem][0] = "".get_string("logs").":";
if ($info->backup_logs == "true") {
@@ -1083,7 +1072,7 @@ function restore_create_sections(&$restore, $xml_file) {
$course_module->indent = $mod->indent;
$course_module->visible = $mod->visible;
$course_module->groupmode = $mod->groupmode;
- if ($mod->groupingid and $grouping = backup_getid($restore->backup_unique_code,"groupings",$mod->groupingid)) {
+ if ($mod->groupingid and $grouping = restore_grouping_getid($restore, $mod->groupingid)) {
$course_module->groupingid = $grouping->new_id;
} else {
$course_module->groupingid = 0;
@@ -3067,6 +3056,20 @@ function restore_group_getid($restore, $groupid) {
return $group;
}
+ /**
+ * Recode grouping ID field, and set grouping ID based on restore options.
+ * @return object Group object with new_id field.
+ */
+ function restore_grouping_getid($restore, $groupingid) {
+ //We have to recode the groupid field
+ $grouping = backup_getid($restore->backup_unique_code, 'groupings', $groupingid);
+
+ if ($restore->groups == RESTORE_GROUPS_GROUPINGS or $restore->groups == RESTORE_GROUPINGS_ONLY) {
+ $grouping->new_id = 0;
+ }
+ return $grouping;
+ }
+
//This function creates all the groups
function restore_create_groups($restore,$xml_file) {
@@ -3280,7 +3283,7 @@ function restore_create_groupings($restore,$xml_file) {
// now fix the defaultgroupingid in course
$course = get_record('course', 'id', $restore->course_id);
if ($course->defaultgroupingid) {
- if ($grouping = backup_getid($restore->backup_unique_code,"groupings",$course->defaultgroupingid)) {
+ if ($grouping = restore_grouping_getid($restore, $course->defaultgroupingid)) {
set_field('course', 'defaultgroupingid', $grouping->new_id, 'id', $course->id);
} else {
set_field('course', 'defaultgroupingid', 0, 'id', $course->id);
|