5a3a8ab3d4d67720e156be14a06d5596469e876f
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\condition\user\activity\event;
3 use wcf\data\object\type\ObjectTypeCache;
4 use wcf\data\user\activity\event\UserActivityEventList;
5 use wcf\data\DatabaseObjectList;
6 use wcf\system\condition\AbstractMultiSelectCondition;
7 use wcf\system\condition\IObjectListCondition;
8 use wcf\system\WCF;
9
10 /**
11 * Condition implementation for the excluded object types of user activity events.
12 *
13 * @author Matthias Schmidt
14 * @copyright 2001-2018 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package WoltLabSuite\Core\System\Condition\User\Activity\Event
17 * @since 3.0
18 */
19 class UserActivityEventExcludedObjectTypeCondition extends AbstractMultiSelectCondition implements IObjectListCondition {
20 /**
21 * @inheritDoc
22 */
23 protected $description = 'wcf.global.multiSelect';
24
25 /**
26 * @inheritDoc
27 */
28 protected $fieldName = 'userActivityEventExcludedObjectTypeID';
29
30 /**
31 * @inheritDoc
32 */
33 protected $label = 'wcf.user.recentActivity.condition.excludedObjectType';
34
35 /**
36 * @inheritDoc
37 */
38 public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
39 if (!($objectList instanceof UserActivityEventList)) {
40 throw new \InvalidArgumentException("Object list is no instance of '".UserActivityEventList::class."', instance of '".get_class($objectList)."' given.");
41 }
42
43 $objectList->getConditionBuilder()->add('user_activity_event.objectTypeID NOT IN (?)', [$conditionData[$this->fieldName]]);
44 }
45
46 /**
47 * @inheritDoc
48 */
49 public function getOptions() {
50 $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.user.recentActivityEvent');
51
52 $options = [];
53 foreach ($objectTypes as $objectType) {
54 $options[$objectType->objectTypeID] = WCF::getLanguage()->getDynamicVariable('wcf.user.recentActivity.' . $objectType->objectType);
55 }
56
57 return $options;
58 }
59 }