Skip to content

Commit ffbd755

Browse files
committed
Use the new condition types to check whether the user meets the condition.
1 parent 71b4566 commit ffbd755

File tree

1 file changed

+8
-50
lines changed

1 file changed

+8
-50
lines changed

wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace wcf\system\trophy\condition;
44

5-
use wcf\data\object\type\ObjectType;
6-
use wcf\data\object\type\ObjectTypeCache;
75
use wcf\data\trophy\Trophy;
86
use wcf\data\trophy\TrophyList;
97
use wcf\data\user\trophy\UserTrophyAction;
108
use wcf\data\user\UserList;
9+
use wcf\system\condition\ConditionHandler;
10+
use wcf\system\condition\provider\UserConditionProvider;
1111
use wcf\system\SingletonFactory;
1212

1313
/**
@@ -20,49 +20,6 @@
2020
*/
2121
class TrophyConditionHandler extends SingletonFactory
2222
{
23-
/**
24-
* definition name for trophy conditions
25-
* @var string
26-
*/
27-
const CONDITION_DEFINITION_NAME = 'com.woltlab.wcf.condition.trophy';
28-
29-
/**
30-
* list of grouped trophy condition object types
31-
* @var ObjectType[][]
32-
*/
33-
protected $groupedObjectTypes = [];
34-
35-
/**
36-
* @inheritDoc
37-
*/
38-
protected function init()
39-
{
40-
// TODO
41-
$objectTypes = ObjectTypeCache::getInstance()->getObjectTypes(self::CONDITION_DEFINITION_NAME);
42-
43-
foreach ($objectTypes as $objectType) {
44-
if (!$objectType->conditiongroup) {
45-
continue;
46-
}
47-
48-
if (!isset($this->groupedObjectTypes[$objectType->conditiongroup])) {
49-
$this->groupedObjectTypes[$objectType->conditiongroup] = [];
50-
}
51-
52-
$this->groupedObjectTypes[$objectType->conditiongroup][$objectType->objectTypeID] = $objectType;
53-
}
54-
}
55-
56-
/**
57-
* Returns the list of grouped trophy condition object types.
58-
*
59-
* @return ObjectType[][]
60-
*/
61-
public function getGroupedObjectTypes()
62-
{
63-
return $this->groupedObjectTypes;
64-
}
65-
6623
/**
6724
* Assign trophies based on rules.
6825
*
@@ -140,10 +97,10 @@ private function getUserIDs(Trophy $trophy)
14097
LEFT JOIN wcf1_user_option_value user_option_value
14198
ON user_option_value.userID = user_table.userID";
14299

143-
$conditions = $trophy->getConditions();
144-
// TODO
100+
$provider = new UserConditionProvider();
101+
$conditions = ConditionHandler::getInstance()->getConditionsWithFilter($provider, $trophy->getConditions());
145102
foreach ($conditions as $condition) {
146-
$condition->getObjectType()->getProcessor()->addUserCondition($condition, $userList);
103+
$condition->applyFilter($userList);
147104
}
148105

149106
// prevent multiple awards from a trophy for a user
@@ -187,9 +144,10 @@ private function getRevocableUserTrophyIDs(Trophy $trophy, $maxTrophyIDs)
187144
}
188145

189146
// Assign the condition to the pseudo DBOList object
190-
// TODO
147+
$provider = new UserConditionProvider();
148+
$conditions = ConditionHandler::getInstance()->getConditionsWithFilter($provider, $trophy->getConditions());
191149
foreach ($conditions as $condition) {
192-
$condition->getObjectType()->getProcessor()->addUserCondition($condition, $pseudoUserList);
150+
$condition->applyFilter($pseudoUserList);
193151
}
194152

195153
// Now we create our own query to find out which users no longer meet the conditions.

0 commit comments

Comments
 (0)