]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10888: groupings - mod/chat - update to work with groupings
authormattc-catalyst <mattc-catalyst>
Mon, 27 Aug 2007 02:28:35 +0000 (02:28 +0000)
committermattc-catalyst <mattc-catalyst>
Mon, 27 Aug 2007 02:28:35 +0000 (02:28 +0000)
mod/chat/gui_basic/index.php
mod/chat/gui_header_js/index.php
mod/chat/gui_header_js/users.php
mod/chat/gui_sockets/index.php
mod/chat/lib.php
mod/chat/mod_form.php
mod/chat/report.php
mod/chat/view.php

index 89210c8e60f1d9ab636cc5a39c063a43ad3c3b96..79509f18cf57ef6428639ab6eb9e5887ebbd4d85 100644 (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'));
     }
 
index 231899521b68a24b217899206a0a00103fc00d49..f82eb5060b9adf48f35b3fac3be4df5abd17b0f8 100644 (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!");
             }
index 9cd107c5afc7cb9c48156c772fc772f5459d3451..35956794a96c49343bbb0595864149b25a499d16 100644 (file)
 
     $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'));
     }
 
index 33ca929dc10a91e787000535cafed83ec3169879..a7953abaea7cd5668cb7cb92460aa9aea8d775ef 100644 (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;
index a923cbc0cbd8ae45bb5e9234a57a3bef4135b79b..265d3a710bc4ed7ebacc7f50f53a2faffd988dff 100644 (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");
 }
 
index adf195008c113551c741fa206c52ea95d6237bf9..af8a6032e18b489390a6988ce512aebb96b81dc5 100644 (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();
     }
index 3fc45643b8d4b4d2ec5cc7476c699aa5aa36db5e..17ca573b63ccd76dbabce045aca95df6c5f061f1 100644 (file)
                       '', '', 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'";
 
 
 /// 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;
     }
index 99d4d26b5ca646a8fff95c645be05bba0c07574b..8ad9e46a3eeac0e4e738175bc15c39cd999e3a4e 100644 (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'";
 
     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);