From ea3b0f69cf6c32bbc50dbcc525d38241dbf4cbd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 20 Oct 2012 18:24:48 +0200 Subject: [PATCH] Add suspensions to cronjob and add getSuspensionByUserRoomAndType --- .../chat/suspension/ChatSuspension.class.php | 25 +++++++++++++++++++ .../cronjob/ChatCleanupCronjob.class.php | 3 +++ 2 files changed, 28 insertions(+) diff --git a/file/lib/data/chat/suspension/ChatSuspension.class.php b/file/lib/data/chat/suspension/ChatSuspension.class.php index 7e70929..fe7222e 100644 --- a/file/lib/data/chat/suspension/ChatSuspension.class.php +++ b/file/lib/data/chat/suspension/ChatSuspension.class.php @@ -49,4 +49,29 @@ class ChatSuspension extends \wcf\data\DatabaseObject { return $suspensions; } + + /** + * Returns the appropriate suspension for user, room and type. + * + * @param \wcf\data\user\User $user + * @param \wcf\data\chat\room\ChatRoom $room + * @param integer $type + * @return \wcf\data\chat\suspension\ChatSuspension + */ + public static function getSuspensionByUserRoomAndType(\wcf\data\user\User $user, \wcf\data\chat\room\ChatRoom $room, $type) { + $sql = "SELECT + * + FROM + wcf".WCF_N."_user_group_application + WHERE + userID = ? + AND roomID = ? + AND type = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($user->userID, $room->roomID, $type)); + $row = $statement->fetchArray(); + if(!$row) $row = array(); + + return new self(null, $row); + } } diff --git a/file/lib/system/cronjob/ChatCleanupCronjob.class.php b/file/lib/system/cronjob/ChatCleanupCronjob.class.php index 752ed32..3260ec5 100644 --- a/file/lib/system/cronjob/ChatCleanupCronjob.class.php +++ b/file/lib/system/cronjob/ChatCleanupCronjob.class.php @@ -20,6 +20,9 @@ class ChatCleanupCronjob implements ICronjob { $messageAction->executeAction(); $roomAction = new chat\room\ChatRoomAction(array(), 'prune'); $roomAction->executeAction(); + $suspensionAction = new chat\suspension\ChatSuspensionAction(array(), 'prune'); + $suspensionAction->executeAction(); + // kill dead users $deadUsers = \wcf\util\ChatUtil::getDiedUsers();