Moderation queue management overhaul
authorAlexander Ebert <ebert@woltlab.com>
Wed, 13 Aug 2014 13:52:55 +0000 (15:52 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 13 Aug 2014 13:52:55 +0000 (15:52 +0200)
12 files changed:
com.woltlab.wcf/templates/moderationActivation.tpl
com.woltlab.wcf/templates/moderationQueueAssignUser.tpl [new file with mode: 0644]
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/ModerationQueueAction.class.php
wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueActivationAction.class.php
wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueEditor.class.php
wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueReportAction.class.php
wcfsetup/install/files/lib/form/AbstractModerationForm.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index baf7b2d074d8a307b8015458217e27688ab84882..0ad592644f94c547bf427748ad5fdd8288bfdb69 100644 (file)
                        
                        WCF.Language.addObject({
                                'wcf.moderation.activation.enableContent.confirmMessage': '{lang}wcf.moderation.activation.enableContent.confirmMessage{/lang}',
-                               'wcf.moderation.activation.removeContent.confirmMessage': '{lang}wcf.moderation.activation.removeContent.confirmMessage{/lang}'
+                               'wcf.moderation.activation.removeContent.confirmMessage': '{lang}wcf.moderation.activation.removeContent.confirmMessage{/lang}',
+                               'wcf.moderation.assignedUser': '{lang}wcf.moderation.assignedUser{/lang}',
+                               'wcf.moderation.assignedUser.change': '{lang}wcf.moderation.assignedUser.change{/lang}',
+                               'wcf.moderation.assignedUser.error.notAffected': '{lang}wcf.moderation.assignedUser.error.notAffected{/lang}',
+                               'wcf.moderation.status.outstanding': '{lang}wcf.moderation.status.outstanding{/lang}',
+                               'wcf.moderation.status.processing': '{lang}wcf.moderation.status.processing{/lang}'
                        });
                });
                //]]>
 
 <body id="tpl{$templateName|ucfirst}">
 
-{capture assign='sidebar'}
-       <form method="post" action="{link controller='ModerationActivation' id=$queue->queueID}{/link}">
-               <fieldset>
-                       <legend>{lang}wcf.moderation.report.details{/lang}</legend>
-                       
-                       <dl>
-                               <dt>{lang}wcf.moderation.assignedUser{/lang}</dt>
-                               <dd>
-                                       <ul>
-                                               {if $assignedUserID && ($assignedUserID != $__wcf->getUser()->userID)}
-                                                       <li><label><input type="radio" name="assignedUserID" value="{@$assignedUserID}" checked="checked" /> {$queue->assignedUsername}</label></li>
-                                               {/if}
-                                               <li><label><input type="radio" name="assignedUserID" value="{@$__wcf->getUser()->userID}"{if $assignedUserID == $__wcf->getUser()->userID} checked="checked"{/if} /> {$__wcf->getUser()->username}</label></li>
-                                               <li><label><input type="radio" name="assignedUserID" value="0"{if !$assignedUserID} checked="checked"{/if} /> {lang}wcf.moderation.assignedUser.nobody{/lang}</label></li>
-                                       </ul>
-                               </dd>
-                       </dl>
-                       {if $queue->assignedUser}
-                               <dl>
-                                       <dt></dt>
-                                       <dd><a href="{link controller='User' id=$assignedUserID}{/link}" class="userLink" data-user-id="{@$assignedUserID}">{$queue->assignedUsername}</a></dd>
-                               </dl>
-                       {/if}
-                       
-                       {event name='detailsFields'}
-                       
-                       <div class="formSubmit">
-                               <input type="submit" value="{lang}wcf.global.button.submit{/lang}" />
-                               {@SECURITY_TOKEN_INPUT_TAG}
-                       </div>
-               </fieldset>
-               
-               {event name='fieldsets'}
-       </form>
-       
-       {event name='boxes'}
-{/capture}
-
-{include file='header' sidebarOrientation='right'}
+{include file='header'}
 
 <header class="boxHeadline">
        <h1>{lang}wcf.moderation.activation{/lang}: {$queue->getTitle()}</h1>
                        <dd>{@$queue->lastChangeTime|time}</dd>
                </dl>
        {/if}
+       
+       <dl class="plain inlineDataList" id="moderationAssignedUserContainer">
+               <dt>{lang}wcf.moderation.assignedUser{/lang}</dt>
+               <dd>
+                       <span>
+                               {if $queue->assignedUserID}
+                                       <a href="{link controller='User' id=$assignedUserID}{/link}" class="userLink" data-user-id="{@$assignedUserID}">{$queue->assignedUsername}</a>
+                               {else}
+                                       {lang}wcf.moderation.assignedUser.nobody{/lang}
+                               {/if}
+                       </span>
+               </dd>
+       </dl>
+       
+       <dl class="plain inlineDataList" id="moderationStatusContainer">
+               <dt>{lang}wcf.moderation.status{/lang}</dt>
+               <dd>{$queue->getStatus()}</dd>
+       </dl>
 </header>
 
 {include file='userNotice'}
