[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  <?php
   2  
   3  final class PhamePostUnpublishController 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        ->requireCapabilities(
  19          array(
  20            PhabricatorPolicyCapability::CAN_EDIT,
  21          ))
  22        ->executeOne();
  23      if (!$post) {
  24        return new Aphront404Response();
  25      }
  26  
  27      if ($request->isFormPost()) {
  28        $post->setVisibility(PhamePost::VISIBILITY_DRAFT);
  29        $post->setDatePublished(0);
  30        $post->save();
  31  
  32        return id(new AphrontRedirectResponse())
  33          ->setURI($this->getApplicationURI('/post/view/'.$post->getID().'/'));
  34      }
  35  
  36      $cancel_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/');
  37  
  38      $dialog = id(new AphrontDialogView())
  39        ->setUser($user)
  40        ->setTitle(pht('Unpublish Post?'))
  41        ->appendChild(
  42          pht(
  43            'The post "%s" will no longer be visible to other users until you '.
  44            'republish it.',
  45            $post->getTitle()))
  46        ->addSubmitButton(pht('Unpublish'))
  47        ->addCancelButton($cancel_uri);
  48  
  49      return id(new AphrontDialogResponse())->setDialog($dialog);
  50    }
  51  
  52  }


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