Permalink
Browse files

Now restoring groups is cross-db (the detection of existing groups)

  • Loading branch information...
1 parent 15ef45d commit 2b27d0a9460263a247a02f6c4703471fdb9eb1bf stronk7 committed Sep 5, 2007
Showing with 12 additions and 1 deletion.
  1. +12 −1 backup/restorelib.php
View
@@ -2100,7 +2100,18 @@ function restore_create_groups($restore,$xml_file) {
//Now search if that group exists (by name and description field) in
//restore->course_id course
- $gro_db = get_record("groups","courseid",$restore->course_id,"name",$gro->name,"description",$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;

0 comments on commit 2b27d0a

Please sign in to comment.