1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00

Adding some more doc-blocks and cleaning up code.

This commit is contained in:
Tim Düsterhus 2012-05-31 16:57:20 +02:00
parent c71d19e16a
commit 0a7fa7f640
5 changed files with 71 additions and 10 deletions

View File

@ -2,7 +2,7 @@
namespace be\bastelstu\wcf\chat; namespace be\bastelstu\wcf\chat;
/** /**
* Handles updates. * Handles updates of Tims Chat.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2012 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
@ -10,11 +10,20 @@
* @package be.bastelstu.wcf.chat * @package be.bastelstu.wcf.chat
*/ */
final class Update { final class Update {
/**
* Contains all the rooms the current installation has.
*
* @var array<\wcf\data\chat\room\ChatRoom>
*/
private $rooms = null; private $rooms = null;
public function __construct() { public function __construct() {
$this->rooms = \wcf\data\chat\room\ChatRoom::getCache(); $this->rooms = \wcf\data\chat\room\ChatRoom::getCache();
} }
/**
* Notifies users to refresh the chat as the JS may no longer be fully compatible with the PHP code.
*/
public function execute() { public function execute() {
foreach ($this->rooms as $room) { foreach ($this->rooms as $room) {
$messageAction = new \wcf\data\chat\message\ChatMessageAction(array(), 'create', array( $messageAction = new \wcf\data\chat\message\ChatMessageAction(array(), 'create', array(

View File

@ -12,7 +12,14 @@
* @subpackage page * @subpackage page
*/ */
class ChatCopyrightPage extends AbstractPage { class ChatCopyrightPage extends AbstractPage {
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
public $neededModules = array('CHAT_ACTIVE'); public $neededModules = array('CHAT_ACTIVE');
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
public $neededPermissions = array('user.chat.canEnter'); public $neededPermissions = array('user.chat.canEnter');
/** /**

View File

@ -13,12 +13,40 @@
* @subpackage page * @subpackage page
*/ */
class ChatMessagePage extends AbstractPage { class ChatMessagePage extends AbstractPage {
/**
* The new and unseen messages.
*
* @var array<\wcf\data\chat\message\ChatMessage>
*/
public $messages = array(); public $messages = array();
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
public $neededModules = array('CHAT_ACTIVE'); public $neededModules = array('CHAT_ACTIVE');
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
public $neededPermissions = array('user.chat.canEnter'); public $neededPermissions = array('user.chat.canEnter');
/**
* The room the user joined.
*
* @var \wcf\data\chat\room\ChatRoom
*/
public $room = null; public $room = null;
public $roomID = 0;
/**
* All the users that are currently in the room $this->room.
*
* @var array<\wcf\data\user\User>
*/
public $users = array(); public $users = array();
/**
* @see \wcf\page\AbstractPage::$useTemplate
*/
public $useTemplate = false; public $useTemplate = false;
/** /**
@ -82,9 +110,9 @@ public function readMessages() {
* Initializes the room databaseobject. * Initializes the room databaseobject.
*/ */
public function readRoom() { public function readRoom() {
$this->roomID = \wcf\util\ChatUtil::readUserData('roomID'); $roomID = \wcf\util\ChatUtil::readUserData('roomID');
$this->room = chat\room\ChatRoom::getCache()->search($this->roomID); $this->room = chat\room\ChatRoom::getCache()->search($roomID);
if (!$this->room) throw new \wcf\system\exception\IllegalLinkException(); if (!$this->room) throw new \wcf\system\exception\IllegalLinkException();
if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException(); if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException();
} }

View File

@ -15,7 +15,14 @@
*/ */
class ChatPage extends AbstractPage { class ChatPage extends AbstractPage {
public $chatVersion = ''; public $chatVersion = '';
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
public $neededModules = array('CHAT_ACTIVE'); public $neededModules = array('CHAT_ACTIVE');
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
public $neededPermissions = array('user.chat.canEnter'); public $neededPermissions = array('user.chat.canEnter');
public $newestMessages = array(); public $newestMessages = array();
public $room = null; public $room = null;

View File

@ -14,23 +14,33 @@
* @subpackage page * @subpackage page
*/ */
class ChatRefreshRoomListPage extends AbstractPage { class ChatRefreshRoomListPage extends AbstractPage {
/**
* @see \wcf\page\AbstractPage::$neededModules
*/
public $neededModules = array('CHAT_ACTIVE'); public $neededModules = array('CHAT_ACTIVE');
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
public $neededPermissions = array('user.chat.canEnter'); public $neededPermissions = array('user.chat.canEnter');
public $room = null;
public $roomID = 0;
public $rooms = array(); public $rooms = array();
/**
* @see \wcf\page\AbstractPage::$useTemplate
*/
public $useTemplate = false; public $useTemplate = false;
/** /**
* Reads room data. * @see \wcf\page\IPage::readData()
*/ */
public function readData() { public function readData() {
parent::readData(); parent::readData();
$this->roomID = \wcf\util\ChatUtil::readUserData('roomID');
$this->rooms = chat\room\ChatRoom::getCache(); $this->rooms = chat\room\ChatRoom::getCache();
$this->room = $this->rooms->search($this->roomID); $roomID = \wcf\util\ChatUtil::readUserData('roomID');
if (!$this->room) throw new \wcf\system\exception\IllegalLinkException(); $room = $this->rooms->search($roomID);
if (!$room) throw new \wcf\system\exception\IllegalLinkException();
} }
/** /**