]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9842 Groups from groupings not moved to "Not in a grouping"; merged from MOODLE_1...
authorskodak <skodak>
Fri, 18 May 2007 09:20:52 +0000 (09:20 +0000)
committerskodak <skodak>
Fri, 18 May 2007 09:20:52 +0000 (09:20 +0000)
group/db/upgrade.php
lib/db/upgrade.php
version.php

index e338c435c7465569fe6583f6e8159dfba342673d..b071675da640ef02e95cc857ae383153d78aa196 100644 (file)
@@ -48,6 +48,33 @@ function install_group_db() {
     notify(get_string('databaseupgradegroups', '', $group_version), 'green');
 }
 
+function undo_groupings() {
+    global $CFG;
+
+    if (!$rs = get_recordset_sql("
+                    SELECT gpgs.courseid, ggs.groupid 
+                    FROM {$CFG->prefix}groups_courses_groupings gpgs,
+                         {$CFG->prefix}groups_groupings_groups ggs
+                    WHERE gpgs.groupingid = ggs.groupingid")) {
+        //strange - did we already remove the tables?
+        return;
+    }
+
+    $db->debug = false;
+    if ($rs && $rs->RecordCount() > 0) {
+        while ($group = rs_fetch_next_record($rs)) {
+            if (!record_exists('groups_courses_groups', 'courseid', $group->courseid, 'groupid', $group->groupid)) {
+                insert_record('groups_courses_groups', $group);
+            }
+        }
+    }
+    $db->debug = true;
+
+    delete_records('groups_courses_groupings');
+    delete_records('groups_groupings_groups');
+    delete_records('groups_groupings');
+}
+
 
 function upgrade_group_db($continueto) {
 /// This function upgrades the group tables, if necessary
index b25d330e66712ee35bf7724a6b08989f3b1ffbee..f25f5b350952aef0946128c876b59e8161a45920 100644 (file)
@@ -1270,7 +1270,16 @@ function xmldb_main_upgrade($oldversion=0) {
     /// Launch add field signup
         $result = $result && add_field($table, $field);
     }
-    
+
+    if ($result && $oldversion < 2007051101) {
+        if (empty($CFG->enablegroupings)) {
+            // delete all groupings - they do not work yet :-(
+            // while keeping all existing groups
+            require_once("$CFG->dirroot/group/db/upgrade.php");
+            undo_groupings();
+        }
+    }
+
     return $result; 
 }
 
index b4532b92ed38a412910182d4f288f4cefb1fabb3..ec0eff3525908bc0c8da773229d04100f0ac1fe0 100644 (file)
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-   $version = 2007051100;  // YYYYMMDD = date
+   $version = 2007051101;  // YYYYMMDD = date
                            //       XY = increments within a single day
 
    $release = '1.9 dev';    // Human-friendly version name