Support changing moderation queue status of closed entries (#3924)
authorMatthias Schmidt <gravatronics@live.com>
Tue, 2 Feb 2021 14:22:52 +0000 (15:22 +0100)
committerGitHub <noreply@github.com>
Tue, 2 Feb 2021 14:22:52 +0000 (15:22 +0100)
Close #3227

com.woltlab.wcf/templates/moderationReport.tpl
wcfsetup/install/files/js/WCF.Moderation.js
wcfsetup/install/files/lib/data/moderation/queue/ModerationQueue.class.php
wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueReportAction.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 8c3942d792e733c50fbce7265dd42995b2368af5..38e354d3adfdf1d36ac643e70d54349849bc966f 100644 (file)
@@ -40,6 +40,9 @@
                                                        {if $queueManager->canRemoveContent($queue->getDecoratedObject())}<li class="jsOnly"><a id="removeContent" class="button"><span class="icon icon16 fa-times"></span> <span>{lang}wcf.moderation.report.removeContent{/lang}</span></a></li>{/if}
                                                        <li class="jsOnly"><a id="removeReport" class="button"><span class="icon icon16 fa-check"></span> <span>{lang}wcf.moderation.report.removeReport{/lang}</span></a></li>
                                                {/if}
+                                               {if $queue->canChangeJustifiedStatus()}
+                                                       <li class="jsOnly"><a id="changeJustifiedStatus" class="button"><span class="icon icon16 fa-pencil"></span> <span>{lang}wcf.moderation.report.changeJustifiedStatus{/lang}</span></a></li>
+                                               {/if}
                                                {if $queue->getAffectedObject()}<li><a href="{$queue->getAffectedObject()->getLink()}" class="button"><span class="icon icon16 fa-arrow-right"></span> <span>{lang}wcf.moderation.jumpToContent{/lang}</span></a></li>{/if}
                                                
                                                {event name='contentHeaderNavigation'}
                        'wcf.moderation.report.removeContent.reason': '{jslang}wcf.moderation.report.removeContent.reason{/jslang}',
                        'wcf.moderation.report.removeReport.confirmMessage': '{jslang}wcf.moderation.report.removeReport.confirmMessage{/jslang}',
                        'wcf.moderation.report.removeReport.markAsJustified': '{jslang}wcf.moderation.report.removeReport.markAsJustified{/jslang}',
+                       'wcf.moderation.report.removeReport.confirmMessage': '{jslang}wcf.moderation.report.removeReport.confirmMessage{/jslang}',
+                       'wcf.moderation.report.changeJustifiedStatus.markAsJustified': '{jslang}wcf.moderation.report.changeJustifiedStatus.markAsJustified{/jslang}',
+                       'wcf.moderation.report.changeJustifiedStatus.confirmMessage': '{jslang}wcf.moderation.report.changeJustifiedStatus.confirmMessage{/jslang}',
                        'wcf.moderation.status.outstanding': '{jslang}wcf.moderation.status.outstanding{/jslang}',
                        'wcf.moderation.status.processing': '{jslang}wcf.moderation.status.processing{/jslang}',
                        'wcf.user.username.error.notFound': '{jslang __literal=true}wcf.user.username.error.notFound{/jslang}'
                });
                
-               new WCF.Moderation.Report.Management({@$queue->queueID}, '{link controller='ModerationList' encode=false}{/link}');
+               new WCF.Moderation.Report.Management(
+                       {@$queue->queueID},
+                       '{link controller='ModerationList' encode=false}{/link}',
+                       {if $queue->markAsJustified}true{else}false{/if}
+               );
        });
 </script>
 
