3 namespace wcf\system\condition
;
5 use wcf\data\condition\Condition
;
6 use wcf\data\DatabaseObjectList
;
7 use wcf\data\user\User
;
8 use wcf\data\user\UserList
;
9 use wcf\system\exception\InvalidObjectArgument
;
13 * Condition implementation for the cover photo of a user.
15 * @author Matthias Schmidt
16 * @copyright 2001-2020 WoltLab GmbH
17 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
18 * @package WoltLabSuite\Core\System\Condition
21 class UserCoverPhotoCondition
extends AbstractSelectCondition
implements
26 use TObjectListUserCondition
;
31 protected $fieldName = 'userCoverPhoto';
36 protected $label = 'wcf.user.condition.coverPhoto';
39 * value of the "user has no cover photo" option
42 const NO_COVER_PHOTO
= 0;
45 * value of the "user has a cover photo" option
48 const COVER_PHOTO
= 1;
53 public function addObjectListCondition(DatabaseObjectList
$objectList, array $conditionData)
55 if (!($objectList instanceof UserList
)) {
56 throw new InvalidObjectArgument($objectList, UserList
::class, 'Object list');
59 switch ($conditionData['userCoverPhoto']) {
60 case self
::NO_COVER_PHOTO
:
61 $objectList->getConditionBuilder()->add(
62 '(user_table.coverPhotoHash = ? OR user_table.coverPhotoHash IS NULL)',
67 case self
::COVER_PHOTO
:
68 $objectList->getConditionBuilder()->add(
69 '(user_table.coverPhotoHash <> ? AND user_table.coverPhotoHash IS NOT NULL)',
79 public function checkUser(Condition
$condition, User
$user)
81 switch ($condition->userCoverPhoto
) {
82 case self
::NO_COVER_PHOTO
:
83 return $user->coverPhotoExtension
=== '' ||
$user->coverPhotoExtension
=== null;
86 case self
::COVER_PHOTO
:
87 return $user->coverPhotoExtension
!== '' && $user->coverPhotoExtension
!== null;
95 protected function getOptions()
98 self
::NO_SELECTION_VALUE
=> 'wcf.global.noSelection',
99 self
::NO_COVER_PHOTO
=> 'wcf.user.condition.coverPhoto.noCoverPhoto',
100 self
::COVER_PHOTO
=> 'wcf.user.condition.coverPhoto.coverPhoto',
107 public function showContent(Condition
$condition)
109 if (!WCF
::getUser()->userID
) {
113 return $this->checkUser($condition, WCF
::getUser());