]> git.mjollnir.org Git - moodle.git/commitdiff
Preliminary support for groups in Chat.
authormoodler <moodler>
Tue, 24 Feb 2004 06:35:57 +0000 (06:35 +0000)
committermoodler <moodler>
Tue, 24 Feb 2004 06:35:57 +0000 (06:35 +0000)
It's not well tested yet - I'm hoping to do some testing on moodle.org
with some real people and get this refined enough for the Beta release
later today.

13 files changed:
mod/chat/db/mysql.php
mod/chat/db/mysql.sql
mod/chat/db/postgres7.php
mod/chat/db/postgres7.sql
mod/chat/gui_header_js/chatinput.php
mod/chat/gui_header_js/index.php
mod/chat/gui_header_js/jsupdate.php
mod/chat/insert.php
mod/chat/lib.php
mod/chat/report.php
mod/chat/users.php
mod/chat/version.php
mod/chat/view.php

index 15afb08cefff01228830b65f0fd3a816c7b4255a..bc762e6a5d983842a912ef789061d22cab141fd2 100644 (file)
@@ -23,6 +23,11 @@ function chat_upgrade($oldversion) {
         table_column("chat", "", "schedule", "integer", "4", "", "0", "not null", "studentlogs");
     }
 
+    if ($oldversion < 2004022300) {
+        table_column("chat_messages", "", "groupid", "integer", "10", "unsigned", "0", "not null", "userid");
+        table_column("chat_users",    "", "groupid", "integer", "10", "unsigned", "0", "not null", "userid");
+    }
+
     return true;
 }
 
index dde169848b00d9d32d15385f9e3704f95e22c33a..d11b71c1a5e106cfbe9d8793dd1269872dcc85a6 100644 (file)
@@ -24,6 +24,7 @@ CREATE TABLE `prefix_chat_messages` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `chatid` int(10) NOT NULL default '0',
   `userid` int(10) NOT NULL default '0',
+  `groupid` int(10) NOT NULL default '0',
   `system` int(1) unsigned NOT NULL default '0',
   `message` text NOT NULL,
   `timestamp` int(10) unsigned NOT NULL default '0',
@@ -40,6 +41,7 @@ CREATE TABLE `prefix_chat_users` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `chatid` int(11) NOT NULL default '0',
   `userid` int(11) NOT NULL default '0',
+  `groupid` int(11) NOT NULL default '0',
   `version` varchar(16) NOT NULL default '',
   `ip` varchar(15) NOT NULL default '',
   `firstping` int(10) unsigned NOT NULL default '0',
index 371bd9216207d8a390c4c2acec9cebd2ce609beb..82764d60077009072d53975329585d5874475d66 100644 (file)
@@ -6,6 +6,12 @@ function chat_upgrade($oldversion) {
 
     global $CFG;
 
+    if ($oldversion < 2004022300) {
+        table_column("chat_messages", "", "groupid", "integer", "10", "unsigned", "0", "not null", "userid");
+        table_column("chat_users",    "", "groupid", "integer", "10", "unsigned", "0", "not null", "userid");
+    }
+
+
     return true;
 }
 
