diff --git a/file/js/be.bastelstu.Chat.litcoffee b/file/js/be.bastelstu.Chat.litcoffee index a5468c7..60b9645 100644 --- a/file/js/be.bastelstu.Chat.litcoffee +++ b/file/js/be.bastelstu.Chat.litcoffee @@ -192,7 +192,7 @@ Open the smiley wcfDialog Handle private channel menu $('#timsChatMessageTabMenu > .tabMenu').on 'click', '.timsChatMessageTabMenuAnchor', -> - openPrivateChannel $(@).data 'userID' + openPrivateChannel $(@).data 'userID' Handle submitting the form. The message will be validated by some basic checks, passed to the `submit` eventlisteners and afterwards sent to the server by an AJAX request. @@ -410,11 +410,19 @@ Show invite dialog. success: (data) -> do new WCF.System.Notification(WCF.Language.get 'wcf.global.success').show + failure: (data) -> + return true unless (data?.returnValues?.errorType?) or (data?.message?) + + $("""
#{(data?.returnValues?.errorType) ? data.message}
""").wcfDialog title: WCF.Language.get 'wcf.global.error.title' + + return false + $('#timsChatInviteDialog').wcfDialog 'close' timsChatInviteDialog.wcfDialog title: WCF.Language.get 'chat.global.invite' - + onShow: -> do $('#userInviteDialogUsernameInput').focus + Hide topic container. diff --git a/file/lib/data/user/UserAction.class.php b/file/lib/data/user/UserAction.class.php index 91cc035..a53b66b 100644 --- a/file/lib/data/user/UserAction.class.php +++ b/file/lib/data/user/UserAction.class.php @@ -67,12 +67,35 @@ public function validateInvite() { if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException(); if (!isset($this->parameters['recipients'])) throw new \wcf\system\exception\UserInputException("recipients"); + + $this->parameters['recipients'] = \wcf\util\ArrayUtil::toIntegerArray($this->parameters['recipients']); + + $ignoredByList = new \wcf\data\user\ignore\UserIgnoreList(); + $ignoredByList->getConditionBuilder()->add('user_ignore.ignoreUserID = ?', array(WCF::getUser()->userID)); + $ignoredByList->getConditionBuilder()->add('user_ignore.userID IN (?)', array($this->parameters['recipients'])); + + if (!empty($ignoredByList->sqlSelects)) $ignoredByList->sqlSelects .= ','; + $ignoredByList->sqlSelects .= "user_ignore.ignoreID"; + $ignoredByList->sqlSelects .= ", user_table.username"; + $ignoredByList->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user user_table ON (user_table.userID = user_ignore.userID)"; + + $ignoredByList->readObjects(); + $ignoredByUsers = $ignoredByList->getObjects(); + + if (!empty($ignoredByUsers)) { + $usernames = array(); + foreach ($ignoredByUsers as $user) { + $usernames[] = $user->username; + } + + throw new \wcf\system\exception\UserInputException("recipients", WCF::getLanguage()->getDynamicVariable('chat.error.invite.ignored', array('users' => $ignoredByUsers, 'usernames' => $usernames))); + } } /** * 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), \wcf\util\ArrayUtil::toIntegerArray($this->parameters['recipients']), array('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 27dd04c..bc58b85 100644 --- a/language/de.xml +++ b/language/de.xml @@ -149,6 +149,7 @@ Probieren Sie, den Chat neu zu laden