0103bb66e1b30dbf746c8525766677c509d34fe3
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\condition\user\trophy;
3 use wcf\data\trophy\category\TrophyCategoryCache;
4 use wcf\data\user\trophy\UserTrophyList;
5 use wcf\data\DatabaseObjectList;
6 use wcf\system\condition\AbstractMultiSelectCondition;
7 use wcf\system\condition\IObjectListCondition;
8
9 /**
10 * Condition implementation for the excluded trophies.
11 *
12 * @author Joshua Ruesweg
13 * @copyright 2001-2017 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package WoltLabSuite\Core\System\Condition\User\Trophy
16 * @since 3.1
17 */
18 class UserTrophyExcludedTrophyCategoriesCondition extends AbstractMultiSelectCondition implements IObjectListCondition {
19 /**
20 * @inheritDoc
21 */
22 protected $description = 'wcf.global.multiSelect';
23
24 /**
25 * @inheritDoc
26 */
27 protected $fieldName = 'userTrophyExcludedTrophyCategories';
28
29 /**
30 * @inheritDoc
31 */
32 protected $label = 'wcf.user.trophy.condition.excludedTrophyCategories';
33
34 /**
35 * @inheritDoc
36 */
37 public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
38 if (!($objectList instanceof UserTrophyList)) {
39 throw new \InvalidArgumentException("Object list is no instance of '".UserTrophyList::class."', instance of '".get_class($objectList)."' given.");
40 }
41
42 $objectList->getConditionBuilder()->add('user_trophy.category NOT IN (?)', [$conditionData[$this->fieldName]]);
43 }
44
45 /**
46 * @inheritDoc
47 */
48 public function getOptions() {
49 $categories = TrophyCategoryCache::getInstance()->getCategories();
50
51 $options = [];
52 foreach ($categories as $category) {
53 $options[$category->categoryID] = $category->getTitle();
54 }
55
56 asort($options);
57
58 return $options;
59 }
60 }