[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/phame/controller/post/ -> PhamePostNotLiveController.php (source)

   1  <?php
   2  
   3  final class PhamePostNotLiveController extends PhameController {
   4  
   5    private $id;
   6  
   7    public function willProcessRequest(array $data) {
   8      $this->id = $data['id'];
   9    }
  10  
  11    public function processRequest() {
  12      $request = $this->getRequest();
  13      $user = $request->getUser();
  14  
  15      $post = id(new PhamePostQuery())
  16        ->setViewer($user)
  17        ->withIDs(array($this->id))
  18        ->executeOne();
  19      if (!$post) {
  20        return new Aphront404Response();
  21      }
  22  
  23      $reasons = array();
  24      if (!$post->getBlog()) {
  25        $reasons[] = phutil_tag('p', array(), pht(
  26          'You can not view the live version of this post because it '.
  27          'is not associated with a blog. Move the post to a blog in order to '.
  28          'view it live.'));
  29      }
  30  
  31      if ($post->isDraft()) {
  32        $reasons[] = phutil_tag('p', array(), pht(
  33          'You can not view the live version of this post because it '.
  34          'is still a draft. Use "Preview/Publish" to publish the post.'));
  35      }
  36  
  37      if ($reasons) {
  38        $cancel_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/');
  39  
  40        $dialog = id(new AphrontDialogView())
  41          ->setUser($user)
  42          ->setTitle(pht('Post Not Live'))
  43          ->addCancelButton($cancel_uri);
  44  
  45        foreach ($reasons as $reason) {
  46          $dialog->appendChild($reason);
  47        }
  48  
  49        return id(new AphrontDialogResponse())->setDialog($dialog);
  50      }
  51  
  52      // No reason this can't go live, maybe an old link. Kick them live and see
  53      // what happens.
  54      $live_uri = $post->getViewURI();
  55      return id(new AphrontRedirectResponse())->setURI($live_uri);
  56    }
  57  
  58  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1