Commit | Line | Data |
---|---|---|
a5a4f02d | 1 | <?php |
a9229942 | 2 | |
a5a4f02d | 3 | namespace wcf\system\category; |
a9229942 | 4 | |
0da68e3b | 5 | use wcf\data\article\ArticleAction; |
0da68e3b | 6 | use wcf\data\category\CategoryEditor; |
a5a4f02d MW |
7 | use wcf\system\WCF; |
8 | ||
9 | /** | |
10 | * Category type implementation for article categories. | |
11 | * | |
a9229942 TD |
12 | * @author Marcel Werk |
13 | * @copyright 2001-2019 WoltLab GmbH | |
14 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
a9229942 | 15 | * @since 3.0 |
a5a4f02d | 16 | */ |
a9229942 TD |
17 | class ArticleCategoryType extends AbstractCategoryType |
18 | { | |
19 | /** | |
20 | * @inheritDoc | |
21 | */ | |
22 | protected $langVarPrefix = 'wcf.article.category'; | |
23 | ||
24 | /** | |
25 | * @inheritDoc | |
26 | */ | |
27 | protected $forceDescription = false; | |
28 | ||
29 | /** | |
30 | * @inheritDoc | |
31 | */ | |
32 | protected $maximumNestingLevel = 9; | |
33 | ||
34 | /** | |
35 | * @inheritDoc | |
36 | */ | |
a7272346 MW |
37 | protected $objectTypes = [ |
38 | 'com.woltlab.wcf.acl' => 'com.woltlab.wcf.article.category', | |
39 | 'com.woltlab.wcf.user.objectWatch' => 'com.woltlab.wcf.article.category', | |
40 | ]; | |
a9229942 | 41 | |
0da68e3b MW |
42 | /** |
43 | * @inheritDoc | |
44 | */ | |
626aa67d | 45 | public function beforeDeletion(CategoryEditor $categoryEditor) |
0da68e3b | 46 | { |
626aa67d | 47 | parent::beforeDeletion($categoryEditor); |
0da68e3b | 48 | |
626aa67d TD |
49 | // Delete articles in this category. |
50 | $sql = "SELECT articleID | |
51 | FROM wcf1_article | |
52 | WHERE categoryID = ?"; | |
53 | $statement = WCF::getDB()->prepare($sql); | |
54 | $statement->execute([ | |
55 | $categoryEditor->categoryID, | |
56 | ]); | |
57 | $articleIDs = $statement->fetchAll(\PDO::FETCH_COLUMN); | |
0da68e3b | 58 | |
626aa67d TD |
59 | if ($articleIDs !== []) { |
60 | $articleAction = new ArticleAction($articleIDs, 'delete'); | |
61 | $articleAction->executeAction(); | |
62 | } | |
0da68e3b | 63 | } |
a9229942 TD |
64 | |
65 | /** | |
66 | * @inheritDoc | |
67 | */ | |
68 | public function canAddCategory() | |
69 | { | |
70 | return $this->canEditCategory(); | |
71 | } | |
72 | ||
73 | /** | |
74 | * @inheritDoc | |
75 | */ | |
76 | public function canDeleteCategory() | |
77 | { | |
78 | return $this->canEditCategory(); | |
79 | } | |
80 | ||
81 | /** | |
82 | * @inheritDoc | |
83 | */ | |
84 | public function canEditCategory() | |
85 | { | |
86 | return WCF::getSession()->getPermission('admin.content.article.canManageCategory'); | |
87 | } | |
88 | ||
89 | /** | |
90 | * @inheritDoc | |
91 | * @since 5.2 | |
92 | */ | |
93 | public function supportsHtmlDescription() | |
94 | { | |
95 | return true; | |
96 | } | |
a5a4f02d | 97 | } |