diff --git a/com.woltlab.wcf/templates/moderationQueueAssignUser.tpl b/com.woltlab.wcf/templates/moderationQueueAssignUser.tpl
new file mode 100644 (file)
index 0000000..b42e51a
--- /dev/null
@@ -0,0 +1,42 @@
+<fieldset>
+       <dl>
+               <dt>{lang}wcf.moderation.assignedUser{/lang}</dt>
+               <dd>
+                       <ul>
+                               {if $assignedUser && $assignedUser->userID != $__wcf->getUser()->userID}
+                                       <li><label><input type="radio" name="assignedUserID" value="{@$assignedUser->userID}" checked="checked" /> {$assignedUser->username}</label></li>
+                               {/if}
+                               <li><label><input type="radio" name="assignedUserID" value="{@$__wcf->getUser()->userID}"{if $assignedUser && $assignedUser->userID == $__wcf->getUser()->userID} checked="checked"{/if} /> {$__wcf->getUser()->username}</label></li>
+                               <li><label><input type="radio" name="assignedUserID" value="0"{if !$assignedUser} checked="checked"{/if} /> {lang}wcf.moderation.assignedUser.nobody{/lang}</label></li>
+                               <li>
+                                       <label><input type="radio" name="assignedUserID" value="-1"{if !$assignedUser} checked="checked"{/if} />
+                                               <input type="text" id="assignedUsername" name="assignedUsername" value="{if $assignedUser}{$assignedUser->username}{/if}" />
+                                               {*if $errorField == 'assignedUsername'}
+                                                       <small class="innerError">
+                                                               {if $errorType == 'empty'}
+                                                                       {lang}wcf.global.form.error.empty{/lang}
+                                                               {elseif $errorType == 'notAffected'}
+                                                                       {lang}wcf.moderation.assignedUser.error.{@$errorType}{/lang}
+                                                               {else}
+                                                                       {lang username=$assignedUsername}wcf.user.username.error.{@$errorType}{/lang}
+                                                               {/if}
+                                                       </small>
+                                               {/if*}
+                                       </label>
+                               </li>
+                       </ul>
+               </dd>
+       </dl>
+       
+       <div class="formSubmit">
+               <button data-type="submit">{lang}wcf.global.button.submit{/lang}</button>
+       </div>
+</fieldset>
+<script>
+       $(function() {
+               new WCF.Search.User('#assignedUsername');
+               $('#assignedUsername').click(function() {
+                       $(this).parents('li').find('input[type=radio]').click();
+               });
+       });
+</script>
index a48f5434308a5c66dab9ccd27424eac3ebd7f6ab..b5da14e9a4c224356b7e64e4eed9780dbcff6fa9 100644 (file)
@@ -9,17 +9,17 @@
                //<![CDATA[
                $(function() {
                        WCF.Language.addObject({
+                               'wcf.moderation.assignedUser': '{lang}wcf.moderation.assignedUser{/lang}',
+                               'wcf.moderation.assignedUser.change': '{lang}wcf.moderation.assignedUser.change{/lang}',
+                               'wcf.moderation.assignedUser.error.notAffected': '{lang}wcf.moderation.assignedUser.error.notAffected{/lang}',
                                'wcf.moderation.report.removeContent.confirmMessage': '{lang}wcf.moderation.report.removeContent.confirmMessage{/lang}',
                                'wcf.moderation.report.removeContent.reason': '{lang}wcf.moderation.report.removeContent.reason{/lang}',
-                               'wcf.moderation.report.removeReport.confirmMessage': '{lang}wcf.moderation.report.removeReport.confirmMessage{/lang}'
+                               'wcf.moderation.report.removeReport.confirmMessage': '{lang}wcf.moderation.report.removeReport.confirmMessage{/lang}',
+                               'wcf.moderation.status.outstanding': '{lang}wcf.moderation.status.outstanding{/lang}',
+                               'wcf.moderation.status.processing': '{lang}wcf.moderation.status.processing{/lang}'
                        });
                        
                        new WCF.Moderation.Report.Management({@$queue->queueID}, '{link controller='ModerationList'}{/link}');
-                       
-                       new WCF.Search.User('#assignedUsername');
-                       $('#assignedUsername').click(function() {
-                               $(this).parents('li').find('input[type=radio]').click();
-                       });
                });
                //]]>
        </script>
 
 <body id="tpl{$templateName|ucfirst}">
 
