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

Improve code

- Add function comments
- Use $this->parameters in UserAction
This commit is contained in:
Maximilian Mader 2014-12-10 00:18:21 +01:00
parent 47a84a9d7f
commit c2cceb5f27
4 changed files with 22 additions and 9 deletions

View File

@ -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));
}
}

View File

@ -162,7 +162,7 @@ Probieren Sie, den Chat neu zu laden<!-- , bei Risiken und Nebenwirkungen fragen
<item name="chat.global.users"><![CDATA[Nutzer]]></item>
<item name="chat.global.invite"><![CDATA[Benutzer einladen]]></item>
<item name="chat.global.invite.noFollowing"><![CDATA[Keine Benutzer gefunden, verwenden Sie bitte die Suche.]]></item>
<item name="chat.global.invite.noFollowing"><![CDATA[Sie folgen niemandem, verwenden Sie bitte die Suche.]]></item>
<item name="chat.global.copyright"><![CDATA[<a href="http://tims.bastelstu.be"{if EXTERNAL_LINK_TARGET_BLANK} target="_blank"{/if}><strong>Tims Chat{if SHOW_VERSION_NUMBER} {PACKAGE_VERSION}{/if}</strong>, entwickelt in <strong>Tims Bastelstu.be</strong></a>]]></item>
<item name="chat.global.copyright.leader"><![CDATA[Projektleiter]]></item>

View File

@ -162,7 +162,7 @@ Please try to reload the chat.]]></item>
<item name="chat.global.users"><![CDATA[Users]]></item>
<item name="chat.global.invite"><![CDATA[Invite users]]></item>
<item name="chat.global.invite.noFollowing"><![CDATA[No users found, please use the search function instead.]]></item>
<item name="chat.global.invite.noFollowing"><![CDATA[You do not follow anybody, please use the search function instead.]]></item>
<item name="chat.global.copyright"><![CDATA[<a href="http://tims.bastelstu.be"{if EXTERNAL_LINK_TARGET_BLANK} target="_blank"{/if}><strong>Tims Chat{if SHOW_VERSION_NUMBER} {PACKAGE_VERSION}{/if}</strong>, developed in <strong>Tims Bastelstu.be</strong></a>]]></item>
<item name="chat.global.copyright.leader"><![CDATA[Project Lead]]></item>

View File

@ -70,7 +70,9 @@
data: {
actionName: 'invite',
className: 'chat\\data\\user\\UserAction',
parameters: {
recipients: userList
}
},
success: function (data) {
new WCF.System.Notification('{lang}wcf.global.success{/lang}').show();