2012-03-08 21:07:46 +00:00
|
|
|
<?php
|
|
|
|
namespace wcf\system\cronjob;
|
2012-05-19 18:33:25 +00:00
|
|
|
use \wcf\data\chat;
|
2012-03-08 21:07:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Vaporizes unneeded data.
|
|
|
|
*
|
|
|
|
* @author Tim Düsterhus
|
|
|
|
* @copyright 2010-2012 Tim Düsterhus
|
|
|
|
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
2012-03-12 16:18:15 +00:00
|
|
|
* @package be.bastelstu.wcf.chat
|
2012-03-08 21:07:46 +00:00
|
|
|
* @subpackage system.cronjob
|
|
|
|
*/
|
|
|
|
class ChatCleanupCronjob implements ICronjob {
|
|
|
|
/**
|
|
|
|
* @see wcf\system\ICronjob::execute()
|
|
|
|
*/
|
|
|
|
public function execute(\wcf\data\cronjob\Cronjob $cronjob) {
|
2012-05-19 18:33:25 +00:00
|
|
|
$messageAction = new chat\message\ChatMessageAction(array(), 'prune');
|
|
|
|
$messageAction->executeAction();
|
|
|
|
$roomAction = new chat\room\ChatRoomAction(array(), 'prune');
|
|
|
|
$roomAction->executeAction();
|
2012-10-20 16:24:48 +00:00
|
|
|
$suspensionAction = new chat\suspension\ChatSuspensionAction(array(), 'prune');
|
|
|
|
$suspensionAction->executeAction();
|
|
|
|
|
2012-04-19 13:06:34 +00:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
}
|
2012-03-08 21:07:46 +00:00
|
|
|
}
|
|
|
|
}
|