From a2e9f1c5791464b09321572c374ed7c652c3939a Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 9 Jul 2003 04:27:23 +0000 Subject: [PATCH] Add a notification when people have left --- lang/en/chat.php | 1 + mod/chat/users.php | 18 +++++++++++++++++- mod/chat/view.php | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lang/en/chat.php b/lang/en/chat.php index 603bbf276f..6d00940bf1 100644 --- a/lang/en/chat.php +++ b/lang/en/chat.php @@ -10,6 +10,7 @@ $string['chatname'] = "Name of this chat room"; $string['enterchat'] = "Click here to enter the chat"; $string['idle'] = "Idle"; $string['messageenter'] = "\$a has just entered this chat"; +$string['messageexit'] = "\$a has left this chat"; $string['savemessages'] = "Number of messages to save"; $string['strftimemessage'] = "%%H:%%M"; diff --git a/mod/chat/users.php b/mod/chat/users.php index d68bb77aa1..fc19c1c2eb 100644 --- a/mod/chat/users.php +++ b/mod/chat/users.php @@ -37,7 +37,23 @@ if (isset($chat_enter)) { $timeold = time() - CHAT_OLD_PING; -delete_records_select("chat_users", "lastping < '$timeold'"); +if ($oldusers = get_records_select("chat_users", "lastping < '$timeold'") ) { + delete_records_select("chat_users", "lastping < '$timeold'"); + foreach ($oldusers as $olduser) { + $message->chatid = $olduser->chatid; + $message->userid = $olduser->userid; + $message->message = "exit"; + $message->system = 1; + $message->timestamp = time(); + + if (!insert_record("chat_messages", $message)) { + error("Could not insert a chat message!"); + } + } + + +} + /// Get list of users diff --git a/mod/chat/view.php b/mod/chat/view.php index 0d66e25aa1..fefdaf6d95 100644 --- a/mod/chat/view.php +++ b/mod/chat/view.php @@ -71,7 +71,7 @@ // chat_display_version("box", $browser); // chat_display_version("text", $browser); - print_heading(""); + print_heading($chat->name); print_simple_box( text_to_html($chat->intro) , "center"); -- 2.39.5