1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-21 21:30:08 +00:00

Improve validation in UserAction

This commit is contained in:
Maximilian Mader 2014-12-13 15:02:36 +01:00
parent 55d634d78e
commit 1d40423c91
5 changed files with 34 additions and 16 deletions

View File

@ -21,7 +21,13 @@ class UserAction extends \wcf\data\AbstractDatabaseObjectAction {
* Validates invite preparation.
*/
public function validatePrepareInvite() {
// Todo: Proper validation
WCF::getSession()->checkPermissions(array('user.chat.canInvite'));
if (!WCF::getUser()->chatRoomID) throw new \wcf\system\exception\PermissionDeniedException();
$room = \chat\data\room\RoomCache::getInstance()->getRoom(WCF::getUser()->chatRoomID);
if (!$room || !$room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException();
}
/**
@ -50,14 +56,15 @@ public function prepareInvite() {
* Validates invites.
*/
public function validateInvite() {
if (!isset($this->parameters['recipients'])) throw new \wcf\system\exception\UserInputException("recipients");
WCF::getSession()->checkPermissions(array('user.chat.canInvite'));
if (WCF::getUser()->chatRoomID) {
$this->room = \chat\data\room\RoomCache::getInstance()->getRoom(WCF::getUser()->chatRoomID);
}
else {
throw new \wcf\system\exception\UserInputException("roomID");
}
if (!WCF::getUser()->chatRoomID) throw new \wcf\system\exception\PermissionDeniedException();
$this->room = \chat\data\room\RoomCache::getInstance()->getRoom(WCF::getUser()->chatRoomID);
if (!$this->room || !$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException();
if (!isset($this->parameters['recipients'])) throw new \wcf\system\exception\UserInputException("recipients");
}
/**

View File

@ -60,6 +60,7 @@
<item name="wcf.acp.group.option.user.chat.canEnter"><![CDATA[Kann Chat betreten]]></item>
<item name="wcf.acp.group.option.user.chat.canWrite"><![CDATA[Kann im Chat schreiben]]></item>
<item name="wcf.acp.group.option.user.chat.canTempRoom"><![CDATA[Kann temporäre Räume erstellen]]></item>
<item name="wcf.acp.group.option.user.chat.canInvite"><![CDATA[Kann Benutzer zum Chatten einladen]]></item>
<item name="wcf.acp.group.option.user.chat.allowedBBCodes"><![CDATA[Erlaubte BBCodes]]></item>
<item name="wcf.acp.group.option.user.chat.allowedBBCodes.description"><![CDATA[Die hier ausgewählten BBCodes dürfen von Mitgliedern dieser Benutzergruppe verwendet werden.]]></item>
<item name="wcf.acp.group.option.user.chat.canUploadAttachment"><![CDATA[Kann Dateien anhängen]]></item>

View File

@ -40,8 +40,8 @@
</category>
<category name="chat.notification">
<item name="chat.notification.invited.title"><![CDATA[TODO: Jemand möchte mit Ihnen chatten!]]></item>
<item name="chat.notification.invited.message"><![CDATA[TODO: „{$author->username}“ möchte mit Ihnen im Chatraum „{$userNotificationObject->getTitle()}“ chatten!]]></item>
<item name="chat.notification.invited.title"><![CDATA[Someone wants to chat with you!]]></item>
<item name="chat.notification.invited.message"><![CDATA[“{$author->username}” wants to chat with you in “{$userNotificationObject->getTitle()}”!]]></item>
</category>
<category name="wcf.acl.option">
@ -60,6 +60,7 @@
<item name="wcf.acp.group.option.user.chat.canEnter"><![CDATA[Can enter chat]]></item>
<item name="wcf.acp.group.option.user.chat.canWrite"><![CDATA[Can write messages]]></item>
<item name="wcf.acp.group.option.user.chat.canTempRoom"><![CDATA[Can create temporary rooms]]></item>
<item name="wcf.acp.group.option.user.chat.canInvite"><![CDATA[Can invite users to chat]]></item>
<item name="wcf.acp.group.option.user.chat.allowedBBCodes"><![CDATA[Allowed BBCodes]]></item>
<item name="wcf.acp.group.option.user.chat.allowedBBCodes.description"><![CDATA[Selected BBCodes may be used by members of this group.]]></item>
<item name="wcf.acp.group.option.user.chat.canUploadAttachment"><![CDATA[Can upload attachments]]></item>

View File

@ -192,12 +192,14 @@
</li>
{/if}
<li>
<a id="timsChatInvite" class="button jsTooltip" title="{lang}chat.global.invite{/lang}">
<span class="icon icon16 icon-user"></span>
<span class="invisible">{lang}chat.global.invite{/lang}</span>
</a>
</li>
{if $__wcf->session->getPermission('user.chat.canInvite')}
<li>
<a id="timsChatInvite" class="button jsTooltip" title="{lang}chat.global.invite{/lang}">
<span class="icon icon16 icon-user"></span>
<span class="invisible">{lang}chat.global.invite{/lang}</span>
</a>
</li>
{/if}
<li>
<a id="timsChatClear" class="button jsTooltip" title="{lang}chat.global.clear{/lang}">

View File

@ -35,6 +35,13 @@
<admindefaultvalue>1</admindefaultvalue>
<usersonly>1</usersonly>
</option>
<option name="user.chat.canInvite">
<categoryname>user.chat</categoryname>
<optiontype>boolean</optiontype>
<defaultvalue>0</defaultvalue>
<admindefaultvalue>1</admindefaultvalue>
<usersonly>1</usersonly>
</option>
<option name="user.chat.allowedBBCodes">
<categoryname>user.chat</categoryname>
<optiontype>BBCodeSelect</optiontype>