2012-03-04 14:38:25 +00:00
|
|
|
<?php
|
2012-03-12 16:18:15 +00:00
|
|
|
namespace be\bastelstu\wcf\chat;
|
2012-03-04 14:38:25 +00:00
|
|
|
|
|
|
|
/**
|
2012-05-31 14:57:20 +00:00
|
|
|
* Handles updates of Tims Chat.
|
2012-03-04 14:38:25 +00:00
|
|
|
*
|
|
|
|
* @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-04 14:38:25 +00:00
|
|
|
*/
|
|
|
|
final class Update {
|
2012-05-31 14:57:20 +00:00
|
|
|
/**
|
|
|
|
* Contains all the rooms the current installation has.
|
|
|
|
*
|
|
|
|
* @var array<\wcf\data\chat\room\ChatRoom>
|
|
|
|
*/
|
2012-03-04 14:38:25 +00:00
|
|
|
private $rooms = null;
|
2012-05-31 14:57:20 +00:00
|
|
|
|
2012-03-04 14:38:25 +00:00
|
|
|
public function __construct() {
|
|
|
|
$this->rooms = \wcf\data\chat\room\ChatRoom::getCache();
|
|
|
|
}
|
|
|
|
|
2012-05-31 14:57:20 +00:00
|
|
|
/**
|
|
|
|
* Notifies users to refresh the chat as the JS may no longer be fully compatible with the PHP code.
|
|
|
|
*/
|
2012-03-04 14:38:25 +00:00
|
|
|
public function execute() {
|
|
|
|
foreach ($this->rooms as $room) {
|
|
|
|
$messageAction = new \wcf\data\chat\message\ChatMessageAction(array(), 'create', array(
|
|
|
|
'data' => array(
|
|
|
|
'roomID' => $room->roomID,
|
|
|
|
'time' => TIME_NOW,
|
|
|
|
'type' => \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION,
|
2012-03-04 14:42:57 +00:00
|
|
|
// TODO: Language item
|
2012-03-04 14:38:25 +00:00
|
|
|
'message' => 'Tims Chat was updated. Please refresh the page.'
|
|
|
|
)
|
|
|
|
));
|
|
|
|
$messageAction->executeAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$update = new Update();
|
|
|
|
$update->execute();
|