3 namespace wcf\data\moderation\queue
;
5 use wcf\system\exception\PermissionDeniedException
;
6 use wcf\system\exception\UserInputException
;
7 use wcf\system\moderation\queue\ModerationQueueActivationManager
;
9 use wcf\util\StringUtil
;
12 * Executes actions for reports.
14 * @author Alexander Ebert
15 * @copyright 2001-2019 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\Data\Moderation\Queue
19 class ModerationQueueActivationAction
extends ModerationQueueAction
24 protected $allowGuestAccess = ['enableContent', 'removeContent'];
27 * moderation queue editor object
28 * @var ModerationQueueEditor
33 * Validates parameters to enable content.
35 public function validateEnableContent()
37 if (empty($this->objects
)) {
40 if (empty($this->objects
)) {
41 throw new UserInputException('objectIDs');
45 foreach ($this->getObjects() as $moderationQueueEditor) {
46 if (!$moderationQueueEditor->canEdit()) {
47 throw new PermissionDeniedException();
55 public function enableContent()
57 WCF
::getDB()->beginTransaction();
58 foreach ($this->getObjects() as $moderationQueueEditor) {
59 ModerationQueueActivationManager
::getInstance()->enableContent(
60 $moderationQueueEditor->getDecoratedObject()
63 $moderationQueueEditor->markAsConfirmed();
65 WCF
::getDB()->commitTransaction();
71 * Validates parameters to delete reported content.
73 public function validateRemoveContent()
75 $this->readString('message', true);
76 $this->validateEnableContent();
80 * Deletes reported content.
82 public function removeContent()
84 // mark content as deleted
85 ModerationQueueActivationManager
::getInstance()->removeContent(
86 $this->queue
->getDecoratedObject(),
87 $this->parameters
['message']
90 $this->queue
->markAsRejected();
96 * Validates the `removeActivationContent` action.
100 public function validateRemoveActivationContent(): void
102 if (empty($this->objects
)) {
103 $this->readObjects();
105 if (empty($this->objects
)) {
106 throw new UserInputException('objectIDs');
110 foreach ($this->getObjects() as $moderationQueueEditor) {
112 !$moderationQueueEditor->canEdit()
113 ||
!ModerationQueueActivationManager
::getInstance()->canRemoveContent($moderationQueueEditor->getDecoratedObject())
115 throw new PermissionDeniedException();
119 $this->parameters
['message'] = StringUtil
::trim($this->parameters
['message'] ??
'');
123 * Deletes disabled content via clipboard.
127 public function removeActivationContent(): void
129 WCF
::getDB()->beginTransaction();
130 foreach ($this->getObjects() as $moderationQueueEditor) {
131 ModerationQueueActivationManager
::getInstance()->removeContent(
132 $moderationQueueEditor->getDecoratedObject(),
133 $this->parameters
['message']
136 $moderationQueueEditor->markAsConfirmed();
138 WCF
::getDB()->commitTransaction();
140 $this->unmarkItems();