mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Improve validation in UserAction
This commit is contained in:
parent
55d634d78e
commit
1d40423c91
@ -21,7 +21,13 @@ class UserAction extends \wcf\data\AbstractDatabaseObjectAction {
|
|||||||
* Validates invite preparation.
|
* Validates invite preparation.
|
||||||
*/
|
*/
|
||||||
public function validatePrepareInvite() {
|
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.
|
* Validates invites.
|
||||||
*/
|
*/
|
||||||
public function validateInvite() {
|
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) {
|
if (!WCF::getUser()->chatRoomID) throw new \wcf\system\exception\PermissionDeniedException();
|
||||||
$this->room = \chat\data\room\RoomCache::getInstance()->getRoom(WCF::getUser()->chatRoomID);
|
|
||||||
}
|
$this->room = \chat\data\room\RoomCache::getInstance()->getRoom(WCF::getUser()->chatRoomID);
|
||||||
else {
|
|
||||||
throw new \wcf\system\exception\UserInputException("roomID");
|
if (!$this->room || !$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException();
|
||||||
}
|
|
||||||
|
if (!isset($this->parameters['recipients'])) throw new \wcf\system\exception\UserInputException("recipients");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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.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.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.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"><![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.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>
|
<item name="wcf.acp.group.option.user.chat.canUploadAttachment"><![CDATA[Kann Dateien anhängen]]></item>
|
||||||
|
@ -40,8 +40,8 @@
|
|||||||
</category>
|
</category>
|
||||||
|
|
||||||
<category name="chat.notification">
|
<category name="chat.notification">
|
||||||
<item name="chat.notification.invited.title"><![CDATA[TODO: Jemand möchte mit Ihnen chatten!]]></item>
|
<item name="chat.notification.invited.title"><![CDATA[Someone wants to chat with you!]]></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.message"><![CDATA[“{$author->username}” wants to chat with you in “{$userNotificationObject->getTitle()}”!]]></item>
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
<category name="wcf.acl.option">
|
<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.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.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.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"><![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.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>
|
<item name="wcf.acp.group.option.user.chat.canUploadAttachment"><![CDATA[Can upload attachments]]></item>
|
||||||
|
@ -192,12 +192,14 @@
|
|||||||
</li>
|
</li>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<li>
|
{if $__wcf->session->getPermission('user.chat.canInvite')}
|
||||||
<a id="timsChatInvite" class="button jsTooltip" title="{lang}chat.global.invite{/lang}">
|
<li>
|
||||||
<span class="icon icon16 icon-user"></span>
|
<a id="timsChatInvite" class="button jsTooltip" title="{lang}chat.global.invite{/lang}">
|
||||||
<span class="invisible">{lang}chat.global.invite{/lang}</span>
|
<span class="icon icon16 icon-user"></span>
|
||||||
</a>
|
<span class="invisible">{lang}chat.global.invite{/lang}</span>
|
||||||
</li>
|
</a>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a id="timsChatClear" class="button jsTooltip" title="{lang}chat.global.clear{/lang}">
|
<a id="timsChatClear" class="button jsTooltip" title="{lang}chat.global.clear{/lang}">
|
||||||
|
@ -35,6 +35,13 @@
|
|||||||
<admindefaultvalue>1</admindefaultvalue>
|
<admindefaultvalue>1</admindefaultvalue>
|
||||||
<usersonly>1</usersonly>
|
<usersonly>1</usersonly>
|
||||||
</option>
|
</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">
|
<option name="user.chat.allowedBBCodes">
|
||||||
<categoryname>user.chat</categoryname>
|
<categoryname>user.chat</categoryname>
|
||||||
<optiontype>BBCodeSelect</optiontype>
|
<optiontype>BBCodeSelect</optiontype>
|
||||||
|
Loading…
Reference in New Issue
Block a user