-{capture assign='sidebar'}
-       <form method="post" action="{link controller='ModerationReport' id=$queue->queueID}{/link}">
-               <fieldset>
-                       <legend>{lang}wcf.moderation.report.details{/lang}</legend>
-                       
-                       <dl>
-                               <dt>{lang}wcf.moderation.assignedUser{/lang}</dt>
-                               <dd>
-                                       <ul>
-                                               {if $assignedUserID && $assignedUserID != -1 && $assignedUserID != $__wcf->getUser()->userID}
-                                                       <li><label><input type="radio" name="assignedUserID" value="{@$assignedUserID}" checked="checked" /> {$queue->assignedUsername}</label></li>
-                                               {/if}
-                                               <li><label><input type="radio" name="assignedUserID" value="{@$__wcf->getUser()->userID}"{if $assignedUserID == $__wcf->getUser()->userID} checked="checked"{/if} /> {$__wcf->getUser()->username}</label></li>
-                                               <li><label><input type="radio" name="assignedUserID" value="0"{if !$assignedUserID} checked="checked"{/if} /> {lang}wcf.moderation.assignedUser.nobody{/lang}</label></li>
-                                               <li>
-                                                       <label><input type="radio" name="assignedUserID" value="-1"{if $assignedUserID == -1} checked="checked"{/if} />
-                                                               <input type="text" id="assignedUsername" name="assignedUsername" value="{$assignedUsername}" />
-                                                               {if $errorField == 'assignedUsername'}
-                                                                       <small class="innerError">
-                                                                               {if $errorType == 'empty'}
-                                                                                       {lang}wcf.global.form.error.empty{/lang}
-                                                                               {elseif $errorType == 'notAffected'}
-                                                                                       {lang}wcf.moderation.assignedUser.error.{@$errorType}{/lang}
-                                                                               {else}
-                                                                                       {lang username=$assignedUsername}wcf.user.username.error.{@$errorType}{/lang}
-                                                                               {/if}
-                                                                       </small>
-                                                               {/if}
-                                                       </label>
-                                               </li>
-                                       </ul>
-                               </dd>
-                       </dl>
-                       {if $queue->assignedUser}
-                               <dl>
-                                       <dt></dt>
-                                       <dd><a href="{link controller='User' id=$assignedUserID}{/link}" class="userLink" data-user-id="{@$assignedUserID}">{$queue->assignedUsername}</a></dd>
-                               </dl>
-                       {/if}
-                       
-                       {event name='detailsFields'}
-                       
-                       <div class="formSubmit">
-                               <input type="submit" value="{lang}wcf.global.button.submit{/lang}" />
-                               {@SECURITY_TOKEN_INPUT_TAG}
-                       </div>
-               </fieldset>
-               
-               {event name='fieldsets'}
-       </form>
-       
-       {event name='boxes'}
-{/capture}
-
-{include file='header' sidebarOrientation='right'}
+{include file='header'}
 
 <header class="boxHeadline">
        <h1>{lang}wcf.moderation.report{/lang}: {$queue->getTitle()}</h1>
                        <dd>{@$queue->lastChangeTime|time}</dd>
                </dl>
        {/if}
+       
+       <dl class="plain inlineDataList" id="moderationAssignedUserContainer">
+               <dt>{lang}wcf.moderation.assignedUser{/lang}</dt>
+               <dd>
+                       <span>
+                               {if $queue->assignedUserID}
+                                       <a href="{link controller='User' id=$assignedUserID}{/link}" class="userLink" data-user-id="{@$assignedUserID}">{$queue->assignedUsername}</a>
+                               {else}
+                                       {lang}wcf.moderation.assignedUser.nobody{/lang}
+                               {/if}
+                       </span>
+               </dd>
+       </dl>
+       
+       <dl class="plain inlineDataList" id="moderationStatusContainer">
+               <dt>{lang}wcf.moderation.status{/lang}</dt>
+               <dd>{$queue->getStatus()}</dd>
+       </dl>
 </header>
 
 {include file='userNotice'}
