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> | |
16 | * @package WoltLabSuite\Core\System\Category | |
17 | * @since 3.1 | |
e539f186 | 18 | */ |
a9229942 TD |
19 | class TrophyCategoryType extends AbstractCategoryType |
20 | { | |
21 | /** | |
22 | * @inheritDoc | |
23 | */ | |
24 | protected $langVarPrefix = 'wcf.trophy.category'; | |
25 | ||
26 | /** | |
27 | * @inheritDoc | |
28 | */ | |
29 | protected $maximumNestingLevel = 0; | |
30 | ||
31 | /** | |
32 | * @inheritDoc | |
33 | */ | |
34 | protected $forceDescription = false; | |
35 | ||
36 | /** | |
37 | * @inheritDoc | |
38 | */ | |
39 | public function canAddCategory() | |
40 | { | |
41 | return $this->canEditCategory(); | |
42 | } | |
43 | ||
44 | /** | |
45 | * @inheritDoc | |
46 | */ | |
47 | public function canDeleteCategory() | |
48 | { | |
49 | return $this->canEditCategory(); | |
50 | } | |
51 | ||
52 | /** | |
53 | * @inheritDoc | |
54 | */ | |
55 | public function canEditCategory() | |
56 | { | |
57 | return WCF::getSession()->getPermission('admin.trophy.canManageTrophy'); | |
58 | } | |
59 | ||
60 | /** | |
61 | * @inheritDoc | |
62 | */ | |
63 | public function beforeDeletion(CategoryEditor $categoryEditor) | |
64 | { | |
65 | // update user trophyPoints | |
66 | $userTrophyList = new UserTrophyList(); | |
67 | if (!empty($userTrophyList->sqlJoins)) { | |
68 | $userTrophyList->sqlJoins .= ' '; | |
69 | } | |
d3bd0a85 MS |
70 | $userTrophyList->sqlJoins .= ' |
71 | LEFT JOIN wcf' . WCF_N . '_trophy trophy | |
72 | ON user_trophy.trophyID = trophy.trophyID | |
73 | LEFT JOIN wcf' . WCF_N . '_category category | |
74 | ON trophy.categoryID = category.categoryID'; | |
a9229942 TD |
75 | |
76 | $userTrophyList->getConditionBuilder()->add('trophy.isDisabled = ?', [0]); | |
77 | $userTrophyList->getConditionBuilder()->add('category.isDisabled = ?', [0]); | |
78 | $userTrophyList->getConditionBuilder()->add('category.categoryID = ?', [$categoryEditor->categoryID]); | |
79 | $userTrophyList->readObjects(); | |
80 | ||
81 | $userTrophyAction = new UserTrophyAction($userTrophyList->getObjects(), 'delete'); | |
82 | $userTrophyAction->executeAction(); | |
83 | } | |
84 | ||
85 | /** | |
86 | * @inheritDoc | |
87 | * @since 5.2 | |
88 | */ | |
89 | public function supportsHtmlDescription() | |
90 | { | |
91 | return true; | |
92 | } | |
e539f186 | 93 | } |