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