From: Matthias Schmidt Date: Thu, 15 Apr 2021 05:23:59 +0000 (+0200) Subject: Merge branch '5.3' X-Git-Tag: 5.4.0_Alpha_1~90 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=87b2c8cfb43bbeab77dff79c9b6329b01e9bcc6c;p=GitHub%2FWoltLab%2FWCF.git Merge branch '5.3' --- 87b2c8cfb43bbeab77dff79c9b6329b01e9bcc6c diff --cc wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueActivationAction.class.php index 4e112a1134,d3610da40f..3d02f8963f --- a/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueActivationAction.class.php +++ b/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueActivationAction.class.php @@@ -10,133 -5,63 +10,137 @@@ use wcf\util\StringUtil /** * Executes actions for reports. - * - * @author Alexander Ebert - * @copyright 2001-2019 WoltLab GmbH - * @license GNU Lesser General Public License - * @package WoltLabSuite\Core\Data\Moderation\Queue + * + * @author Alexander Ebert + * @copyright 2001-2019 WoltLab GmbH + * @license GNU Lesser General Public License + * @package WoltLabSuite\Core\Data\Moderation\Queue */ -class ModerationQueueActivationAction extends ModerationQueueAction { - /** - * @inheritDoc - */ - protected $allowGuestAccess = ['enableContent', 'removeContent']; - - /** - * moderation queue editor object - * @var ModerationQueueEditor - */ - public $queue = null; - - /** - * Validates parameters to enable content. - */ - public function validateEnableContent() { - $this->queue = $this->getSingleObject(); - if (!$this->queue->canEdit()) { - throw new PermissionDeniedException(); - } - } - - /** - * Enables content. - */ - public function enableContent() { - // enable content - ModerationQueueActivationManager::getInstance()->enableContent($this->queue->getDecoratedObject()); - - $this->queue->markAsConfirmed(); - } - - /** - * Validates parameters to delete reported content. - */ - public function validateRemoveContent() { - $this->readString('message', true); - $this->validateEnableContent(); - - if (!ModerationQueueActivationManager::getInstance()->canRemoveContent($this->queue->getDecoratedObject())) { - throw new PermissionDeniedException(); - } - } - - /** - * Deletes reported content. - */ - public function removeContent() { - // mark content as deleted - ModerationQueueActivationManager::getInstance()->removeContent($this->queue->getDecoratedObject(), $this->parameters['message']); - - $this->queue->markAsRejected(); - } +class ModerationQueueActivationAction extends ModerationQueueAction +{ + /** + * @inheritDoc + */ + protected $allowGuestAccess = ['enableContent', 'removeContent']; + + /** + * moderation queue editor object + * @var ModerationQueueEditor + */ + public $queue; + + /** + * Validates parameters to enable content. + */ + public function validateEnableContent() + { + if (empty($this->objects)) { + $this->readObjects(); + + if (empty($this->objects)) { + throw new UserInputException('objectIDs'); + } + } + + foreach ($this->getObjects() as $moderationQueueEditor) { + if (!$moderationQueueEditor->canEdit()) { + throw new PermissionDeniedException(); + } + } + } + + /** + * Enables content. + */ + public function enableContent() + { + WCF::getDB()->beginTransaction(); + foreach ($this->getObjects() as $moderationQueueEditor) { + ModerationQueueActivationManager::getInstance()->enableContent( + $moderationQueueEditor->getDecoratedObject() + ); + + $moderationQueueEditor->markAsConfirmed(); + } + WCF::getDB()->commitTransaction(); + + $this->unmarkItems(); + } + + /** + * Validates parameters to delete reported content. + */ + public function validateRemoveContent() + { + $this->readString('message', true); + $this->validateEnableContent(); ++ ++ if (!ModerationQueueActivationManager::getInstance()->canRemoveContent($this->queue->getDecoratedObject())) { ++ throw new PermissionDeniedException(); ++ } + } + + /** + * Deletes reported content. + */ + public function removeContent() + { + // mark content as deleted + ModerationQueueActivationManager::getInstance()->removeContent( + $this->queue->getDecoratedObject(), + $this->parameters['message'] + ); + + $this->queue->markAsRejected(); + + $this->unmarkItems(); + } + + /** + * Validates the `removeActivationContent` action. + * + * @since 5.4 + */ + public function validateRemoveActivationContent(): void + { + if (empty($this->objects)) { + $this->readObjects(); + + if (empty($this->objects)) { + throw new UserInputException('objectIDs'); + } + } + + foreach ($this->getObjects() as $moderationQueueEditor) { + if ( + !$moderationQueueEditor->canEdit() + || !ModerationQueueActivationManager::getInstance()->canRemoveContent($moderationQueueEditor->getDecoratedObject()) + ) { + throw new PermissionDeniedException(); + } + } + + $this->parameters['message'] = StringUtil::trim($this->parameters['message'] ?? ''); + } + + /** + * Deletes disabled content via clipboard. + * + * @since 5.4 + */ + public function removeActivationContent(): void + { + WCF::getDB()->beginTransaction(); + foreach ($this->getObjects() as $moderationQueueEditor) { + ModerationQueueActivationManager::getInstance()->removeContent( + $moderationQueueEditor->getDecoratedObject(), + $this->parameters['message'] + ); + + $moderationQueueEditor->markAsConfirmed(); + } + WCF::getDB()->commitTransaction(); + + $this->unmarkItems(); + } } diff --cc wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueReportAction.class.php index 049c5e399d,8c18a9369d..b66ece5e6d --- a/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueReportAction.class.php +++ b/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueReportAction.class.php @@@ -10,271 -8,139 +10,275 @@@ use wcf\util\StringUtil /** * Executes actions for reports. - * - * @author Alexander Ebert - * @copyright 2001-2019 WoltLab GmbH - * @license GNU Lesser General Public License - * @package WoltLabSuite\Core\Data\Moderation\Queue + * + * @author Alexander Ebert + * @copyright 2001-2019 WoltLab GmbH + * @license GNU Lesser General Public License + * @package WoltLabSuite\Core\Data\Moderation\Queue */ -class ModerationQueueReportAction extends ModerationQueueAction { - /** - * @inheritDoc - */ - protected $allowGuestAccess = ['prepareReport', 'removeContent', 'removeReport', 'report']; - - /** - * moderation queue editor object - * @var ModerationQueueEditor - */ - public $queue = null; - - /** - * Validates parameters to delete reported content. - */ - public function validateRemoveContent() { - $this->validateRemoveReport(); - - if (!ModerationQueueReportManager::getInstance()->canRemoveContent($this->queue->getDecoratedObject())) { - throw new PermissionDeniedException(); - } - - $this->parameters['message'] = (isset($this->parameters['message']) ? StringUtil::trim($this->parameters['message']) : ''); - } - - /** - * Deletes reported content. - */ - public function removeContent() { - // mark content as deleted - ModerationQueueReportManager::getInstance()->removeContent($this->queue->getDecoratedObject(), $this->parameters['message']); - - $this->queue->markAsConfirmed(); - } - - /** - * Validates parameters to mark this report as done. - */ - public function validateRemoveReport() { - $this->queue = $this->getSingleObject(); - if (!$this->queue->canEdit()) { - throw new PermissionDeniedException(); - } - - $this->readBoolean('markAsJustified', true); - } - - /** - * Removes this report by marking it as done without further processing. - */ - public function removeReport() { - $this->queue->markAsRejected((isset($this->parameters['markAsJustified']) ? $this->parameters['markAsJustified'] : false)); - } - - /** - * Validates parameters to prepare a report. - */ - public function validatePrepareReport() { - WCF::getSession()->checkPermissions(['user.profile.canReportContent']); - - $this->readInteger('objectID'); - $this->readString('objectType'); - - if (!ModerationQueueReportManager::getInstance()->isValid($this->parameters['objectType'])) { - throw new UserInputException('objectType'); - } - - // validate the combination of object type and object id - if (!ModerationQueueReportManager::getInstance()->isValid($this->parameters['objectType'], $this->parameters['objectID'])) { - throw new UserInputException('objectID'); - } - - // validate if user may read the content (prevent information disclosure by reporting random ids) - if (!ModerationQueueReportManager::getInstance()->canReport($this->parameters['objectType'], $this->parameters['objectID'])) { - throw new PermissionDeniedException(); - } - } - - /** - * Prepares a report. - */ - public function prepareReport() { - // content was already reported - $alreadyReported = ModerationQueueReportManager::getInstance()->hasPendingReport($this->parameters['objectType'], $this->parameters['objectID']) ? 1 : 0; - - WCF::getTPL()->assign([ - 'alreadyReported' => $alreadyReported, - 'object' => ModerationQueueReportManager::getInstance()->getReportedObject($this->parameters['objectType'], $this->parameters['objectID']) - ]); - - return [ - 'alreadyReported' => $alreadyReported, - 'template' => WCF::getTPL()->fetch('moderationReportDialog') - ]; - } - - /** - * Validates parameters for reporting. - */ - public function validateReport() { - WCF::getSession()->checkPermissions(['user.profile.canReportContent']); - - $this->readString('message'); - if (mb_strlen($this->parameters['message']) > 64000) { - // we allow only up to 64.000 characters (~1.5 below TEXT maximum) - $this->parameters['message'] = mb_substr($this->parameters['messages'], 0, 64000); - } - - $this->validatePrepareReport(); - } - - /** - * Reports an item. - */ - public function report() { - // if the specified content was already reported, e.g. a different user reported this - // item meanwhile, silently ignore it. Just display a success and the user is happy :) - if (!ModerationQueueReportManager::getInstance()->hasPendingReport($this->parameters['objectType'], $this->parameters['objectID'])) { - ModerationQueueReportManager::getInstance()->addReport( - $this->parameters['objectType'], - $this->parameters['objectID'], - $this->parameters['message'] - ); - } - - return [ - 'reported' => 1 - ]; - } +class ModerationQueueReportAction extends ModerationQueueAction +{ + /** + * @inheritDoc + */ + protected $allowGuestAccess = ['prepareReport', 'removeContent', 'removeReport', 'report']; + + /** + * moderation queue editor object + * @var ModerationQueueEditor + */ + public $queue; + + /** + * Validates parameters to delete reported content. + */ + public function validateRemoveContent() + { + $this->validateRemoveReport(); + ++ if (!ModerationQueueReportManager::getInstance()->canRemoveContent($this->queue->getDecoratedObject())) { ++ throw new PermissionDeniedException(); ++ } ++ + $this->parameters['message'] = (isset($this->parameters['message']) ? StringUtil::trim($this->parameters['message']) : ''); + } + + /** + * Deletes reported content. + */ + public function removeContent() + { + // mark content as deleted + ModerationQueueReportManager::getInstance()->removeContent( + $this->queue->getDecoratedObject(), + $this->parameters['message'] + ); + + $this->queue->markAsConfirmed(); + + $this->unmarkItems(); + } + + /** + * Validates parameters to mark this report as done. + */ + public function validateRemoveReport() + { + if (empty($this->objects)) { + $this->readObjects(); + + if (empty($this->objects)) { + throw new UserInputException('objectIDs'); + } + } + + foreach ($this->getObjects() as $moderationQueueEditor) { + if (!$moderationQueueEditor->canEdit()) { + throw new PermissionDeniedException(); + } + } + + if (isset($this->parameters['data']['markAsJustified'])) { + $this->readBoolean('markAsJustified', true, 'data'); + + // Clipboard passes `markAsJustified` in the `data` array. + $this->parameters['markAsJustified'] = $this->parameters['data']['markAsJustified']; + } else { + $this->readBoolean('markAsJustified', true); + } + } + + /** + * Removes this report by marking it as done without further processing. + */ + public function removeReport() + { + WCF::getDB()->beginTransaction(); + foreach ($this->getObjects() as $moderationQueueEditor) { + $moderationQueueEditor->markAsRejected($this->parameters['markAsJustified'] ?? false); + } + WCF::getDB()->commitTransaction(); + + $this->unmarkItems(); + } + + /** + * Validates parameters to prepare a report. + */ + public function validatePrepareReport() + { + WCF::getSession()->checkPermissions(['user.profile.canReportContent']); + + $this->readInteger('objectID'); + $this->readString('objectType'); + + if (!ModerationQueueReportManager::getInstance()->isValid($this->parameters['objectType'])) { + throw new UserInputException('objectType'); + } + + // validate the combination of object type and object id + if ( + !ModerationQueueReportManager::getInstance()->isValid( + $this->parameters['objectType'], + $this->parameters['objectID'] + ) + ) { + throw new UserInputException('objectID'); + } + + // validate if user may read the content (prevent information disclosure by reporting random ids) + if ( + !ModerationQueueReportManager::getInstance()->canReport( + $this->parameters['objectType'], + $this->parameters['objectID'] + ) + ) { + throw new PermissionDeniedException(); + } + } + + /** + * Prepares a report. + */ + public function prepareReport() + { + // content was already reported + $alreadyReported = ModerationQueueReportManager::getInstance()->hasPendingReport( + $this->parameters['objectType'], + $this->parameters['objectID'] + ) ? 1 : 0; + + WCF::getTPL()->assign([ + 'alreadyReported' => $alreadyReported, + 'object' => ModerationQueueReportManager::getInstance()->getReportedObject( + $this->parameters['objectType'], + $this->parameters['objectID'] + ), + ]); + + return [ + 'alreadyReported' => $alreadyReported, + 'template' => WCF::getTPL()->fetch('moderationReportDialog'), + ]; + } + + /** + * Validates parameters for reporting. + */ + public function validateReport() + { + WCF::getSession()->checkPermissions(['user.profile.canReportContent']); + + $this->readString('message'); + if (\mb_strlen($this->parameters['message']) > 64000) { + // we allow only up to 64.000 characters (~1.5 below TEXT maximum) + $this->parameters['message'] = \mb_substr($this->parameters['messages'], 0, 64000); + } + + $this->validatePrepareReport(); + } + + /** + * Reports an item. + */ + public function report() + { + // if the specified content was already reported, e.g. a different user reported this + // item meanwhile, silently ignore it. Just display a success and the user is happy :) + if ( + !ModerationQueueReportManager::getInstance()->hasPendingReport( + $this->parameters['objectType'], + $this->parameters['objectID'] + ) + ) { + ModerationQueueReportManager::getInstance()->addReport( + $this->parameters['objectType'], + $this->parameters['objectID'], + $this->parameters['message'] + ); + } + + return [ + 'reported' => 1, + ]; + } + + /** + * Validates the `changeJustifiedStatus` action. + * + * @since 5.4 + */ + public function validateChangeJustifiedStatus(): void + { + $this->queue = $this->getSingleObject(); + if (!$this->queue->canEdit() || !$this->queue->canChangeJustifiedStatus()) { + throw new PermissionDeniedException(); + } + + $this->readBoolean('markAsJustified', true); + } + + /** + * Updates the `markAsJustified` status. + */ + public function changeJustifiedStatus(): void + { + $additionalData = $this->queue->additionalData; + if (!\is_array($additionalData)) { + $additionalData = []; + } + $additionalData['markAsJustified'] = $this->parameters['markAsJustified']; + + $this->queue->update([ + 'additionalData' => \serialize($additionalData), + ]); + } + + /** + * Validates the `removeReportContent` action. + * + * @since 5.4 + */ + public function validateRemoveReportContent(): void + { + if (empty($this->objects)) { + $this->readObjects(); + + if (empty($this->objects)) { + throw new UserInputException('objectIDs'); + } + } + + foreach ($this->getObjects() as $moderationQueueEditor) { + if ( + !$moderationQueueEditor->canEdit() + || !ModerationQueueReportManager::getInstance()->canRemoveContent($moderationQueueEditor->getDecoratedObject()) + ) { + throw new PermissionDeniedException(); + } + } + + $this->parameters['message'] = StringUtil::trim($this->parameters['message'] ?? ''); + } + + /** + * Deletes reported content via clipboard. + * + * @since 5.4 + */ + public function removeReportContent(): void + { + WCF::getDB()->beginTransaction(); + foreach ($this->getObjects() as $moderationQueueEditor) { + ModerationQueueReportManager::getInstance()->removeContent( + $moderationQueueEditor->getDecoratedObject(), + $this->parameters['message'] + ); + + $moderationQueueEditor->markAsConfirmed(); + } + WCF::getDB()->commitTransaction(); + + $this->unmarkItems(); + } } diff --cc wcfsetup/install/files/style/bbcode/code.scss index 510d83918c,f2bd7fbf8f..a911de2685 --- a/wcfsetup/install/files/style/bbcode/code.scss +++ b/wcfsetup/install/files/style/bbcode/code.scss @@@ -99,11 -95,20 +99,20 @@@ > .codeBoxHeadline { flex: 1 1 auto; padding: 0 10px; - + @include wcfFontHeadline; + + @include screen-sm-down { + overflow: auto; + white-space: nowrap; + } + } + + .icon { + flex: 0 0 auto; } } - + .codeBoxCode { position: relative; padding-left: 7ch;