index 6e5208615d29014a8c2b4b9e26c9d9e12e31d9ff..a7e44355076e94a9b8f8d638f33534914cb216db 100644 (file)
@@ -32,6 +32,12 @@ WCF.Moderation.Management = Class.extend({
         */
        _confirmationTemplate: { },
        
+       /**
+        * dialog overlay
+        * @var jQuery
+        */
+       _dialog: null,
+       
        /**
         * language item pattern
         * @var string
@@ -73,15 +79,19 @@ WCF.Moderation.Management = Class.extend({
                        return;
                }
                
+               this._dialog = null;
                this._queueID = queueID;
                this._redirectURL = redirectURL;
                this._languageItem = languageItem;
                
                this._proxy = new WCF.Action.Proxy({
+                       failure: $.proxy(this._failure, this),
                        success: $.proxy(this._success, this)
                });
                
                $(this._buttonSelector).click($.proxy(this._click, this));
+               
+               $('<a>' + WCF.Language.get('wcf.moderation.assignedUser.change') + '</a>').click($.proxy(this._clickAssignedUser, this)).insertAfter($('#moderationAssignedUserContainer > dd > span'));
        },
        
        /**
@@ -128,6 +138,18 @@ WCF.Moderation.Management = Class.extend({
                }, this), { }, $innerTemplate);
        },
        
+       /**
+        * Handles clicks on the assign user link.
+        */
+       _clickAssignedUser: function() {
+               this._proxy.setOption('data', {
+                       actionName: 'getAssignUserForm',
+                       className: 'wcf\\data\\moderation\\queue\\ModerationQueueAction',
+                       objectIDs: [ this._queueID ]
+               });
+               this._proxy.sendRequest();
+       },
+       
        /**
         * Handles successful AJAX requests.
         * 
@@ -136,11 +158,112 @@ WCF.Moderation.Management = Class.extend({
         * @param       jQuery          jqXHR
         */
        _success: function(data, textStatus, jqXHR) {
-               var $notification = new WCF.System.Notification(WCF.Language.get('wcf.global.success'));
-               var self = this;
-               $notification.show(function() {
-                       window.location = self._redirectURL;
+               switch (data.actionName) {
+                       case 'getAssignUserForm':
+                               if (this._dialog === null) {
+                                       this._dialog = $('<div />').hide().appendTo(document.body);
+                                       this._dialog.html(data.returnValues.template).wcfDialog({
+                                               title: WCF.Language.get('wcf.moderation.assignedUser')
+                                       });
+                               }
+                               else {
+                                       this._dialog.html(data.returnValues.template).wcfDialog('open');
+                               }
+                               
+                               this._dialog.find('button[data-type=submit]').click($.proxy(this._assignUser, this));
+                       break;
+                       
+                       case 'assignUser':
+                               var $span = $('#moderationAssignedUserContainer > dd > span').empty();
+                               if (data.returnValues.userID) {
+                                       $('<a href="' + data.returnValues.link + '" data-user-id="' + data.returnValues.userID + '" class="userLink">' + WCF.String.escapeHTML(data.returnValues.username) + '</a>').appendTo($span);
+                               }
+                               else {
+                                       $span.append(data.returnValues.username)
+                               }
+                               
+                               $span.append(' ');
+                               
+                               if (data.returnValues.newStatus) {
+                                       $('#moderationStatusContainer > dd').text(WCF.Language.get('wcf.moderation.status.' + data.returnValues.newStatus));
+                               }
+                               
+                               this._dialog.wcfDialog('close');
+                               
+                               new WCF.System.Notification().show();
+                       break;
+                       
+                       default:
+                               var $notification = new WCF.System.Notification(WCF.Language.get('wcf.global.success'));
+                               var self = this;
+                               $notification.show(function() {
+                                       window.location = self._redirectURL;
+                               });
+                       break;
+               }
+       },
+       
+       /**
+        * Handles errorneus AJAX requests.
+        * 
+        * @param       object          data
+        * @param       jQuery          jqXHR
+        * @param       string          textStatus
+        * @param       string          errorThrown
+        */
+       _failure: function(data, jqXHR, textStatus, errorThrown) {
+               if (data.returnValues && data.returnValues.fieldName && data.returnValues.fieldName == 'assignedUsername') {
+                       this._dialog.find('small.innerError').remove();
+                       
+                       var $errorString = '';
+                       switch (data.returnValues.errorType) {
+                               case 'empty':
+                                       $errorString = WCF.Language.get('wcf.global.form.error.empty');
+                               break;
+                               
+                               case 'notAffected':
+                                       $errorString = WCF.Language.get('wcf.moderation.assignedUser.error.notAffected');
+                               break;
+                               
+                               default:
+                                       $errorString = WCF.Language.get('wcf.user.username.error.' + data.returnValues.errorType, { username: this._dialog.find('#assignedUsername').val() });
+                               break;
+                       }
+                       
+                       $('<small class="innerError">' + $errorString + '</small>').insertAfter(this._dialog.find('#assignedUsername'));
+                       
+                       return false;
+               }
+               
+               return true;
+       },
+       
+       /**
+        * Submits the assign user form.
+        */
+       _assignUser: function() {
+               var $assignedUserID = this._dialog.find('input[name=assignedUserID]:checked').val();
+               var $assignedUsername = '';
+               if ($assignedUserID == -1) {
+                       $assignedUsername = $.trim(this._dialog.find('#assignedUsername').val());
+               }
+               
+               if ($assignedUserID == -1 && $assignedUsername.length == 0) {
+                       this._dialog.find('small.innerError').remove();
+                       $('<small class="innerError">' + WCF.Language.get('wcf.global.form.error.empty') + '</small>').insertAfter(this._dialog.find('#assignedUsername'));
+                       return;
+               }
+               
+               this._proxy.setOption('data', {
+                       actionName: 'assignUser',
+                       className: 'wcf\\data\\moderation\\queue\\ModerationQueueAction',
+                       objectIDs: [ this._queueID ],
+                       parameters: {
+                               assignedUserID: $assignedUserID,
+                               assignedUsername: $assignedUsername
+                       }
                });
+               this._proxy.sendRequest();
        }
 });
 
index 5cf33df0b23b6095975d768ef9cc667e8c38f555..cda6d9e606e8a80829b748d33b33172a97dc4e00 100644 (file)
@@ -2,6 +2,7 @@
 namespace wcf\data\moderation\queue;
 use wcf\data\DatabaseObject;
 use wcf\system\WCF;
+use wcf\data\object\type\ObjectTypeCache;
 
 /**
  * Represents a moderation queue entry.
@@ -28,6 +29,8 @@ class ModerationQueue extends DatabaseObject {
        const STATUS_OUTSTANDING = 0;
        const STATUS_PROCESSING = 1;
        const STATUS_DONE = 2;
+       const STATUS_REJECTED = 3;
+       const STATUS_CONFIRMED = 4;
        
        /**
         * @see \wcf\data\IStorableObject::__get()
@@ -85,4 +88,35 @@ class ModerationQueue extends DatabaseObject {
        public function isDone() {
                return ($this->status == self::STATUS_DONE);
        }
+       
+       /**
+        * Returns status text.
+        * 
+        * @param       integer         $status
+        * @return      string
+        */
+       public function getStatus($status = null) {
+               $status = ($status === null) ? $this->status : $status;
+               switch ($status) {
+                       case self::STATUS_OUTSTANDING:
+                               return WCF::getLanguage()->get('wcf.moderation.status.outstanding');
+                       break;
+                       
+                       case self::STATUS_PROCESSING:
+                               return WCF::getLanguage()->get('wcf.moderation.status.processing');
+                       break;
+                       
+                       case self::STATUS_DONE:
+                               return WCF::getLanguage()->get('wcf.moderation.status.done');
+                       break;
+                       
+                       case self::STATUS_REJECTED:
+                       case self::STATUS_CONFIRMED:
+                               $objectType = ObjectTypeCache::getInstance()->getObjectType($this->objectTypeID);
+                               $definition = ObjectTypeCache::getInstance()->getDefinition($objectType->definitionID);
+                               
+                               return WCF::getLanguage()->get('wcf.moderation.status.' . ($status == self::STATUS_REJECTED ? 'rejected' : 'confirmed') . '.' . $definition->definitionName);
+                       break;
+               }
+       }
 }
index 15a2b8fd9a639e03ecd3cf64a116d681b63d0543..0379b03f8486389ef6a846d0185bff1067f697ba 100644 (file)
@@ -1,10 +1,16 @@
 <?php
 namespace wcf\data\moderation\queue;
+use wcf\data\object\type\ObjectTypeCache;
+use wcf\data\user\User;
 use wcf\data\AbstractDatabaseObjectAction;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\PermissionDeniedException;
+use wcf\system\exception\UserInputException;
 use wcf\system\moderation\queue\ModerationQueueManager;
 use wcf\system\user\storage\UserStorageHandler;
 use wcf\system\WCF;
+use wcf\system\request\LinkHandler;
+
 
 /**
  * Executes moderation queue-related actions.
@@ -22,6 +28,18 @@ class ModerationQueueAction extends AbstractDatabaseObjectAction {
         */
        protected $className = 'wcf\data\moderation\queue\ModerationQueueEditor';
        
+       /**
+        * moderation queue editor object
+        * @var \wcf\data\moderation\queue\ModerationQueueEditor
+        */
+       public $moderationQueueEditor = null;
+       
+       /**
+        * user object
+        * @var \wcf\data\user\User
+        */
+       public $user = null;
+       
        /**
         * @see \wcf\data\AbstractDatabaseObjectAction::create()
         */
@@ -115,4 +133,109 @@ class ModerationQueueAction extends AbstractDatabaseObjectAction {
                        'totalCount' => $totalCount
                );
        }
