MDL-10888: groupings - mod/chat - update to work with groupings

This commit is contained in:
mattc-catalyst
2007-08-27 02:28:35 +00:00
parent ba3dc7b4a8
commit a12e11c13a
8 changed files with 43 additions and 22 deletions
+4 -4
View File
@@ -27,9 +27,9 @@
require_capability('mod/chat:chat',$context);
/// Check to see if groups are being used here
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
if ($groupid = get_and_set_current_group($course, $groupmode, $groupid)) {
if (!$group = get_record('groups', 'id', $groupid)) {
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
if ($groupid = groups_get_activity_group($cm)) {
if (!$group = groups_get_group($groupid, false)) {
error("That group (id $groupid) doesn't exist!");
}
$groupname = ': '.$group->name;
@@ -48,7 +48,7 @@
error('Could not log in to chat room!!');
}
if (!$chatusers = chat_get_users($chat->id, $groupid)) {
if (!$chatusers = chat_get_users($chat->id, $groupid, $cm->groupingid)) {
error(get_string('errornousers', 'chat'));
}
+2 -2
View File
@@ -30,8 +30,8 @@
}
/// Check to see if groups are being used here
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
if ($groupid = get_and_set_current_group($course, $groupmode, $groupid)) {
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
if ($groupid = groups_get_activity_group($cm)) {
if (!$group = groups_get_group($groupid, false)) {
error("That group (id $groupid) doesn't exist!");
}
+5 -1
View File
@@ -28,6 +28,10 @@
$courseid = $chatuser->course;
if (!$cm = get_coursemodule_from_instance('chat', $chatuser->chatid, $courseid)) {
error('Course Module ID was incorrect');
}
if ($beep) {
$message->chatid = $chatuser->chatid;
$message->userid = $chatuser->userid;
@@ -50,7 +54,7 @@
/// Get list of users
if (!$chatusers = chat_get_users($chatuser->chatid, $chatuser->groupid)) {
if (!$chatusers = chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid)) {
error(get_string('errornousers', 'chat'));
}
+3 -3
View File
@@ -30,9 +30,9 @@
}
/// Check to see if groups are being used here
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
if ($groupid = get_and_set_current_group($course, $groupmode, $groupid)) {
if (! groups_group_exists($groupid)) {
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
if ($groupid = groups_get_activity_group($cm)) {
if (!$group = groups_get_group($groupid, false)) {
error("That group (id $groupid) doesn't exist!");
}
$groupname = ': '.$group->name;
+13 -4
View File
@@ -315,7 +315,7 @@ function chat_refresh_events($courseid = 0) {
//////////////////////////////////////////////////////////////////////
/// Functions that require some SQL
function chat_get_users($chatid, $groupid=0) {
function chat_get_users($chatid, $groupid=0, $groupingid=0) {
global $CFG;
@@ -324,12 +324,21 @@ function chat_get_users($chatid, $groupid=0) {
} else {
$groupselect = "";
}
if (!empty($CFG->enablegroupings) && !(empty($groupingid))) {
$groupingjoin = "INNER JOIN {$CFG->prefix}groups_members gm ON u.id = gm.userid
INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = gg.groupid AND gg.groupingid = $groupingid ";
} else {
$groupingjoin = '';
}
return get_records_sql("SELECT DISTINCT u.id, u.firstname, u.lastname, u.picture, c.lastmessageping, c.firstping
FROM {$CFG->prefix}chat_users c,
{$CFG->prefix}user u
FROM {$CFG->prefix}chat_users c
INNER JOIN {$CFG->prefix}user u ON u.id = c.userid
$groupingjoin
WHERE c.chatid = '$chatid'
AND u.id = c.userid $groupselect
$groupselect
ORDER BY c.firstping ASC");
}
+5 -1
View File
@@ -47,7 +47,11 @@ class mod_chat_mod_form extends moodleform_mod {
$mform->addElement('selectyesno', 'studentlogs', get_string('studentseereports', 'chat'));
$this->standard_coursemodule_elements();
$features = new stdClass;
$features->groups = true;
$features->groupings = true;
$features->groupmembersonly = true;
$this->standard_coursemodule_elements($features);
$this->add_action_buttons();
}
+7 -4
View File
@@ -50,8 +50,10 @@
'', '', true, '', navmenu($course, $cm));
/// Check to see if groups are being used here
$groupmode = groupmode($course, $cm);
$currentgroup = setup_and_print_groups($course, $groupmode, "report.php?id=$cm->id");
$groupmode = groups_get_activity_groupmode($cm);
$currentgroup = groups_get_activity_group($cm, true);
groups_print_activity_menu($cm, "report.php?id=$cm->id");
if ($currentgroup) {
$groupselect = " AND groupid = '$currentgroup'";
@@ -106,8 +108,9 @@
/// Check to see if groups are being used here
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
$currentgroup = setup_and_print_groups($course, $groupmode, "report.php?id=$cm->id");
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
$currentgroup = groups_get_activity_group($cm, true);
groups_print_activity_menu($cm, "report.php?id=$cm->id");
} else {
$currentgroup = false;
}
+4 -3
View File
@@ -84,8 +84,9 @@
if (!empty($THEME->customcorners)) print_custom_corners_start();
/// Check to see if groups are being used here
$groupmode = groupmode($course, $cm);
$currentgroup = setup_and_print_groups($course, $groupmode, "view.php?id=$cm->id");
$groupmode = groups_get_activity_groupmode($cm);
$currentgroup = groups_get_activity_group($cm, true);
groups_print_activity_menu($cm, "view.php?id=$cm->id");
if ($currentgroup) {
$groupselect = " AND groupid = '$currentgroup'";
@@ -163,7 +164,7 @@
chat_delete_old_users();
if ($chatusers = chat_get_users($chat->id, $currentgroup)) {
if ($chatusers = chat_get_users($chat->id, $currentgroup, $cm->groupingid)) {
$timenow = time();
print_simple_box_start('center');
print_heading($strcurrentusers);