Add permissions for attachments in signatures (#3683)
authorMatthias Schmidt <gravatronics@live.com>
Mon, 2 Nov 2020 15:32:12 +0000 (16:32 +0100)
committerGitHub <noreply@github.com>
Mon, 2 Nov 2020 15:32:12 +0000 (16:32 +0100)
* Add permissions for attachments in signatures

Close #3675

* Add missing `module_user_signature` option

* Add `enableoptions` for `user.signature.attachment.canUpload`

com.woltlab.wcf/userGroupOption.xml
wcfsetup/install/files/lib/system/attachment/SignatureAttachmentObjectType.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 227c57a8807aee80df14cde0c74616674680625d..db4b49739625248e7689979ebf0548bb71dbfe3f 100644 (file)
@@ -663,6 +663,40 @@ pdf</defaultvalue>
                                <options>module_user_signature</options>
                                <usersonly>1</usersonly>
                        </option>
+                       <option name="user.signature.attachment.canUpload">
+                               <categoryname>user.signature</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>1</defaultvalue>
+                               <usersonly>1</usersonly>
+                               <enableoptions>user.signature.attachment.maxSize,user.signature.attachment.allowedExtensions,user.signature.attachment.maxCount</enableoptions>
+                               <options>module_user_signature</options>
+                       </option>
+                       <option name="user.signature.attachment.maxSize">
+                               <categoryname>user.signature</categoryname>
+                               <optiontype>fileSize</optiontype>
+                               <defaultvalue>2000000</defaultvalue>
+                               <minvalue>10000</minvalue>
+                               <options>module_user_signature</options>
+                       </option>
+                       <option name="user.signature.attachment.allowedExtensions">
+                               <categoryname>user.signature</categoryname>
+                               <optiontype>textarea</optiontype>
+                               <defaultvalue>gif
+jpg
+jpeg
+png
+bmp</defaultvalue>
+                               <wildcard>*</wildcard>
+                               <options>module_user_signature</options>
+                       </option>
+                       <option name="user.signature.attachment.maxCount">
+                               <categoryname>user.signature</categoryname>
+                               <optiontype>integer</optiontype>
+                               <defaultvalue>10</defaultvalue>
+                               <minvalue>1</minvalue>
+                               <maxvalue>100</maxvalue>
+                               <options>module_user_signature</options>
+                       </option>
                        <!-- /user.signature -->
                        <!-- user.profile -->
                        <option name="user.profile.canChangeEmail">
index 6d3f7997bb5a1c6f5032ba3cab518124a7e0fde9..ae3e4be14b2ba9667b90d3bacdb0221788d97903 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\system\attachment;
 use wcf\data\user\UserProfile;
 use wcf\system\cache\runtime\UserProfileRuntimeCache;
 use wcf\system\WCF;
+use wcf\util\ArrayUtil;
 
 /**
  * Attachment object type implementation for posts.
@@ -49,15 +50,17 @@ class SignatureAttachmentObjectType extends AbstractAttachmentObjectType {
                        return false;
                }
                
-               $userProfile = UserProfileRuntimeCache::getInstance()->getObject($objectID);
-               
                if (!MODULE_USER_SIGNATURE) {
                        return false;
                }
                
+               $userProfile = UserProfileRuntimeCache::getInstance()->getObject($objectID);
                if ($userProfile->disableSignature) {
                        return false;
                }
+               if (!$userProfile->getPermission('user.signature.attachment.canUpload')) {
+                       return false;
+               }
                
                return true;
        }
@@ -76,6 +79,27 @@ class SignatureAttachmentObjectType extends AbstractAttachmentObjectType {
                $this->setCachedObjects(UserProfileRuntimeCache::getInstance()->getObjects($objectIDs));
        }
        
+       /**
+        * @inheritDoc
+        */
+       public function getMaxSize() {
+               return WCF::getSession()->getPermission('user.signature.attachment.maxSize');
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function getAllowedExtensions() {
+               return ArrayUtil::trim(explode("\n", WCF::getSession()->getPermission('user.signature.attachment.allowedExtensions')));
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function getMaxCount() {
+               return WCF::getSession()->getPermission('user.signature.attachment.maxCount');
+       }
+       
        /** @noinspection PhpMissingParentCallCommonInspection */
        /**
         * @inheritDoc
index 54ea896e63b5174bdb14044208d285c0d41755dc..2de97848ee1ce79c5f198281c9b6e8b8328919d6 100644 (file)
@@ -904,6 +904,11 @@ ACHTUNG: Die oben genannten Meldungen sind stark gekürzt. Sie können Details z
                <item name="wcf.acp.group.promoteOwner"><![CDATA[Besitzer-Gruppe festlegen]]></item>
                <item name="wcf.acp.group.promoteOwner.group"><![CDATA[Besitzer-Gruppe auswählen]]></item>
                <item name="wcf.acp.group.promoteOwner.warning"><![CDATA[Die Besitzer-Gruppe kann, einmal festgelegt, nicht mehr geändert werden. Diese Gruppe verfügt über besondere Berechtigungen und wird vor Änderungen durch andere Gruppen geschützt, Mitglieder dieser Gruppe können nicht mehr gesperrt werden.]]></item>
+               <item name="wcf.acp.group.option.user.signature.attachment.canUpload"><![CDATA[Kann Dateianhänge hochladen]]></item>
+               <item name="wcf.acp.group.option.user.signature.attachment.maxSize"><![CDATA[Maximale Dateianhangsgröße]]></item>
+               <item name="wcf.acp.group.option.user.signature.attachment.allowedExtensions"><![CDATA[Erlaubte Dateiendungen]]></item>
+               <item name="wcf.acp.group.option.user.signature.attachment.allowedExtensions.description"><![CDATA[Eine Dateiendung pro Zeile]]></item>
+               <item name="wcf.acp.group.option.user.signature.attachment.maxCount"><![CDATA[Maximale Dateianhänge]]></item>
        </category>
        <category name="wcf.acp.index">
                <item name="wcf.acp.index.credits"><![CDATA[Über WoltLab Suite&trade;]]></item>
index ea3669bd6f0d3be925b285eeb331ff661d42a199..1d3a396acd4bedaa89ac91cba52bda70525af1fd 100644 (file)
@@ -881,6 +881,11 @@ ATTENTION: The messages listed above are greatly shortened. You can view details
                <item name="wcf.acp.group.promoteOwner"><![CDATA[Set Up the Owner Group]]></item>
                <item name="wcf.acp.group.promoteOwner.group"><![CDATA[Select the owner group]]></item>
                <item name="wcf.acp.group.promoteOwner.warning"><![CDATA[The owner group cannot be modified once it has been set up. This group has special privileges and is protected from modifications by any other group, its members cannot be banned.]]></item>
+               <item name="wcf.acp.group.option.user.signature.attachment.canUpload"><![CDATA[Can Upload Attachments]]></item>
+               <item name="wcf.acp.group.option.user.signature.attachment.maxSize"><![CDATA[Maximum Attachment File Size]]></item>
+               <item name="wcf.acp.group.option.user.signature.attachment.allowedExtensions"><![CDATA[Allowed Attachment File Extensions]]></item>
+               <item name="wcf.acp.group.option.user.signature.attachment.allowedExtensions.description"><![CDATA[Enter one extension per line.]]></item>
+               <item name="wcf.acp.group.option.user.signature.attachment.maxCount"><![CDATA[Maximum Attachments]]></item>
        </category>
        <category name="wcf.acp.index">
                <item name="wcf.acp.index.credits"><![CDATA[About WoltLab Suite&trade;]]></item>