+       
+       /**
+        * Validates parameters to show the user assign form.
+        */
+       public function validateGetAssignUserForm() {
+               $this->moderationQueueEditor = $this->getSingleObject();
+               
+               // check if queue is accessible for current user
+               if (!$this->moderationQueueEditor->canEdit()) {
+                       throw new PermissionDeniedException();
+               }
+       }
+       
+       /**
+        * Returns the user assign form.
+        * 
+        * @return      array<string>
+        */
+       public function getAssignUserForm() {
+               $assignedUser = ($this->moderationQueueEditor->assignedUserID) ? new User($this->moderationQueueEditor->assignedUserID) : null;
+               
+               WCF::getTPL()->assign(array(
+                       'assignedUser' => $assignedUser,
+                       'queue' => $this->moderationQueueEditor
+               ));
+               
+               return array(
+                       'template' => WCF::getTPL()->fetch('moderationQueueAssignUser')
+               );
+       }
+       
+       /**
+        * Validates parameters to assign a user.
+        */
+       public function validateAssignUser() {
+               $this->moderationQueueEditor = $this->getSingleObject();
+               $this->readInteger('assignedUserID', true);
+               
+               if ($this->parameters['assignedUserID'] && $this->parameters['assignedUserID'] != -1) {
+                       if ($this->parameters['assignedUserID'] != WCF::getUser()->userID && $this->parameters['assignedUserID'] != $this->moderationQueueEditor->assignedUserID) {
+                               // user id is either faked or changed during viewing, use database value instead
+                               $this->parameters['assignedUserID'] = $this->moderationQueueEditor->assignedUserID;
+                       }
+               }
+               
+               if ($this->parameters['assignedUserID'] == -1) {
+                       $this->readString('assignedUsername');
+                               
+                       $this->user = User::getUserByUsername($this->parameters['assignedUsername']);
+                       if (!$this->user->userID) {
+                               throw new UserInputException('assignedUsername', 'notFound');
+                       }
+                               
+                       // get handler
+                       $objectType = ObjectTypeCache::getInstance()->getObjectType($this->moderationQueueEditor->objectTypeID);
+                       if (!$objectType->getProcessor()->isAffectedUser($this->moderationQueueEditor->getDecoratedObject(), $this->user->userID)) {
+                               throw new UserInputException('assignedUsername', 'notAffected');
+                       }
+                       
+                       $this->parameters['assignedUserID'] = $this->user->userID;
+                       $this->parameters['assignedUsername'] = '';
+               }
+               else {
+                       $this->user = new User($this->parameters['assignedUserID']);
+               }
+       }
+       
+       /**
+        * Returns the data for the newly assigned user.
+        * 
+        * @return      array<string>
+        */
+       public function assignUser() {
+               $data = array('assignedUserID' => ($this->parameters['assignedUserID'] ?: null));
+               if ($this->user->userID) {
+                       if ($this->moderationQueueEditor->status == ModerationQueue::STATUS_OUTSTANDING) {
+                               $data['status'] = ModerationQueue::STATUS_PROCESSING;
+                       }
+               }
+               else {
+                       if ($this->moderationQueueEditor->status == ModerationQueue::STATUS_PROCESSING) {
+                               $data['status'] = ModerationQueue::STATUS_OUTSTANDING;
+                       }
+               }
+               
+               $this->moderationQueueEditor->update($data);
+               
+               $username = ($this->user->userID) ? $this->user->username : WCF::getLanguage()->get('wcf.moderation.assignedUser.nobody');
+               $link = '';
+               if ($this->user->userID) {
+                       $link = LinkHandler::getInstance()->getLink('User', array('object' => $this->user));
+               }
+               
+               $newStatus = '';
+               if (isset($data['status'])) {
+                       $newStatus = ($data['status'] == ModerationQueue::STATUS_OUTSTANDING) ? 'outstanding' : 'processing';
+               }
+               
+               return array(
+                       'link' => $link,
+                       'newStatus' => $newStatus,
+                       'userID' => $this->user->userID,
+                       'username' => $username
+               );
+       }
 }
