2 namespace wcf\system\category
;
3 use wcf\data\category\CategoryEditor
;
4 use wcf\data\user\trophy\UserTrophyAction
;
5 use wcf\data\user\trophy\UserTrophyList
;
9 * Trophy category type.
11 * @author Joshua Ruesweg
12 * @copyright 2001-2018 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package WoltLabSuite\Core\System\Category
17 class TrophyCategoryType
extends AbstractCategoryType
{
21 protected $langVarPrefix = 'wcf.trophy.category';
26 protected $maximumNestingLevel = 0;
31 protected $forceDescription = false;
33 /** @noinspection PhpMissingParentCallCommonInspection */
37 public function canAddCategory() {
38 return $this->canEditCategory();
41 /** @noinspection PhpMissingParentCallCommonInspection */
45 public function canDeleteCategory() {
46 return $this->canEditCategory();
49 /** @noinspection PhpMissingParentCallCommonInspection */
53 public function canEditCategory() {
54 return WCF
::getSession()->getPermission('admin.trophy.canManageTrophy');
60 public function beforeDeletion(CategoryEditor
$categoryEditor) {
61 // update user trophyPoints
62 $userTrophyList = new UserTrophyList();
63 if (!empty($userTrophyList->sqlJoins
)) $userTrophyList->sqlJoins
.= ' ';
64 $userTrophyList->sqlJoins
.= 'LEFT JOIN wcf'.WCF_N
.'_trophy trophy ON user_trophy.trophyID = trophy.trophyID';
65 $userTrophyList->sqlJoins
.= ' LEFT JOIN wcf'.WCF_N
.'_category category ON trophy.categoryID = category.categoryID';
67 $userTrophyList->getConditionBuilder()->add('trophy.isDisabled = ?', [0]);
68 $userTrophyList->getConditionBuilder()->add('category.isDisabled = ?', [0]);
69 $userTrophyList->getConditionBuilder()->add('category.categoryID = ?', [$categoryEditor->categoryID
]);
70 $userTrophyList->readObjects();
72 $userTrophyAction = new UserTrophyAction($userTrophyList->getObjects(), 'delete');
73 $userTrophyAction->executeAction();