2012-03-04 14:38:25 +00:00
|
|
|
<?php
|
2013-05-03 20:13:58 +00:00
|
|
|
namespace be\bastelstu\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
|
2013-01-19 19:36:40 +00:00
|
|
|
* @copyright 2010-2013 Tim Düsterhus
|
2012-03-04 14:38:25 +00:00
|
|
|
* @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
|
2012-03-04 14:38:25 +00:00
|
|
|
*/
|
2012-12-20 18:07:58 +00:00
|
|
|
// @codingStandardsIgnoreFile
|
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-10-15 10:15:56 +00:00
|
|
|
/**
|
|
|
|
* Contains all the styles the current installation has.
|
|
|
|
*
|
|
|
|
* @var array<\wcf\data\style\Style>
|
|
|
|
*/
|
|
|
|
private $styles = null;
|
|
|
|
|
2012-03-04 14:38:25 +00:00
|
|
|
public function __construct() {
|
2013-05-24 00:21:49 +00:00
|
|
|
$this->rooms = \chat\data\room\RoomCache::getInstance()->getRooms();
|
2012-10-15 10:15:56 +00:00
|
|
|
$this->styles = \wcf\system\style\StyleHandler::getInstance()->getAvailableStyles();
|
2012-03-04 14:38:25 +00:00
|
|
|
}
|
|
|
|
|
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-10-15 10:15:56 +00:00
|
|
|
* Resets styles.
|
2012-05-31 14:57:20 +00:00
|
|
|
*/
|
2012-03-04 14:38:25 +00:00
|
|
|
public function execute() {
|
|
|
|
foreach ($this->rooms as $room) {
|
2013-01-27 20:58:10 +00:00
|
|
|
$messageAction = new \chat\data\message\MessageAction(array(), 'create', array(
|
2012-03-04 14:38:25 +00:00
|
|
|
'data' => array(
|
|
|
|
'roomID' => $room->roomID,
|
|
|
|
'time' => TIME_NOW,
|
2013-01-27 20:58:10 +00:00
|
|
|
'type' => \chat\data\message\Message::TYPE_INFORMATION,
|
2012-10-20 16:04:46 +00:00
|
|
|
'message' => \wcf\system\WCF::getLanguage()->get('wcf.chat.information.chatUpdate')
|
2012-03-04 14:38:25 +00:00
|
|
|
)
|
|
|
|
));
|
|
|
|
$messageAction->executeAction();
|
|
|
|
}
|
2012-10-15 10:15:56 +00:00
|
|
|
|
|
|
|
foreach ($this->styles as $style) {
|
|
|
|
\wcf\system\style\StyleHandler::getInstance()->resetStylesheet($style);
|
|
|
|
}
|
2012-03-04 14:38:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$update = new Update();
|
|
|
|
$update->execute();
|