From 0a7fa7f640a73e2610b5e063a370c47e26ed3dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 31 May 2012 16:57:20 +0200 Subject: [PATCH] Adding some more doc-blocks and cleaning up code. --- file/acp/be.bastelstu.wcf.chat.update.php | 11 +++++- file/lib/page/ChatCopyrightPage.class.php | 7 ++++ file/lib/page/ChatMessagePage.class.php | 34 +++++++++++++++++-- file/lib/page/ChatPage.class.php | 7 ++++ .../page/ChatRefreshRoomListPage.class.php | 22 ++++++++---- 5 files changed, 71 insertions(+), 10 deletions(-) diff --git a/file/acp/be.bastelstu.wcf.chat.update.php b/file/acp/be.bastelstu.wcf.chat.update.php index ba1d721..4f7504b 100644 --- a/file/acp/be.bastelstu.wcf.chat.update.php +++ b/file/acp/be.bastelstu.wcf.chat.update.php @@ -2,7 +2,7 @@ namespace be\bastelstu\wcf\chat; /** - * Handles updates. + * Handles updates of Tims Chat. * * @author Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus @@ -10,11 +10,20 @@ * @package be.bastelstu.wcf.chat */ final class Update { + /** + * Contains all the rooms the current installation has. + * + * @var array<\wcf\data\chat\room\ChatRoom> + */ private $rooms = null; + public function __construct() { $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() { foreach ($this->rooms as $room) { $messageAction = new \wcf\data\chat\message\ChatMessageAction(array(), 'create', array( diff --git a/file/lib/page/ChatCopyrightPage.class.php b/file/lib/page/ChatCopyrightPage.class.php index 47b7a78..2b93f38 100644 --- a/file/lib/page/ChatCopyrightPage.class.php +++ b/file/lib/page/ChatCopyrightPage.class.php @@ -12,7 +12,14 @@ * @subpackage page */ class ChatCopyrightPage extends AbstractPage { + /** + * @see \wcf\page\AbstractPage::$neededModules + */ public $neededModules = array('CHAT_ACTIVE'); + + /** + * @see \wcf\page\AbstractPage::$neededPermissions + */ public $neededPermissions = array('user.chat.canEnter'); /** diff --git a/file/lib/page/ChatMessagePage.class.php b/file/lib/page/ChatMessagePage.class.php index 1f821df..403de43 100644 --- a/file/lib/page/ChatMessagePage.class.php +++ b/file/lib/page/ChatMessagePage.class.php @@ -13,12 +13,40 @@ * @subpackage page */ class ChatMessagePage extends AbstractPage { + /** + * The new and unseen messages. + * + * @var array<\wcf\data\chat\message\ChatMessage> + */ public $messages = array(); + + /** + * @see \wcf\page\AbstractPage::$neededModules + */ public $neededModules = array('CHAT_ACTIVE'); + + /** + * @see \wcf\page\AbstractPage::$neededPermissions + */ public $neededPermissions = array('user.chat.canEnter'); + + /** + * The room the user joined. + * + * @var \wcf\data\chat\room\ChatRoom + */ 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(); + + /** + * @see \wcf\page\AbstractPage::$useTemplate + */ public $useTemplate = false; /** @@ -82,9 +110,9 @@ public function readMessages() { * Initializes the room databaseobject. */ 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->canEnter()) throw new \wcf\system\exception\PermissionDeniedException(); } diff --git a/file/lib/page/ChatPage.class.php b/file/lib/page/ChatPage.class.php index f0d31f1..a294867 100644 --- a/file/lib/page/ChatPage.class.php +++ b/file/lib/page/ChatPage.class.php @@ -15,7 +15,14 @@ */ class ChatPage extends AbstractPage { public $chatVersion = ''; + /** + * @see \wcf\page\AbstractPage::$neededModules + */ public $neededModules = array('CHAT_ACTIVE'); + + /** + * @see \wcf\page\AbstractPage::$neededPermissions + */ public $neededPermissions = array('user.chat.canEnter'); public $newestMessages = array(); public $room = null; diff --git a/file/lib/page/ChatRefreshRoomListPage.class.php b/file/lib/page/ChatRefreshRoomListPage.class.php index ce68602..05ed646 100644 --- a/file/lib/page/ChatRefreshRoomListPage.class.php +++ b/file/lib/page/ChatRefreshRoomListPage.class.php @@ -14,23 +14,33 @@ * @subpackage page */ class ChatRefreshRoomListPage extends AbstractPage { + /** + * @see \wcf\page\AbstractPage::$neededModules + */ public $neededModules = array('CHAT_ACTIVE'); + + /** + * @see \wcf\page\AbstractPage::$neededPermissions + */ public $neededPermissions = array('user.chat.canEnter'); - public $room = null; - public $roomID = 0; public $rooms = array(); + + /** + * @see \wcf\page\AbstractPage::$useTemplate + */ public $useTemplate = false; /** - * Reads room data. + * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); - $this->roomID = \wcf\util\ChatUtil::readUserData('roomID'); + $this->rooms = chat\room\ChatRoom::getCache(); - $this->room = $this->rooms->search($this->roomID); - if (!$this->room) throw new \wcf\system\exception\IllegalLinkException(); + $roomID = \wcf\util\ChatUtil::readUserData('roomID'); + $room = $this->rooms->search($roomID); + if (!$room) throw new \wcf\system\exception\IllegalLinkException(); } /**