Support undeletable ModerationQueue items
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 17 Apr 2014 14:57:27 +0000 (16:57 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Sun, 20 Apr 2014 13:59:42 +0000 (15:59 +0200)
com.woltlab.wcf/templates/moderationActivation.tpl
com.woltlab.wcf/templates/moderationReport.tpl
com.woltlab.wcf/templates/moderationUser.tpl
wcfsetup/install/files/lib/form/ModerationActivationForm.class.php
wcfsetup/install/files/lib/form/ModerationReportForm.class.php
wcfsetup/install/files/lib/system/moderation/queue/AbstractModerationQueueHandler.class.php
wcfsetup/install/files/lib/system/moderation/queue/AbstractModerationQueueManager.class.php
wcfsetup/install/files/lib/system/moderation/queue/IModerationQueueHandler.class.php
wcfsetup/install/files/lib/system/moderation/queue/IModerationQueueManager.class.php
wcfsetup/install/files/lib/system/moderation/queue/report/UserModerationQueueReportHandler.class.php

index 95811ab723410b12deca54153e75fbe729e37832..0f5cd3a4881d99c6e2cf8ae8c7c5467466d60161 100644 (file)
        <nav>
                <ul>
                        {if !$queue->isDone()}
-                               <li class="jsOnly"><a id="enableContent" class="button"><span class="icon icon16 icon-check"></span> <span>{lang}wcf.moderation.activation.enableContent{/lang}</span></a></li>
+                               {if $queueManager->canRemoveContent($queue->getDecoratedObject())}<li class="jsOnly"><a id="enableContent" class="button"><span class="icon icon16 icon-check"></span> <span>{lang}wcf.moderation.activation.enableContent{/lang}</span></a></li>{/if}
                                <li class="jsOnly"><a id="removeContent" class="button"><span class="icon icon16 icon-remove"></span> <span>{lang}wcf.moderation.activation.removeContent{/lang}</span></a></li>
                        {/if}
                        <li><a href="{link controller='ModerationList'}{/link}" class="button"><span class="icon icon16 icon-list"></span> <span>{lang}wcf.moderation.moderation{/lang}</span></a></li>
index fb2166d4a319935cdac7275f0b905c19787f9c3f..96c34227e7a2938117cbcf21e635c85319bd50da 100644 (file)
        <nav>
                <ul>
                        {if !$queue->isDone()}
-                               <li class="jsOnly"><a id="removeContent" class="button"><span class="icon icon16 icon-remove"></span> <span>{lang}wcf.moderation.report.removeContent{/lang}</span></a></li>
+                               {if $queueManager->canRemoveContent($queue->getDecoratedObject())}<li class="jsOnly"><a id="removeContent" class="button"><span class="icon icon16 icon-remove"></span> <span>{lang}wcf.moderation.report.removeContent{/lang}</span></a></li>{/if}
                                <li class="jsOnly"><a id="removeReport" class="button"><span class="icon icon16 icon-remove"></span> <span>{lang}wcf.moderation.report.removeReport{/lang}</span></a></li>
                        {/if}
                        <li><a href="{link controller='ModerationList'}{/link}" class="button"><span class="icon icon16 icon-list"></span> <span>{lang}wcf.moderation.moderation{/lang}</span></a></li>
index 552bafa59fe234587179134a6b6119b96337c91a..1695d1cc78aa379b296cfeff1fe0c64196d31f6c 100644 (file)
@@ -3,11 +3,3 @@
                {include file='userListItem'}
        </ol>
 </div>
-
-<script data-relocate="true">
-       //<![CDATA[
-       $(function() {
-               $('#removeContent').hide();
-       });
-       //]]>
-</script>
index 142e4fe3fc72915108a03b4559dcf785acc488c2..c292be8d0d42ba2d3c9b8810da823d6ee661743f 100644 (file)
@@ -21,7 +21,8 @@ class ModerationActivationForm extends AbstractModerationForm {
                parent::assignVariables();
                
                WCF::getTPL()->assign(array(
-                       'disabledContent' => ModerationQueueActivationManager::getInstance()->getDisabledContent($this->queue)
+                       'disabledContent' => ModerationQueueActivationManager::getInstance()->getDisabledContent($this->queue),
+                       'queueManager' => ModerationQueueActivationManager::getInstance()
                ));
        }
 }
