From b7602a115e22833a4bc6f29ad9ad48c5d6680ab7 Mon Sep 17 00:00:00 2001
From: moodler
Date: Thu, 10 Jul 2003 04:46:03 +0000
Subject: [PATCH] Chat now prints something useful under recent activity
---
lang/en/chat.php | 1 +
mod/chat/lib.php | 35 +++++++++++++++++++++++++++++------
2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/lang/en/chat.php b/lang/en/chat.php
index ed309e9a00f..163fb0c6a80 100644
--- a/lang/en/chat.php
+++ b/lang/en/chat.php
@@ -8,6 +8,7 @@ $string['modulenameplural'] = "Chats";
$string['beep'] = "beep";
$string['chatintro'] = "Introduction text";
$string['chatname'] = "Name of this chat room";
+$string['currentchats'] = "Currently active chats";
$string['enterchat'] = "Click here to enter the chat";
$string['idle'] = "Idle";
$string['messagebeepseveryone'] = "\$a beeps everyone!";
diff --git a/mod/chat/lib.php b/mod/chat/lib.php
index 6320a5ed720..2c38cd49126 100644
--- a/mod/chat/lib.php
+++ b/mod/chat/lib.php
@@ -91,15 +91,38 @@ function chat_user_complete($course, $user, $mod, $chat) {
return true;
}
-function chat_print_recent_activity(&$logs, $isteacher=false) {
-/// Given a list of logs, assumed to be those since the last login
-/// this function prints a short list of changes related to this module
-/// If isteacher is true then perhaps additional information is printed.
+function chat_print_recent_activity($course, $isteacher, $timestart) {
+/// Given a course and a date, prints a summary of all chat rooms
+/// that currently have people in them.
/// This function is called from course/lib.php: print_recent_activity()
- global $CFG, $COURSE_TEACHER_COLOR;
+ global $CFG;
- return $content; // True if anything was printed, otherwise false
+ if (!$chatusers = get_records_sql("SELECT cu.chatid, u.firstname, u.lastname
+ FROM {$CFG->prefix}chat_users as cu,
+ {$CFG->prefix}user as u
+ WHERE cu.userid = u.id
+ ORDER BY cu.chatid ASC") ) {
+ return false;
+ }
+
+ print_headline(get_string("currentchats", "chat").":");
+
+ $current = 0;
+ foreach ($chatusers as $chatuser) {
+ if ($current != $chatuser->chatid) {
+ if ($current) {
+ echo "
";
+ }
+ if ($chat = get_record("chat", "id", $chatuser->chatid)) {
+ echo "wwwroot/mod/chat/view.php?c=$chat->id\">$chat->name
";
+ }
+ $current = $chatuser->chatid;
+ }
+ echo " - $chatuser->firstname $chatuser->lastname
";
+ }
+
+ return true;
}
function chat_cron () {