Disabling the occupation and hobbies profile field did not hide them from the profiel...
authorAlexander Ebert <ebert@woltlab.com>
Mon, 4 Feb 2019 16:40:10 +0000 (17:40 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 4 Feb 2019 16:40:10 +0000 (17:40 +0100)
com.woltlab.wcf/templates/userProfilePreview.tpl
wcfsetup/install/files/lib/data/user/User.class.php

index c71da8221fb1e4ca366ba6abbbeb027b8270d1a2..bac4a67379d9646a71a31cf286249abd7336dc66 100644 (file)
                                <dl class="plain inlineDataList userFields">
                                        {content}
                                                {if $__wcf->getSession()->getPermission('user.profile.canViewUserProfile') && $user->isAccessible('canViewProfile')}
-                                                       {if $user->occupation}
+                                                       {if $user->getUserOption('occupation', true)}
                                                                <dt>{lang}wcf.user.option.occupation{/lang}</dt>
-                                                               <dd>{$user->occupation}</dd>
+                                                               <dd>{$user->getUserOption('occupation', true)}</dd>
                                                        {/if}
-                                                       {if $user->hobbies}
+                                                       {if $user->getUserOption('hobbies', true)}
                                                                <dt>{lang}wcf.user.option.hobbies{/lang}</dt>
-                                                               <dd>{$user->hobbies}</dd>
+                                                               <dd>{$user->getUserOption('hobbies', true)}</dd>
                                                        {/if}
                                                {/if}
                                                {event name='userFields'}
index c92b89809ba5778ce7ea89e5ddb22c2918f8900a..3ce8a3b0dcfc594b2fb483e084db0cfb0065d8f4 100644 (file)
@@ -4,6 +4,7 @@ use wcf\data\language\Language;
 use wcf\data\user\group\UserGroup;
 use wcf\data\DatabaseObject;
 use wcf\data\IUserContent;
+use wcf\data\user\option\UserOption;
 use wcf\system\cache\builder\UserOptionCacheBuilder;
 use wcf\system\language\LanguageFactory;
 use wcf\system\request\IRouteController;
@@ -75,31 +76,31 @@ final class User extends DatabaseObject implements IRouteController, IUserConten
         * list of group ids
         * @var integer[]
         */
-       protected $groupIDs = null;
+       protected $groupIDs;
        
        /**
         * true, if user has access to the ACP
         * @var boolean
         */
-       protected $hasAdministrativePermissions = null;
+       protected $hasAdministrativePermissions;
        
        /**
         * list of language ids
         * @var integer[]
         */
-       protected $languageIDs = null;
+       protected $languageIDs;
        
        /**
         * date time zone object
         * @var \DateTimeZone
         */
-       protected $timezoneObj = null;
+       protected $timezoneObj;
        
        /**
         * list of user options
-        * @var string[]
+        * @var UserOption[]
         */
-       protected static $userOptions = null;
+       protected static $userOptions;
        
        /** @noinspection PhpMissingParentConstructorInspection */
        /**
@@ -262,13 +263,17 @@ final class User extends DatabaseObject implements IRouteController, IUserConten
         * Returns the value of the user option with the given name.
         * 
         * @param       string          $name           user option name
+        * @param       boolean         $filterDisabled suppress values for disabled options
         * @return      mixed                           user option value
         */
-       public function getUserOption($name) {
+       public function getUserOption($name, $filterDisabled = false) {
                $optionID = self::getUserOptionID($name);
                if ($optionID === null) {
                        return null;
                }
+               else if ($filterDisabled && self::$userOptions[$name]->isDisabled) {
+                       return null;
+               }
                
                if (!isset($this->data['userOption'.$optionID])) return null;
                return $this->data['userOption'.$optionID];