2 namespace wcf\data\moderation\queue
;
3 use wcf\system\exception\PermissionDeniedException
;
4 use wcf\system\exception\UserInputException
;
5 use wcf\system\moderation\queue\ModerationQueueReportManager
;
7 use wcf\util\StringUtil
;
10 * Executes actions for reports.
12 * @author Alexander Ebert
13 * @copyright 2001-2014 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package com.woltlab.wcf
16 * @subpackage data.moderation.queue
17 * @category Community Framework
19 class ModerationQueueReportAction
extends ModerationQueueAction
{
21 * @see \wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess
23 protected $allowGuestAccess = array('prepareReport', 'removeContent', 'removeReport', 'report');
26 * moderation queue editor object
27 * @var \wcf\data\moderation\queue\ModerationQueueEditor
32 * Validates parameters to delete reported content.
34 public function validateRemoveContent() {
35 $this->validateRemoveReport();
37 $this->parameters
['message'] = (isset($this->parameters
['message']) ? StringUtil
::trim($this->parameters
['message']) : '');
41 * Deletes reported content.
43 public function removeContent() {
44 // mark content as deleted
45 ModerationQueueReportManager
::getInstance()->removeContent($this->queue
->getDecoratedObject(), $this->parameters
['message']);
47 $this->queue
->markAsDone();
51 * Validates parameters to mark this report as done.
53 public function validateRemoveReport() {
54 $this->queue
= $this->getSingleObject();
55 if (!$this->queue
->canEdit()) {
56 throw new PermissionDeniedException();
61 * Removes this report by marking it as done without further processing.
63 public function removeReport() {
64 $this->queue
->markAsDone();
68 * Validates parameters to prepare a report.
70 public function validatePrepareReport() {
71 $this->readInteger('objectID');
72 $this->readString('objectType');
74 if (!ModerationQueueReportManager
::getInstance()->isValid($this->parameters
['objectType'])) {
75 throw new UserInputException('objectType');
78 // validate the combination of object type and object id
79 if (!ModerationQueueReportManager
::getInstance()->isValid($this->parameters
['objectType'], $this->parameters
['objectID'])) {
80 throw new UserInputException('objectID');
83 // validate if user may read the content (prevent information disclosure by reporting random ids)
84 if (!ModerationQueueReportManager
::getInstance()->canReport($this->parameters
['objectType'], $this->parameters
['objectID'])) {
85 throw new PermissionDeniedException();
92 public function prepareReport() {
93 // content was already reported
94 $alreadyReported = (ModerationQueueReportManager
::getInstance()->isAlreadyReported($this->parameters
['objectType'], $this->parameters
['objectID'])) ?
1 : 0;
96 WCF
::getTPL()->assign(array(
97 'alreadyReported' => $alreadyReported,
98 'object' => ModerationQueueReportManager
::getInstance()->getReportedObject($this->parameters
['objectType'], $this->parameters
['objectID'])
102 'alreadyReported' => $alreadyReported,
103 'template' => WCF
::getTPL()->fetch('moderationReportDialog')
108 * Validates parameters for reporting.
110 public function validateReport() {
111 $this->readString('message');
113 $this->validatePrepareReport();
119 public function report() {
120 // if the specified content was already reported, e.g. a different user reported this
121 // item meanwhile, silently ignore it. Just display a success and the user is happy :)
122 if (!ModerationQueueReportManager
::getInstance()->isAlreadyReported($this->parameters
['objectType'], $this->parameters
['objectID'])) {
123 ModerationQueueReportManager
::getInstance()->addReport(
124 $this->parameters
['objectType'],
125 $this->parameters
['objectID'],
126 $this->parameters
['message']