From 548c4e2e5571b87b1d65bcccbebb4e1b47c4d673 Mon Sep 17 00:00:00 2001 From: defacer Date: Wed, 15 Dec 2004 07:08:31 +0000 Subject: [PATCH] Fix for bug 2285: chatd shows all chat users as present in every chatroom Should be fixed, but needs testing. --- mod/chat/chatd.php | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/mod/chat/chatd.php b/mod/chat/chatd.php index 8ea2ee623d..8123e6891c 100755 --- a/mod/chat/chatd.php +++ b/mod/chat/chatd.php @@ -251,27 +251,29 @@ class ChatDaemon { echo ''; echo ''; - if(empty($this->sets_info)) { - // No users - echo ''; - } - else { - foreach ($this->sets_info as $usersid => $userinfo) { - $lastping = $timenow - $userinfo['chatuser']->lastmessageping; - $popuppar = '\'/user/view.php?id='.$userinfo['user']->id.'&course='.$userinfo['courseid'].'\',\'user'.$userinfo['chatuser']->id.'\',\'\''; - echo '"; - } + + // Get the users from that chatroom + $users = $this->chatrooms[$info['chatid']]['users']; + + foreach ($users as $usersessionid => $userid) { + // Fetch each user's sessionid and then the rest of his data from $this->sets_info + $userinfo = $this->sets_info[$usersessionid]; + + $lastping = $timenow - $userinfo['chatuser']->lastmessageping; + $popuppar = '\'/user/view.php?id='.$userinfo['user']->id.'&course='.$userinfo['courseid'].'\',\'user'.$userinfo['chatuser']->id.'\',\'\''; + echo '"; } + echo '
 
'; - echo ''; - print_user_picture($userinfo['user']->id, 0, $userinfo['user']->picture, false, false, false); - echo ""; - echo "

"; - echo fullname($userinfo['user'])."
"; - echo "$str->idle: ".format_time($lastping, $str)." "; - echo ''.$str->beep."\n"; - echo "

"; - echo "
'; + echo ''; + print_user_picture($userinfo['user']->id, 0, $userinfo['user']->picture, false, false, false); + echo ""; + echo "

"; + echo fullname($userinfo['user'])."
"; + echo "$str->idle: ".format_time($lastping, $str)." "; + echo ''.$str->beep."\n"; + echo "

"; + echo "
'; // About 2K of HTML comments to force browsers to render the HTML -- 2.39.5