index 7596fd1560d45324e13b8144cd2e601f9e43e6c2..5f4331b82a07f495862368f64084ba0cdf88fa31 100644 (file)
@@ -42,7 +42,7 @@ class ModerationQueueActivationAction extends ModerationQueueAction {
                // enable content
                ModerationQueueActivationManager::getInstance()->enableContent($this->queue->getDecoratedObject());
                
-               $this->queue->markAsDone();
+               $this->queue->markAsConfirmed();
        }
        
        /**
@@ -60,6 +60,6 @@ class ModerationQueueActivationAction extends ModerationQueueAction {
                // mark content as deleted
                ModerationQueueActivationManager::getInstance()->removeContent($this->queue->getDecoratedObject(), $this->parameters['message']);
                
-               $this->queue->markAsDone();
+               $this->queue->markAsRejected();
        }
 }
index b9f5a3a460aa2553e9e99fe8ace8e643a12fdebb..ade397428e4e469a5c98692cf3adb500903e2f44 100644 (file)
@@ -21,6 +21,8 @@ class ModerationQueueEditor extends DatabaseObjectEditor {
        
        /**
         * Marks this entry as done.
+        * 
+        * @deprecated  2.1 - Please use markAsConfirmed() or markAsRejected()
         */
        public function markAsDone() {
                $this->update(array('status' => ModerationQueue::STATUS_DONE));
@@ -29,6 +31,27 @@ class ModerationQueueEditor extends DatabaseObjectEditor {
                ModerationQueueManager::getInstance()->resetModerationCount();
        }
        
+       /**
+        * Marks this entry as confirmed, e.g. report was justified and content was deleted or
+        * content was approved.
+        */
+       public function markAsConfirmed() {
+               $this->update(array('status' => ModerationQueue::STATUS_CONFIRMED));
+               
+               // reset moderation count
+               ModerationQueueManager::getInstance()->resetModerationCount();
+       }
+       
+       /**
+        * Marks this entry as rejected, e.g. report was unjustified or content approval was denied.
+        */
+       public function markAsRejected() {
+               $this->update(array('status' => ModerationQueue::STATUS_REJECTED));
+               
+               // reset moderation count
+               ModerationQueueManager::getInstance()->resetModerationCount();
+       }
+       
        /**
         * Marks this entry as in progress.
         */
index 4a6168bb16cc78fe39973e3815b5a9681267a560..96d637abe7914a2472513e50359e4d8258a086c0 100644 (file)
@@ -44,7 +44,7 @@ class ModerationQueueReportAction extends ModerationQueueAction {
                // mark content as deleted
                ModerationQueueReportManager::getInstance()->removeContent($this->queue->getDecoratedObject(), $this->parameters['message']);
                
-               $this->queue->markAsDone();
+               $this->queue->markAsConfirmed();
        }
        
        /**
@@ -61,7 +61,7 @@ class ModerationQueueReportAction extends ModerationQueueAction {
         * Removes this report by marking it as done without further processing.
         */
        public function removeReport() {
-               $this->queue->markAsDone();
+               $this->queue->markAsRejected();
        }
        
        /**
index dfde2b447843249f3c01a74ab0caacce537dde65..620304ab7e1ca6dc50b4be0904855b9ec2c2f813 100644 (file)
@@ -27,18 +27,6 @@ use wcf\util\StringUtil;
  * @category   Community Framework
  */
 abstract class AbstractModerationForm extends AbstractForm {
-       /**
-        * assigned user id
-        * @var integer
-        */
-       public $assignedUserID = 0;
-       
-       /**
-        * assigned user's name
-        * @var string
-        */
-       public $assignedUsername = '';
-       
        /**
         * data used for moderation queue update
         * @var array
@@ -102,53 +90,6 @@ abstract class AbstractModerationForm extends AbstractForm {
                }
        }
        
-       /**
-        * @see \wcf\form\IForm::readFormParameters()
-        */
-       public function readFormParameters() {
-               parent::readFormParameters();
-               
-               if (isset($_POST['assignedUsername'])) $this->assignedUsername = StringUtil::trim($_POST['assignedUsername']);
-               
-               // verify assigned user id
-               if (isset($_POST['assignedUserID'])) {
-                       $this->assignedUserID = intval($_POST['assignedUserID']);
-                       if ($this->assignedUserID && $this->assignedUserID != -1) {
-                               if ($this->assignedUserID != WCF::getUser()->userID && $this->assignedUserID != $this->queue->assignedUserID) {
-                                       // user id is either faked or changed during viewing, use database value instead
-                                       $this->assignedUserID = $this->queue->assignedUserID;
-                               }
-                       }
-               }
-       }
-       
-       /**
-        * @see \wcf\form\IForm::validate()
-        */
-       public function validate() {
-               parent::validate();
-               
-               if ($this->assignedUserID == -1) {
-                       if (empty($this->assignedUsername)) {
-                               throw new UserInputException('assignedUsername');
-                       }
-                       
-                       $assignedUser = User::getUserByUsername($this->assignedUsername);
-                       if (!$assignedUser->userID) {
-                               throw new UserInputException('assignedUsername', 'notFound');
-                       }
-                       
-                       // get handler
-                       $objectType = ObjectTypeCache::getInstance()->getObjectType($this->queue->objectTypeID);
-                       if (!$objectType->getProcessor()->isAffectedUser($this->queue->getDecoratedObject(), $assignedUser->userID)) {
-                               throw new UserInputException('assignedUsername', 'notAffected');
-                       }
-                       
-                       $this->assignedUserID = $assignedUser->userID;
-                       $this->assignedUsername = '';
-               }
-       }
-       
        /**
         * @see \wcf\page\IPage::readData()
         */
@@ -184,48 +125,10 @@ abstract class AbstractModerationForm extends AbstractForm {
                        'commentObjectTypeID' => $this->commentObjectTypeID,
                        'lastCommentTime' => ($this->commentList ? $this->commentList->getMinCommentTime() : 0),
                        'sidebarCollapsed' => UserCollapsibleContentHandler::getInstance()->isCollapsed('com.woltlab.wcf.collapsibleSidebar', 'com.woltlab.wcf.ModerationForm'),
-                       'sidebarName' => 'com.woltlab.wcf.ModerationForm',
-                       'assignedUsername' => $this->assignedUsername
+                       'sidebarName' => 'com.woltlab.wcf.ModerationForm'
                ));
        }
        
