From 8dcd287fb4eecf11e2cc6f248ae593472782a6bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 19 Apr 2012 15:06:34 +0200 Subject: [PATCH] Clean Up dead users by cronjob as well. --- cronjob.xml | 2 +- .../cronjob/ChatCleanupCronjob.class.php | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/cronjob.xml b/cronjob.xml index 337757f..9384a61 100644 --- a/cronjob.xml +++ b/cronjob.xml @@ -4,7 +4,7 @@ wcf\system\cronjob\ChatCleanupCronjob Cleans up Tims Chat - */30 + */15 * * * diff --git a/file/lib/system/cronjob/ChatCleanupCronjob.class.php b/file/lib/system/cronjob/ChatCleanupCronjob.class.php index 5acde97..9e73303 100644 --- a/file/lib/system/cronjob/ChatCleanupCronjob.class.php +++ b/file/lib/system/cronjob/ChatCleanupCronjob.class.php @@ -17,5 +17,31 @@ class ChatCleanupCronjob implements ICronjob { public function execute(\wcf\data\cronjob\Cronjob $cronjob) { \wcf\data\chat\message\ChatMessageEditor::prune(); \wcf\data\chat\room\ChatRoomEditor::prune(); + + // kill dead users + $deadUsers = \wcf\util\ChatUtil::getDiedUsers(); + foreach ($deadUsers as $deadUser) { + if (!$deadUser) continue; + + $user = new \wcf\data\user\User($deadUser['userID']); + if (CHAT_DISPLAY_JOIN_LEAVE) { + $userData['color'] = \wcf\util\ChatUtil::readUserData('color', $user); + + $messageAction = new chat\message\ChatMessageAction(array(), 'create', array( + 'data' => array( + 'roomID' => $deadUser['roomID'], + 'sender' => $user->userID, + 'username' => $user->username, + 'time' => TIME_NOW, + 'type' => chat\message\ChatMessage::TYPE_LEAVE, + 'message' => '', + 'color1' => $userData['color'][1], + 'color2' => $userData['color'][2] + ) + )); + $messageAction->executeAction(); + } + \wcf\util\ChatUtil::writeUserData(array('roomID' => null), $user); + } } }