Commit | Line | Data |
---|---|---|
e539f186 | 1 | <?php |
a9229942 | 2 | |
e539f186 | 3 | namespace wcf\system\category; |
a9229942 | 4 | |
9e1fe407 JR |
5 | use wcf\data\category\CategoryEditor; |
6 | use wcf\data\user\trophy\UserTrophyAction; | |
7 | use wcf\data\user\trophy\UserTrophyList; | |
e539f186 JR |
8 | use wcf\system\WCF; |
9 | ||
10 | /** | |
11 | * Trophy category type. | |
12 | * | |
a9229942 TD |
13 | * @author Joshua Ruesweg |
14 | * @copyright 2001-2019 WoltLab GmbH | |
15 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
a9229942 | 16 | * @since 3.1 |
e539f186 | 17 | */ |
a9229942 TD |
18 | class TrophyCategoryType extends AbstractCategoryType |
19 | { | |
20 | /** | |
21 | * @inheritDoc | |
22 | */ | |
23 | protected $langVarPrefix = 'wcf.trophy.category'; | |
24 | ||
25 | /** | |
26 | * @inheritDoc | |
27 | */ | |
28 | protected $maximumNestingLevel = 0; | |
29 | ||
30 | /** | |
31 | * @inheritDoc | |
32 | */ | |
33 | protected $forceDescription = false; | |
34 | ||
35 | /** | |
36 | * @inheritDoc | |
37 | */ | |
38 | public function canAddCategory() | |
39 | { | |
40 | return $this->canEditCategory(); | |
41 | } | |
42 | ||
43 | /** | |
44 | * @inheritDoc | |
45 | */ | |
46 | public function canDeleteCategory() | |
47 | { | |
48 | return $this->canEditCategory(); | |
49 | } | |
50 | ||
51 | /** | |
52 | * @inheritDoc | |
53 | */ | |
54 | public function canEditCategory() | |
55 | { | |
56 | return WCF::getSession()->getPermission('admin.trophy.canManageTrophy'); | |
57 | } | |
58 | ||
59 | /** | |
60 | * @inheritDoc | |
61 | */ | |
62 | public function beforeDeletion(CategoryEditor $categoryEditor) | |
63 | { | |
64 | // update user trophyPoints | |
65 | $userTrophyList = new UserTrophyList(); | |
66 | if (!empty($userTrophyList->sqlJoins)) { | |
67 | $userTrophyList->sqlJoins .= ' '; | |
68 | } | |
d3bd0a85 MS |
69 | $userTrophyList->sqlJoins .= ' |
70 | LEFT JOIN wcf' . WCF_N . '_trophy trophy | |
71 | ON user_trophy.trophyID = trophy.trophyID | |
72 | LEFT JOIN wcf' . WCF_N . '_category category | |
73 | ON trophy.categoryID = category.categoryID'; | |
a9229942 TD |
74 | |
75 | $userTrophyList->getConditionBuilder()->add('trophy.isDisabled = ?', [0]); | |
76 | $userTrophyList->getConditionBuilder()->add('category.isDisabled = ?', [0]); | |
77 | $userTrophyList->getConditionBuilder()->add('category.categoryID = ?', [$categoryEditor->categoryID]); | |
78 | $userTrophyList->readObjects(); | |
79 | ||
80 | $userTrophyAction = new UserTrophyAction($userTrophyList->getObjects(), 'delete'); | |
81 | $userTrophyAction->executeAction(); | |
82 | } | |
83 | ||
84 | /** | |
85 | * @inheritDoc | |
86 | * @since 5.2 | |
87 | */ | |
88 | public function supportsHtmlDescription() | |
89 | { | |
90 | return true; | |
91 | } | |
e539f186 | 92 | } |