index 63cf11955a8235e9b68f0223ec0dc40f5f2838b5..0386f99bc0520da08ffd7b5094e57cc7b6de6d8f 100644 (file)
@@ -667,14 +667,30 @@ if (COMPILER_TARGET_DEFAULT) {
                /**
                 * @see        WCF.Moderation.Management.init()
                 */
-               init: function (queueID, redirectURL) {
-                       this._buttonSelector = '#removeContent, #removeReport';
+               init: function (queueID, redirectURL, isMarkedAsConfirmed) {
+                       this._buttonSelector = '#removeContent, #removeReport, #changeJustifiedStatus';
                        this._className = 'wcf\\data\\moderation\\queue\\ModerationQueueReportAction';
                        
                        this._super(queueID, redirectURL, 'wcf.moderation.report.{actionName}.confirmMessage');
                        
                        this._confirmationTemplate.removeContent = $('<div class="section"><dl><dt><label for="message">' + WCF.Language.get('wcf.moderation.report.removeContent.reason') + '</label></dt><dd><textarea name="message" id="message" cols="40" rows="3" /></dd></dl></div>');
                        this._confirmationTemplate.removeReport = $('<div class="section"><dl><dt></dt><dd><label><input type="checkbox" name="markAsJustified" id="markAsJustified" value="1"> ' + WCF.Language.get('wcf.moderation.report.removeReport.markAsJustified') + '</label></dd></dl></div>');
+                       this._confirmationTemplate.changeJustifiedStatus = $('<div class="section"><dl><dt></dt><dd><label><input type="checkbox" name="markAsJustified" id="markAsJustified" value="1"' + (isMarkedAsConfirmed ? ' checked="checked"' : '') + '> ' + WCF.Language.get('wcf.moderation.report.changeJustifiedStatus.markAsJustified') + '</label></dd></dl></div>');
+               },
+
+               /**
+                * @see        WCF.Moderation.Management._success()
+                */
+               _success: function (data, textStatus, jqXHR) {
+                       if (data.actionName === 'changeJustifiedStatus') {
+                               var notification = new WCF.System.Notification();
+                               notification.show(() => {
+                                       window.location.reload();
+                               });
+                       }
+                       else {
+                               this._super(data, textStatus, jqXHR);
+                       }
                }
        });
        
index 7464ea77de23bb75456bec76cc5186d8714fab4e..31134f3a02dace6d1283a4c3662d997f1770dc88 100644 (file)
@@ -137,4 +137,14 @@ class ModerationQueue extends DatabaseObject
                 break;
         }
     }
+
+    /**
+     * Returns `true` if the `justified` status can be changed.
+     *
+     * @since   5.4
+     */
+    public function canChangeJustifiedStatus(): bool
+    {
+        return \in_array($this->status, [self::STATUS_REJECTED, self::STATUS_CONFIRMED]);
+    }
 }
index e899ca7d7590074d139ab36a6beb5c8c96d0dedd..ef63c38366a9edecaca89a30687b4f53f38ffb8e 100644 (file)
@@ -174,4 +174,35 @@ class ModerationQueueReportAction extends ModerationQueueAction
             '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),
+        ]);
+    }
 }
index 06a5dea0c6d466ee0b2478a59309dcd090d622ff..3816db2b10cb01055a8e0012f11bd2500d0c1e92 100644 (file)
@@ -4314,6 +4314,9 @@ Dateianhänge:
                <item name="wcf.moderation.report.reportedBy"><![CDATA[Gemeldet von]]></item>
                <item name="wcf.moderation.report.reportedContent"><![CDATA[Gemeldeter Inhalt]]></item>
                <item name="wcf.moderation.report.success"><![CDATA[Der Inhalt wurde den Moderatoren gemeldet.]]></item>
+               <item name="wcf.moderation.report.changeJustifiedStatus"><![CDATA[„Berechtigt“-Status ändern]]></item>
+               <item name="wcf.moderation.report.changeJustifiedStatus.markAsJustified"><![CDATA[Meldung als „Berechtigt“ markieren]]></item>
+               <item name="wcf.moderation.report.changeJustifiedStatus.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} den „Berechtigt“-Status dieser Meldung wirklich ändern?]]></item>
        </category>
        <category name="wcf.notice">
                <item name="wcf.notice.button.dismiss"><![CDATA[Hinweis dauerhaft ausblenden]]></item>
index ff44af36803770e3a2a0abd3dd9c7166ab19b13a..1b66ff066b3c07e2ae8eb8e6bb97b85267c79efb 100644 (file)
@@ -4260,6 +4260,9 @@ Attachments:
                <item name="wcf.moderation.report.reportedBy"><![CDATA[Reported by]]></item>
                <item name="wcf.moderation.report.reportedContent"><![CDATA[Reported Content]]></item>
                <item name="wcf.moderation.report.success"><![CDATA[The content has been reported.]]></item>
+               <item name="wcf.moderation.report.changeJustifiedStatus"><![CDATA[Change “Justified” status]]></item>
+               <item name="wcf.moderation.report.changeJustifiedStatus.markAsJustified"><![CDATA[Mark report as “Justified”]]></item>
+               <item name="wcf.moderation.report.changeJustifiedStatus.confirmMessage"><![CDATA[Do you really want to change the “Justified” status of this report?]]></item>
        </category>
        <category name="wcf.notice">
                <item name="wcf.notice.button.dismiss"><![CDATA[Permanently dismiss this notice]]></item>