Allow image-only ranks
authorAlexander Ebert <ebert@woltlab.com>
Mon, 17 Jul 2017 18:50:23 +0000 (20:50 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 17 Jul 2017 18:50:23 +0000 (20:50 +0200)
Closes #2325

wcfsetup/install/files/acp/templates/userRankAdd.tpl
wcfsetup/install/files/lib/acp/form/UserRankAddForm.class.php
wcfsetup/install/files/lib/acp/form/UserRankEditForm.class.php
wcfsetup/install/files/lib/data/user/UserProfile.class.php
wcfsetup/install/files/lib/data/user/rank/UserRank.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml
wcfsetup/setup/db/install.sql

index 9225de04d76c99b95696421b84fddfab0a1a588f..035791ca85f565419505bf6e015b2490f794fc53 100644 (file)
                        </dl>
                {/if}
                
+               <dl{if $errorField == 'hideTitle'} class="formError"{/if}>
+                       <dt></dt>
+                       <dd>
+                               <label><input type="checkbox" id="hideTitle" name="hideTitle" value="1"{if $hideTitle} checked{/if}> {lang}wcf.acp.user.rank.hideTitle{/lang}</label>
+                               {if $errorField == 'hideTitle'}
+                                       <small class="innerError">
+                                               {lang}wcf.acp.user.rank.hideTitle.error.{@$errorType}{/lang}
+                                       </small>
+                               {/if}
+                               <small>{lang}wcf.acp.user.rank.hideTitle.description{/lang}</small>
+                       </dd>
+               </dl>
+               
                {event name='imageFields'}
        </section>
        
index 76a5dad3c86a598fe1221464a9e9e1581987f4b9..d993b752c1bef552eb1c499289596b02752b04a7 100644 (file)
@@ -82,6 +82,12 @@ class UserRankAddForm extends AbstractForm {
         */
        public $requiredGender = 0;
        
+       /**
+        * hide generic user title
+        * @var integer
+        */
+       public $hideTitle = 0;
+       
        /**
         * list of pre-defined css class names
         * @var string[]
@@ -126,6 +132,7 @@ class UserRankAddForm extends AbstractForm {
                if (isset($_POST['rankImage'])) $this->rankImage = StringUtil::trim($_POST['rankImage']);
                if (isset($_POST['repeatImage'])) $this->repeatImage = intval($_POST['repeatImage']);
                if (isset($_POST['requiredGender'])) $this->requiredGender = intval($_POST['requiredGender']);
+               if (isset($_POST['hideTitle'])) $this->hideTitle = intval($_POST['hideTitle']);
        }
        
        /**
@@ -170,6 +177,10 @@ class UserRankAddForm extends AbstractForm {
                if ($this->requiredGender < 0 || $this->requiredGender > 2) {
                        $this->requiredGender = 0;
                }
+               
+               if ($this->hideTitle && !$this->rankImage) {
+                       throw new UserInputException('hideTitle', 'rankImage');
+               }
        }
        
        /**
@@ -186,7 +197,8 @@ class UserRankAddForm extends AbstractForm {
                        'requiredPoints' => $this->requiredPoints,
                        'rankImage' => $this->rankImage,
                        'repeatImage' => $this->repeatImage,
-                       'requiredGender' => $this->requiredGender
+                       'requiredGender' => $this->requiredGender,
+                       'hideTitle' => ($this->hideTitle ? 1 : 0)
                ])]);
                $this->objectAction->executeAction();
                
@@ -205,7 +217,7 @@ class UserRankAddForm extends AbstractForm {
                
                // reset values
                $this->rankTitle = $this->cssClassName = $this->customCssClassName = $this->rankImage = '';
-               $this->groupID = $this->requiredPoints = $this->requiredGender = 0;
+               $this->groupID = $this->requiredPoints = $this->requiredGender = $this->hideTitle = 0;
                $this->repeatImage = 1;
                
                I18nHandler::getInstance()->reset();
@@ -233,7 +245,8 @@ class UserRankAddForm extends AbstractForm {
                        'requiredPoints' => $this->requiredPoints,
                        'rankImage' => $this->rankImage,
                        'repeatImage' => $this->repeatImage,
-                       'requiredGender' => $this->requiredGender
+                       'requiredGender' => $this->requiredGender,
+                       'hideTitle' => $this->hideTitle
                ]);
        }
 }
index 0828e8b080801731a69274c2f62224a2323ee40f..458b4ed349cade2fe93993c5c7e2ce354e469920 100644 (file)
@@ -69,7 +69,8 @@ class UserRankEditForm extends UserRankAddForm {
                        'requiredPoints' => $this->requiredPoints,
                        'rankImage' => $this->rankImage,
                        'repeatImage' => $this->repeatImage,
-                       'requiredGender' => $this->requiredGender
+                       'requiredGender' => $this->requiredGender,
+                       'hideTitle' => $this->hideTitle
                ])]);
                $this->objectAction->executeAction();
                $this->saved();
@@ -100,6 +101,7 @@ class UserRankEditForm extends UserRankAddForm {
                        $this->requiredGender = $this->rank->requiredGender;
                        $this->repeatImage = $this->rank->repeatImage;
                        $this->rankImage = $this->rank->rankImage;
+                       $this->hideTitle = $this->rank->hideTitle;
                }
        }
        
index b5adf1d2a346dc3ce4e1cb10e57553a81451fa6d..502f78a3824488ed6a5eef5231c3ed79e8dcf309 100644 (file)
@@ -561,7 +561,7 @@ class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject {
         */
        public function getUserTitle() {
                if ($this->userTitle) return $this->userTitle;
-               if ($this->getRank()) return WCF::getLanguage()->get($this->getRank()->rankTitle);
+               if ($this->getRank() && $this->getRank()->showTitle()) return WCF::getLanguage()->get($this->getRank()->rankTitle);
                
                return '';
        }
@@ -583,7 +583,8 @@ class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject {
                                                'cssClassName' => $this->cssClassName,
                                                'rankImage' => $this->rankImage,
                                                'repeatImage' => $this->repeatImage,
-                                               'requiredGender' => $this->requiredGender
+                                               'requiredGender' => $this->requiredGender,
+                                               'hideTitle' => $this->hideTitle
                                        ]);
                                }
                                else {
index f2036d28be675bb98106fc740bba9b96a9605482..88c24ee828eeff7f87b42e81afa6e9071dbd5b55 100644 (file)
@@ -20,6 +20,7 @@ use wcf\util\StringUtil;
  * @property-read      string          $rankImage              (WCF relative) path to the image displayed next to the rank or empty if no rank image exists
  * @property-read      integer         $repeatImage            number of times the rank image is displayed
  * @property-read      integer         $requiredGender         numeric representation of the user's gender required for the user rank (see `UserProfile::GENDER_*` constants) or 0 if no specific gender is required
+ * @property-read      integer         $hideTitle              hides the generic title of the rank, but not custom titles, `0` to show the title at all times
  */
 class UserRank extends DatabaseObject {
        /**
@@ -36,4 +37,13 @@ class UserRank extends DatabaseObject {
                
                return '';
        }
+       
+       /**
+        * Returns true if the generic rank title should be displayed.
+        * 
+        * @return      boolean
+        */
+       public function showTitle() {
+               return !$this->rankImage || !$this->hideTitle;
+       }
 }
index 72140416401350def7f834333fb1a4a5bb265600..ae009a20811d4b595af0a730b2a4c889ced05b7c 100644 (file)
@@ -2084,6 +2084,9 @@ Wenn {if LANGUAGE_USE_INFORMAL_VARIANT}du{else}Sie{/if} unter „Konfiguration 
                <item name="wcf.acp.user.rank.currentImage"><![CDATA[Aktuelle Ranggrafik]]></item>
                <item name="wcf.acp.user.rank.delete.sure"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} den Benutzerrang <span class="confirmationObject">{$userRank->rankTitle|language}</span> wirklich löschen?]]></item>
                <item name="wcf.acp.user.rank.edit"><![CDATA[Benutzerrang bearbeiten]]></item>
