use wcf\data\trophy\TrophyCache;
use wcf\data\user\trophy\UserTrophy;
use wcf\data\user\trophy\UserTrophyList;
+use wcf\data\user\User;
use wcf\system\cache\builder\UserOptionCacheBuilder;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\database\util\PreparedStatementConditionBuilder;
$this->objectList->getConditionBuilder()->add('user_trophy.trophyID = ?', [$this->trophy->getObjectID()]);
$canViewTrophyDefaultValue = UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->defaultValue;
+ $canViewTrophiesOptionID = User::getUserOptionID('canViewTrophies');
if (!WCF::getUser()->userID) {
$this->objectList->getConditionBuilder()->add('user_trophy.userID IN (
SELECT userID
FROM wcf' . WCF_N . '_user_option_value
- WHERE COALESCE(userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ', ' . $canViewTrophyDefaultValue . ') = 0)');
+ WHERE COALESCE(userOption' . $canViewTrophiesOptionID . ', ' . $canViewTrophyDefaultValue . ') = 0)');
} elseif (!WCF::getSession()->getPermission('admin.general.canViewPrivateUserOptions')) {
$conditionBuilder = new PreparedStatementConditionBuilder(false, 'OR');
$conditionBuilder->add('user_trophy.userID IN (
SELECT userID
FROM wcf' . WCF_N . '_user_option_value
WHERE (
- COALESCE(userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ', ' . $canViewTrophyDefaultValue . ') = 0
- OR COALESCE(userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ', ' . $canViewTrophyDefaultValue . ') = 1
+ COALESCE(userOption' . $canViewTrophiesOptionID . ', ' . $canViewTrophyDefaultValue . ') = 0
+ OR COALESCE(userOption' . $canViewTrophiesOptionID . ', ' . $canViewTrophyDefaultValue . ') = 1
)
)');
$friendshipConditionBuilder->add('user_trophy.userID IN (
SELECT userID
FROM wcf' . WCF_N . '_user_option_value
- WHERE COALESCE(userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ', ' . $canViewTrophyDefaultValue . ') = 2
+ WHERE COALESCE(userOption' . $canViewTrophiesOptionID . ', ' . $canViewTrophyDefaultValue . ') = 2
)');
$friendshipConditionBuilder->add(
'user_trophy.userID IN (
namespace wcf\system\box;
use wcf\data\user\trophy\UserTrophyList;
-use wcf\system\cache\builder\UserOptionCacheBuilder;
+use wcf\data\user\User;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\WCF;
$list->getConditionBuilder()->add('trophy.isDisabled = ?', [0]);
$list->getConditionBuilder()->add('category.isDisabled = ?', [0]);
+ $canViewTrophiesOptionID = User::getUserOptionID('canViewTrophies');
if (!WCF::getUser()->userID) {
$list->getConditionBuilder()->add('user_trophy.userID IN (
SELECT userID
FROM wcf' . WCF_N . '_user_option_value
- WHERE userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ' = 0
+ WHERE userOption' . $canViewTrophiesOptionID . ' = 0
)');
} elseif (!WCF::getSession()->getPermission('admin.general.canViewPrivateUserOptions')) {
$conditionBuilder = new PreparedStatementConditionBuilder(false, 'OR');
SELECT userID
FROM wcf' . WCF_N . '_user_option_value
WHERE (
- userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ' = 0
- OR userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ' = 1
+ userOption' . $canViewTrophiesOptionID . ' = 0
+ OR userOption' . $canViewTrophiesOptionID . ' = 1
)
)');
$friendshipConditionBuilder->add('user_trophy.userID IN (
SELECT userID
FROM wcf' . WCF_N . '_user_option_value
- WHERE userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ' = 2
+ WHERE userOption' . $canViewTrophiesOptionID . ' = 2
)');
$friendshipConditionBuilder->add(
'user_trophy.userID IN (