From ef37949e2075598f57c32d23d53d4a056c5303d6 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 4 Feb 2019 17:40:10 +0100 Subject: [PATCH] Disabling the occupation and hobbies profile field did not hide them from the profiel preview --- .../templates/userProfilePreview.tpl | 8 ++++---- .../files/lib/data/user/User.class.php | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/com.woltlab.wcf/templates/userProfilePreview.tpl b/com.woltlab.wcf/templates/userProfilePreview.tpl index c71da8221f..bac4a67379 100644 --- a/com.woltlab.wcf/templates/userProfilePreview.tpl +++ b/com.woltlab.wcf/templates/userProfilePreview.tpl @@ -32,13 +32,13 @@
{content} {if $__wcf->getSession()->getPermission('user.profile.canViewUserProfile') && $user->isAccessible('canViewProfile')} - {if $user->occupation} + {if $user->getUserOption('occupation', true)}
{lang}wcf.user.option.occupation{/lang}
-
{$user->occupation}
+
{$user->getUserOption('occupation', true)}
{/if} - {if $user->hobbies} + {if $user->getUserOption('hobbies', true)}
{lang}wcf.user.option.hobbies{/lang}
-
{$user->hobbies}
+
{$user->getUserOption('hobbies', true)}
{/if} {/if} {event name='userFields'} diff --git a/wcfsetup/install/files/lib/data/user/User.class.php b/wcfsetup/install/files/lib/data/user/User.class.php index c92b89809b..3ce8a3b0dc 100644 --- a/wcfsetup/install/files/lib/data/user/User.class.php +++ b/wcfsetup/install/files/lib/data/user/User.class.php @@ -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]; -- 2.20.1