+               <item name="wcf.acp.user.rank.hideTitle"><![CDATA[Rangbezeichnung ausblenden]]></item>
+               <item name="wcf.acp.user.rank.hideTitle.description"><![CDATA[Es wird nur die Ranggrafik angezeigt. Dies gilt nicht, wenn der Benutzer einen individuellen Titel eingestellt hat.]]></item>
+               <item name="wcf.acp.user.rank.hideTitle.error.rankImage"><![CDATA[Diese Option erfordert eine gültige Ranggrafik.]]></item>
                <item name="wcf.acp.user.rank.image"><![CDATA[Ranggrafik]]></item>
                <item name="wcf.acp.user.rank.list"><![CDATA[Benutzerränge]]></item>
                <item name="wcf.acp.user.rank.rankImage.description"><![CDATA[Der Pfad zur Ranggrafik kann relativ zum WCF-Verzeichnis oder absolut angegeben werden.]]></item>
index b27cfb99201f7c3a7c472e8dd41f34b51e5dd273..b718eeda8fae6cfee8510a5d0fd85b94e548cf0b 100644 (file)
@@ -2027,6 +2027,9 @@ You can define the default sender in “Configuration » Options » General » E
                <item name="wcf.acp.user.rank.currentImage"><![CDATA[Current Rank Image]]></item>
                <item name="wcf.acp.user.rank.delete.sure"><![CDATA[Do you really want to delete the user rank <span class="confirmationObject">{$userRank->rankTitle|language}</span>?]]></item>
                <item name="wcf.acp.user.rank.edit"><![CDATA[Edit User Rank]]></item>
+               <item name="wcf.acp.user.rank.hideTitle"><![CDATA[Hide title]]></item>
+               <item name="wcf.acp.user.rank.hideTitle.description"><![CDATA[Hides the title of this rank. Does not work for users that have an individual title set.]]></item>
+               <item name="wcf.acp.user.rank.hideTitle.error.rankImage"><![CDATA[This option requires a valid rank image.]]></item>
                <item name="wcf.acp.user.rank.image"><![CDATA[Rank Image]]></item>
                <item name="wcf.acp.user.rank.list"><![CDATA[User Ranks]]></item>
                <item name="wcf.acp.user.rank.rankImage.description"><![CDATA[The path must be either relative to WCF’s directory or absolute.]]></item>
index 0d570c7f3118b96ea9343e56eb25b3b3357fa820..17289be07129f3e393ad92d03c40567555d789e9 100644 (file)
@@ -1706,7 +1706,8 @@ CREATE TABLE wcf1_user_rank (
        cssClassName VARCHAR(255) NOT NULL DEFAULT '',
        rankImage VARCHAR(255) NOT NULL DEFAULT '',
        repeatImage TINYINT(3) NOT NULL DEFAULT 1,
-       requiredGender TINYINT(1) NOT NULL DEFAULT 0
+       requiredGender TINYINT(1) NOT NULL DEFAULT 0,
+       hideTitle TINYINT(1) NOT NULL DEFAULT 0
 );
 
 DROP TABLE IF EXISTS wcf1_user_storage;