index ff2143775a2f75e47684898e800f99fd94a4dcc1..7b54e6749efb287e1322052474df596554d6b84c 100644 (file)
@@ -24,6 +24,7 @@ CREATE TABLE prefix_chat_messages (
   id SERIAL,
   chatid integer NOT NULL default '0',
   userid integer NOT NULL default '0',
+  groupid integer NOT NULL default '0',
   system integer NOT NULL default '0',
   message text NOT NULL,
   timestamp integer NOT NULL default '0',
@@ -39,6 +40,7 @@ CREATE TABLE prefix_chat_users (
   id SERIAL,
   chatid integer NOT NULL default '0',
   userid integer NOT NULL default '0',
+  groupid integer NOT NULL default '0',
   version varchar(16) NOT NULL default '',
   ip varchar(15) NOT NULL default '',
   firstping integer NOT NULL default '0',
index 01ba155146cc07f3c08bb82ed0de144ef9727ca8..64793c93f0e6a822856dd0fc70a91897f34d4da4 100644 (file)
@@ -4,6 +4,7 @@ require("../../../config.php");
 require("../lib.php");
 
 require_variable($chat_sid);
+optional_variable($groupid);
 
 if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) {
     echo "Not logged in!";
@@ -51,7 +52,8 @@ function empty_field_and_submit() {
 
 <form action="../insert.php" method="GET" target="empty" name="fdummy" 
       OnSubmit="return empty_field_and_submit()">
-    <input type="hidden" name="chat_sid" value="<?php echo $chat_sid; ?>">
+    <input type="hidden" name="chat_sid" value="<?php echo $chat_sid ?>">
+    <input type="hidden" name="groupid" value="<?php echo $groupid ?>">
     <input type="hidden" name="chat_version" value="header_js">
     <input type="hidden" name="chat_message">
 </form>
index c74eac2de06ce565c63d567aa697d5c3e959f46a..2948a4fbe803a9be8785dfe1ddf12ffd2b22c81f 100644 (file)
@@ -1,49 +1,71 @@
 <?php
 
-require_once('../../../config.php');
-require_once('../lib.php');
+    require_once('../../../config.php');
+    require_once('../lib.php');
 
-require_variable($id);
+    require_variable($id);
+    optional_variable($groupid);
 
-if (!$chat = get_record("chat", "id", $id)) {
-    error("Could not find that chat room!");
-}
+    if (!$chat = get_record("chat", "id", $id)) {
+        error("Could not find that chat room!");
+    }
+    
+    if (!$course = get_record("course", "id", $chat->course)) {
+        error("Could not find the course this belongs to!");
+    }
+    
+    require_login($course->id);
+    
+    if (isguest()) {
+        error("Guest does not have access to chat rooms");
+    }
 
-if (!$course = get_record("course", "id", $chat->course)) {
-    error("Could not find the course this belongs to!");
-}
+/// Check to see if groups are being used here
+    if ($groupmode = groupmode($course, $cm)) {   // Groups are being used
+        if ($currentgroup = get_and_set_current_group($course->id, $groupmode, $groupid)) {
+            if (!$group = get_record('groups', 'id', $currentgroup)) {
+                error("That group (id $currentgroup) doesn't exist!");
+            }
+            $groupname = ': '.$group->name;
+        } else {
+            $groupname = ': '.get_string('allparticipants');
+        }
+    } else {
+        $currentgroup = false;
+        $groupname = '';
+    }
 
-require_login($course->id);
+    if (!$chat_sid = chat_login_user($chat->id, "header_js")) {
+        error("Could not log in to chat room!!");
+    }
 
-if (isguest()) {
-    error("Guest does not have access to chat rooms");
-}
-
-if (!$chat_sid = chat_login_user($chat->id, "header_js")) {
-    error("Could not log in to chat room!!");
-}
-
-$strchat = get_string("modulename", "chat");
+    if ($currentgroup !== false) {
+        $params = "chat_enter=true&chat_sid=$chat_sid&groupid=$currentgroup";
+    } else {
+        $params = "chat_enter=true&chat_sid=$chat_sid";
+    }
 
+    $strchat = get_string("modulename", "chat");
+    
 
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
 <html>
  <head>
   <title>
-   <?php echo "$strchat: $course->shortname: $chat->name" ?>
+   <?php echo "$strchat: $course->shortname: $chat->name$groupname" ?>
   </title>
  </head>
  <frameset cols="*,200" border="5" framespacing="no" frameborder="yes" marginwidth="2" marginheight="1">
   <frameset rows="0,0,*,40" border="0" framespacing="no" frameborder="no" marginwidth="2" marginheight="1">
    <frame src="../empty.php" NAME="empty" scrolling="no" marginwidth="0" marginheight="0">
-   <frame src="jsupdate.php?chat_sid=<?php echo $chat_sid; ?>&chat_enter=true" scrolling="no" marginwidth="0" marginheight="0">
+   <frame src="jsupdate.php?<?php echo $params ?>" scrolling="no" marginwidth="0" marginheight="0">
    <frame src="chatmsg.php" NAME="msg" scrolling="auto" marginwidth="2" marginheight="1">
-   <frame src="chatinput.php?chat_sid=<?php echo $chat_sid; ?>" name="input" scrolling="no" marginwidth="2" marginheight="1">
+   <frame src="chatinput.php?<?php echo $params ?>" name="input" scrolling="no" marginwidth="2" marginheight="1">
   </frameset>
-  <frame src="../users.php?chat_sid=<?php echo $chat_sid; ?>&chat_enter=true" name="users" scrolling="auto" marginwidth="5" marginheight="5">
+  <frame src="../users.php?<?php echo $params ?>" name="users" scrolling="auto" marginwidth="5" marginheight="5">
  </frameset>
  <noframes>
-  Sorry, this version of ARSC needs a browser that understands framesets. We have a Lynx friendly version too.
+  Sorry, this version of Moodle Chat needs a browser that handles frames.
  </noframes>
 </html>
index d5734c6a3d066ee22e36606f22a2a62ab8fad86d..659df29e32740b712f6dcafe83013d14f9cb24a3 100644 (file)
@@ -3,6 +3,9 @@
 require("../../../config.php");
 require("../lib.php");
 
+$groupid = empty($_GET['groupid']) ? 0 : $_GET['groupid'];
+$groupselect = $groupid ? " AND (groupid='$groupid' OR groupid='0') " : "";
+
 if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) {
     echo "Not logged in!";
     die;
@@ -14,8 +17,7 @@ if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
 
 require_login($chat->course);
 
-
-if ($message = chat_get_latest_message($chatuser->chatid)) {
+if ($message = chat_get_latest_message($chatuser->chatid, $groupid)) {
     $chat_newlasttime = $message->timestamp;
 } else {
     $chat_newlasttime = 0;
@@ -31,7 +33,7 @@ header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
 header("Cache-Control: no-cache, must-revalidate");
 header("Pragma: no-cache");
 header("Content-Type: text/html");
-header("Refresh: $CFG->chat_refresh_room; URL=jsupdate.php?chat_sid=".$chat_sid."&chat_lasttime=".$chat_newlasttime);
+header("Refresh: $CFG->chat_refresh_room; URL=jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&groupid=$groupid");
 
 ?>
   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
@@ -44,8 +46,8 @@ header("Refresh: $CFG->chat_refresh_room; URL=jsupdate.php?chat_sid=".$chat_sid.
 
      if ($chat_lasttime) {
          if ($messages = get_records_select("chat_messages", 
-                                            "chatid = '$chatuser->chatid' AND timestamp > '$chat_lasttime'", 
-                                            "timestamp ASC")) {
+                                 "chatid = '$chatuser->chatid' AND timestamp > '$chat_lasttime' $groupselect", 
+                                 "timestamp ASC")) {
              foreach ($messages as $message) {
                  $formatmessage = chat_format_message($message, $chat->course);
                  if ($formatmessage->beep) {
index 36e70a2306da453590b6a0c4c39430e4c92a04d5..2b0031d1db050dcba4afb272f5d09be26728ab93 100644 (file)
@@ -6,6 +6,7 @@
     require_variable($chat_sid);
     require_variable($chat_version);
     require_variable($chat_message);
+    optional_variable($groupid);
 
     if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) {
         echo "Not logged in!";
     }
     
     require_login($chat->course);
+
+    if ($groupid) {
+        if (!isteacheredit($course->id) and !ismember($groupid)) {
+            error("You can't chat here!");
+        }
+    }
     
 /// Clean up the message
 
@@ -28,6 +35,7 @@
     
         $message->chatid = $chatuser->chatid;
         $message->userid = $chatuser->userid;
+        $message->groupid = $groupid;
         $message->message = $chat_message;
         $message->timestamp = time();
      
 /// Go back to the other page
 
     if ($chat_version == "header" OR $chat_version == "box") {
-        redirect("../gui_$chat_version/chatinput.php?chat_sid=$chat_sid");
+        redirect("../gui_$chat_version/chatinput.php?chat_sid=$chat_sid&groupid=$groupid");
     
     } else if ($chat_version == "text") {
-        redirect("../gui_$chat_version/index.php?chat_sid=$chat_sid&chat_lastid=$chat_lastid");
+        redirect("../gui_$chat_version/index.php?chat_sid=$chat_sid&chat_lastid=$chat_lastid&groupid=$groupid");
     
     } else {
         redirect("empty.php");
index 94764119cec057f7f9290a320a1a9bc22eb9da88..f1cf18281092154915e51cc359a0a32267f27c2d 100644 (file)
@@ -165,18 +165,24 @@ function chat_cron () {
     return true;
 }
 
-function chat_get_participants($chatid) {
+function chat_get_participants($chatid, $groupid=0) {
 //Returns the users with data in one chat
 //(users with records in chat_messages, students)
 
     global $CFG;
 
+    if ($groupid) {
+        $groupselect = " AND (c.groupid='$groupid' OR c.groupid='0')";
+    } else {
+        $groupselect = "";
+    }
+
     //Get students
     $students = get_records_sql("SELECT DISTINCT u.*
                                  FROM {$CFG->prefix}user u,
                                       {$CFG->prefix}chat_messages c
-                                 WHERE c.chatid = '$chatid' and
-                                       u.id = c.userid");
+                                 WHERE c.chatid = '$chatid' $groupselect
+                                   AND u.id = c.userid");
 
     //Return students array (it contains an array of unique users)
     return ($students);
@@ -185,20 +191,26 @@ function chat_get_participants($chatid) {
 //////////////////////////////////////////////////////////////////////
 /// Functions that require some SQL
 
-function chat_get_users($chatid) {
+function chat_get_users($chatid, $groupid=0) {
 
     global $CFG;
+
+    if ($groupid) {
+        $groupselect = " AND (c.groupid='$groupid' OR c.groupid='0')";
+    } else {
+        $groupselect = "";
+    }
    
     return get_records_sql("SELECT u.id, u.firstname, u.lastname, u.picture, c.lastmessageping
                               FROM {$CFG->prefix}chat_users c,
                                    {$CFG->prefix}user u
                              WHERE c.chatid = '$chatid'
-                               AND u.id = c.userid
+                               AND u.id = c.userid $groupselect
                              GROUP BY u.id
                              ORDER BY c.firstping ASC");
 }
 
-function chat_get_latest_message($chatid) {
+function chat_get_latest_message($chatid, $groupid=0) {
 /// Efficient way to extract just the latest message
 /// Uses ADOdb directly instead of get_record_sql()
 /// because the LIMIT command causes problems with 
@@ -206,9 +218,15 @@ function chat_get_latest_message($chatid) {
 
     global $db, $CFG;
 
+    if ($groupid) {
+        $groupselect = " AND (groupid='$groupid' OR groupid='0')";
+    } else {
+        $groupselect = "";
+    }
+
     if (!$rs = $db->Execute("SELECT *
                                FROM {$CFG->prefix}chat_messages 
-                              WHERE chatid = '$chatid' 
+                              WHERE chatid = '$chatid' $groupselect
                            ORDER BY timestamp DESC LIMIT 1")) {
         return false;
     }
@@ -251,6 +269,7 @@ function chat_delete_old_users() {
         foreach ($oldusers as $olduser) {
             $message->chatid = $olduser->chatid;
             $message->userid = $olduser->userid;
+            $message->groupid = $olduser->groupid;
             $message->message = "exit";
             $message->system = 1;
             $message->timestamp = time();
index 9ea6211440fc62646fb04140d4865bb38299eccc..b15b2d380db2ec3ac0631b60dd38fbbfa911692e 100644 (file)
@@ -5,21 +5,22 @@
     require_once("../../config.php");
     require_once("lib.php");
 
-    require_variable($id);      // Chat Module ID, or
+    require_variable($id);          // Course module ID
+    optional_variable($group, "");  // Start of period
     optional_variable($start, "");  // Start of period
     optional_variable($end, "");    // End of period
     optional_variable($deletesession, "");    // Delete a session
     optional_variable($confirmdelete, "");    // End of period
 
-    if (! $chat = get_record("chat", "id", $id)) {
+    if (! $cm = get_record("course_modules", "id", $id)) {
+        error("Course Module ID was incorrect");
+    }
+    if (! $chat = get_record("chat", "id", $cm->instance)) {
         error("Course module is incorrect");
     }
     if (! $course = get_record("course", "id", $chat->course)) {
         error("Course is misconfigured");
     }
-    if (! $cm = get_coursemodule_from_instance("chat", $chat->id, $course->id)) {
-        error("Course Module ID was incorrect");
-    }
 
     require_login($course->id);
 
@@ -30,7 +31,7 @@
         error("You can not view these chat reports");
     }
 
-    add_to_log($course->id, "chat", "view", "view.php?id=$cm->id", "$chat->id", "$cm->id");
+    add_to_log($course->id, "chat", "report", "report.php?id=$cm->id", "$chat->id", "$cm->id");
 
 /// Print the page header
 
         print_header("$course->shortname: $chat->name: $strchatreport", "$course->fullname",
                      "$navigation <a href=\"index.php?id=$course->id\">$strchats</a> -> 
                      <a href=\"view.php?id=$cm->id\">$chat->name</a> -> 
-                     <a href=\"report.php?id=$chat->id\">$strchatreport</a>", 
+                     <a href=\"report.php?id=$cm->id\">$strchatreport</a>", 
                       "", "", true, "", navmenu($course, $cm));
 
         if ($deletesession and $isteacheredit) {
             notice_yesno(get_string("deletesessionsure", "chat"), 
-                         "report.php?id=$chat->id&deletesession=1&confirmdelete=1&start=$start&end=$end", 
-                         "report.php?id=$chat->id");
+                         "report.php?id=$cm->id&deletesession=1&confirmdelete=1&start=$start&end=$end", 
+                         "report.php?id=$cm->id");
         }
 
         if (!$messages = get_records_select("chat_messages", "chatid = $chat->id AND 
@@ -78,7 +79,7 @@
         }
 
         if (!$deletesession or !$isteacheredit) {
-            print_continue("report.php?id=$chat->id");
+            print_continue("report.php?id=$cm->id");
         }
 
         print_footer($course);
                   "", "", true, "", navmenu($course, $cm));
 
 
-    print_heading($chat->name.": ".get_string("sessions", "chat"));
+/// 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");
+    } else {
+        $currentgroup = false;
+    }
+
+    if ($currentgroup) {
+        $groupselect = " AND groupid = '$currentgroup'";
+        $groupparam = "&group=$currentgroup";
+    } else {
+        $groupselect = "";
+        $groupparam = "";
+    }
 
+    print_heading($chat->name.": ".get_string("sessions", "chat"));
 
 /// Delete a session if one has been specified
 
     if ($deletesession and $isteacheredit and $confirmdelete and $start and $end) {
         delete_records_select("chat_messages", "chatid = $chat->id AND 
                                             timestamp >= '$start' AND 
-                                            timestamp <= '$end'");
+                                            timestamp <= '$end' $groupselect");
         $strdeleted  = get_string("deleted");
         notify("$strdeleted: ".userdate($start)." --> ". userdate($end));
         unset($deletesession);
 /// Get the messages
 
     if (empty($messages)) {   /// May have already got them above
-        if (!$messages = get_records("chat_messages", "chatid", $chat->id, "timestamp DESC")) {
+        if (!$messages = get_records_select("chat_messages", "chatid = '$chat->id' $groupselect", "timestamp DESC")) {
             print_heading(get_string("nomessages", "chat"));
             print_footer($course);
             exit;
                 }
 
                 echo "<p align=\"right\">";
-                echo "<a href=\"report.php?id=$chat->id&start=$sessionstart&end=$sessionend\">$strseesession</a>";
+                echo "<a href=\"report.php?id=$cm->id&start=$sessionstart&end=$sessionend$groupparam\">$strseesession</a>";
                 if ($isteacheredit) {
-                    echo "<br /><a href=\"report.php?id=$chat->id&start=$sessionstart&end=$sessionend&deletesession=1\">$strdeletesession</a>";
+                    echo "<br /><a href=\"report.php?id=$cm->id&start=$sessionstart&end=$sessionend&deletesession=1$groupparam\">$strdeletesession</a>";
                 }
                 echo "</p>";
                 print_simple_box_end();
index 319b32a2c3a6a5fa0e343273a81bb5ae29510a98..5f9088c1e68797798078a927e211922d4eb5b8f7 100644 (file)
@@ -4,6 +4,7 @@ include("../../config.php");
 include("lib.php");
 
 require_variable($chat_sid);
+optional_variable($groupid, 0);
 
 if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) {
     echo "Not logged in!";
@@ -24,6 +25,7 @@ if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
 if (isset($_GET['chat_enter'])) {
     $message->chatid = $chatuser->chatid;
     $message->userid = $chatuser->userid;
+    $message->groupid = $groupid;
     $message->message = "enter";
     $message->system = 1;
     $message->timestamp = time();
@@ -36,6 +38,7 @@ if (isset($_GET['chat_enter'])) {
 if (isset($_GET['beep'])) {
     $message->chatid = $chatuser->chatid;
     $message->userid = $chatuser->userid;
+    $message->groupid = $groupid;
     $message->message = "beep $beep";
     $message->system = 0;
     $message->timestamp = time();
@@ -80,7 +83,7 @@ $str->secs  = get_string("secs");
 
 /// Get list of users
 
-if (!$chatusers = chat_get_users($chatuser->chatid)) {
+if (!$chatusers = chat_get_users($chatuser->chatid, $groupid)) {
     print_string("errornousers", "chat");
     exit;
 }
@@ -96,7 +99,7 @@ foreach ($chatusers as $chatuser) {
     echo "<p><font size=1>";
     echo fullname($chatuser)."<br />";
     echo "<font color=\"#888888\">$stridle: ".format_time($lastping, $str)."</font>";
-    echo " <a href=\"users.php?chat_sid=$chat_sid&beep=$chatuser->id\">$strbeep</a>";
+    echo " <a href=\"users.php?chat_sid=$chat_sid&beep=$chatuser->id&groupid=$groupid\">$strbeep</a>";
     echo "</font></p>";
     echo "<td></tr>";
 }
index d931424e101c7573e99ffd70b97af64ab54b7913..3bd9ef5fd1e0a3463d093f2de461ef0adf8c6ac1 100644 (file)
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2004013101;   // The (date) version of this module
+$module->version  = 2004022300;   // The (date) version of this module
 $module->requires = 2004013101;  // Requires this Moodle version
 $module->cron     = 300;          // How often should cron check this module (seconds)?
 
index a9c29a67afa6a466fafca359c0bedea56fc43eb4..54b3b2b8abac8ff96a979c36928112b8f71e933e 100644 (file)
                   navmenu($course, $cm));
 
     if (($chat->studentlogs or isteacher($course->id)) and !isguest()) {
-        echo "<p align=right><a href=\"report.php?id=$chat->id\">".
+        echo "<p align=right><a href=\"report.php?id=$cm->id\">".
               get_string("viewreport", "chat")."</a></p>";
     }
 
+
+/// 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, "view.php?id=$cm->id");
+    } else {
+        $currentgroup = false;
+    }
+
+    if ($currentgroup) {
+        $groupselect = " AND groupid = '$currentgroup'";
+        $groupparam = "&group=$currentgroup";
+    } else {
+        $groupselect = "";
+        $groupparam = "";
+    }
+
 /// Print the main part of the page
 
    // Do the browser-detection etc later on.
 
     if (!isguest()) {
         print_simple_box_start("center");
-        link_to_popup_window ("/mod/chat/gui_$chatversion/index.php?id=$chat->id", 
-                              "chat$course->id$chat->id", "$strenterchat", 500, 700, $strchat);
+        link_to_popup_window ("/mod/chat/gui_$chatversion/index.php?id=$chat->id$groupparam", 
+                              "chat$course->id$chat->id$groupparam", "$strenterchat", 500, 700, $strchat);
         print_simple_box_end();
     }