Restrict the mentioning of groups using a permission
authorAlexander Ebert <ebert@woltlab.com>
Thu, 17 Jan 2019 15:31:48 +0000 (16:31 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 17 Jan 2019 15:31:48 +0000 (16:31 +0100)
See #2804

com.woltlab.wcf/userGroupOption.xml
wcfsetup/install/files/lib/data/user/UserAction.class.php
wcfsetup/install/files/lib/data/user/group/UserGroup.class.php
wcfsetup/install/files/lib/util/MessageUtil.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 182536ce474fd837feb83a09fd23ca5fb1141ac4..c84d2f599a3154936f585bf4aadacb6e973408e1 100644 (file)
@@ -588,6 +588,11 @@ pdf</defaultvalue>
                                <categoryname>user.message</categoryname>
                                <optiontype>BBCodeSelect</optiontype>
                        </option>
+                       <option name="user.message.canMentionGroups">
+                               <categoryname>user.message</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>1</defaultvalue>
+                       </option>
                        <!-- /user.message -->
                        <!-- user.message.comment -->
                        <option name="user.comment.floodControlTime">
index af4e7916ddf7dfc784154f2a78b6f9bf08b2f509..a48403bfcfadadf02addbffddfcb2d097db55c2d 100644 (file)
@@ -505,13 +505,13 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
                $list = [];
                
                if ($this->parameters['data']['includeUserGroups']) {
-                       $accessibleGroups = UserGroup::getAccessibleGroups();
+                       $accessibleGroups = UserGroup::getMentionableGroups();
                        foreach ($accessibleGroups as $group) {
                                if (!empty($this->parameters['data']['restrictUserGroupIDs']) && !in_array($group->groupID, $this->parameters['data']['restrictUserGroupIDs'])) {
                                        continue;
                                }
                                
-                               if ($this->parameters['data']['scope'] === 'mention' && !$group->canBeMentioned()) {
+                               if ($this->parameters['data']['scope'] === 'mention' && (!WCF::getSession()->getPermission('user.message.canMentionGroups') || !$group->canBeMentioned())) {
                                        continue;
                                }
                                
index 9cfa83c24e809565c5dbf1762da9964cebb9d195..e15d8888106f75ca693df0c013a5a8289aa4e5a3 100644 (file)
@@ -426,6 +426,10 @@ class UserGroup extends DatabaseObject implements ITitledObject {
         * @since 5.2
         */
        public static function getMentionableGroups() {
+               if (!WCF::getSession()->getPermission('user.message.canMentionGroups')) {
+                       return [];
+               }
+               
                self::getCache();
                
                $groups = [];
index f6357a0fcfac46459c6a5941255657121d73c700..be136db97a65cf03a7d2b58741a481fee07c34e3 100644 (file)
@@ -66,7 +66,7 @@ class MessageUtil {
                        if ($type === 'user') {
                                $usernames[] = $element->textContent;
                        }
-                       else if ($type === 'group') {
+                       else if ($type === 'group' && WCF::getSession()->getPermission('user.message.canMentionGroups')) {
                                $attributes = $htmlInputProcessor->getHtmlInputNodeProcessor()->parseAttributes(
                                        $element->getAttribute('data-attributes')
                                );
index a609611eac0ada95e958854ead687c3425feb828..cfc4858d8da63999d4aa84edf2e5b4069f719ef9 100644 (file)
                <item name="wcf.acp.group.option.user.comment.disallowedBBCodes.description"><![CDATA[Die hier ausgewählten BBCodes dürfen von Mitgliedern dieser Benutzergruppe <em>nicht</em> verwendet werden.]]></item>
                <item name="wcf.acp.group.option.user.message.disallowedBBCodes"><![CDATA[Nicht erlaubte BBCodes]]></item>
                <item name="wcf.acp.group.option.user.message.disallowedBBCodes.description"><![CDATA[Die hier ausgewählten BBCodes dürfen von Mitgliedern dieser Benutzergruppe <em>nicht</em> verwendet werden.]]></item>
+               <item name="wcf.acp.group.option.user.message.canMentionGroups"><![CDATA[Kann Benutzergruppen erwähnen]]></item>
                <item name="wcf.acp.group.option.admin.user.rank.canManageRank"><![CDATA[Kann Benutzerränge verwalten]]></item>
                <item name="wcf.acp.group.option.admin.user.canEditActivityPoints"><![CDATA[Kann Aktivitätspunkte bearbeiten]]></item>
                <item name="wcf.acp.group.option.admin.user.canViewInvisible"><![CDATA[Kann unsichtbare Benutzer sehen]]></item>
index 657bd02faeb3800b133800377c6d069ee60df883..7d643b1114aab8fb7ceed03444940ce68fdd8532 100644 (file)
                <item name="wcf.acp.group.option.user.comment.disallowedBBCodes.description"><![CDATA[Selected BBCodes <em>cannot</em> be used by the users of this user group.]]></item>
                <item name="wcf.acp.group.option.user.message.disallowedBBCodes"><![CDATA[Disallowed BBCodes]]></item>
                <item name="wcf.acp.group.option.user.message.disallowedBBCodes.description"><![CDATA[Selected BBCodes <em>cannot</em> be used by the users of this user group.]]></item>
+               <item name="wcf.acp.group.option.user.message.canMentionGroups"><![CDATA[Can mention user groups]]></item>
                <item name="wcf.acp.group.option.admin.user.rank.canManageRank"><![CDATA[Can manage user ranks]]></item>
                <item name="wcf.acp.group.option.admin.user.canEditActivityPoints"><![CDATA[Can manage activity points]]></item>
                <item name="wcf.acp.group.option.admin.user.canViewInvisible"><![CDATA[Can view invisible users]]></item>