/// Continue with the instalation
$db->debug = false;
if ($status) {
- //ugly hack - install new groups: MDL-9217
- require_once("$CFG->dirroot/group/db/upgrade.php");
- install_group_db();
+
+ /// Groups install is now in core above.
// Install the roles system.
moodle_install_roles();
/// 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();
+
+ /// Groups upgrade is now in core above.
+
// Upgrade to the roles system.
moodle_install_roles();
set_config('rolesactive', 1);
}
}
-/// ugly hack - convert to new groups if upgrading from 1.7; must be reworked
- require_once("$CFG->dirroot/group/db/upgrade.php");
- upgrade_group_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
+/// Groups install/upgrade is now in core above.
/// Find and check all main modules and load them up or upgrade them if necessary
fwrite ($bf,full_tag("SHOWREPORTS",3,false,$course->showreports));
fwrite ($bf,full_tag("GROUPMODE",3,false,$course->groupmode));
fwrite ($bf,full_tag("GROUPMODEFORCE",3,false,$course->groupmodeforce));
+ fwrite ($bf,full_tag("DEFAULTGROUPINGID",3,false,$course->defaultgroupingid));
fwrite ($bf,full_tag("LANG",3,false,$course->lang));
fwrite ($bf,full_tag("THEME",3,false,$course->theme));
fwrite ($bf,full_tag("COST",3,false,$course->cost));
fwrite ($bf,full_tag("INDENT",6,false,$course_module[$tok]->indent));
fwrite ($bf,full_tag("VISIBLE",6,false,$course_module[$tok]->visible));
fwrite ($bf,full_tag("GROUPMODE",6,false,$course_module[$tok]->groupmode));
+ fwrite ($bf,full_tag("GROUPINGID",6,false,$course_module[$tok]->groupingid));
+ fwrite ($bf,full_tag("GROUPMEMBERSONLY",6,false,$course_module[$tok]->groupmembersonly));
// get all the role_capabilities overrides in this mod
write_role_overrides_xml($bf, $context, 6);
/// write role_assign code here
$status2 = true;
//Get groups
- $groups = get_groups($preferences->backup_course); //TODO:check.
+ $groups = get_records("groups","courseid",$preferences->backup_course);
//Pring groups header
if ($groups) {
fwrite ($bf,start_tag("GROUP",3,true));
//Output group contents
fwrite ($bf,full_tag("ID",4,false,$group->id));
- ///fwrite ($bf,full_tag("COURSEID",4,false,$group->courseid));
+ //fwrite ($bf,full_tag("COURSEID",4,false,$group->courseid));
fwrite ($bf,full_tag("NAME",4,false,$group->name));
fwrite ($bf,full_tag("DESCRIPTION",4,false,$group->description));
- fwrite ($bf,full_tag("ENROLMENTKEY",4,false,$group->enrolmentkey)); //TODO:
- fwrite ($bf,full_tag("LANG",4,false,$group->lang));
- fwrite ($bf,full_tag("THEME",4,false,$group->theme));
+ fwrite ($bf,full_tag("ENROLMENTKEY",4,false,$group->enrolmentkey));
fwrite ($bf,full_tag("PICTURE",4,false,$group->picture));
fwrite ($bf,full_tag("HIDEPICTURE",4,false,$group->hidepicture));
fwrite ($bf,full_tag("TIMECREATED",4,false,$group->timecreated));
$status = true;
//Get groups_members
- $groups_members = groups_get_member_records($groupid);
+ $groups_members = get_records("groups_members","groupid",$groupid);
//Pring groups_members header
if ($groups_members) {
//Begin group_member tag
fwrite ($bf,start_tag("MEMBER",5,true));
//Output group_member contents
+ fwrite ($bf,full_tag("GROUPID",6,false,$group_member->groupid));
fwrite ($bf,full_tag("USERID",6,false,$group_member->userid));
fwrite ($bf,full_tag("TIMEADDED",6,false,$group_member->timeadded));
//End group_member tag
global $CFG;
$status = true;
- $status2 = true;
//Get groups
- $groupings = groups_get_grouping_records($preferences->backup_course);
+ $groupings = get_records("groupings","courseid",$preferences->backup_course);
//Pring groups header
if ($groupings) {
fwrite ($bf,start_tag("GROUPING",3,true));
//Output group contents
fwrite ($bf,full_tag("ID",4,false,$grouping->id));
+ //fwrite ($bf,full_tag("COURSEID",4,false,$grouping->courseid));
fwrite ($bf,full_tag("NAME",4,false,$grouping->name));
fwrite ($bf,full_tag("DESCRIPTION",4,false,$grouping->description));
+ fwrite ($bf,full_tag("CONFIGDATA",4,false,$grouping->configdata));
fwrite ($bf,full_tag("TIMECREATED",4,false,$grouping->timecreated));
-
- $status2 = backup_groupids_info($bf,$preferences,$grouping->id);
+ fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$grouping->timemodified));
//End group tag
fwrite ($bf,end_tag("GROUPING",3,true));
//(Now save grouping_files)
}
- return ($status && $status2);
+ return $status;
}
//Backup groupings-groups info
- function backup_groupids_info($bf,$preferences,$groupingid) {
+ function backup_groupings_groups_info($bf,$preferences) {
global $CFG;
$status = true;
- //Get groups_members
- $grouping_groups = groups_get_groups_in_grouping_records($groupingid) ;
+ //Get grouping_groups
+ $courseid = $preferences->backup_course;
+ $sql = "SELECT gg.* FROM {$CFG->prefix}groupings g, {$CFG->prefix}groupings_groups g
+ WHERE g.courseid=$courseid AND g.id=gg.groupingid";
+ $grouping_groups = get_records_sql($sql);
- //Pring groups_members header
+ //Pring grouping_groups header
if ($grouping_groups) {
- //Pring groups_members header
- fwrite ($bf,start_tag("GROUPS",4,true));
+ //Pring grouping_groups header
+ fwrite ($bf,start_tag("GROUPINGSGROUPS",4,true));
//Iterate
foreach ($grouping_groups as $group2) {
- //Begin group tag
- fwrite ($bf,start_tag("GROUP",5,true));
+ //Begin grouping_group tag
+ fwrite ($bf,start_tag("GROUPINGSGROUP",5,true));
//Output group_member contents
+ fwrite ($bf,full_tag("GROUPINGID",6,false,$group2->groupingid));
fwrite ($bf,full_tag("GROUPID",6,false,$group2->groupid));
- fwrite ($bf,full_tag("TIMEADDED",6,false,$group2->timeadded)); //TODO:
- //End group tag
- fwrite ($bf,end_tag("GROUP",5,true));
+ fwrite ($bf,full_tag("TIMEADDED",6,false,$group2->timeadded));
+ //End grouping_group tag
+ fwrite ($bf,end_tag("GROUPINGSGROUP",5,true));
}
- //End groups_members tag
- $status = fwrite ($bf,end_tag("GROUPS",4,true));
+ //End grouping_groups tag
+ $status = fwrite ($bf,end_tag("GROUPINGSGROUPS",4,true));
}
return $status;
}
//Iterate
foreach ($list as $dir) {
//Look for dir like group in groups table
- $data = groups_group_belongs_to_course($dir, $preferences->backup_course);
- //TODO:check. get_record ('groups', 'courseid', $preferences->backup_course,'id',$dir);
+ $data = get_record ('groups', 'courseid', $preferences->backup_course,
+ 'id',$dir);
//If exists, copy it
if ($data) {
$status = backup_copy_file($rootdir."/".$dir,
}
}
+ //Print groups info
+ if ($status) {
+ if (!defined('BACKUP_SILENTLY')) {
+ echo "<li>".get_string("writinggroupsinfo").'</li>';
+ }
+ if (!$status = backup_groups_info($backup_file,$preferences)) {
+ if (!defined('BACKUP_SILENTLY')) {
+ notify("An error occurred while backing up groups");
+ }
+ else {
+ $errostr = "An error occurred while backing up groups";
+ return false;
+ }
+ }
+ }
+
//Print groupings info
if ($status) {
if (!defined('BACKUP_SILENTLY')) {
}
}
- //Print groups info
+ //Print groupings_groups info
if ($status) {
if (!defined('BACKUP_SILENTLY')) {
- echo "<li>".get_string("writinggroupsinfo").'</li>';
+ echo "<li>".get_string("writinggroupingsgroupsinfo").'</li>';
}
- if (!$status = backup_groups_info($backup_file,$preferences)) {
+ if (!$status = backup_groupings_groups_info($backup_file,$preferences)) {
if (!defined('BACKUP_SILENTLY')) {
- notify("An error occurred while backing up groups");
+ notify("An error occurred while backing up groupings groups");
}
else {
- $errostr = "An error occurred while backing up groups";
+ $errorstr = "An error occurred while backing up groupings groups";
return false;
}
}
return $info;
}
+ //This function read the xml file and store its data from the groupings in
+ //backup_ids->info db (and grouping's id in $info)
+ function restore_read_xml_groupings_groups ($restore,$xml_file) {
+
+ //We call the main read_xml function, with todo = GROUPINGS
+ $info = restore_read_xml ($xml_file,"GROUPINGSGROUPS",$restore);
+
+ return $info;
+ }
+
//This function read the xml file and store its data from the events (course) in
//backup_ids->info db (and event's id in $info)
function restore_read_xml_events ($restore,$xml_file) {
if (isset($course_header->course_groupmodeforce)) {
$course->groupmodeforce = addslashes($course_header->course_groupmodeforce);
}
+ $course->defaultgroupingid = 0; // TODO: add proper handling of ddefaultgroupingid
$course->lang = addslashes($course_header->course_lang);
$course->theme = addslashes($course_header->course_theme);
$course->cost = addslashes($course_header->course_cost);
foreach ($groups as $group) {
//Get record from backup_ids
$data = backup_getid($restore->backup_unique_code,"groups",$group->id);
- //Init variables
- $create_group = false;
if ($data) {
//Now get completed xmlized object
//$GLOBALS['traverse_array']=""; //Debug
//Now build the GROUP record structure
$gro = new Object();
- ///$gro->courseid = backup_todb($info['GROUP']['#']['COURSEID']['0']['#']);
- $gro->name = backup_todb($info['GROUP']['#']['NAME']['0']['#']);
- $gro->description = backup_todb($info['GROUP']['#']['DESCRIPTION']['0']['#']);
+ $gro->courseid = $restore->course_id;
+ $gro->name = backup_todb($info['GROUP']['#']['NAME']['0']['#']);
+ $gro->description = backup_todb($info['GROUP']['#']['DESCRIPTION']['0']['#']);
if (isset($info['GROUP']['#']['ENROLMENTKEY']['0']['#'])) {
$gro->enrolmentkey = backup_todb($info['GROUP']['#']['ENROLMENTKEY']['0']['#']);
- } else { //if (! isset($gro->enrolment)) {
+ } else {
$gro->enrolmentkey = backup_todb($info['GROUP']['#']['PASSWORD']['0']['#']);
}
- $gro->lang = backup_todb($info['GROUP']['#']['LANG']['0']['#']);
- $gro->theme = backup_todb($info['GROUP']['#']['THEME']['0']['#']);
- $gro->picture = backup_todb($info['GROUP']['#']['PICTURE']['0']['#']);
- $gro->hidepicture = backup_todb($info['GROUP']['#']['HIDEPICTURE']['0']['#']);
- $gro->timecreated = backup_todb($info['GROUP']['#']['TIMECREATED']['0']['#']);
- $gro->timemodified = backup_todb($info['GROUP']['#']['TIMEMODIFIED']['0']['#']);
+ $gro->picture = backup_todb($info['GROUP']['#']['PICTURE']['0']['#']);
+ $gro->hidepicture = backup_todb($info['GROUP']['#']['HIDEPICTURE']['0']['#']);
+ $gro->timecreated = backup_todb($info['GROUP']['#']['TIMECREATED']['0']['#']);
+ $gro->timemodified = backup_todb($info['GROUP']['#']['TIMEMODIFIED']['0']['#']);
//Now search if that group exists (by name and description field) in
- //restore->course_id course
- $gro_db = groups_group_matches($restore->course_id, $gro->name, $gro->description);
- //If it doesn't exist, create
- if (!$gro_db) {
- $create_group = true;
- }
- //If we must create the group
- if ($create_group) {
- //Me must recode the courseid to the restore->course_id
- $gro->courseid = $restore->course_id;
-
- //Check if the theme exists in destination server
- $themes = get_list_of_themes();
- if (!in_array($gro->theme, $themes)) {
- $gro->theme = '';
- }
+ if (!$gro_db = get_record('groups', 'courseid', $restore->course_id, 'name', $gro->name, 'description', $gro->description)) {
+ //If it doesn't exist, create
+ $newid = insert_record ('groups', $gro);
- //The structure is equal to the db, so insert the group
- $newid = groups_restore_group($restore->course_id, $gro);
} else {
//get current group id
$newid = $gro_db->id;
}
+
if ($newid) {
//We have the newid, update backup_ids
- backup_putid($restore->backup_unique_code,"groups",
- $group->id, $newid);
+ backup_putid($restore->backup_unique_code,"groups", $group->id, $newid);
}
+
//Now restore members in the groups_members, only if
//users are included
if ($restore->users != 2) {
- $status2 = restore_create_groups_members($newid,$info,$restore);
+ $status2 = restore_create_groups_members($newid,$info,$restore);
}
}
}
$group_member->userid = backup_todb($mem_info['#']['USERID']['0']['#']);
$group_member->timeadded = backup_todb($mem_info['#']['TIMEADDED']['0']['#']);
+ $newid = false;
+
//We have to recode the userid field
$user = backup_getid($restore->backup_unique_code,"user",$group_member->userid);
if ($user) {
$group_member->userid = $user->new_id;
+
+ //The structure is equal to the db, so insert the groups_members
+ $newid = insert_record ("groups_members", $group_member);
+ } else {
+ echo "grrr";
}
- //The structure is equal to the db, so insert the groups_members
- $newid = groups_restore_member($group_member);
//Do some output
if (($i+1) % 50 == 0) {
if (!defined('RESTORE_SILENTLY')) {
global $CFG, $db;
$status = true;
- $status2 = true;
+
//Check it exists
if (!file_exists($xml_file)) {
$status = false;
//Now build the GROUPING record structure
$gro = new Object();
///$gro->id = backup_todb($info['GROUPING']['#']['ID']['0']['#']);
- $gro->name = backup_todb($info['GROUPING']['#']['NAME']['0']['#']);
+ $gro->courseid = $restore->course_id;
+ $gro->name = backup_todb($info['GROUPING']['#']['NAME']['0']['#']);
$gro->description = backup_todb($info['GROUPING']['#']['DESCRIPTION']['0']['#']);
+ $gro->configdata = backup_todb($info['GROUPING']['#']['CONFIGDATA']['0']['#']);
$gro->timecreated = backup_todb($info['GROUPING']['#']['TIMECREATED']['0']['#']);
//Now search if that group exists (by name and description field) in
- //restore->course_id course
- $gro_db = groups_grouping_matches($restore->course_id, $gro->name, $gro->description);
- //If it doesn't exist, create
- if (!$gro_db) {
- $create_grouping = true;
- }
- //If we must create the group
- if ($create_grouping) {
+ if (!$gro_db = get_record('groupings', 'courseid', $restore->course_id, 'name', $gro->name, 'description', $gro->description)) {
+ //The structure is equal to the db, so insert the grouping
+ $newid = insert_record($restore->course_id, $gro);
- //The structure is equal to the db, so insert the grouping TODO: RESTORE.
- $newid = groups_create_grouping($restore->course_id, $gro);
} else {
//get current group id
$newid = $gro_db->id;
}
+
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,"groupings",
$grouping->id, $newid);
}
- //Now restore links from groupings to groups
- $status2 = restore_create_groupings_groups($newid,$info,$restore);
}
}
//(Now, restore grouping_files)
} else {
$status = false;
}
- return ($status && $status2);
+
+ return $status;
}
//This function restores the groups_members
- function restore_create_groupings_groups($grouping_id,$info,$restore) {
+ function restore_create_groupings_groups($restore,$xml_file) {
+
+//TODO: fix me
+return true;
global $CFG;
case "GROUPMODE":
$this->info->tempmod->groupmode = $this->getContents();
break;
+ case "GROUPINGID":
+ $this->info->tempmod->groupingid = $this->getContents();
+ break;
+ case "GROUPMEMBERSONLY":
+ $this->info->tempmod->groupmembersonly = $this->getContents();
+ break;
default:
- break;
+ break;
}
}
}
}
+ //Now create groupings as needed
+ if ($status) {
+ if (!defined('RESTORE_SILENTLY')) {
+ echo "<li>".get_string("creatinggroupingsgroups");
+ }
+ if (!$status = restore_create_groupings_groups($restore,$xml_file)) {
+ if (!defined('RESTORE_SILENTLY')) {
+ notify("Could not restore groupings groups!");
+ } else {
+ $errorstr = "Could not restore groupings groups!";
+ return false;
+ }
+ }
+ if (!defined('RESTORE_SILENTLY')) {
+ echo '</li>';
+ }
+ }
+
//Now create events as needed
if ($status) {
if (!defined('RESTORE_SILENTLY')) {
}
if (!empty($groupids)) {
- $sql = "SELECT id, groupid
- FROM {$CFG->prefix}groups_courses_groups
+ $sql = "SELECT id
+ FROM {$CFG->prefix}groups
WHERE courseid IN (".implode(',', $groupids).')';
if ($grouprecords= get_records_sql($sql)) {
*
* @copyright © 2006 The Open University
* @author N.D.Freear AT open.ac.uk
- * @author J.White AT open.ac.uk
+ * @author J.White AT open.ac.uk
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package groups
*/
require_once('../config.php');
require_once('lib.php');
-require_once($CFG->libdir.'/moodlelib.php');
-$success = true;
+$groupid = required_param('group', PARAM_INT);
-$courseid = required_param('courseid', PARAM_INT);
-$groupingid = required_param('grouping', PARAM_INT);
-$groupid = required_param('group', PARAM_INT);
+require_login();
+if (!$group = get_record('groups', 'id', $groupid)) {
+ error('Incorrect group id');
+}
-// Get the course information so we can print the header and
-// check the course id is valid
-$course = groups_get_course_info($courseid);
-if (! $course) {
- $success = false;
+if (! $course = get_record('course', 'id', $group->courseid)) {
print_error('invalidcourse');
}
-if (empty($groupid)) {
- $success = false;
- print_error('errorinvalidgroup', 'group', groups_home_url($courseid));
-}
-if ($success) {
- // Make sure that the user has permissions to manage groups.
- require_login($courseid);
+require_login($course);
+$courseid = $course->id;
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
- if (! has_capability('moodle/course:managegroups', $context)) {
- redirect();
- }
-
- if ($frm = data_submitted() and confirm_sesskey()) {
+$returnurl = $CFG->wwwroot.'/group/index.php?id='.$courseid.'&group='.$groupid;
+
+$context = get_context_instance(CONTEXT_COURSE, $courseid);
+require_capability('moodle/course:managegroups', $context);
+
+ if ($frm = data_submitted() and confirm_sesskey()) {
if (isset($frm->cancel)) {
- redirect('index.php?id='. $courseid
- .'&grouping='. $groupingid .'&group='. $groupid);
- }
- elseif (isset($frm->add) and !empty($frm->addselect)) {
+ redirect($returnurl);
+
+ } else if (isset($frm->add) and !empty($frm->addselect)) {
foreach ($frm->addselect as $userid) {
if (! $userid = clean_param($userid, PARAM_INT)) {
continue;
}
- $success = groups_add_member($groupid, $userid);
- if (! $success) {
- print_error('erroraddremoveuser', 'group', groups_home_url($courseid));
+ if (!groups_add_member($groupid, $userid)) {
+ print_error('erroraddremoveuser', 'group', $returnurl);
}
}
- }
- elseif (isset($frm->remove) and !empty($frm->removeselect)) {
+
+ } else if (isset($frm->remove) and !empty($frm->removeselect)) {
foreach ($frm->removeselect as $userid) {
if (! $userid = clean_param($userid, PARAM_INT)) {
continue;
}
- $success = groups_remove_member($groupid, $userid);
- if (! $success) {
- print_error('erroraddremoveuser', 'group', groups_home_url($courseid));
+ if (!groups_remove_member($groupid, $userid)) {
+ print_error('erroraddremoveuser', 'group', $returnurl);
}
-
+
// MDL-9983
$eventdata = new object();
$eventdata -> groupid = $groupid;
$eventdata -> userid = $userid;
- events_trigger('group_user_removed', $eventdata);
+ events_trigger('group_user_removed', $eventdata);
}
}
}
-
+
$groupmembers = groups_get_members($groupid);
$groupmembersoptions = '';
$groupmemberscount = 0;
} else {
$groupmembersoptions .= '<option> </option>';
}
-
- //TODO: If no 'showall' button, then set true.
- $showall = true;
-
- $potentialmembers = array();
+
+ $potentialmembers = array();
$potentialmembersoptions = '';
$potentialmemberscount = 0;
- if (!$showall && $groupingid != GROUP_NOT_IN_GROUPING) {
- $potentialmembers = groups_get_users_not_in_any_group_in_grouping($courseid, $groupingid, $groupid);
- } else {
- $potentialmembers = groups_get_users_not_in_group($courseid, $groupid);
- }
-
+ $potentialmembers = groups_get_users_not_in_group($courseid, $groupid);
+
if ($potentialmembers != false) {
// Put the groupings into a hash and sorts them
foreach ($potentialmembers as $userid) {
- $nonmembers[$userid] = groups_get_user_displayname($userid, $courseid);
+ $nonmembers[$userid] = groups_get_user_displayname($userid, $courseid);
$potentialmemberscount++;
}
natcasesort($nonmembers);
$groupname = groups_get_group_displayname($groupid);
- print_header("$course->shortname: $strgroups",
- $course->fullname,
+ print_header("$course->shortname: $strgroups",
+ $course->fullname,
"<a href=\"$CFG->wwwroot/course/view.php?id=$courseid\">$course->shortname</a> ".
"-> <a href=\"$CFG->wwwroot/user/index.php?id=$courseid\">$strparticipants</a> ".
- '-> <a href="' .format_string(groups_home_url($courseid, $groupid, $groupingid, false)) . "\">$strgroups</a>".
+ "-> <a href=\"$CFG->wwwroot/group/index.php?id=$courseid\">$strgroups</a>".
'-> '. get_string('adduserstogroup', 'group'), '', '', true, '', user_login_string($course, $USER));
?>
<form id="assignform" method="post" action="">
<div>
<input type="hidden" name="sesskey" value="<?php p(sesskey()); ?>" />
- <input type="hidden" name="courseid" value="<?php p($courseid); ?>" />
- <input type="hidden" name="grouping" value="<?php echo $groupingid; ?>" />
<input type="hidden" name="group" value="<?php echo $groupid; ?>" />
<table summary="" cellpadding="5" cellspacing="0">
</select>
<br />
<?php //TODO: Search box?
-
+
/*if (!empty($searchtext)) {
echo '<input name="showall" type="submit" value="'.get_string('showall').'" />'."\n";
}*/
</td>
</tr>
<tr><td>
- <input type="submit" name="cancel" value="<?php print_string('backtogroups', 'group'); ?>" />
+ <input type="submit" name="cancel" value="<?php print_string('backtogroups', 'group'); ?>" />
</td></tr>
</table>
</div>
<?php
print_footer($course);
-}
+
?>
/**
* Functions to make changes to groups in the database i.e. functions that
* access tables:
- * groups_courses_groups, groups and groups_members.
+ * groups and groups_members.
*
* @copyright © 2006 The Open University
* @author J.White AT open.ac.uk
if (! $courseid) {
return false;
}
- $records = get_records('groups_courses_groups', 'courseid', $courseid,
- '', $fields='id, groupid');
+ $records = get_records('groups', 'courseid', $courseid,
+ '', $fields='id');
if (! $records) {
return false;
}
// Put the results into an array, note these are NOT 'group' objects.
$groupids = array();
foreach ($records as $record) {
- array_push($groupids, $record->groupid);
+ array_push($groupids, $record->id);
}
return $groupids;
FROM {$CFG->prefix}groups_members gm
INNER JOIN {$CFG->prefix}groups g
ON gm.groupid = g.id
- INNER JOIN {$CFG->prefix}groups_courses_groups cg
- ON g.id = cg.groupid
- WHERE cg.courseid = '$courseid' AND gm.userid = '$userid'";
+ WHERE g.courseid = '$courseid' AND gm.userid = '$userid'";
$groups = get_records_sql($sql);
$groupids = groups_groups_to_groupids($groups);
/**
* Get the group settings object for a group - this contains the following
* properties:
- * name, description, lang, theme, picture, hidepicture
+ * name, description, picture, hidepicture
* @param int $groupid The id of the group
* @param $courseid Optionally add the course ID, for backwards compatibility.
* @return object The group settings object
$groupsettings = false;
} else {
global $CFG;
- $select = ($alldata) ? '*' : 'id, name, description, lang, theme, picture, hidepicture';
+ $select = ($alldata) ? '*' : 'id, name, description, picture, hidepicture';
$sql = "SELECT $select
FROM {$CFG->prefix}groups
WHERE id = $groupid";
global $CFG;
$sql = "SELECT g.id, g.name, g.description
FROM {$CFG->prefix}groups g
- INNER JOIN {$CFG->prefix}groups_courses_groups cg ON g.id = cg.groupid
WHERE g.name = '$grp_name'
AND g.description = '$grp_description'
- AND cg.courseid = '$courseid'";
+ AND g.courseid = '$courseid'";
$records = get_records_sql($sql);
$group = false;
if ($records) {
global $CFG;
$sql = "SELECT g.id, g.name
FROM {$CFG->prefix}groups g
- INNER JOIN {$CFG->prefix}groups_courses_groups cg ON g.id = cg.groupid
WHERE g.name = '$grp_name'
- AND cg.courseid = '$courseid'";
+ AND g.courseid = '$courseid'";
$records = get_records_sql($sql);
$group = false;
if ($records) {
if (!$groupid or !$courseid) {
$ismember = false;
} else {
- $ismember = record_exists($table = 'groups_courses_groups',
- 'groupid', $groupid,
+ $ismember = record_exists($table = 'groups',
+ 'id', $groupid,
'courseid', $courseid);
}
}
//print_r($record);
$groupid = insert_record('groups', $record);
-
- if ($groupid != false) {
- $record2 = new Object();
- $record2->courseid = $courseid;
- $record2->groupid = $groupid;
- if ($copytime) {
- $record2->timeadded = $record->timemodified;
- } else {
- $record2->timeadded = $now;
- }
- $groupadded = insert_record('groups_courses_groups', $record2);
- if (!$groupadded) {
- $groupid = false;
- }
- }
+
}
return $groupid;
}
$r = addslashes_object($group);
$sql = "INSERT INTO {$CFG->prefix}groups
- (id,name,description, enrolmentkey,lang,theme,picture,hidepicture, timecreated,timemodified)
- VALUES ('$r->id','$r->name','$r->description', '$r->enrolmentkey','$r->lang',
- '$r->theme','$r->picture','$r->hidepicture', '$r->timecreated','$r->timemodified')";
-
- if ($result = execute_sql($sql)) {
- $record2 = new Object();
- $record2->courseid = $courseid;
- $record2->groupid = $group->id;
- $record2->timeadded = $group->timemodified;
-
- $groupadded = insert_record('groups_courses_groups', $record2);
- if (! $groupadded) {
- $groupid = false;
- }
- }
+ (id,courseid,name,description, enrolmentkey,picture,hidepicture, timecreated,timemodified)
+ VALUES ('$r->id','$r->courseid','$r->name','$r->description', '$r->enrolmentkey','$r->picture',
+ '$r->hidepicture', '$r->timecreated','$r->timemodified')";
+
+ $result = execute_sql($sql);
return $group->id;
}
* Sets the information about a group
* @param object $groupsettings An object containing some or all of the
* following properties:
- * name, description, lang, theme, picture, hidepicture
+ * name, description, picture, hidepicture
* @return boolean True if info was added successfully, false otherwise.
*/
function groups_db_set_group_settings($groupid, $groupsettings) {
}
}
}
-
- // Remove links with courses.
- $results = delete_records('groups_courses_groups', 'groupid', $groupid);
- if ($results == false) {
- $success = false;
- }
-
+
// Delete the group itself
$results = delete_records($table = 'groups', $field1 = 'id',
$value1 = $groupid);
+++ /dev/null
-<?php
-// @@@ TO DO
-function groups_db_get_forced_grouping($courseid) {
-}
-
-function groups__db_set_forced_grouping($courseid, $groupingid) {
-}
-
-
-?>
/**
* Functions to make changes to groupings in the database. In general these
* access the tables:
- * groups_groupings, groups_courses_groupings and groups_groupings_groups
+ * groups_groupings, groups_courses_groupings and groupings_groups
* although some access all the tables that store information about groups.
*
* @copyright © 2006 The Open University
$groupid = false;
} else {
- $groups = get_records('groups_groupings_groups', 'groupingid ',
+ $groups = get_records('groupings_groups', 'groupingid ',
$groupingid, '', $fields='id, groupid');
if (!$groups) {
$groupids = false;
if (!$groupid) {
$groupingids = false;
} else {
- $groupings = get_records('groups_groupings_groups', 'groupid ',
+ $groupings = get_records('groupings_groups', 'groupid ',
$groupid, '', $fields='id, groupingid');
if (!$groupings) {
$groupingids = false;
if (!$groupid) {
$isingrouping = false;
} else {
- $isingrouping = record_exists('groups_groupings_groups', 'groupid',
+ $isingrouping = record_exists('groupings_groups', 'groupid',
$groupid);
}
if (!$groupid or !$groupingid) {
$isingrouping = false;
} else {
- $isingrouping = record_exists('groups_groupings_groups', 'groupid',
+ $isingrouping = record_exists('groupings_groups', 'groupid',
$groupid, 'groupingid', $groupingid);
}
} else {
global $CFG;
$sql = "SELECT gm.id
- FROM {$CFG->prefix}groups_groupings_groups gg
+ FROM {$CFG->prefix}groupings_groups gg
INNER JOIN {$CFG->prefix}groups_members gm
ON gg.groupid = gm.groupid
WHERE gm.userid = '$userid' AND gg.groupingid = '$groupingid'";
$record->groupid = $groupid;
$record->timeadded = time();
- $results = insert_record('groups_groupings_groups', $record);
+ $results = insert_record('groupings_groups', $record);
if (!$results) {
$success = false;
}
if (!$groupingid or !$groupid) {
$success = false;
} else {
- $results = delete_records('groups_groupings_groups', 'groupid',
+ $results = delete_records('groupings_groups', 'groupid',
$groupid, 'groupingid', $groupingid);
// delete_records returns an array of the results from the sql call,
// not a boolean, so we have to set our return variable
$success = false;
}
- $results = delete_records('groups_groupings_groups', 'groupingid',
+ $results = delete_records('groupings_groups', 'groupingid',
$groupingid);
if ($results == false) {
$success = false;
+++ /dev/null
-<?php
-/**
- * Functions required for setting up the database to use the new groups.
- *
- * TODO: replace with, postrges7.sql, mysql.php, install.xml
- *
- * @copyright © 2006 The Open University
- * @author J.White AT open.ac.uk
- * @author N.D.Freear AT open.ac.uk
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package groups
- */
-require_once($CFG->libdir.'/datalib.php');
-
-
-// @@@ TO DO Needs lots of sorting out so proper install/upgrade and also
-// so used new db stuff. In practice we probably don't actually want to rename
-// the tables (the group_member table in particular as this is basically
-// unchanged)that already exist on the whole if we can help it so this and the
-// the other dblib files should really be sorted out to do this.
-
-// Database changes
-// New tables - the SQL for creating the tables is below (though should be
-// foreign keys!) - however it might be more sensible to modify the existing
-// tables instead as much as we can so that we don't need to copy data over and
-// that any existing code that does assume the existence of those tables
-// might still work.
-// Another caveat - the code below doesn't contain the new fields in the
-// groupings table - viewowngroup, viewallgroupsmemebers, viewallgroupsactivities,
-// teachersgroupmark, teachersgroupview, teachersoverride, teacherdeletetable.
-// Other changes:
-// * course currently contains groupmode and groupmodeforce - we need to change
-// this to groupingid which is either null or a forced groupingid - need to
-// copy over existing data sensibly.
-// * course_modules needs groupingid (think it previously had groupmode)
-
-
-// Change database tables - course table need to remove two fields add groupingid field
-// Move everything over
-// Course module instance need to add groupingid field
-// Module table - add group support field.
-// Add deletable by teacher field.
-
-
-/**
- * Creates the database tables required
- */
-function groups_create_database_tables() {
- global $CFG;
-
- if ('mysql' == $CFG->dbfamily) {
-
- $createcoursegrouptablesql = "CREATE TABLE IF NOT EXISTS `{$CFG->prefix}groups_courses_groups` (
- `id` int(10) unsigned NOT NULL auto_increment,
- `courseid` int(10) unsigned NOT NULL default '0',
- `groupid` int(11) NOT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `id` (`id`),
- KEY `courseid` (`courseid`)
- ) ";
-
- $creategroupstablesql = "CREATE TABLE IF NOT EXISTS `{$CFG->prefix}groups_groups` (
- `id` int(10) unsigned NOT NULL auto_increment,
- `name` varchar(254) collate latin1_general_ci NOT NULL default '',
- `description` text collate latin1_general_ci NOT NULL,
- `enrolmentkey` varchar(50) collate latin1_general_ci NOT NULL default '',
- `lang` varchar(10) collate latin1_general_ci NOT NULL default 'en',
- `theme` varchar(50) collate latin1_general_ci NOT NULL default '',
- `picture` int(10) unsigned NOT NULL default '0',
- `hidepicture` int(2) unsigned NOT NULL default '0',
- `timecreated` int(10) unsigned NOT NULL default '0',
- `timemodified` int(10) unsigned NOT NULL default '0',
- PRIMARY KEY (`id`),
- UNIQUE KEY `id` (`id`)
- ) ";
-
- $creategroupsuserstablesql = "CREATE TABLE IF NOT EXISTS `{$CFG->prefix}groups_groups_users` (
- `id` int(10) unsigned NOT NULL auto_increment,
- `groupid` int(10) unsigned NOT NULL default '0',
- `userid` int(10) unsigned NOT NULL default '0',
- `timeadded` int(10) unsigned NOT NULL default '0',
- PRIMARY KEY (`id`),
- UNIQUE KEY `id` (`id`),
- KEY `groupid` (`groupid`),
- KEY `userid` (`userid`)
- ) ";
-
- $createcoursesgroupingtablesql = "CREATE TABLE IF NOT EXISTS `{$CFG->prefix}groups_courses_groupings` (
- `id` int(10) unsigned NOT NULL auto_increment,
- `courseid` int(10) unsigned NOT NULL default '0',
- `groupingid` mediumint(9) NOT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `id` (`id`),
- KEY `courseid` (`courseid`)
- ) ";
-
- $creategroupingstablesql = "CREATE TABLE `{$CFG->prefix}groups_groupings` (
- `id` int(10) unsigned NOT NULL auto_increment,
- `name` varchar(254) collate latin1_general_ci NOT NULL,
- `description` text collate latin1_general_ci NOT NULL default '',
- `timecreated` int(10) unsigned NOT NULL default 0,
- `viewowngroup` binary(1) NOT NULL default 1,
- `viewallgroupsmembers` binary(1) NOT NULL default 0,
- `viewallgroupsactivities` binary(1) NOT NULL default 0,
- `teachersgroupmark` binary(1) NOT NULL default 0,
- `teachersgroupview` binary(1) NOT NULL default 0,
- `teachersoverride` binary(1) NOT NULL default 0,
- PRIMARY KEY (`id`),
- UNIQUE KEY `id` (`id`)
- ) ";
-
- $creategroupingsgroupstablesql = "CREATE TABLE IF NOT EXISTS `{$CFG->prefix}groups_groupings_groups` (
- `id` int(10) unsigned NOT NULL auto_increment,
- `groupingid` int(10) unsigned default '0',
- `groupid` int(10) NOT NULL,
- `timeadded` int(10) unsigned NOT NULL default '0',
- PRIMARY KEY (`id`),
- UNIQUE KEY `id` (`id`),
- KEY `courseid` (`groupingid`)
- ) ";
-
- } else { //postgres7
-
- $createcoursegrouptablesql = "CREATE TABLE {$CFG->prefix}groups_courses_groups (
- id SERIAL PRIMARY KEY,
- courseid integer NOT NULL default '0',
- groupid integer NOT NULL default '0'
- );
- CREATE INDEX {$CFG->prefix}groups_courses_groups_courseid_idx ON {$CFG->prefix}groups_courses_groups (courseid);
- ";
- //?? CONSTRAINT {$CFG->prefix}groups_courses_groups_id_courseid_uk UNIQUE (id, courseid)
-
- $creategroupstablesql = "CREATE TABLE {$CFG->prefix}groups_groups (
- id SERIAL PRIMARY KEY,
- name varchar(255) NOT NULL,
- description text NOT NULL default '',
- enrolmentkey varchar(50) NOT NULL default '',
- lang varchar(10) NOT NULL default 'en',
- theme varchar(50) NOT NULL default '',
- picture integer NOT NULL default '0',
- hidepicture integer NOT NULL default '0',
- timecreated integer NOT NULL default '0',
- timemodified integer NOT NULL default '0'
- ) ";
-
- $creategroupsuserstablesql = "CREATE TABLE {$CFG->prefix}groups_groups_users (
- id SERIAL PRIMARY KEY,
- groupid integer NOT NULL default '0',
- userid integer NOT NULL default '0',
- timeadded integer NOT NULL default '0'
- );
- CREATE INDEX {$CFG->prefix}groups_groups_users_groupid_idx ON {$CFG->prefix}groups_groups_users (groupid);
- CREATE INDEX {$CFG->prefix}groups_groups_users_userid_idx ON {$CFG->prefix}groups_groups_users (userid);
- COMMENT ON TABLE {$CFG->prefix}groups_groups_users IS 'New groupings (OU).';
- ";
-
- $createcoursesgroupingtablesql = "CREATE TABLE {$CFG->prefix}groups_courses_groupings (
- id SERIAL PRIMARY KEY,
- courseid integer NOT NULL default '0',
- groupingid integer NOT NULL
- );
- CREATE INDEX {$CFG->prefix}groups_courses_groupings_courseid_idx ON {$CFG->prefix}groups_courses_groupings (courseid);
- COMMENT ON TABLE {$CFG->prefix}groups_courses_groupings IS 'New groupings (OU).';
- ";
-
- $creategroupingstablesql = "CREATE TABLE {$CFG->prefix}groups_groupings (
- id SERIAL PRIMARY KEY,
- name varchar(254) NOT NULL default,
- description text NOT NULL default '',
- timecreated integer NOT NULL default 0,
- viewowngroup integer NOT NULL default 1,
- viewallgroupsmembers integer NOT NULL default 0,
- viewallgroupsactivities integer NOT NULL default 0,
- teachersgroupmark integer NOT NULL default 0,
- teachersgroupview integer NOT NULL default 0,
- teachersoverride integer NOT NULL default 0
- ) ";
-
- $creategroupingsgroupstablesql = "CREATE TABLE {$CFG->prefix}groups_groupings_groups (
- id SERIAL PRIMARY KEY,
- groupingid integer default '0',
- groupid integer NOT NULL,
- timeadded integer NOT NULL default '0'
- );
- CREATE INDEX {$CFG->prefix}groups_groupings_groups_groupingid_idx ON {$CFG->prefix}groups_groupings_groups (groupingid);
- ";
- }
-
- modify_database('', $createcoursegrouptablesql);
- modify_database('', $creategroupstablesql);
- modify_database('', $creategroupsuserstablesql);
- modify_database('', $createcoursesgroupingtablesql);
- modify_database('', $creategroupingstablesql);
- modify_database('', $creategroupingsgroupstablesql);
-}
-
-
-/**
- * Copies any old style moodle group to a new style moodle group - we'll need this for any upgrade code
- * @param int $groupid The 'old moodle groups' id of the group to copy
- * @param int $courseid The course id
- * @param boolean True if the operation was successful, false otherwise.
- */
-function groups_db_copy_moodle_group_to_imsgroup($groupid, $courseid) {
-
- $success = true;
-
- $groupsettings = get_record('groups', 'id ', $groupid, '');
-
- // Only copy the group if the group exists.
- if ($groupsettings != false) {
- $record = new Object();
- $record->name = $groupsettings->name;
- $record->description = $groupsettings->description;
- $record->password = $groupsettings->password;
- $record->lang = $groupsettings->lang;
- $record->theme = $groupsettings->theme;
- $record->picture = $groupsettings->picture;
- $record->hidepicture = $groupsettings->hidepicture;
- $record->timecreated = $groupsettings->timecreated;
- $record->timemodified = $groupsettings->timemodified;
-
- $newgroupid = insert_record('groups_groups', $record);
- if (!$newgroupid) {
- $success = false;
- }
-
- $courserecord = new Object();
- $courserecord->courseid = $groupsettings->courseid;
- $courserecord->groupid = $newgroupid;
-
- $added = insert_record('groups_courses_groups', $courserecord);
-
- if (!$added) {
- $success = false;
- }
-
- // Copy over the group members
- $groupmembers = get_records('groups_users', 'groupid', $groupid);
- if ($groupmembers != false) {
- foreach($groupmembers as $member) {
- $record = new Object();
- $record->groupid = $newgroupid;
- $record->userid = $member->userid;
- $useradded = insert_record('groups_groups_users', $record);
- if (!$useradded) {
- $success = false;
- }
- }
- }
- }
-
- if (!$success) {
- notify('Copy operations from Moodle groups to IMS Groups failed');
- }
-
- return $success;
-}
-
-?>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="group/db" VERSION="20070122" COMMENT="XMLDB file for Moodle groups."
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
->
- <TABLES>
- <TABLE NAME="groups" COMMENT="Each record represents a group." NEXT="groups_groupings">
- <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_groupings" COMMENT="A grouping is a collection of groups." PREVIOUS="groups" NEXT="groups_members">
- <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_members" COMMENT="Link a user to a group." PREVIOUS="groups_groupings" NEXT="groups_courses_groups">
- <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_courses_groups" COMMENT="Link a group to a course (or the site)." PREVIOUS="groups_members" 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">
- <SENTENCES>
- <SENTENCE TEXT="(module, action, mtable, field) VALUES ('group', 'view', 'groups', 'name')" />
- </SENTENCES>
- </STATEMENT>
- </STATEMENTS>
-</XMLDB>
\ No newline at end of file
+++ /dev/null
-<?php //$Id$
-
-// This file keeps track of upgrades to
-// groups
-//
-// Sometimes, changes between versions involve
-// alterations to database structures and other
-// major things that may break installations.
-//
-// The upgrade function in this file will attempt
-// to perform all the necessary actions to upgrade
-// your older installtion to the current version.
-//
-// If there's something it cannot do itself, it
-// will tell you what you need to do.
-//
-// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
-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;
-
- //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');
- }
-
- // 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();
-
- $db->debug = false;
-
- if (!$status or !set_config('group_version', $group_version)) {
- error("Upgrade of group system failed!");
- }
-
- notify(get_string('databasesuccess'), 'green');
- 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->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);
- }
- }
- }
- rs_close($rs);
- $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
-/// It's called from admin/index.php.
-
- global $CFG, $db;
-
- $group_version = ''; // Get code versions
- 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, " ", " ");
-
- upgrade_log_start();
- //initialize default group settings now
- install_group_db();
-
- print_continue($continueto);
- print_footer('none');
- exit;
- }
-
-/// Upgrading code starts here
- if ($group_version > $CFG->group_version) { // Upgrade tables
- $strdatabaseupgrades = get_string('databaseupgrades');
- print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', upgrade_get_javascript());
-
- upgrade_log_start();
- print_heading('group');
-
- $db->debug = true;
- $status = xmldb_group_upgrade($CFG->group_version);
- $db->debug = false;
-
- /// Now analyze upgrade results
- if ($status) { // No upgrading failed
- if (set_config('group_version', $group_version)) {
- notify(get_string('databasesuccess'), 'green');
- notify(get_string('databaseupgradegroups', '', $group_version), 'green');
- print_continue($continueto);
- print_footer('none');
- exit;
- } else {
- error("Error: Upgrade of group system failed! (Could not update version in config table)");
- }
- } else {
- error("Error: Upgrade failed! See group/upgrade.php");
- }
-
- } else if ($group_version < $CFG->group_version) {
- error("Error: The code you are using is OLDER than the version that made these databases!");
- }
-}
-
-/**
- * Transfer data from old 1.7 to new 1.8 groups tables.
- */
-function groups_transfer_db() {
- $status = true;
-
- if (table_exists($t_groups = new XMLDBTable('groups_temp'))) {
- $groups_r = get_records('groups_temp');
- $members_r = get_records('groups_members_temp');
-
- if (!$groups_r) {
- // No gropus to upgrade.
- return true;
- }
- foreach ($groups_r as $group) {
- if (debugging()) {
- print_object($group);
- }
- $group->enrolmentkey = $group->password;
- $status = $status && ($newgroupid = groups_db_upgrade_group($group->courseid, $group));
- if ($members_r) {
- foreach ($members_r as $member) {
- if ($member->groupid == $group->id) {
- $status = $status && groups_add_member($newgroupid, $member->userid);
- }
- }
- }
- }
- } else {
- $status = true; //new install - it is ok!
- }
- return $status;
-}
-
-function groups_drop_keys_indexes_db() {
- $result = true;
- /// 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 && drop_index($table, $index);
-
- /// Define key courseid (foreign) to be added to groups_courses_groups
- $table = new XMLDBTable('groups_courses_groups');
- $key = new XMLDBKey('courseid');
- $key->setAttributes(XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
-
- /// Launch add key courseid
- $result = $result && drop_key($table, $key);
-
- /// Define key groupid (foreign) to be added to groups_courses_groups
- $key = new XMLDBKey('groupid');
- $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
-
- /// Launch add key groupid
- $result = $result && drop_key($table, $key);
-
- /// Define index courseid-groupid (unique) to be added to groups_courses_groups
- $index = new XMLDBIndex('courseid-groupid');
- $index->setAttributes(XMLDB_INDEX_UNIQUE, array('courseid', 'groupid'));
-
- /// Launch add index courseid-groupid
- $result = $result && drop_index($table, $index);
-
- /// Define key courseid (foreign) to be added to groups_courses_groupings
- $table = new XMLDBTable('groups_courses_groupings');
- $key = new XMLDBKey('courseid');
- $key->setAttributes(XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
-
- /// Launch add key courseid
- $result = $result && drop_key($table, $key);
-
- /// Define key groupingid (foreign) to be added to groups_courses_groupings
- $key = new XMLDBKey('groupingid');
- $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupingid'), 'groups_groupings', array('id'));
-
- /// Launch add key groupingid
- $result = $result && drop_key($table, $key);
-
- /// Define index courseid-groupingid (unique) to be added to groups_courses_groupings
- $index = new XMLDBIndex('courseid-groupingid');
- $index->setAttributes(XMLDB_INDEX_UNIQUE, array('courseid', 'groupingid'));
-
- /// Launch add index courseid-groupingid
- $result = $result && drop_index($table, $index);
-
- /// Define key groupingid (foreign) to be added to groups_groupings_groups
- $table = new XMLDBTable('groups_groupings_groups');
- $key = new XMLDBKey('groupingid');
- $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupingid'), 'groups_groupings', array('id'));
-
- /// Launch add key groupingid
- $result = $result && drop_key($table, $key);
-
- /// Define key groupid (foreign) to be added to groups_groupings_groups
- $key = new XMLDBKey('groupid');
- $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
-
- /// Launch add key groupid
- $result = $result && drop_key($table, $key);
-
- /// Define index groupingid-groupid (unique) to be added to groups_groupings_groups
- $index = new XMLDBIndex('groupingid-groupid');
- $index->setAttributes(XMLDB_INDEX_UNIQUE, array('groupingid', 'groupid'));
-
- /// Launch add index groupingid-groupid
- $result = $result && drop_index($table, $index);
-
- return $result;
-}
-
-/**
- * Drop 'new' 1.8 groups tables for 200701240 upgrade below.
- * (Also, for testing it's useful to be able to revert to 'old' groups.)
- */
-function groups_revert_db($renametemp=true) {
- $status = true;
- ///$status = (bool)$rs = delete_records('config', 'name', 'group_version');
- if (table_exists(new XMLDBTable('groups_groupings'))) {
-
- $tables = array('', '_members', '_groupings', '_courses_groups', '_courses_groupings', '_groupings_groups');
- foreach ($tables as $t_name) {
- $status = $status && drop_table(new XMLDBTable('groups'.$t_name));
- }
- $status = $status && (bool)delete_records('log_display', 'module', 'group');
-
- if ($renametemp) {
- $status = $status && rename_table(new XMLDBTable('groups_temp'), 'groups');
- $status = $status && rename_table(new XMLDBTable('groups_members_temp'), 'groups_members');
- }
- }
- return $status;
-}
-
-
-function xmldb_group_upgrade($oldversion=0) {
- global $CFG;
-
- $result = true;
-
- if ($result && $oldversion < 2007012000) {
-
- /// 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);
-
- /// Changing nullability of field description on table groups_groupings to null
- $table = new XMLDBTable('groups_groupings');
- $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);
- }
-
- if ($result && $oldversion < 2007012100) {
-
- /// Changing precision of field lang on table groups to (30)
- $table = new XMLDBTable('groups');
- $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);
- }
-
- /// Adding all the missing FK + Unique indexes (XMLDB will create the underlying indexes)
- if ($result && $oldversion < 2007012200) {
-
- /// 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);
-
- /// Define key courseid (foreign) to be added to groups_courses_groups
- $table = new XMLDBTable('groups_courses_groups');
- $key = new XMLDBKey('courseid');
- $key->setAttributes(XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
-
- /// Launch add key courseid
- $result = $result && add_key($table, $key);
-
- /// Define key groupid (foreign) to be added to groups_courses_groups
- $table = new XMLDBTable('groups_courses_groups');
- $key = new XMLDBKey('groupid');
- $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
-
- /// Launch add key groupid
- $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'));
-
- /// Launch add index courseid-groupid
- $result = $result && add_index($table, $index);
-
- /// Define key courseid (foreign) to be added to groups_courses_groupings
- $table = new XMLDBTable('groups_courses_groupings');
- $key = new XMLDBKey('courseid');
- $key->setAttributes(XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
-
- /// Launch add key courseid
- $result = $result && add_key($table, $key);
-
- /// Define key groupingid (foreign) to be added to groups_courses_groupings
- $table = new XMLDBTable('groups_courses_groupings');
- $key = new XMLDBKey('groupingid');
- $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupingid'), 'groups_groupings', array('id'));
-
- /// Launch add key groupingid
- $result = $result && add_key($table, $key);
-
- /// Define index courseid-groupingid (unique) to be added to groups_courses_groupings
- $table = new XMLDBTable('groups_courses_groupings');
- $index = new XMLDBIndex('courseid-groupingid');
- $index->setAttributes(XMLDB_INDEX_UNIQUE, array('courseid', 'groupingid'));
-
- /// Launch add index courseid-groupingid
- $result = $result && add_index($table, $index);
-
- /// Define key groupingid (foreign) to be added to groups_groupings_groups
- $table = new XMLDBTable('groups_groupings_groups');
- $key = new XMLDBKey('groupingid');
- $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupingid'), 'groups_groupings', array('id'));
-
- /// Launch add key groupingid
- $result = $result && add_key($table, $key);
-
- /// Define key groupid (foreign) to be added to groups_groupings_groups
- $table = new XMLDBTable('groups_groupings_groups');
- $key = new XMLDBKey('groupid');
- $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
-
- /// Launch add key groupid
- $result = $result && add_key($table, $key);
-
- /// Define index groupingid-groupid (unique) to be added to groups_groupings_groups
- $table = new XMLDBTable('groups_groupings_groups');
- $index = new XMLDBIndex('groupingid-groupid');
- $index->setAttributes(XMLDB_INDEX_UNIQUE, array('groupingid', 'groupid'));
-
- /// Launch add index groupingid-groupid
- $result = $result && add_index($table, $index);
- }
-
- if ($result && $oldversion < 2007012400) {
- if (table_exists(new XMLDBTable('groups_temp')) && file_exists($CFG->dirroot.'/group/db/install.xml')) {
- /// Need to drop foreign keys/indexes added in last upgrade, drop 'new' tables, then start again!!
- $result = $result && groups_drop_keys_indexes_db();
- $result = $result && groups_revert_db($renametemp=false);
- $result = $result && install_from_xmldb_file($CFG->dirroot.'/group/db/install.xml');
- $result = $result && groups_transfer_db();
- }
- }
-
- return $result;
-}
-
-?>
*
* @copyright © 2006 The Open University
* @author N.D.Freear AT open.ac.uk
- * @author J.White AT open.ac.uk
+ * @author J.White AT open.ac.uk
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package groups
*/
/// get url variables
$courseid = required_param('courseid', PARAM_INT);
-$id = optional_param('id', false, PARAM_INT);
-$groupingid = optional_param('grouping', false, PARAM_INT);
-$newgrouping = optional_param('newgrouping', false, PARAM_INT);
+$id = optional_param('id', 0, PARAM_INT);
$delete = optional_param('delete', 0, PARAM_BOOL);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
-if (empty($CFG->enablegroupings)) {
- // NO GROUPINGS YET!
- $groupingid = GROUP_NOT_IN_GROUPING;
-}
-
-/// Course must be valid
+/// Course must be valid
if (!$course = get_record('course', 'id', $courseid)) {
error('Course ID was incorrect');
}
error(get_string('errorinvalidgroup'));
}
-if ($delete && !$confirm) {
- print_header(get_string('deleteselectedgroup', 'group'), get_string('deleteselectedgroup', 'group'));
- $optionsyes = array('id'=>$id, 'delete'=>1, 'courseid'=>$courseid, 'sesskey'=>sesskey(), 'confirm'=>1);
- $optionsno = array('id'=>$courseid);
- if (!$group = get_record('groups', 'id', $id)) {
- error('Group ID was incorrect');
- }
- notice_yesno(get_string('deletegroupconfirm', 'group', $group->name), 'edit.php', 'index.php', $optionsyes, $optionsno, 'post', 'get');
- print_footer();
- die;
+/// basic access control checks
+if (! $course = get_record('course', 'id', $courseid)) {
+ error("Incorrect course id ");
}
+$context = get_context_instance(CONTEXT_COURSE, $course->id);
+require_capability('moodle/course:managegroups', $context);
+
+$returnurl = $CFG->wwwroot.'/group/index.php?id='.$course->id.'&group='.$id;
-/// basic access control checks
if ($id) {
if (!$group = get_record('groups', 'id', $id)) {
error('Group ID was incorrect');
- }
- $context = get_context_instance(CONTEXT_COURSE, $course->id);
- require_capability('moodle/course:managegroups', $context);
-
- // If group given but no groupingid, retrieve grouping id
- if (empty($groupingid)) {
- $groupings = groups_get_groupings_for_group($id);
- if (empty($groupings)) {
- $groupingid = -1;
- } else {
- $groupingid = $groupings[0];
- }
- }
+ }
+ if ($group->courseid != $courseid) {
+ error('incorrect courseid');
+ }
+} else {
+ $group = new object();
+ $group->courseid = $courseid;
}
-/// First create the form
-$editform = new group_edit_form('edit.php', compact('group', 'groupingid', 'newgrouping', 'group', 'courseid'));
+if ($id and $delete) {
-/// Override defaults if group is set
-if (!empty($group)) {
- $editform->set_data($group);
-}
+ if (!$confirm) {
+ print_header(get_string('deleteselectedgroup', 'group'), get_string('deleteselectedgroup', 'group'));
+ $optionsyes = array('id'=>$id, 'delete'=>1, 'courseid'=>$courseid, 'sesskey'=>sesskey(), 'confirm'=>1);
+ $optionsno = array('id'=>$courseid);
+ if (!$group = get_record('groups', 'id', $id)) {
+ error('Group ID was incorrect');
+ }
+ notice_yesno(get_string('deletegroupconfirm', 'group', $group->name), 'edit.php', 'index.php', $optionsyes, $optionsno, 'post', 'get');
+ print_footer();
+ die;
-// Process delete action
-if ($delete) {
- if (!confirm_sesskey()) {
- error('Sesskey error');
- }
- if (groups_delete_group($id)) {
- // MDL-9983
- $eventdata = new object();
- $eventdata->group = $id;
- $eventdata->course = $courseid;
- events_trigger('group_deleted', $eventdata);
- redirect(groups_home_url($course->id, null, $groupingid, false));
- } else {
- print_error('erroreditgroup', 'group', groups_home_url($course->id));
+ } else if (confirm_sesskey()){
+ if (groups_delete_group($id)) {
+ // MDL-9983
+ $eventdata = new object();
+ $eventdata->group = $id;
+ $eventdata->course = $courseid;
+ events_trigger('group_deleted', $eventdata);
+ redirect('index.php?id='.$course->id);
+ } else {
+ print_error('erroreditgroup', 'group', groups_home_url($course->id));
+ }
}
}
-$error = null;
+/// First create the form
+$editform = new group_edit_form();
+$editform->set_data($group);
if ($editform->is_cancelled()) {
- redirect(groups_home_url($courseid, $id, $groupingid, false));
+ redirect($returnurl);
+
} elseif ($data = $editform->get_data()) {
- $success = true;
- // preprocess data
- if (empty($group)) { // New group
- // First check if this group name doesn't already exist
- if (groups_group_name_exists($courseid, $data->name)) {
- $error = get_string('groupnameexists', 'group', $data->name);
- $success = false;
- } elseif (!$id = groups_create_group($course->id, $data)) {
- print_error('erroreditgroup');
- } else {
- $success = (bool)$id;
- $data->id = $id;
- if ($groupingid) {
- $success = $success && groups_add_group_to_grouping($id, $groupingid);
- }
- // MDL-9983
- if ($success) {
- events_trigger('group_created', $data);
- }
- }
- } elseif ($groupingid != $newgrouping) { // Moving group to new grouping
- $success = $success && groups_remove_group_from_grouping($id, $groupingid);
- $success = $success && groups_add_group_to_grouping($id, $newgrouping);
- } else { // Updating group
- $group = groups_get_group($data->id);
- if (groups_group_name_exists($courseid, $data->name) && $group->name != $data->name) {
- $error = get_string('groupnameexists', 'group', $data->name);
- $success = false;
- } elseif (!groups_update_group($data, $course->id)) {
- print_error('groupnotupdated');
+
+ $result = false;
+ if ($data->id) {
+ if (!update_record('groups', $data)) {
+ error('Error updating group');
}
- // MDL-9983
- if ($success) {
- events_trigger('group_updated', $data);
+ } else {
+ if (!$data->id = insert_record('groups', $data)) {
+ error('Error updating group');
}
}
- // Handle file upload
- if ($success) {
- require_once("$CFG->libdir/gdlib.php");
- if (save_profile_image($id, $editform->_upload_manager, 'groups')) {
- $data->picture = 1;
- $success = $success && groups_update_group($data, $course->id);
- }
- }
- if ($success) {
- redirect(groups_home_url($course->id, $id, $groupingid, false));
- } elseif (empty($error)) {
- print_error('erroreditgroup', 'group', groups_home_url($course->id));
+ //update image
+ require_once("$CFG->libdir/gdlib.php");
+ if (save_profile_image($data->id, $editform->_upload_manager, 'groups')) {
+ $data->picture = 1;
+ update_record('groups', $data);
}
-}
+
+ redirect($returnurl);
+}
+
$strgroups = get_string('groups');
$strparticipants = get_string('participants');
$strheading = get_string('creategroup', 'group');
}
print_header("$course->shortname: ". $strheading,
- $course->fullname,
+ $course->fullname,
"<a href=\"$CFG->wwwroot/course/view.php?id=$courseid\">$course->shortname</a> ".
"-> <a href=\"$CFG->wwwroot/user/index.php?id=$courseid\">$strparticipants</a> ".
- '-> <a href="' .format_string(groups_home_url($courseid, $id, $groupingid, false)) . "\">$strgroups</a>".
+ "-> <a href=\"$CFG->wwwroot/group/index.php?id=$courseid\">$strgroups</a>".
"-> $strheading", '', '', true, '', user_login_string($course, $USER));
print_heading($strheading);
-if ($error) {
- notify($error);
-}
-
echo '<div id="grouppicture">';
if ($id) {
print_group_picture($group, $course->id);
global $USER, $CFG, $COURSE;
$strrequired = get_string('required');
- $buttonstr = get_string('creategroup', 'group');
-
- if (isset($this->_customdata['group'])) {
- $group = $this->_customdata['group'];
- } else {
- $group = false;
- }
-
- $groupingid = $this->_customdata['groupingid'];
- $newgrouping = $this->_customdata['newgrouping'];
- $courseid = $this->_customdata['courseid'];
$mform =& $this->_form;
-
+
$mform->addElement('text','name', get_string('groupname', 'group'),'maxlength="254" size="50"');
- $mform->setDefault('name', get_string('defaultgroupname', 'group'));
- $mform->addRule('name', get_string('missingname'), 'required', null, 'client');
+ $mform->addRule('name', $strrequired, 'required', null, 'client');
$mform->setType('name', PARAM_MULTILANG);
- $mform->addElement('htmleditor', 'description', get_string('groupdescription', 'group'), array('rows'=> '15', 'course' => $courseid, 'cols'=>'45'));
+ $mform->addElement('htmleditor', 'description', get_string('groupdescription', 'group'), array('rows'=> '15', 'course' => $COURSE->id, 'cols'=>'45'));
$mform->setType('description', PARAM_RAW);
-
+
$mform->addElement('passwordunmask', 'enrolmentkey', get_string('enrolmentkey', 'group'), 'maxlength="254" size="24"', get_string('enrolmentkey'));
$mform->setHelpButton('enrolmentkey', array('groupenrolmentkey', get_string('enrolmentkey', 'group')), true);
$mform->setType('enrolmentkey', PARAM_RAW);
-
+
$maxbytes = get_max_upload_file_size($CFG->maxbytes, $COURSE->maxbytes);
-
+
if (!empty($CFG->gdversion) and $maxbytes) {
$options = array(get_string('no'), get_string('yes'));
$mform->addElement('select', 'hidepicture', get_string('hidepicture'), $options);
-
+
$this->set_upload_manager(new upload_manager('imagefile', false, false, null, false, 0, true, true, false));
$mform->addElement('file', 'imagefile', get_string('newpicture', 'group'));
$mform->setHelpButton('imagefile', array ('picture', get_string('helppicture')), true);
}
+ $mform->addElement('hidden','id');
+ $mform->setType('id', PARAM_INT);
- if ($group) {
- $buttonstr = get_string('save', 'group');
- $mform->addElement('hidden','id', null);
- $mform->setType('id', PARAM_INT);
-if (empty($CFG->enablegroupings)) {
- // NO GROUPINGS YET!
- $mform->addElement('hidden', 'newgrouping', GROUP_NOT_IN_GROUPING);
- $mform->setType('newgrouping', PARAM_INT);
-} else {
- // Options to move group to another grouping
- $groupingids = groups_get_groupings($courseid);
-
- // Add pseudo-grouping "Not in a grouping"
- $groupingids[] = GROUP_NOT_IN_GROUPING;
- if ($groupingids) {
- // Put the groupings into a hash and sort them
- foreach($groupingids as $id) {
- $listgroupings[$id] = groups_get_grouping_displayname($id, $courseid);
- }
- natcasesort($listgroupings);
- $mform->addElement('select', 'newgrouping', get_string('addgroupstogrouping', 'group'), $listgroupings);
- $mform->setDefault('newgrouping', $groupingid);
- }
-}
- }
-
- if($groupingid) {
- $mform->addElement('hidden', 'grouping', $groupingid);
- $mform->setType('grouping', PARAM_INT);
- }
+ $mform->addElement('hidden','courseid');
+ $mform->setType('courseid', PARAM_INT);
- $this->add_action_buttons(true, $buttonstr);
- $mform->addElement('hidden', 'courseid', $courseid);
+ $this->add_action_buttons(true);
}
function definition_after_data() {
global $USER, $CFG;
}
+ function validation($data) {
+ global $COURSE;
+
+ $errors = array();
+
+ $name = $data['name'];
+ if ($data['id'] and $group = get_record('groups', 'id', $data['id'])) {
+ if ($group->name != stripslashes($name)) {
+ if (groups_group_name_exists($COURSE->id, name)) {
+ $errors['name'] = get_string('groupnameexists', 'group', stripslashes($name));
+ }
+ }
+
+ } else {
+ if (groups_group_name_exists($COURSE->id, $name)) {
+ $errors['name'] = get_string('groupnameexists', 'group', $name);
+ }
+ }
+
+ if (count($errors) > 0) {
+ return $errors;
+ } else {
+ return true;
+ }
+ }
+
function get_um() {
return $this->_upload_manager;
}
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package groups
*/
+
+//TODO: reimplement
+die;die;die;
+
require_once('../config.php');
require_once('lib.php');
require_once($CFG->libdir.'/moodlelib.php');
*
* @copyright © 2006 The Open University
* @author N.D.Freear AT open.ac.uk
- * @author J.White AT open.ac.uk
+ * @author J.White AT open.ac.uk
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package groups
*/
require_once('../config.php');
require_once('lib.php');
-require_once($CFG->libdir.'/moodlelib.php');
require_once($CFG->libdir.'/json/JSON.php');
require_js('yui_yahoo');
require_js('yui_connection');
require_js($CFG->wwwroot.'/group/lib/clientlib.js');
-$success = true;
-
-$courseid = required_param('id', PARAM_INT);
-$groupingid = optional_param('grouping', GROUP_NOT_IN_GROUPING, PARAM_INT);
-$groupid = optional_param('group', false, PARAM_INT);
-$userid = optional_param('user', false, PARAM_INT);
-$action = groups_param_action();
-
-if (empty($CFG->enablegroupings)) {
- // NO GROUPINGS YET!
- $groupingid = GROUP_NOT_IN_GROUPING;
-}
-
-if ($groupid) {
- $groupingsforgroup = groups_get_groupings_for_group($groupid);
- if ($groupingsforgroup) {
- // NOTE
- // We currently assume that a group can only belong to one grouping.
- // FIXME
- // The UI will have to be fixed if we want to support more than one
- // groupings per group in the future.
- //
- // vy-shane AT moodle DOT com
- $groupingid = array_shift($groupingsforgroup);
- }
-}
+$courseid = required_param('id', PARAM_INT);
+$groupid = optional_param('group', false, PARAM_INT);
+$userid = optional_param('user', false, PARAM_INT);
+$action = groups_param_action();
+$returnurl = $CFG->wwwroot.'/group/index.php?id='.$courseid;
// Get the course information so we can print the header and
// check the course id is valid
-$course = groups_get_course_info($courseid);
-if (! $course) {
+
+if (!$course = groups_get_course_info($courseid)) {
$success = false;
print_error('invalidcourse'); //'The course ID is invalid'
}
-if ($success) {
// Make sure that the user has permissions to manage groups.
- require_login($courseid);
+ require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $courseid);
if (! has_capability('moodle/course:managegroups', $context)) {
redirect(); //"group.php?id=$course->id"); // Not allowed to see all groups
}
- // Set the session key so we can check this later
- $sesskey = !empty($USER->id) ? $USER->sesskey : '';
-
-
switch ($action) {
case false: //OK, display form.
break;
- case 'ajax_getgroupsingrouping':
- if (GROUP_NOT_IN_GROUPING == $groupingid) {
- $groupids = groups_get_groups_not_in_any_grouping($courseid);
- } else {
- $groupids = groups_get_groups_in_grouping($groupingid);
- }
- $group_names = groups_groupids_to_group_names($groupids);
- $json = new Services_JSON();
- echo $json->encode($group_names);
- die; // Client side JavaScript takes it from here.
-
case 'ajax_getmembersingroup':
$members = array();
}
die; // Client side JavaScript takes it from here.
- case 'showgroupingsettingsform':
- redirect(groups_grouping_edit_url($courseid, $groupingid, false));
- break;
- case 'showgroupingpermsform':
- break;
- case 'deletegrouping':
- redirect(groups_grouping_edit_url($courseid, $groupingid, $html=false, $param='delete=1'));
- break;
- case 'showcreategroupingform':
- redirect(groups_grouping_edit_url($courseid, null, false));
- break;
- case 'printerfriendly':
- redirect('printgrouping.php?courseid='. $courseid .'&groupingid='. $groupingid);
- break;
-
- case 'showgroupsettingsform':
- redirect(groups_group_edit_url($courseid, $groupid, $groupingid, false));
- break;
case 'deletegroup':
- redirect(groups_group_edit_url($courseid, $groupid, $groupingid, $html=false, $param='delete=1'));
- break;
- case 'removegroup':
- break;
- case 'showcreategroupform':
- // Allow groups to be created outside of groupings
- /*
- if (GROUP_NOT_IN_GROUPING == $groupingid) {
- print_error('errornotingrouping', 'group', groups_home_url($courseid), get_string('notingrouping', 'group'));
- }
- */
- redirect(groups_group_edit_url($courseid, null, $groupingid, false));
+ redirect('edit.php?delete=1&courseid='.$courseid.'&id='.$groupid);
break;
+
case 'showcreateorphangroupform':
- redirect(groups_group_edit_url($courseid, null, null, false));
+ redirect('edit.php?courseid='.$courseid);
break;
- case 'addgroupstogroupingform':
+
+ case 'showgroupsettingsform':
+ redirect('edit.php?courseid='.$courseid.'&id='.$groupid);
break;
+
case 'updategroups': //Currently reloading.
break;
case 'removemembers':
break;
+
case 'showaddmembersform':
- redirect(groups_members_add_url($courseid, $groupid, $groupingid, false));
+ redirect('assign.php?group='.$groupid);
break;
+
case 'updatemembers': //Currently reloading.
break;
default: //ERROR.
if (debugging()) {
- error('Error, unknown button/action. Probably a user-interface bug!', groups_home_url($courseid));
+ error('Error, unknown button/action. Probably a user-interface bug!', $returnurl);
break;
}
}
$strgroups = get_string('groups');
$strparticipants = get_string('participants');
- print_header("$course->shortname: $strgroups home", //TODO: home
- $course->fullname,
+ print_header("$course->shortname: $strgroups",
+ $course->fullname,
"<a href=\"$CFG->wwwroot/course/view.php?id=$courseid\">$course->shortname</a> ".
"-> <a href=\"$CFG->wwwroot/user/index.php?id=$courseid\">$strparticipants</a> ".
"-> $strgroups", '', '', true, '', user_login_string($course, $USER));
- $usehtmleditor = false;
- //TODO: eventually we'll implement all buttons, meantime hide the ones we haven't finished.
- $shownotdone = false;
$disabled = 'disabled="disabled"';
-
- // Pre-disable buttons based on URL variables
- if (!empty($groupingid) && $groupingid > -1) {
- $showeditgroupsettingsform_disabled = '';
- $showeditgroupingsettingsform_disabled = '';
- $deletegroup_disabled = '';
- $deletegrouping_disabled = '';
- $printerfriendly_disabled = '';
- $showcreategroupform_disabled = '';
- } else {
- $showeditgroupsettingsform_disabled = $disabled;
- $showeditgroupingsettingsform_disabled = $disabled;
- $deletegroup_disabled = $disabled;
- $deletegrouping_disabled = $disabled;
- $printerfriendly_disabled = $disabled;
- $showcreategroupform_disabled = $disabled;
- }
-
- if ($groupingid == -1 && groups_count_groups_in_grouping(GROUP_NOT_IN_GROUPING, $courseid) > 0) {
- $printerfriendly_disabled = '';
- }
+
+ $showeditgroupsettingsform_disabled = $disabled;
+ $deletegroup_disabled = $disabled;
+ $showcreategroupform_disabled = $disabled;
if (!empty($groupid)) {
$showaddmembersform_disabled = '';
- $showeditgroupsettingsform_disabled = '';
+ $showeditgroupsettingsform_disabled = '';
$deletegroup_disabled = '';
} else {
$deletegroup_disabled = $disabled;
- $showeditgroupsettingsform_disabled = $disabled;
- $showaddmembersform_disabled = $disabled;
+ $showeditgroupsettingsform_disabled = $disabled;
+ $showaddmembersform_disabled = $disabled;
}
-
+
print_heading(format_string($course->shortname) .' '.$strgroups, 'center', 3);
echo '<form id="groupeditform" action="index.php" method="post">'."\n";
echo '<div>'."\n";
echo '<input type="hidden" name="id" value="' . $courseid . '" />'."\n";
-/*
-<input type="hidden" name="groupid" value="<?php p($selectedgroup) ?>" />
-<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>" />
-<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
-*/
echo '<table cellpadding="6" class="generaltable generalbox groupmanagementtable boxaligncenter" summary="">'."\n";
echo '<tr>'."\n";
-if (empty($CFG->enablegroupings)) {
-// NO GROUPIGS YET!
- $sel_groupingid = -1;
-} else {
- echo '<td class="generalboxcontent">'."\n";
- echo '<p><label for="groupings">' . get_string('groupings', 'group') . '<span id="dummygrouping"> </span></label></p>'."\n";
- echo '<select name="grouping" id="groupings" size="15" class="select"';
- echo ' onchange="groupsCombo.refreshGroups(this.options[this.selectedIndex].value);"';
- //NOTE: onclick/onmouseout is for long names in IE6 (Firefox/IE7 display OPTION title).
- echo ' onclick="window.status=this.options[this.selectedIndex].title;" onmouseout="window.status=\'\';">'."\n";
- $groupingids = groups_get_groupings($courseid);
- if (groups_count_groups_in_grouping(GROUP_NOT_IN_GROUPING, $courseid) > 0) {
- //NOTE, only show the pseudo-grouping if it has groups.
- $groupingids[] = GROUP_NOT_IN_GROUPING;
- }
-
- $sel_groupingid = -1;
-
- if ($groupingids) {
- // Put the groupings into a hash and sort them
- foreach($groupingids as $id) {
- $listgroupings[$id] = groups_get_grouping_displayname($id, $courseid);
- }
- natcasesort($listgroupings);
-
- // Print out the HTML
- $count = 1;
- foreach($listgroupings as $id => $name) {
- $select = '';
- if ($groupingid == $id) { //|| $count <= 1) ??
- $select = ' selected="selected"';
- $sel_groupingid = $id;
- }
- echo "<option value=\"$id\"$select title=\"$name\">$name</option>\n";
- $count++;
- }
- } else {
- echo '<option> </option>';
- }
-
- echo '</select>'."\n";
-
-
- echo '<p><input type="submit" name="act_updategroups" id="updategroups" value="'
- . get_string('showgroupsingrouping', 'group') . '" /></p>'."\n";
- echo '<p><input type="submit" ' . $showeditgroupingsettingsform_disabled . ' name="act_showgroupingsettingsform" id="showeditgroupingsettingsform" value="'
- . get_string('editgroupingsettings', 'group') . '" /></p>'."\n";
-
- if ($shownotdone) {
- echo '<p><input type="submit" '.$disabled.' name="act_showgroupingpermsform" '
- . 'id="showeditgroupingpermissionsform" value="'
- . get_string('editgroupingpermissions', 'group') . '" /></p>'."\n";
- }
-
- echo '<p><input type="submit" ' . $deletegrouping_disabled . ' name="act_deletegrouping" id="deletegrouping" value="'
- . get_string('deletegrouping', 'group') . '" /></p>'."\n";
- echo '<p><input type="submit" name="act_showcreategroupingform" id="showcreategroupingform" value="'
- . get_string('creategrouping', 'group') . '" /></p>'."\n";
-
- if ($shownotdone) {
- echo '<p><input type="submit" '.$disabled.' name="act_createautomaticgroupingform" '
- . 'id="showcreateautomaticgroupingform" value="'
- . get_string('createautomaticgrouping', 'group') . '" /></p>'."\n";
- }
-
- echo '<p><input type="submit" ' . $printerfriendly_disabled . ' name="act_printerfriendly" id="printerfriendly" value="'
- . get_string('printerfriendly', 'group') . '" /></p>'."\n";
- echo "</td>\n";
-}
echo "<td>\n";
-if (empty($CFG->enablegroupings)) {
// NO GROUPINGS YET!
echo '<p><label for="groups"><span id="groupslabel">'.get_string('groups').':</span><span id="thegrouping"> </span></label></p>'."\n";
-} else {
- echo '<p><label for="groups"><span id="groupslabel">'.get_string('groupsinselectedgrouping', 'group').' </span><span id="thegrouping">'.get_string('grouping', 'group').'</span></label></p>'."\n";
-}
+
echo '<select name="group" id="groups" size="15" class="select" onchange="membersCombo.refreshMembers(this.options[this.selectedIndex].value);"'."\n";
echo ' onclick="window.status=this.options[this.selectedIndex].title;" onmouseout="window.status=\'\';">'."\n";
- if (GROUP_NOT_IN_GROUPING == $sel_groupingid) {
- $groupids = groups_get_groups_not_in_any_grouping($courseid); //$sel_groupingid
+ if ($groups_records = get_groups($courseid)) {
+ $groupids = groups_groups_to_groupids($groups_records, $courseid);
} else {
- $groupids = groups_get_groups_in_grouping($sel_groupingid);
+ $groupids = false;
}
+
+ $sel_groupid = 0;
+
if ($groupids) {
// Put the groups into a hash and sort them
$group_names = groups_groupids_to_group_names($groupids);
-
+
// Print out the HTML
$count = 1;
foreach ($group_names as $group) {
echo "<option value=\"{$group->id}\"$select title=\"{$group->name}\">{$group->name}</option>\n";
$count++;
}
- } else {
+ } else {
// Print an empty option to avoid the XHTML error of having an empty select element
echo '<option> </option>';
}
-
+
echo '</select>'."\n";
echo '<p><input type="submit" name="act_updatemembers" id="updatemembers" value="'
. get_string('showmembersforgroup', 'group') . '" /></p>'."\n";
echo '<p><input type="submit" '. $deletegroup_disabled . ' name="act_deletegroup" onclick="onDeleteGroup()" id="deletegroup" value="'
. get_string('deleteselectedgroup', 'group') . '" /></p>'."\n";
- if ($shownotdone) {
- echo '<p><input type="submit" '.$disabled.' name="act_removegroup" '
- . 'id="removegroup" value="' . get_string('removegroupfromselectedgrouping', 'group') . '" /></p>'."\n";
- }
-
-if (empty($CFG->enablegroupings)) {
-// NO GROUPIGS YET!
echo '<p><input type="submit" name="act_showcreateorphangroupform" id="showcreateorphangroupform" value="'
. get_string('creategroup', 'group') . '" /></p>'."\n";
- echo '<p><input type="submit" name="act_printerfriendly" id="printerfriendly" value="'
- . get_string('printerfriendly', 'group') . '" /></p>'."\n";
-} else {
- echo '<p><input type="submit" ' . $showcreategroupform_disabled . ' name="act_showcreategroupform" id="showcreategroupform" value="'
- . get_string('creategroupinselectedgrouping', 'group') . '" /></p>'."\n";
-
- echo '<p><input type="submit" name="act_showcreateorphangroupform" id="showcreateorphangroupform" value="'
- . get_string('createorphangroup', 'group') . '" /></p>'."\n";
-
- if ($shownotdone) {
- echo '<p><input type="submit" '.$disabled.' name="act_addgroupstogroupingform" '
- . 'id="showaddgroupstogroupingform" value="' . get_string('addgroupstogrouping', 'group') . '" /></p>'."\n";
- }
-}
echo '</td>'."\n";
echo '<td>'."\n";
//NOTE: the SELECT was, multiple="multiple" name="user[]" - not used and breaks onclick.
echo '<select name="user" id="members" size="15" class="select"'."\n";
echo ' onclick="window.status=this.options[this.selectedIndex].title;" onmouseout="window.status=\'\';">'."\n";
-
- if (isset($sel_groupid)) {
+
+ $userids = false;
+ if ($sel_groupid) {
$userids = groups_get_members($sel_groupid);
}
- if (isset($userids)) { //&& is_array($userids)
+
+ if ($userids) {
// Put the groupings into a hash and sort them
$user_names = groups_userids_to_user_names($userids, $courseid);
if(empty($user_names)) {
echo "<option value=\"{$user->id}\" title=\"{$user->name}\">{$user->name}</option>\n";
}
}
- } else {
+ } else {
// Print an empty option to avoid the XHTML error of having an empty select element
echo '<option> </option>';
}
-
+
echo '</select>'."\n";
- if ($shownotdone) {
- echo '<p><input type="submit" '.$disabled.' name="act_removemembers" '
- . 'id="removemembers" value="' . get_string('removeselectedusers', 'group') . '"/></p>'."\n";
- }
-
echo '<p><input type="submit" ' . $showaddmembersform_disabled . ' name="act_showaddmembersform" '
. 'id="showaddmembersform" value="' . get_string('adduserstogroup', 'group'). '" /></p>'."\n";
echo '</td>'."\n";
//<input type="hidden" name="rand" value="om" />
echo '</div>'."\n";
echo '</form>'."\n";
-
+
echo '<script type="text/javascript">'."\n";
echo '//<![CDATA['."\n";
echo 'var groupsCombo = new UpdatableGroupsCombo("'.$CFG->wwwroot.'", '.$course->id.');'."\n";
echo '</script>'."\n";
print_footer($course);
-}
+
?>
\ No newline at end of file
/**
* Get the group settings object for a group - this contains the following
* properties:
- * name, description, lang, theme, picture, hidepicture
+ * name, description, picture, hidepicture
* @param int $groupid The group ID.
* @return object The group settings object
*/
$groupinfo->description = '';
}
- if (!isset($groupinfo->lang)) {
- $groupinfo->lang = current_language();
- }
-
- if (!isset($groupinfo->theme)) {
- $groupinfo->theme = '';
- }
-
if (!isset($groupinfo->picture)) {
$groupinfo->picture = 0;
}
* Sets the information about a group
* Only sets the string for the picture - does not upload the picture!
* @param object $groupsettings An object containing some or all of the
- * following properties: name, description, lang, theme, picture, hidepicture
+ * following properties: name, description, picture, hidepicture
* @return boolean True if info was added successfully, false otherwise.
*/
function groups_set_group_settings($groupid, $groupsettings) {
YAHOO.util.Dom.setStyle("updategroups", "display", "none");
}
-/**
- * When a grouping is selected, we need to update the groups.
- */
-UpdatableGroupsCombo.prototype.refreshGroups = function (groupingId) {
- // Add the loader gif image.
- createLoaderImg("groupsloader", "groupslabel", this.wwwRoot);
-
- // Update the label.
- var selectEl = document.getElementById("groupings");
- var spanEl = document.getElementById("thegrouping");
- if (selectEl && selectEl.selectedIndex >= 0) {
- spanEl.innerHTML = selectEl.options[selectEl.selectedIndex].title;
- }
-
- // Clear the groups combo box.
- selectEl = document.getElementById("groups");
- if (selectEl) {
- while (selectEl.firstChild) {
- selectEl.removeChild(selectEl.firstChild);
- }
- }
-
- if (groupingId > -1) {
- document.getElementById("showaddmembersform").disabled = true;
- document.getElementById("showeditgroupingsettingsform").disabled = false;
- document.getElementById("deletegrouping").disabled = false;
- document.getElementById("printerfriendly").disabled = false;
- document.getElementById("showeditgroupsettingsform").disabled = true;
- document.getElementById("deletegroup").disabled = true;
- document.getElementById("showcreategroupform").disabled = false;
- } else {
- document.getElementById("showeditgroupingsettingsform").disabled = true;
- document.getElementById("deletegrouping").disabled = true;
- document.getElementById("showcreategroupform").disabled = true;
- document.getElementById("showeditgroupsettingsform").disabled = true;
- document.getElementById("deletegroup").disabled = true;
- document.getElementById("showaddmembersform").disabled = true;
-
- }
-
- var sUrl = this.wwwRoot+"/group/index.php?id="+this.courseId+"&grouping="+groupingId+"&act_ajax_getgroupsingrouping";
- YAHOO.util.Connect.asyncRequest('GET', sUrl, this.connectCallback, null);
-};
-
-
/**
* Class UpdatableMembersCombo
+++ /dev/null
-<?php
-// @@@ TO DO
-function groups_get_forced_grouping($courseid) {
-}
-
-function groups_set_forced_grouping($courseid, $groupingid) {
-}
-
-function groups_course_print_group_selector($userid, $courseid, $permissiontype) {
-}
-
-?>
if (! $groupingid) {
return false;
}
- $grouping_groups = get_records('groups_groupings_groups', 'groupingid ',
+ $grouping_groups = get_records('groupings_groups', 'groupingid ',
$groupingid, '', $fields='id, groupid, timeadded');
return $grouping_groups;
function groups_get_groups_for_user_in_grouping($userid, $groupingid) {
global $CFG;
$sql = "SELECT gg.groupid
- FROM {$CFG->prefix}groups_groupings_groups gg
+ FROM {$CFG->prefix}groupings_groups gg
INNER JOIN {$CFG->prefix}groups_members gm ON gm.groupid = gg.groupid
WHERE gm.userid = '$userid'
AND gg.groupingid = '$groupingid'";
$join = '';
$where= '';
if ($courseid) {
- $join = "INNER JOIN {$CFG->prefix}groups_courses_groups cg ON g.id = cg.groupid";
- $where= "AND cg.courseid = '$courseid'";
+ $where= "AND g.courseid = '$courseid'";
}
$sql = "SELECT g.id
FROM {$CFG->prefix}groups g
$join
WHERE g.id NOT IN
- (SELECT groupid FROM {$CFG->prefix}groups_groupings_groups)
+ (SELECT groupid FROM {$CFG->prefix}groupings_groups)
$where";
$records = get_records_sql($sql);
return count($groupids);
} elseif (GROUP_ANY_GROUPING == $groupingid) {
- return count_records('groups_courses_groups', 'courseid', $courseid);
+ return count_records('groups', 'courseid', $courseid);
} else {
- return count_records('groups_groupings_groups', 'groupingid ', $groupingid);
+ return count_records('groupings_groups', 'groupingid ', $groupingid);
}
}
* Gets the course ID for a given group.
*/
function groups_get_course($groupid) {
- $course_group = get_record('groups_courses_groups', 'groupid', $groupid);
+ $course_group = get_record('groups', 'id', $groupid);
if ($course_group) {
return $course_group->courseid;
}
+++ /dev/null
-List of nice to haves
----------------------
-
-- A way for modules to register the extent to which they support groups. Warn
-people who try to set up groups with a module with legacy group support that it
-might not work if more than one grouping exists.
-- A proper user interface for using the same groups in more than one course
-- The option of view names by last name rather than first name.
-- Option of only showing students/teachers - having teachers mixed up with
-students is confusing
-- Maybe a nice way to see which users are in more than one group in a grouping?
-- When adding users it would be nice to see the current users.
-- Think about metacourses and how groups relate to these
-
-Global groups - I want it to be possible to set up groupings for course 1 and
-for these to be visible for all course on the site, but not editable or
-deletable. I think this code should actually be quite easy to write now and I
-might even do it before this code is put in, just haven't done it yet.
-# A nicer user interface (that doesn't break the back button :-) Ajax separates
-the back and front end of the code really well, so if anyone has good ideas on
-this, it should be quite easy for someone else to do without having to know how
-the internals of the groups code work.
-# Integration with roles and permissions
-# Sign up sheets for groups
-# Proper support for blocks and global features.
-# A way for modules and blocks to declare whether they support groups or not.
-# Putting in search_users functionality for group permissions as well as just
-members of groups.
-# Cool ways to set up groups automatically for particular pedagogical reasons -
-things like minimising overlap with groups in another grouping, creating groups
-just from the users all in another group and creating groups which merge pairs
-of groups from another grouping.
-# Allow settings for groupings which restrict users from being in more than one
-group, number of people per group, etc.
\ No newline at end of file
+++ /dev/null
-Quick summary!
-
-See the wiki too -
-
-http://docs.moodle.org/en/How_groups_work_in_Moodle
-http://docs.moodle.org/en/Groups_documentation_for_module_developers
-
-To install - run install.php. This create the appropriate database tables and
-sets some default config for using an IMS Enterprise web service (in particular
-the default setting is that such a web service is not called).
-
-The user interface for managing groups for a course is groupsui/index.php.
-A grouping is just a set of groups - the idea is that you can have several
-groupings for a course, and then choose different groupings for different
-activities.
-
-Note that installing this code does not enable you to actually use the groupings
-with activity modules - this is coming :-)
-
-configui - This contains the user interface for changing the IMS Enterprise web
-service config
-
-db - all the functions that access the database, only used internally. There are
-basically six tables that this code deals with groups_groups,
-groups_courses_groups,groups_groups_users, groups_groupings
-
-groupui - the user interface for managing the groups and groupings of a course.
-This uses Ajax so most of the code for the user interface is in the javascript
-files - the PHP files just send back an appropriate XML response to specific
-POST requests. You'll probably need to know the basics of how Ajax works to
-understand the Javascript.
-
-lib - The main libraries for the user interface and other moodle code to user.
--- basicgrouplib.php contains the basic functions for adding users to groups,
-deleting groups etc.
--- groupinglib.php contains the basic function for groupings e.g. creating
-groupings, adding groups to groupings
--- extendedgrouplib.php contains other functions that are useful and use the
-basic group and grouping functions
--- lib.php is just there to let you include all the libraries more easily
--- utillib.php contains functions that are handy but don't use any of the group
-or grouping library function e.g.
-things like getting the names of users
--- configlib.php - Contains wrapper functions for getting and setting config
-
-unittests - This directory needs a bit of sorting out, and I've just discovered
-that I've broken one of the main
-tests...
-
-
-strings.php - This is stuff that will need to go in the language files - it's
-here for convenience while I'm doing the
-development.
-
require_once('../config.php');
require_once('lib.php');
+//TODO: fix me
+die;die;die;
$success = true;
$courseid = required_param('courseid', PARAM_INT);
require_once($CFG->dirroot . '/group/lib/basicgrouplib.php');
require_once($CFG->dirroot . '/group/lib/utillib.php');
-class basicgrouplib_test extends UnitTestCase {
+//TODO: rewrite me
+class basicgrouplib_test /*extends UnitTestCase*/ {
var $courseid= 0;
var $userid = 0;
require_once($CFG->dirroot . '/group/lib/groupinglib.php');
-class groupinglib_test extends UnitTestCase {
+//TODO: rewrite me
+class groupinglib_test /*extends UnitTestCase*/ {
var $courseid= 0;
var $userid = 0;
+++ /dev/null
-Things I know needs doing!
---------------------------
-
-0) The main thing is to sort out how permissions are going to work...
-
-1) Write proper code for creating the database - I left this knowing there were
-changes planned here. db/dbsetup.php obviously isn't what you'd want in the end.
-No foreign keys at the moment either and there ought to be. I've also been
-leaving this until the database structure is reasonably settled. If you've done
-this sort of thing elsewhere, I suspect this will be fine. Also need to delete
-the two Yahoo files and reference the ones in lib/yui instead - copied them
-over when I was trying to debug stuff.
-
-2) Move all the Ajax over to use the Yahoo User Interface library - this
-is straightforward but tedious! I've done one example - UpdateGroupings in
-main-selects-form.js, everything else needs doing. You'll need
-to do something sensible with errors, and eventually delete the current
-functions for doing Ajax requests and responses which aren't very good anyway.
-
-2) Move unit tests over to simple test and improve them - we could also do with
-some automated tests for the interface too - Selenium?
-
-3) Security - Need to do a check of this. In particular in the functions
-giving the XML for the Ajax stuff, I think there was something I remember I
-needed to do...
-
-4) Check complies with the Moodle coding standards. I think I may have
-used tabs by accident because I didn't realise that the PHPEclipse settings
-overrode the main Eclipse ones. Also line lengths are too long all over the
-place.
-
-5) The CSS stuff needs to be moved to where it's supposed to be /rationalised
-etc.
-
-6) The whole issue of permissions - talk to me about this
-
-7) Enrolment keys and user pics - haven't tested these out properly.
-
-8) The automatic grouping code could be a lot simpler I realised afterwards,
-but it works so have been loathe to change it!
-
-9) Interesting question as to whether we should somehow record the extent to
-which modules support groups...
-
-10) Who do we let edit/delete what? If a grouping is used by more than one
-course. Maybe we need an 'owning' course in the database structure. Site-wide
-groupings - making these appear in people's lists, but not editable
-
-11) Check I've done the bits with objects ok - need to check how PHP does OO.
-
-12) Check I've done the PHP docs right - just copied other people's!
-
-13) Check all the strings are in the lang file
-
-14) Make sure everything works on Postgres as well as MySQL.
-
-15) One thing that needs to be thought about is if it shoudl be possible to
-turn a module from not using groups to using groups once students have accessed
-it and if so how this should work.
-
-16) Make sure all references to IMS Enterprise stuff/web services are gone.
-
-
-Other parts of the code that will need changing
-------------------------------------------------
-
-1) All the modules - I started doing these and then roles and permissions
-happen.
-2) Lots of the code in user - if we keep the group_member table the same
-can we avoid modifiying some of this
-3) The form where course settings are chosen. We still want it to be possible
-to set a forced grouping for the whole course still and need to remove the
-current options.
-4) For each module, you need to be able to set a grouping.
-5) Blocks, blogs and calendar also need to be dealt with
-6) Backup code - there are bugs in the groups parts of this at the moment
-so be careful here :-)
-7) Code to delete courses etc.
-8) Need to make sure grouped acitivities only display to people in the group.
-
+++ /dev/null
-<?php
-
-////////////////////////////////////////////////////////////////////////////////
-// Code fragment to define the group version etc.
-// This fragment is called by /admin/index.php
-////////////////////////////////////////////////////////////////////////////////
-
-$group_version = 2007012400;
-//$module->requires = 2006120400; // Requires this Moodle version
-
-?>
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20070809" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20070813" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
<FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="showreports" NEXT="hiddensections"/>
<FIELD NAME="hiddensections" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="visible" NEXT="groupmode"/>
<FIELD NAME="groupmode" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="hiddensections" NEXT="groupmodeforce"/>
- <FIELD NAME="groupmodeforce" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="groupmode" NEXT="lang"/>
- <FIELD NAME="lang" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="groupmodeforce" NEXT="theme"/>
+ <FIELD NAME="groupmodeforce" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="groupmode" NEXT="defaultgroupingid"/>
+ <FIELD NAME="defaultgroupingid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="default grouping used in course modules, does not have key intentionally" PREVIOUS="groupmodeforce" NEXT="lang"/>
+ <FIELD NAME="lang" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="defaultgroupingid" NEXT="theme"/>
<FIELD NAME="theme" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="lang" NEXT="cost"/>
<FIELD NAME="cost" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="theme" NEXT="currency"/>
<FIELD NAME="currency" TYPE="char" LENGTH="3" NOTNULL="true" DEFAULT="USD" SEQUENCE="false" ENUM="false" PREVIOUS="cost" NEXT="timecreated"/>
<FIELD NAME="indent" TYPE="int" LENGTH="5" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="score" NEXT="visible"/>
<FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="indent" NEXT="visibleold"/>
<FIELD NAME="visibleold" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="visible" NEXT="groupmode"/>
- <FIELD NAME="groupmode" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="visibleold"/>
+ <FIELD NAME="groupmode" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="visibleold" NEXT="groupingid"/>
+ <FIELD NAME="groupingid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="groupmode" NEXT="groupmembersonly"/>
+ <FIELD NAME="groupmembersonly" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="only members of any group are allowed to access the activity" PREVIOUS="groupingid"/>
</FIELDS>
<KEYS>
- <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for course_modules"/>
+ <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for course_modules" NEXT="groupingid"/>
+ <KEY NAME="groupingid" TYPE="foreign" FIELDS="groupingid" REFTABLE="groupings" REFFIELDS="id" PREVIOUS="primary"/>
</KEYS>
<INDEXES>
<INDEX NAME="visible" UNIQUE="false" FIELDS="visible" NEXT="course"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="time" NEXT="ip"/>
<FIELD NAME="ip" TYPE="char" LENGTH="15" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="course"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="ip" NEXT="coursename"/>
- <FIELD NAME="coursename" TYPE="char" LENGTH="40" NOTNULL="true" DEFAULT="" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="module"/>
+ <FIELD NAME="coursename" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="module"/>
<FIELD NAME="module" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="coursename" NEXT="cmid"/>
<FIELD NAME="cmid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="module" NEXT="action"/>
<FIELD NAME="action" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="cmid" NEXT="url"/>
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="Required ID field" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Unique user ID" PREVIOUS="id" NEXT="username"/>
- <FIELD NAME="username" TYPE="char" LENGTH="100" NOTNULL="true" DEFAULT="" SEQUENCE="false" ENUM="false" COMMENT="Unique username" PREVIOUS="userid" NEXT="token"/>
- <FIELD NAME="token" TYPE="char" LENGTH="40" NOTNULL="true" DEFAULT="" SEQUENCE="false" ENUM="false" COMMENT="Unique SHA1 Token" PREVIOUS="username" NEXT="mnethostid"/>
+ <FIELD NAME="username" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Unique username" PREVIOUS="userid" NEXT="token"/>
+ <FIELD NAME="token" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Unique SHA1 Token" PREVIOUS="username" NEXT="mnethostid"/>
<FIELD NAME="mnethostid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Unique remote host ID" PREVIOUS="token" NEXT="useragent"/>
- <FIELD NAME="useragent" TYPE="char" LENGTH="40" NOTNULL="true" DEFAULT="" SEQUENCE="false" ENUM="false" COMMENT="SHA1 hash of User Agent" PREVIOUS="mnethostid" NEXT="confirm_timeout"/>
+ <FIELD NAME="useragent" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="SHA1 hash of User Agent" PREVIOUS="mnethostid" NEXT="confirm_timeout"/>
<FIELD NAME="confirm_timeout" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="UNIX timestamp for expiry of session" PREVIOUS="useragent" NEXT="session_id"/>
- <FIELD NAME="session_id" TYPE="char" LENGTH="40" NOTNULL="true" DEFAULT="" SEQUENCE="false" ENUM="false" COMMENT="The PHP Session ID" PREVIOUS="confirm_timeout" NEXT="expires"/>
+ <FIELD NAME="session_id" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="The PHP Session ID" PREVIOUS="confirm_timeout" NEXT="expires"/>
<FIELD NAME="expires" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Expire time of session on peer" PREVIOUS="session_id"/>
</FIELDS>
<KEYS>
<TABLE NAME="mnet_sso_access_control" COMMENT="Users by host permitted (or not) to login from a remote provider" PREVIOUS="mnet_session" NEXT="events_queue">
<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"/>
+ <FIELD NAME="username" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Username" PREVIOUS="id" NEXT="mnet_host_id"/>
<FIELD NAME="mnet_host_id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="id of mnet host" PREVIOUS="username" NEXT="accessctrl"/>
<FIELD NAME="accessctrl" TYPE="char" LENGTH="20" NOTNULL="true" DEFAULT="allow" SEQUENCE="false" ENUM="false" COMMENT="Whether or not this user/host can login" PREVIOUS="mnet_host_id"/>
</FIELDS>
<INDEX NAME="tagid" UNIQUE="true" FIELDS="tagid" COMMENT="tagid"/>
</INDEXES>
</TABLE>
- <TABLE NAME="tag_instance" COMMENT="tag_instance table holds the information of associations between tags and other items" PREVIOUS="tag_correlation">
+ <TABLE NAME="tag_instance" COMMENT="tag_instance table holds the information of associations between tags and other items" PREVIOUS="tag_correlation" NEXT="groups">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="11" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="tagid"/>
<FIELD NAME="tagid" TYPE="int" LENGTH="11" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="itemtype"/>
<INDEX NAME="tagiditem" UNIQUE="true" FIELDS="tagid, itemtype, itemid"/>
</INDEXES>
</TABLE>
+ <TABLE NAME="groups" COMMENT="Each record represents a group." PREVIOUS="tag_instance" NEXT="groupings">
+ <FIELDS>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="courseid"/>
+ <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" 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="courseid" 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="false" SEQUENCE="false" ENUM="false" PREVIOUS="description" NEXT="picture"/>
+ <FIELD NAME="picture" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="enrolmentkey" 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." NEXT="courseid"/>
+ <KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" PREVIOUS="primary"/>
+ </KEYS>
+ </TABLE>
+ <TABLE NAME="groupings" COMMENT="A grouping is a collection of groups. WAS: groups_groupings" PREVIOUS="groups" NEXT="groups_members">
+ <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="name"/>
+ <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Short human readable unique name for group." PREVIOUS="courseid" NEXT="description"/>
+ <FIELD NAME="description" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="configdata"/>
+ <FIELD NAME="configdata" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="extra configuration data - may be used by group IU tools" PREVIOUS="description" NEXT="timecreated"/>
+ <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="configdata" 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 groupings." NEXT="courseid"/>
+ <KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" PREVIOUS="primary"/>
+ </KEYS>
+ </TABLE>
+ <TABLE NAME="groups_members" COMMENT="Link a user to a group." PREVIOUS="groupings" NEXT="groupings_groups">
+ <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>
+ </TABLE>
+ <TABLE NAME="groupings_groups" COMMENT="Link a grouping to a group (note, groups can be in multiple groupings ONLY in a course). WAS: groups_groupings_groups" PREVIOUS="groups_members">
+ <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" DEFAULT="0" 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 groupings_groups" NEXT="groupingid"/>
+ <KEY NAME="groupingid" TYPE="foreign" FIELDS="groupingid" REFTABLE="groupings" REFFIELDS="id" PREVIOUS="primary" NEXT="groupid"/>
+ <KEY NAME="groupid" TYPE="foreign" FIELDS="groupid" REFTABLE="groups" REFFIELDS="id" PREVIOUS="groupingid"/>
+ </KEYS>
+ </TABLE>
</TABLES>
<STATEMENTS>
<STATEMENT NAME="insert mnet_application" TYPE="insert" TABLE="mnet_application" COMMENT="Initial insert of records on table mnet_application" NEXT="insert log_display">
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('message', 'remove contact', 'user', 'CONCAT(firstname," ",lastname)')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('message', 'block contact', 'user', 'CONCAT(firstname," ",lastname)')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('message', 'unblock contact', 'user', 'CONCAT(firstname," ",lastname)')" />
+ <SENTENCE TEXT="(module, action, mtable, field) VALUES ('group', 'view', 'groups', 'name')" />
</SENTENCES>
</STATEMENT>
</STATEMENTS>
$result = $result && add_field($table, $field);
}
- if ($result && $oldversion < 2007051101) {
- if (empty($CFG->enablegroupings) and !empty($CFG->group_version)) {
- // delete all groupings - they do not work yet :-(
- // while keeping all existing groups
- require_once("$CFG->dirroot/group/db/upgrade.php");
- undo_groupings();
- }
- }
-
if (!empty($CFG->rolesactive) && $result && $oldversion < 2007051801) {
// Get the role id of the "Auth. User" role and check if the default role id is different
// note: use of assign_capability() is discouraged in upgrade script!
}
+ if ($result && $oldversion < 2007081000) {
+ require_once($CFG->dirroot . '/question/upgrade.php');
+ $result = $result && question_upgrade_context_etc();
+ }
+
+ if ($result && $oldversion < 2007081302) {
+ require_once($CFG->libdir.'/db/upgradelib.php');
+
+ if (table_exists(new XMLDBTable('groups_groupings'))) {
+ /// IF 'groups_groupings' table exists, this is for 1.8.* only.
+ $result = $result && upgrade_18_groups();
+
+ } else {
+ /// ELSE, 1.7.*/1.6.*/1.5.* - create 'groupings' and 'groupings_groups' + rename password to enrolmentkey
+ $result = $result && upgrade_17_groups();
+ }
+
+ /// For both 1.8.* and 1.7.*/1.6.*..
+
+ // delete not used fields
+ $table = new XMLDBTable('groups');
+ $field = new XMLDBField('theme');
+ if (field_exists($table, $field)) {
+ drop_field($table, $field);
+ }
+ $table = new XMLDBTable('groups');
+ $field = new XMLDBField('lang');
+ if (field_exists($table, $field)) {
+ drop_field($table, $field);
+ }
+
+ /// Add groupingid field/f.key to 'course' table.
+ $table = new XMLDBTable('course');
+ $field = new XMLDBField('defaultgroupingid');
+ $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', $prev='groupmodeforce');
+ $result = $result && add_field($table, $field);
+
+
+ /// Add grouping ID, grouponly field/f.key to 'course_modules' table.
+ $table = new XMLDBTable('course_modules');
+ $field = new XMLDBField('groupingid');
+ $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', $prev='groupmode');
+ $result = $result && add_field($table, $field);
+
+ $table = new XMLDBTable('course_modules');
+ $field = new XMLDBField('groupmembersonly');
+ $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', $prev='groupingid');
+ $result = $result && add_field($table, $field);
+
+ $table = new XMLDBTable('course_modules');
+ $key = new XMLDBKey('groupingid');
+ $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupingid'), 'groupings', array('id'));
+ $result = $result && add_key($table, $key);
+
+ }
+
+
/*
/// drop old gradebook tables
if ($result && $oldversion < 2007072209) {
}
}
*/
- if ($result && $oldversion < 2007081000) {
- require_once($CFG->dirroot . '/question/upgrade.php');
- $result = $result && question_upgrade_context_etc();
- }
return $result;
}
return true;
}
+
+
+/**
+ * Create new groupings tables for upgrade from 1.7.*|1.6.* and so on.
+ */
+function upgrade_17_groups() {
+ global $CFG;
+
+ $result = true;
+
+/// Define table groupings to be created
+ $table = new XMLDBTable('groupings');
+
+/// Adding fields to table 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('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('configdata', 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('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+
+/// Adding keys to table groupings
+ $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
+
+/// Launch create table for groupings
+ $result = $result && create_table($table);
+
+// ==========================================
+
+/// Define table groupings_groups to be created
+ $table = new XMLDBTable('groupings_groups');
+
+/// Adding fields to table 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, '0');
+ $table->addFieldInfo('timeadded', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+
+/// Adding keys to table groupings_groups
+ $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->addKeyInfo('groupingid', XMLDB_KEY_FOREIGN, array('groupingid'), 'groupings', array('id'));
+ $table->addKeyInfo('groupid', XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
+
+/// Launch create table for groupings_groups
+ $result = $result && create_table($table);
+
+/// fix not null constrain
+ $table = new XMLDBTable('groups');
+ $field = new XMLDBField('password');
+ $field->setAttributes(XMLDB_TYPE_CHAR, '50', null, null, null, null, null, null, 'description');
+ $result = $result && change_field_notnull($table, $field);
+
+/// Rename field password in table groups to enrolmentkey
+ $table = new XMLDBTable('groups');
+ $field = new XMLDBField('password');
+ $field->setAttributes(XMLDB_TYPE_CHAR, '50', null, null, null, null, null, null, 'description');
+ $result = $result && rename_field($table, $field, 'enrolmentkey');
+
+ return $result;
+}
+
+/**
+ * Drop, add fields and rename tables for groups upgrade from 1.8.*
+ * @param XMLDBTable $table 'groups_groupings' table object.
+ */
+function upgrade_18_groups() {
+ global $db;
+
+ $result = upgrade_18_groups_drop_keys_indexes();
+
+/// Delete not used columns
+ $fields_r = array('viewowngroup', 'viewallgroupsmembers', 'viewallgroupsactivities',
+ 'teachersgroupmark', 'teachersgroupview', 'teachersoverride', 'teacherdeletable');
+ foreach ($fields_r as $fname) {
+ $table = new XMLDBTable('groups_groupings');
+ $field = new XMLDBField($fname);
+ if (field_exists($table, $field)) {
+ $result = $result && drop_field($table, $field);
+ }
+ }
+
+/// Rename 'groups_groupings' to 'groupings'
+ $table = new XMLDBTable('groups_groupings');
+ $result = $result && rename_table($table, 'groupings');
+
+/// Add columns/key 'courseid', exclusivegroups, maxgroupsize, timemodified.
+ $table = new XMLDBTable('groupings');
+ $field = new XMLDBField('courseid');
+ $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0', 'id');
+ $result = $result && add_field($table, $field);
+
+ $table = new XMLDBTable('groupings');
+ $key = new XMLDBKey('courseid');
+ $key->setAttributes(XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
+ $result = $result && add_key($table, $key);
+
+ $table = new XMLDBTable('groupings');
+ $field = new XMLDBField('configdata');
+ $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'description');
+ $result = $result && add_field($table, $field);
+
+ $table = new XMLDBTable('groupings');
+ $field = new XMLDBField('timemodified');
+ $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timecreated');
+ $result = $result && add_field($table, $field);
+
+//==================
+
+/// Add columns/key 'courseid' into groups table
+ $table = new XMLDBTable('groups');
+ $field = new XMLDBField('courseid');
+ $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0', 'id');
+ $result = $result && add_field($table, $field);
+
+ $table = new XMLDBTable('groups');
+ $key = new XMLDBKey('courseid');
+ $key->setAttributes(XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
+ $result = $result && add_key($table, $key);
+
+ /// Changing nullability of field enrolmentkey on table groups to null
+ $table = new XMLDBTable('groups');
+ $field = new XMLDBField('enrolmentkey');
+ $field->setAttributes(XMLDB_TYPE_CHAR, '50', null, null, null, null, null, null, 'description');
+ $result = $result && change_field_notnull($table, $field);
+//==================
+
+/// Now, rename 'groups_groupings_groups' to 'groupings_groups' and add keys
+ $table = new XMLDBTable('groups_groupings_groups');
+ $result = $result && rename_table($table, 'groupings_groups');
+
+ $table = new XMLDBTable('groupings_groups');
+ $key = new XMLDBKey('groupingid');
+ $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupingid'), 'groupings', array('id'));
+ $result = $result && add_key($table, $key);
+
+ $table = new XMLDBTable('groupings_groups');
+ $key = new XMLDBKey('groupid');
+ $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
+ $result = $result && add_key($table, $key);
+
+///=================
+
+/// Transfer course ID from 'mdl_groups_courses_groups' to 'mdl_groups'.
+ if ($result) {
+ if ($rs = get_recordset('groups_courses_groups')) {
+ $db->debug = false;
+ if ($rs->RecordCount() > 0) {
+ while ($group = rs_fetch_next_record($rs)) {
+ //Update record, overwrite the 'id' (not useful) with group ID.
+ $group->id = $group->groupid;
+ unset($group->groupid);
+ $result = $result && update_record('groups', $group);
+ }
+ }
+ rs_close($rs);
+ $db->debug = true;
+ }
+ }
+
+/// Transfer course ID from 'groups_courses_groupings' to 'mdl_groupings'.
+ if ($result) {
+ if ($rs = get_recordset('groups_courses_groupings')) {
+ if ($rs->RecordCount() > 0) {
+ while ($course_grouping = rs_fetch_next_record($rs)) {
+ //Update record, overwrite the 'id' (not useful) with grouping ID.
+ $course_grouping->id = $course_grouping->groupingid;
+ unset($course_grouping->groupingid);
+ $result = $result && update_record('groupings', $course_grouping);
+ }
+ }
+ rs_close($rs);
+ $db->debug = true;
+ }
+ }
+
+/// Drop the old tables
+ if ($result) {
+ drop_table(new XMLDBTable('groups_courses_groups'));
+ drop_table(new XMLDBTable('groups_courses_groupings'));
+ drop_table(new XMLDBTable('groups_temp'));
+ drop_table(new XMLDBTable('groups_members_temp'));
+ unset_config('group_version');
+ }
+
+ return $result;
+}
+
+/**
+ * Drop keys & indexes for groups upgrade from 1.8.*
+ */
+function upgrade_18_groups_drop_keys_indexes() {
+ $result = true;
+
+/// 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'));
+ $result = $result && drop_index($table, $index);
+
+/// Define key courseid (foreign) to be added to groups_courses_groups
+ $table = new XMLDBTable('groups_courses_groups');
+ $key = new XMLDBKey('courseid');
+ $key->setAttributes(XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
+ $result = $result && drop_key($table, $key);
+
+/// Define key groupid (foreign) to be added to groups_courses_groups
+ $table = new XMLDBTable('groups_courses_groups');
+ $key = new XMLDBKey('groupid');
+ $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
+ $result = $result && drop_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'));
+ $result = $result && drop_index($table, $index);
+
+/// Define key courseid (foreign) to be added to groups_courses_groupings
+ $table = new XMLDBTable('groups_courses_groupings');
+ $key = new XMLDBKey('courseid');
+ $key->setAttributes(XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
+ $result = $result && drop_key($table, $key);
+
+/// Define key groupingid (foreign) to be added to groups_courses_groupings
+ $table = new XMLDBTable('groups_courses_groupings');
+ $key = new XMLDBKey('groupingid');
+ $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupingid'), 'groups_groupings', array('id'));
+ $result = $result && drop_key($table, $key);
+
+/// Define index courseid-groupingid (unique) to be added to groups_courses_groupings
+ $table = new XMLDBTable('groups_courses_groupings');
+ $index = new XMLDBIndex('courseid-groupingid');
+ $index->setAttributes(XMLDB_INDEX_UNIQUE, array('courseid', 'groupingid'));
+ $result = $result && drop_index($table, $index);
+
+
+/// Define key groupingid (foreign) to be added to groups_groupings_groups
+ $table = new XMLDBTable('groups_groupings_groups');
+ $key = new XMLDBKey('groupingid');
+ $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupingid'), 'groups_groupings', array('id'));
+ $result = $result && drop_key($table, $key);
+
+/// Define key groupid (foreign) to be added to groups_groupings_groups
+ $table = new XMLDBTable('groups_groupings_groups');
+ $key = new XMLDBKey('groupid');
+ $key->setAttributes(XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
+ $result = $result && drop_key($table, $key);
+
+/// Define index groupingid-groupid (unique) to be added to groups_groupings_groups
+ $table = new XMLDBTable('groups_groupings_groups');
+ $index = new XMLDBIndex('groupingid-groupid');
+ $index->setAttributes(XMLDB_INDEX_UNIQUE, array('groupingid', 'groupid'));
+ $result = $result && drop_index($table, $index);
+
+ return $result;
+}
+
?>
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2007081301; // YYYYMMDD = date
+ $version = 2007081302; // YYYYMMDD = date
// XY = increments within a single day
$release = '1.9 dev'; // Human-friendly version name