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
/// 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;
}
// 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