1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-24 22:00:09 +00:00
Tims-Chat/file/lib/system/cronjob/CleanupCronjob.class.php

53 lines
1.6 KiB
PHP
Raw Normal View History

<?php
2013-01-19 19:36:40 +00:00
namespace chat\system\cronjob;
use \chat\data;
/**
* Vaporizes unneeded data.
*
* @author Tim Düsterhus
2013-01-19 19:36:40 +00:00
* @copyright 2010-2013 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
2013-01-19 19:36:40 +00:00
* @package be.bastelstu.chat
* @subpackage system.cronjob
*/
2013-01-27 16:27:47 +00:00
class CleanupCronjob implements \wcf\system\cronjob\ICronjob {
/**
* @see wcf\system\ICronjob::execute()
*/
public function execute(\wcf\data\cronjob\Cronjob $cronjob) {
2013-01-19 19:36:40 +00:00
$messageAction = new data\message\MessageAction(array(), 'prune');
2012-05-19 18:33:25 +00:00
$messageAction->executeAction();
2013-01-19 19:36:40 +00:00
$roomAction = new data\room\RoomAction(array(), 'prune');
2012-05-19 18:33:25 +00:00
$roomAction->executeAction();
2013-01-19 19:36:40 +00:00
$suspensionAction = new data\suspension\SuspensionAction(array(), 'prune');
$suspensionAction->executeAction();
// kill dead users
2013-01-19 19:36:40 +00:00
$deadUsers = \chat\util\ChatUtil::getDiedUsers();
foreach ($deadUsers as $deadUser) {
if (!$deadUser) continue;
$user = new \wcf\data\user\User($deadUser['userID']);
if (CHAT_DISPLAY_JOIN_LEAVE) {
2013-01-19 19:36:40 +00:00
$userData['color'] = \chat\util\ChatUtil::readUserData('color', $user);
2013-01-19 19:36:40 +00:00
$messageAction = new data\message\MessageAction(array(), 'create', array(
'data' => array(
'roomID' => $deadUser['roomID'],
'sender' => $user->userID,
'username' => $user->username,
'time' => TIME_NOW,
2013-01-19 19:36:40 +00:00
'type' => data\message\Message::TYPE_LEAVE,
'message' => '',
'color1' => $userData['color'][1],
'color2' => $userData['color'][2]
)
));
$messageAction->executeAction();
}
2013-01-19 19:36:40 +00:00
\chat\util\ChatUtil::writeUserData(array('roomID' => null), $user);
}
}
}