-       /**
-        * @see \wcf\form\IForm::save()
-        */
-       public function save() {
-               parent::save();
-               
-               $this->data = array(
-                       'assignedUserID' => ($this->assignedUserID ?: null),
-               );
-               if ($this->queue->status != ModerationQueue::STATUS_DONE) {
-                       if ($this->assignedUserID) {
-                               // queue item is being processed
-                               if ($this->assignedUserID != $this->queue->assignedUserID) {
-                                       $this->data['status'] = ModerationQueue::STATUS_PROCESSING;
-                               }
-                       }
-                       else {
-                               // queue is no longer processed, mark as outstanding
-                               if ($this->queue->assignedUserID) {
-                                       $this->data['status'] = ModerationQueue::STATUS_OUTSTANDING;
-                               }
-                       }
-               }
-               
-               $this->prepareSave();
-               $this->objectAction = new ModerationQueueAction(array($this->queue->getDecoratedObject()), 'update', array('data' => $this->data));
-               $this->objectAction->executeAction();
-               
-               // call saved event
-               $this->saved();
-               
-               // reload queue to update assignment
-               if ($this->assignedUserID != $this->queue->assignedUserID) {
-                       $this->queue = ViewableModerationQueue::getViewableModerationQueue($this->queue->queueID);
-               }
-       }
-       
        /**
         * Prepares update of moderation queue item.
         */
