From 7f9b934c54e71e8280133c96db5ad5c3bc03b817 Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 17 Mar 2008 21:57:02 +0000 Subject: [PATCH] MDL-2674 adding $cm->grouping reset if groupings not restored; removed info about groups included in backup - they are always included, and there will not be any global groups/groupings; merged from MOODLE_19_STABLE --- backup/restore_form.html | 2 +- backup/restorelib.php | 29 ++++++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/backup/restore_form.html b/backup/restore_form.html index d1eaae7b7c..028d670961 100644 --- a/backup/restore_form.html +++ b/backup/restore_form.html @@ -435,7 +435,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) { $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 8a618d5606..b726b36e8f 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -480,17 +480,6 @@ define('RESTORE_GROUPS_GROUPINGS', 3); $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 @@ define('RESTORE_GROUPS_GROUPINGS', 3); $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 @@ define('RESTORE_GROUPS_GROUPINGS', 3); 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 @@ define('RESTORE_GROUPS_GROUPINGS', 3); // 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); -- 2.39.5