? config.php
? admin/mysql
? group/lib/New Folder
Index: admin/index.php
===================================================================
RCS file: /cvsroot/moodle/moodle/admin/index.php,v
retrieving revision 1.265.2.7
diff -u -r1.265.2.7 index.php
--- admin/index.php	6 Jul 2007 17:39:55 -0000	1.265.2.7
+++ admin/index.php	4 Sep 2007 05:30:33 -0000
@@ -190,8 +190,9 @@
         $db->debug = false;
         if ($status) {
             //ugly hack - install new groups: MDL-9217
-            require_once("$CFG->dirroot/group/db/upgrade.php");
-            install_group_db();
+            require("$CFG->dirroot/group/version.php");
+            set_config('group_version', $group_version);
+            //install_group_db();
 
             // Install the roles system.
             moodle_install_roles();
@@ -325,9 +326,10 @@
             /// If successful, continue upgrading roles and setting everything properly
                 if ($status) {
                     if (empty($CFG->rolesactive)) {
-                        //ugly hack - upgrade to new groups (from 1.6) : MDL-9217
-                        require_once("$CFG->dirroot/group/db/upgrade.php");
-                        install_group_db();
+                        // ugly hack - upgrade to new groups (from 1.6) : MDL-9217
+                        // require_once("$CFG->dirroot/group/db/upgrade.php");
+                        // MDL-11062, proper group upgrade code is done in lib/db/upgrade.php
+                        // install_group_db();
                         // Upgrade to the roles system.
                         moodle_install_roles();
                         set_config('rolesactive', 1);
Index: group/version.php
===================================================================
RCS file: /cvsroot/moodle/moodle/group/Attic/version.php,v
retrieving revision 1.6
diff -u -r1.6 version.php
--- group/version.php	29 Jan 2007 15:03:25 -0000	1.6
+++ group/version.php	4 Sep 2007 05:30:34 -0000
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$group_version  = 2007012400;
+$group_version  = 2007012401;
 //$module->requires = 2006120400;  // Requires this Moodle version
 
 ?>
Index: group/db/upgrade.php
===================================================================
RCS file: /cvsroot/moodle/moodle/group/db/Attic/upgrade.php,v
retrieving revision 1.11.2.5
diff -u -r1.11.2.5 upgrade.php
--- group/db/upgrade.php	18 May 2007 09:50:58 -0000	1.11.2.5
+++ group/db/upgrade.php	4 Sep 2007 05:30:34 -0000
@@ -16,31 +16,205 @@
 //
 // The commands in here will all be database-neutral,
 // using the functions defined in lib/ddllib.php
+
+/// MDL-11062 migrating to 1.8 groups system from versions before 1.8
 function install_group_db() {
     global $CFG, $db;
 
     $group_version = '';  // Get code version
     require ("$CFG->dirroot/group/version.php");
 
-    $status = true;
-
     print_heading('group');
-    $db->debug=true;
+    $db->debug = true;
+    $result = true;
+
+    /// 1) Set groups->description to NULLable
+
+    /// Changing nullability of field description on table groups to null
+
+    $table = new XMLDBTable('groups');
+    $field = new XMLDBField('description');
+    $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'name');
+        
+    /// Launch change of nullability for field description
+    $result = $result && change_field_notnull($table, $field);
+
+    /// 2) Rename the groups->password field to enrolmentkey
+
+    /// Rename field password on table groups to enrolmentkey.
+
+    $field = new XMLDBField('password');
+    $field->setAttributes(XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null, null, null, 'description');
+
+    /// Launch rename field password
+    $result = $result && rename_field($table, $field, 'enrolmentkey');
+
+    /// 3) Change the groups->lang from 10cc to 30cc
+
+    /// Changing precision of field lang on table groups to (30)
+    $field = new XMLDBField('lang');
+    $field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, 'en', 'enrolmentkey');
+
+    /// Launch change of precision for field lang
+    $result = $result && change_field_precision($table, $field);
+
+    /// 4) Change the groups->hidepicture from int(2) to int(1)
+
+    /// Changing precision of field hidepicture on table groups to (1)
+    $field = new XMLDBField('hidepicture');
+    $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'picture');
+
+    /// Launch change of precision for field hidepicture
+    $result = $result && change_field_precision($table, $field);
+
+    /// 5) Add one UNIQUE index on groups_members (groupid, userid)
+
+    /// Define index groupid-courseid (unique) to be added to groups_members
+    $table = new XMLDBTable('groups_members');
+    $index = new XMLDBIndex('groupid-courseid');
+    $index->setAttributes(XMLDB_INDEX_UNIQUE, array('groupid', 'userid'));
+
+    /// Launch add index groupid-courseid
+    $result = $result && add_index($table, $index);
+
+    /// 6) Add the whole groups_groupings table (as is in 1.8.2+)
+
+    /// Define table groups_groupings to be created
+    $table = new XMLDBTable('groups_groupings');
+
+    /// Adding fields to table groups_groupings
+    $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
+    $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
+    $table->addFieldInfo('description', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
+    $table->addFieldInfo('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+    $table->addFieldInfo('viewowngroup', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '1');
+    $table->addFieldInfo('viewallgroupsmembers', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+    $table->addFieldInfo('viewallgroupsactivities', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+    $table->addFieldInfo('teachersgroupmark', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+    $table->addFieldInfo('teachersgroupview', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+    $table->addFieldInfo('teachersoverride', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+    $table->addFieldInfo('teacherdeletable', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+
+    /// Adding keys to table groups_groupings
+    $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
+
+    /// Launch create table for groups_groupings
+    $result = $result && create_table($table);
+
+    /// 7) Add the whole groups_courses_groups table (as is in 1.8.2+)
 
-    //Moodle is already installed - rename old tables, used during tansfer later
-    if (table_exists($t_groups = new XMLDBTable('groups'))) {
-        $status = $status && rename_table($t_groups, 'groups_temp');
-        $status = $status && rename_table(new XMLDBTable('groups_members'), 'groups_members_temp');
+    /// Define table groups_courses_groups to be created
+    $table = new XMLDBTable('groups_courses_groups');
+
+    /// Adding fields to table groups_courses_groups
+    $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
+    $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+    $table->addFieldInfo('groupid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
+
+    /// Adding keys to table groups_courses_groups
+    $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
+    $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
+    $table->addKeyInfo('groupid', XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
+
+    /// Adding indexes to table groups_courses_groups
+    $table->addIndexInfo('courseid-groupid', XMLDB_INDEX_UNIQUE, array('courseid', 'groupid'));
+
+    /// Launch create table for groups_courses_groups
+    $result = $result && create_table($table);
+
+    /// 8) Add the whole groups_courses_groupings table (as is in 1.8.2+)
+
+    /// Define table groups_courses_groupings to be created
+    $table = new XMLDBTable('groups_courses_groupings');
+
+    /// Adding fields to table groups_courses_groupings
+    $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
+    $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+    $table->addFieldInfo('groupingid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
+
+    /// Adding keys to table groups_courses_groupings
+    $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
+    $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
+    $table->addKeyInfo('groupingid', XMLDB_KEY_FOREIGN, array('groupingid'), 'groups_groupings', array('id'));
+
+    /// Adding indexes to table groups_courses_groupings
+    $table->addIndexInfo('courseid-groupingid', XMLDB_INDEX_UNIQUE, array('courseid', 'groupingid'));
+
+    /// Launch create table for groups_courses_groupings
+    $result = $result && create_table($table);
+
+    /// 9) Add the whole groups_groupings_groups table (as is in 1.8.2+)
+
+    /// Define table groups_groupings_groups to be created
+    $table = new XMLDBTable('groups_groupings_groups');
+
+    /// Adding fields to table groups_groupings_groups
+    $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
+    $table->addFieldInfo('groupingid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+    $table->addFieldInfo('groupid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
+    $table->addFieldInfo('timeadded', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+
+    /// Adding keys to table groups_groupings_groups
+    $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
+    $table->addKeyInfo('groupingid', XMLDB_KEY_FOREIGN, array('groupingid'), 'groups_groupings', array('id'));
+    $table->addKeyInfo('groupid', XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
+
+    /// Adding indexes to table groups_groupings_groups
+    $table->addIndexInfo('groupingid-groupid', XMLDB_INDEX_UNIQUE, array('groupingid', 'groupid'));
+
+    /// Launch create table for groups_groupings_groups
+    $result = $result && create_table($table);
+
+    /// 10) Insert one record in log_display (module, action, mtable, field) 
+    ///     VALUES ('group', 'view', 'groups', 'name') IF it doesn't exist.
+
+    if (!record_exists('log_display', 'module', 'group', 'action', 'view')) {
+        $rec = new object();
+        $rec->module = 'group';
+        $rec->action = 'view';
+        $rec->mtable = 'groups';
+        $rec->field  = 'name';
+        $result = insert_record('log_display', $rec);
+    }
+
+    /// 11) PERFORM ALL THE NEEDED MOVEMENTS OF DATA
+    
+    $db->debug = false; // suppressing because there can be too many
+    /// a) get the current groups, foreach one add an entry in groups_courses_groups
+    if ($oldgroups = get_records('groups')) {
+        foreach ($oldgroups as $oldgroup) {
+            $rec = new Object();
+            $rec->courseid = $oldgroup->courseid;
+            $rec->groupid = $oldgroup->id;
+            $rec->timeadded = $oldgroup->timemodified; // I think this is not needed since the field is gone?
+            insert_record('groups_courses_groups', $rec);
+        }
     }
+    $db->debug = true;
+
+    /// TODO, TODO, TODO. At this point is where all the data must be populated to new tables!!
 
-    // install new groups tables
-    $status = $status && install_from_xmldb_file($CFG->dirroot . '/group/db/install.xml');
-    // convert old groups to new ones
-    $status = $status && groups_transfer_db();
+    /// 12) Drop the groups->courseid index
+
+    /// Define index courseid (not unique) to be dropped form groups
+    $table = new XMLDBTable('groups');
+    $index = new XMLDBIndex('courseid');
+    $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('courseid'));
+
+    /// Launch drop index courseid
+    $result = $result && drop_index($table, $index);
+
+    /// 13) Drop the groups->courseid field
+
+    /// Define field courseid to be dropped from groups
+    $field = new XMLDBField('courseid');
+
+    /// Launch drop field courseid
+    $result = $result && drop_field($table, $field);
 
     $db->debug = false;
 
-    if (!$status or !set_config('group_version', $group_version)) {
+    if (!$result or !set_config('group_version', $group_version)) {
         error("Upgrade of group system failed!");
     }
 
@@ -87,6 +261,7 @@
     require("$CFG->dirroot/group/version.php");
 
     if (empty($CFG->group_version)) {  // New 1.8 groups have never been installed...
+    
         $strdatabaseupgrades = get_string('databaseupgrades');
         print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', 
                 upgrade_get_javascript(), false, "&nbsp;", "&nbsp;");
@@ -168,7 +343,7 @@
 }
 
 function groups_drop_keys_indexes_db() {
-    $result = true;
+        $result = true;
     /// Define index groupid-courseid (unique) to be added to groups_members
         $table = new XMLDBTable('groups_members');
         $index = new XMLDBIndex('groupid-courseid');
@@ -269,7 +444,6 @@
     return $status;
 }
 
-
 function xmldb_group_upgrade($oldversion=0) {
     global $CFG;
 
@@ -333,6 +507,7 @@
         $result = $result && add_key($table, $key);
 
     /// Define index courseid-groupid (unique) to be added to groups_courses_groups
+                
         $table = new XMLDBTable('groups_courses_groups');
         $index = new XMLDBIndex('courseid-groupid');
         $index->setAttributes(XMLDB_INDEX_UNIQUE, array('courseid', 'groupid'));
Index: lib/db/install.xml
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/db/install.xml,v
retrieving revision 1.45.2.1
diff -u -r1.45.2.1 install.xml
--- lib/db/install.xml	23 Jul 2007 23:26:32 -0000	1.45.2.1
+++ lib/db/install.xml	4 Sep 2007 05:30:36 -0000
@@ -1152,7 +1152,7 @@
         <INDEX NAME="token" UNIQUE="true" FIELDS="token"/>
       </INDEXES>
     </TABLE>
-    <TABLE NAME="mnet_sso_access_control" COMMENT="Users by host permitted (or not) to login from a remote provider" PREVIOUS="mnet_session">
+    <TABLE NAME="mnet_sso_access_control" COMMENT="Users by host permitted (or not) to login from a remote provider" PREVIOUS="mnet_session" NEXT="groups">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="Required ID field" NEXT="username"/>
         <FIELD NAME="username" TYPE="char" LENGTH="100" NOTNULL="true" DEFAULT="" SEQUENCE="false" ENUM="false" COMMENT="Username" PREVIOUS="id" NEXT="mnet_host_id"/>
@@ -1166,6 +1166,103 @@
         <INDEX NAME="mnethostid_username" UNIQUE="true" FIELDS="mnet_host_id, username"/>
       </INDEXES>
     </TABLE>
+    <TABLE NAME="groups" COMMENT="Each record represents a group." NEXT="groups_members" PREVIOUS="mnet_sso_access_control">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="name"/>
+        <FIELD NAME="name" TYPE="char" LENGTH="254" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Short human readable unique name for the group." PREVIOUS="id" NEXT="description"/>
+        <FIELD NAME="description" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="enrolmentkey"/>
+        <FIELD NAME="enrolmentkey" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="description" NEXT="lang"/>
+        <FIELD NAME="lang" TYPE="char" LENGTH="30" NOTNULL="true" DEFAULT="en" SEQUENCE="false" ENUM="false" PREVIOUS="enrolmentkey" NEXT="theme"/>
+        <FIELD NAME="theme" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="lang" NEXT="picture"/>
+        <FIELD NAME="picture" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="theme" NEXT="hidepicture"/>
+        <FIELD NAME="hidepicture" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="picture" NEXT="timecreated"/>
+        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="hidepicture" NEXT="timemodified"/>
+        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timecreated"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for groups"/>
+      </KEYS>
+    </TABLE>
+    <TABLE NAME="groups_members" COMMENT="Link a user to a group." PREVIOUS="groups" NEXT="groups_groupings">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="groupid"/>
+        <FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="userid"/>
+        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="groupid" NEXT="timeadded"/>
+        <FIELD NAME="timeadded" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="userid"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for groups_members" NEXT="groupid"/>
+        <KEY NAME="groupid" TYPE="foreign" FIELDS="groupid" REFTABLE="groups" REFFIELDS="id" PREVIOUS="primary" NEXT="userid"/>
+        <KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="groupid"/>
+      </KEYS>
+      <INDEXES>
+        <INDEX NAME="groupid-courseid" UNIQUE="true" FIELDS="groupid, userid"/>
+      </INDEXES>
+    </TABLE>    
+    <TABLE NAME="groups_groupings" COMMENT="A grouping is a collection of groups." PREVIOUS="groups_members" NEXT="groups_courses_groups">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="name"/>
+        <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Short human readable unique name for group." PREVIOUS="id" NEXT="description"/>
+        <FIELD NAME="description" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="timecreated"/>
+        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="description" NEXT="viewowngroup"/>
+        <FIELD NAME="viewowngroup" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="timecreated" NEXT="viewallgroupsmembers"/>
+        <FIELD NAME="viewallgroupsmembers" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="viewowngroup" NEXT="viewallgroupsactivities"/>
+        <FIELD NAME="viewallgroupsactivities" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="viewallgroupsmembers" NEXT="teachersgroupmark"/>
+        <FIELD NAME="teachersgroupmark" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="viewallgroupsactivities" NEXT="teachersgroupview"/>
+        <FIELD NAME="teachersgroupview" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="teachersgroupmark" NEXT="teachersoverride"/>
+        <FIELD NAME="teachersoverride" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="teachersgroupview" NEXT="teacherdeletable"/>
+        <FIELD NAME="teacherdeletable" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="teachersoverride"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for groups_groupings"/>
+      </KEYS>
+    </TABLE>
+    <TABLE NAME="groups_courses_groups" COMMENT="Link a group to a course (or the site)." PREVIOUS="groups_groupings" NEXT="groups_courses_groupings">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="courseid"/>
+        <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="groupid"/>
+        <FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="Default comment for the field, please edit me" PREVIOUS="courseid"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for groups_courses_groups" NEXT="courseid"/>
+        <KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" PREVIOUS="primary" NEXT="groupid"/>
+        <KEY NAME="groupid" TYPE="foreign" FIELDS="groupid" REFTABLE="groups" REFFIELDS="id" PREVIOUS="courseid"/>
+      </KEYS>
+      <INDEXES>
+        <INDEX NAME="courseid-groupid" UNIQUE="true" FIELDS="courseid, groupid"/>
+      </INDEXES>
+    </TABLE>
+    <TABLE NAME="groups_courses_groupings" COMMENT="Link a grouping to a course (or the site)." PREVIOUS="groups_courses_groups" NEXT="groups_groupings_groups">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="courseid"/>
+        <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="groupingid"/>
+        <FIELD NAME="groupingid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="courseid"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for groups_courses_groupings" NEXT="courseid"/>
+        <KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" PREVIOUS="primary" NEXT="groupingid"/>
+        <KEY NAME="groupingid" TYPE="foreign" FIELDS="groupingid" REFTABLE="groups_groupings" REFFIELDS="id" PREVIOUS="courseid"/>
+      </KEYS>
+      <INDEXES>
+        <INDEX NAME="courseid-groupingid" UNIQUE="true" FIELDS="courseid, groupingid"/>
+      </INDEXES>
+    </TABLE>
+    <TABLE NAME="groups_groupings_groups" COMMENT="Link a group to a grouping." PREVIOUS="groups_courses_groupings">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="groupingid"/>
+        <FIELD NAME="groupingid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="groupid"/>
+        <FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="groupingid" NEXT="timeadded"/>
+        <FIELD NAME="timeadded" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="groupid"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for groups_groupings_groups" NEXT="groupingid"/>
+        <KEY NAME="groupingid" TYPE="foreign" FIELDS="groupingid" REFTABLE="groups_groupings" REFFIELDS="id" PREVIOUS="primary" NEXT="groupid"/>
+        <KEY NAME="groupid" TYPE="foreign" FIELDS="groupid" REFTABLE="groups" REFFIELDS="id" PREVIOUS="groupingid"/>
+      </KEYS>
+      <INDEXES>
+        <INDEX NAME="groupingid-groupid" UNIQUE="true" FIELDS="groupingid, groupid"/>
+      </INDEXES>
+    </TABLE>
   </TABLES>
   <STATEMENTS>
     <STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
@@ -1186,6 +1283,7 @@
         <SENTENCE TEXT="(module, action, mtable, field) VALUES ('message', 'remove contact', 'user', 'CONCAT(firstname,&quot; &quot;,lastname)')" />
         <SENTENCE TEXT="(module, action, mtable, field) VALUES ('message', 'block contact', 'user', 'CONCAT(firstname,&quot; &quot;,lastname)')" />
         <SENTENCE TEXT="(module, action, mtable, field) VALUES ('message', 'unblock contact', 'user', 'CONCAT(firstname,&quot; &quot;,lastname)')" />
+        <SENTENCE TEXT="(module, action, mtable, field) VALUES ('group', 'view', 'groups', 'name')" />
       </SENTENCES>
     </STATEMENT>
   </STATEMENTS>