index 236164f03312f061383d6b1010f544eb33749df9..d02ef42d5b523cef382351d21f72f1794e01ae57 100644 (file)
@@ -2204,6 +2204,8 @@ Fehler sind beispielsweise:
        
        <category name="wcf.moderation">
                <item name="wcf.moderation.assignedUser"><![CDATA[Zugewiesener Benutzer]]></item>
+               <item name="wcf.moderation.assignedUser.change"><![CDATA[(Ändern)]]></item>
+               <item name="wcf.moderation.assignedUser.error.notAffected"><![CDATA[Dieser Benutzer hat unzureichende Zugriffsrechte]]></item>
                <item name="wcf.moderation.assignedUser.nobody"><![CDATA[Niemand]]></item>
                <item name="wcf.moderation.filterByType"><![CDATA[Typ]]></item>
                <item name="wcf.moderation.filterByUser"><![CDATA[Zugewiesener Benutzer]]></item>
@@ -2217,7 +2219,12 @@ Fehler sind beispielsweise:
                <item name="wcf.moderation.noMoreItems"><![CDATA[Keine weiteren Einträge]]></item>
                <item name="wcf.moderation.status"><![CDATA[Status]]></item>
                <item name="wcf.moderation.status.outstanding"><![CDATA[Ausstehend]]></item>
+               <item name="wcf.moderation.status.processing"><![CDATA[In Bearbeitung]]></item>
                <item name="wcf.moderation.status.done"><![CDATA[Erledigt]]></item>
+               <item name="wcf.moderation.status.confirmed.com.woltlab.wcf.moderation.activation"><![CDATA[Inhalt wurde freigeschaltet]]></item>
+               <item name="wcf.moderation.status.confirmed.com.woltlab.wcf.moderation.report"><![CDATA[Meldung berechtigt, Inhalt wurde gelöscht]]></item>
+               <item name="wcf.moderation.status.rejected.com.woltlab.wcf.moderation.activation"><![CDATA[Freischaltung wurde abgelehnt]]></item>
+               <item name="wcf.moderation.status.rejected.com.woltlab.wcf.moderation.report"><![CDATA[Meldung unberechtigt]]></item>
                <item name="wcf.moderation.time"><![CDATA[Datum]]></item>
                <item name="wcf.moderation.title"><![CDATA[Titel]]></item>
                <item name="wcf.moderation.type"><![CDATA[Typ]]></item>
index 38e8f87d79a6cdbcc89bceea4ec199b0a0862122..4ac1e6b3bb792c8d25baa8322125e86e421f7da9 100644 (file)
@@ -2171,6 +2171,8 @@ Errors are:
        
        <category name="wcf.moderation">
                <item name="wcf.moderation.assignedUser"><![CDATA[Assigned User]]></item>
+               <item name="wcf.moderation.assignedUser.change"><![CDATA[(Change)]]></item>
+               <item name="wcf.moderation.assignedUser.error.notAffected"><![CDATA[This user does not have sufficient privileges]]></item>
                <item name="wcf.moderation.assignedUser.nobody"><![CDATA[Nobody]]></item>
                <item name="wcf.moderation.filterByType"><![CDATA[Type]]></item>
                <item name="wcf.moderation.filterByUser"><![CDATA[Assigned User]]></item>
@@ -2184,7 +2186,12 @@ Errors are:
                <item name="wcf.moderation.noMoreItems"><![CDATA[No more items]]></item>
                <item name="wcf.moderation.status"><![CDATA[Status]]></item>
                <item name="wcf.moderation.status.outstanding"><![CDATA[Pending]]></item>
+               <item name="wcf.moderation.status.processing"><![CDATA[In Progress]]></item>
                <item name="wcf.moderation.status.done"><![CDATA[Done]]></item>
+               <item name="wcf.moderation.status.confirmed.com.woltlab.wcf.moderation.activation"><![CDATA[Content has been approved]]></item>
+               <item name="wcf.moderation.status.confirmed.com.woltlab.wcf.moderation.report"><![CDATA[Report was justified, content has been deleted]]></item>
+               <item name="wcf.moderation.status.rejected.com.woltlab.wcf.moderation.activation"><![CDATA[Approval was denied]]></item>
+               <item name="wcf.moderation.status.rejected.com.woltlab.wcf.moderation.report"><![CDATA[Report was unjustified]]></item>
                <item name="wcf.moderation.time"><![CDATA[Time]]></item>
                <item name="wcf.moderation.title"><![CDATA[Title]]></item>
                <item name="wcf.moderation.type"><![CDATA[Type]]></item>