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

More Docs

This commit is contained in:
Tim Düsterhus 2012-06-04 21:34:07 +02:00
parent d9d90e9c19
commit 9755242683
2 changed files with 29 additions and 4 deletions

View File

@ -17,8 +17,24 @@ class ChatLeaveAction extends AbstractAction {
* @see \wcf\action\AbstractAction::$neededModules * @see \wcf\action\AbstractAction::$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 current room.
*
* @var \wcf\data\chat\room\ChatRoom
*/
public $room = null; public $room = null;
/**
* Values read from the UserStorage of the current user.
*
* @var array
*/
public $userData = array(); public $userData = array();
/** /**
@ -27,7 +43,6 @@ class ChatLeaveAction extends AbstractAction {
public function execute() { public function execute() {
parent::execute(); parent::execute();
// validate
if (!WCF::getUser()->userID) { if (!WCF::getUser()->userID) {
throw new IllegalLinkException(); throw new IllegalLinkException();
} }
@ -41,6 +56,7 @@ public function execute() {
if (CHAT_DISPLAY_JOIN_LEAVE) { if (CHAT_DISPLAY_JOIN_LEAVE) {
$this->userData['color'] = \wcf\util\ChatUtil::readUserData('color'); $this->userData['color'] = \wcf\util\ChatUtil::readUserData('color');
// leave message
$messageAction = new chat\message\ChatMessageAction(array(), 'create', array( $messageAction = new chat\message\ChatMessageAction(array(), 'create', array(
'data' => array( 'data' => array(
'roomID' => $this->room->roomID, 'roomID' => $this->room->roomID,
@ -56,6 +72,7 @@ public function execute() {
$messageAction->executeAction(); $messageAction->executeAction();
} }
// set current room to null
\wcf\util\ChatUtil::writeUserData(array('roomID' => null)); \wcf\util\ChatUtil::writeUserData(array('roomID' => null));
$this->executed(); $this->executed();

View File

@ -29,7 +29,13 @@ final class ChatUtil {
*/ */
const PACKAGE_IDENTIFIER = 'be.bastelstu.wcf.chat'; const PACKAGE_IDENTIFIER = 'be.bastelstu.wcf.chat';
public static $serialize = array('color' => true, 'suspensions' => true); /**
* Which user-storage-keys need serialization.
* The value should always be true.
*
* @var array<boolean>
*/
private static $serialize = array('color' => true, 'suspensions' => true);
/** /**
* Cached packageID of Tims Chat. * Cached packageID of Tims Chat.
@ -242,9 +248,8 @@ public static function timeModifier($time) {
/** /**
* Writes user data * Writes user data
*
* @param \wcf\data\user\User $user
* @param array $data * @param array $data
* @param \wcf\data\user\User $user
*/ */
public static function writeUserData(array $data, \wcf\data\user\User $user = null) { public static function writeUserData(array $data, \wcf\data\user\User $user = null) {
if ($user === null) $user = WCF::getUser(); if ($user === null) $user = WCF::getUser();
@ -256,5 +261,8 @@ public static function writeUserData(array $data, \wcf\data\user\User $user = nu
} }
} }
/**
* Disables the constructor.
*/
private function __construct() { } private function __construct() { }
} }