index 0b58a5b36a2318811bb6aa9ba537bc14348bc297..d86a864a519cf3d088cf47da9761913f0c17eedf 100644 (file)
@@ -21,7 +21,8 @@ class ModerationReportForm extends AbstractModerationForm {
                parent::assignVariables();
                
                WCF::getTPL()->assign(array(
-                       'reportedContent' => ModerationQueueReportManager::getInstance()->getReportedContent($this->queue)
+                       'reportedContent' => ModerationQueueReportManager::getInstance()->getReportedContent($this->queue),
+                       'queueManager' => ModerationQueueReportManager::getInstance()
                ));
        }
 }
index 80d31f8f19928a3a009717feaf7ff534d059a0e4..bdfca1e4749a2b163e28b07d3b8c250a9ae39b12 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\system\moderation\queue;
+use wcf\data\moderation\queue\ModerationQueue;
 use wcf\data\moderation\queue\ModerationQueueAction;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\exception\SystemException;
@@ -89,4 +90,11 @@ abstract class AbstractModerationQueueHandler implements IModerationQueueHandler
                        $queueAction->executeAction();
                }
        }
+       
+       /**
+        * @see \wcf\system\moderation\queue\IModerationQueueHandler::canRemoveContent()
+        */
+       public function canRemoveContent(ModerationQueue $queue) {
+               return true;
+       }
 }
index c17fee2d367f817d7bd98be4101b6554dfd3e942..cce6b922d0253bb2242795a4424ef309e818b907 100644 (file)
@@ -58,6 +58,13 @@ abstract class AbstractModerationQueueManager extends SingletonFactory implement
                ModerationQueueManager::getInstance()->getProcessor($this->definitionName, null, $objectTypeID)->populate($objects);
        }
        
+       /**
+        * @see \wcf\system\moderation\queue\IModerationQueueManager::canRemoveContent()
+        */
+       public function canRemoveContent(ModerationQueue $queue) {
+               return $this->getProcessor(null, $queue->objectTypeID)->canRemoveContent($queue);
+       }
+       
        /**
         * @see \wcf\system\moderation\queue\IModerationQueueManager::removeContent()
         */
index d553026ac0263edb458491d6787303d0998e538a..be46dd725fb1fae498b071702dc50c75bf598a09 100644 (file)
@@ -60,6 +60,13 @@ interface IModerationQueueHandler {
         */
        public function removeContent(ModerationQueue $queue, $message);
        
+       /**
+        * Returns true if the affected content may be removed.
+        * 
+        * @return      boolean
+        */
+       public function canRemoveContent(ModerationQueue $queue);
+       
        /**
         * Removes queses from database, should only be called if the referenced
         * object is permanently deleted.
index 7000a31d648093299d0f68fe84358effb40a0f32..aa484d29d7e2b67c316214afa132bd56d37578c3 100644 (file)
@@ -63,6 +63,14 @@ interface IModerationQueueManager {
         */
        public function populate($objectTypeID, array $objects);
        
+       /**
+        * Returns whether the afftected content may be removed.
+        * 
+        * @param       \wcf\data\moderation\queue\ModerationQueue      $queue
+        * @return      boolean
+        */
+       public function canRemoveContent(ModerationQueue $queue);
+       
        /**
         * Removes affected content. It is up to the processing object to use a
         * soft-delete or remove the content permanently.
index 3960385c0fbd737e783f9a23bd838c9620ac0e81..add3c2ce0781385c3bc15ba840ad1e95b95e083c 100644 (file)
@@ -152,6 +152,13 @@ class UserModerationQueueReportHandler extends AbstractModerationQueueHandler im
                }
        }
        
+       /**
+        * @see \wcf\system\moderation\queue\IModerationQueueHandler::canRemoveContent()
+        */
+       public function canRemoveContent(ModerationQueue $queue) {
+               return false;
+       }
+       
        /**
         * @see \wcf\system\moderation\queue\IModerationQueueHandler::removeContent()
         */