From a2cdd7645ef47a04b71bb498ee303fe3800b812d Mon Sep 17 00:00:00 2001 From: stronk7 Date: Wed, 5 Sep 2007 19:19:34 +0000 Subject: [PATCH] Now restoring groups is cross-db (the detection of existing groups) (NOTE: There is one pending bug about restoring old groups to 1.9. Commented to Petr. Added here because I've to go NOW!) Merged from MOODLE_18_STABLE --- backup/restorelib.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/backup/restorelib.php b/backup/restorelib.php index 30d6de457a..60616b1b48 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -2815,6 +2815,8 @@ //This function creates all the groups function restore_create_groups($restore,$xml_file) { + global $CFG; + //Check it exists if (!file_exists($xml_file)) { return false; @@ -2858,7 +2860,19 @@ $gro->timemodified = backup_todb($info['GROUP']['#']['TIMEMODIFIED']['0']['#']); //Now search if that group exists (by name and description field) in - if (!$gro_db = get_record('groups', 'courseid', $restore->course_id, 'name', $gro->name, 'description', $gro->description)) { + //restore->course_id course + //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); + } + if ($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 $newid = insert_record('groups', $gro); -- 2.39.5