From 97bc9f4934454c1e7cd434a4f7967c807dc3bdf9 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Wed, 5 Sep 2007 18:40:25 +0000 Subject: [PATCH] Now restoring groups is cross-db (the detection of existing groups) Merged from MOODLE_17_STABLE --- backup/restorelib.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/backup/restorelib.php b/backup/restorelib.php index 13b020ba5c6..16d80a5ca4c 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -2208,10 +2208,21 @@ $gro->hidepicture = backup_todb($info['GROUP']['#']['HIDEPICTURE']['0']['#']); $gro->timecreated = backup_todb($info['GROUP']['#']['TIMECREATED']['0']['#']); $gro->timemodified = backup_todb($info['GROUP']['#']['TIMEMODIFIED']['0']['#']); - - //Now search if that group exists (by name and description field) in + + //Now search if that group exists (by name and description field) in //restore->course_id course - $gro_db = groups_group_matches($restore->course_id, $gro->name, $gro->description); + //Going to compare LOB columns so, use the cross-db sql_compare_text() in both sides. + $description_clause = ''; + if (!empty($gro->description)) { /// Only for groups having a description + $literal_description = "'" . $gro->description . "'"; + $description_clause = " AND " . + sql_compare_text('description') . " = " . + sql_compare_text($literal_description); + } + $gro_db = get_record_sql("SELECT * + FROM {$CFG->prefix}groups + WHERE courseid = $restore->course_id AND + name = '{$gro->name}'" . $description_clause); //If it doesn't exist, create if (!$gro_db) { $create_group = true;