mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Improve code
- Add function comments - Use $this->parameters in UserAction
This commit is contained in:
parent
47a84a9d7f
commit
c2cceb5f27
@ -12,12 +12,21 @@
|
|||||||
* @subpackage data.user
|
* @subpackage data.user
|
||||||
*/
|
*/
|
||||||
class UserAction extends \wcf\data\AbstractDatabaseObjectAction {
|
class UserAction extends \wcf\data\AbstractDatabaseObjectAction {
|
||||||
|
/**
|
||||||
|
* @see \wcf\data\AbstractDatabaseObjectAction::$className
|
||||||
|
*/
|
||||||
protected $className = 'wcf\data\user\UserEditor';
|
protected $className = 'wcf\data\user\UserEditor';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates invite preparation.
|
||||||
|
*/
|
||||||
public function validatePrepareInvite() {
|
public function validatePrepareInvite() {
|
||||||
// Todo: Proper validation
|
// Todo: Proper validation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares invites.
|
||||||
|
*/
|
||||||
public function prepareInvite() {
|
public function prepareInvite() {
|
||||||
$followingList = new \wcf\data\user\follow\UserFollowingList();
|
$followingList = new \wcf\data\user\follow\UserFollowingList();
|
||||||
$followingList->getConditionBuilder()->add('user_follow.userID = ?', array(WCF::getUser()->userID));
|
$followingList->getConditionBuilder()->add('user_follow.userID = ?', array(WCF::getUser()->userID));
|
||||||
@ -33,12 +42,11 @@ public function prepareInvite() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates invites.
|
||||||
|
*/
|
||||||
public function validateInvite() {
|
public function validateInvite() {
|
||||||
$this->recipients = (isset($_POST['recipients'])) ? $_POST['recipients'] : null;
|
if (!isset($this->parameters['recipients'])) throw new \wcf\system\exception\UserInputException("recipients");
|
||||||
|
|
||||||
if (!$this->recipients) {
|
|
||||||
throw new \wcf\system\exception\UserInputException("recipients");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WCF::getUser()->chatRoomID) {
|
if (WCF::getUser()->chatRoomID) {
|
||||||
$this->room = \chat\data\room\RoomCache::getInstance()->getRoom(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() {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.users"><![CDATA[Nutzer]]></item>
|
||||||
|
|
||||||
<item name="chat.global.invite"><![CDATA[Benutzer einladen]]></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"><![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>
|
<item name="chat.global.copyright.leader"><![CDATA[Projektleiter]]></item>
|
||||||
|
@ -162,7 +162,7 @@ Please try to reload the chat.]]></item>
|
|||||||
<item name="chat.global.users"><![CDATA[Users]]></item>
|
<item name="chat.global.users"><![CDATA[Users]]></item>
|
||||||
|
|
||||||
<item name="chat.global.invite"><![CDATA[Invite 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>Tim’s Chat{if SHOW_VERSION_NUMBER} {PACKAGE_VERSION}{/if}</strong>, developed in <strong>Tim’s Bastelstu.be</strong></a>]]></item>
|
<item name="chat.global.copyright"><![CDATA[<a href="http://tims.bastelstu.be"{if EXTERNAL_LINK_TARGET_BLANK} target="_blank"{/if}><strong>Tim’s Chat{if SHOW_VERSION_NUMBER} {PACKAGE_VERSION}{/if}</strong>, developed in <strong>Tim’s Bastelstu.be</strong></a>]]></item>
|
||||||
<item name="chat.global.copyright.leader"><![CDATA[Project Lead]]></item>
|
<item name="chat.global.copyright.leader"><![CDATA[Project Lead]]></item>
|
||||||
|
@ -70,7 +70,9 @@
|
|||||||
data: {
|
data: {
|
||||||
actionName: 'invite',
|
actionName: 'invite',
|
||||||
className: 'chat\\data\\user\\UserAction',
|
className: 'chat\\data\\user\\UserAction',
|
||||||
|
parameters: {
|
||||||
recipients: userList
|
recipients: userList
|
||||||
|
}
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
new WCF.System.Notification('{lang}wcf.global.success{/lang}').show();
|
new WCF.System.Notification('{lang}wcf.global.success{/lang}').show();
|
||||||
|
Loading…
Reference in New Issue
Block a user