protected function doModerate(PostRevision $post)
 {
     if ($this->submitted['moderationState'] === AbstractRevision::MODERATED_LOCKED && $post->isModerated()) {
         $this->addError('moderate', $this->context->msg('flow-error-lock-moderated-post'));
         return;
     }
     // Moderation state supplied in request parameters
     $moderationState = isset($this->submitted['moderationState']) ? $this->submitted['moderationState'] : null;
     // $moderationState should be a string like 'restore', 'suppress', etc.  The exact strings allowed
     // are checked below with $post->isValidModerationState(), but this is checked first otherwise
     // a blank string would restore a post(due to AbstractRevision::MODERATED_NONE === '').
     if (!$moderationState) {
         $this->addError('moderate', $this->context->msg('flow-error-invalid-moderation-state'));
         return;
     }
     /*
      * BC: 'suppress' used to be called 'censor', 'lock' was 'close' &
      * 'unlock' was 'reopen'
      */
     $bc = array('censor' => AbstractRevision::MODERATED_SUPPRESSED, 'close' => AbstractRevision::MODERATED_LOCKED, 'reopen' => 'un' . AbstractRevision::MODERATED_LOCKED);
     $moderationState = str_replace(array_keys($bc), array_values($bc), $moderationState);
     // these all just mean set to no moderation, it returns a post to unmoderated status
     $allowedRestoreAliases = array('unlock', 'unhide', 'undelete', 'unsuppress', 'reopen');
     if (in_array($moderationState, $allowedRestoreAliases)) {
         $moderationState = 'restore';
     }
     // By allowing the moderationState to be sourced from $this->submitted['moderationState']
     // we no longer have a unique action name for use with the permissions system.  This rebuilds
     // an action name. e.x. restore-post, restore-topic, suppress-topic, etc.
     $action = $moderationState . ($post->isTopicTitle() ? "-topic" : "-post");
     if ($moderationState === 'restore') {
         $newState = AbstractRevision::MODERATED_NONE;
     } else {
         $newState = $moderationState;
     }
     if (!$post->isValidModerationState($newState)) {
         $this->addError('moderate', $this->context->msg('flow-error-invalid-moderation-state'));
         return;
     }
     if (!$this->permissions->isAllowed($post, $action)) {
         $this->addError('permissions', $this->getDisallowedErrorMessage($post));
         return;
     }
     if (trim($this->submitted['reason']) === '') {
         $this->addError('moderate', $this->context->msg('flow-error-invalid-moderation-reason'));
         return;
     }
     $reason = $this->submitted['reason'];
     $this->newRevision = $post->moderate($this->context->getUser(), $newState, $action, $reason);
     if (!$this->newRevision) {
         $this->addError('moderate', $this->context->msg('flow-error-not-allowed'));
         return;
     }
 }