From c2cceb5f2710d24fb80e2c9ec5bedefb9f0eb03d Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Wed, 10 Dec 2014 00:18:21 +0100 Subject: [PATCH] Improve code - Add function comments - Use $this->parameters in UserAction --- file/lib/data/user/UserAction.class.php | 23 +++++++++++++++++------ language/de.xml | 2 +- language/en.xml | 2 +- template/userInviteDialog.tpl | 4 +++- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/file/lib/data/user/UserAction.class.php b/file/lib/data/user/UserAction.class.php index 9d9b87c..7f65653 100644 --- a/file/lib/data/user/UserAction.class.php +++ b/file/lib/data/user/UserAction.class.php @@ -12,12 +12,21 @@ * @subpackage data.user */ class UserAction extends \wcf\data\AbstractDatabaseObjectAction { + /** + * @see \wcf\data\AbstractDatabaseObjectAction::$className + */ protected $className = 'wcf\data\user\UserEditor'; + /** + * Validates invite preparation. + */ public function validatePrepareInvite() { // Todo: Proper validation } + /** + * Prepares invites. + */ public function prepareInvite() { $followingList = new \wcf\data\user\follow\UserFollowingList(); $followingList->getConditionBuilder()->add('user_follow.userID = ?', array(WCF::getUser()->userID)); @@ -33,12 +42,11 @@ public function prepareInvite() { ); } + /** + * Validates invites. + */ public function validateInvite() { - $this->recipients = (isset($_POST['recipients'])) ? $_POST['recipients'] : null; - - if (!$this->recipients) { - throw new \wcf\system\exception\UserInputException("recipients"); - } + if (!isset($this->parameters['recipients'])) throw new \wcf\system\exception\UserInputException("recipients"); if (WCF::getUser()->chatRoomID) { $this->room = \chat\data\room\RoomCache::getInstance()->getRoom(WCF::getUser()->chatRoomID); @@ -48,7 +56,10 @@ public function validateInvite() { } } + /** + * Invites users. + */ public function invite() { - \wcf\system\user\notification\UserNotificationHandler::getInstance()->fireEvent('invited', 'be.bastelstu.chat.room', new \chat\system\user\notification\object\RoomUserNotificationObject($this->room), $this->recipients, [ 'userID' => WCF::getUser()->userID ]); + \wcf\system\user\notification\UserNotificationHandler::getInstance()->fireEvent('invited', 'be.bastelstu.chat.room', new \chat\system\user\notification\object\RoomUserNotificationObject($this->room), $this->parameters['recipients'], array('userID' => WCF::getUser()->userID)); } } diff --git a/language/de.xml b/language/de.xml index af66711..b79d5af 100644 --- a/language/de.xml +++ b/language/de.xml @@ -162,7 +162,7 @@ Probieren Sie, den Chat neu zu laden