3 final class PhamePostPublishController
extends PhamePostController
{
5 public function handleRequest(AphrontRequest
$request) {
6 $viewer = $request->getViewer();
8 $id = $request->getURIData('id');
9 $post = id(new PhamePostQuery())
12 ->requireCapabilities(
14 PhabricatorPolicyCapability
::CAN_VIEW
,
15 PhabricatorPolicyCapability
::CAN_EDIT
,
19 return new Aphront404Response();
22 $cancel_uri = $post->getViewURI();
24 $action = $request->getURIData('action');
25 $is_publish = ($action == 'publish');
27 if ($request->isFormPost()) {
31 $new_value = PhameConstants
::VISIBILITY_PUBLISHED
;
33 $new_value = PhameConstants
::VISIBILITY_DRAFT
;
36 $xactions[] = id(new PhamePostTransaction())
37 ->setTransactionType(PhamePostVisibilityTransaction
::TRANSACTIONTYPE
)
38 ->setNewValue($new_value);
40 id(new PhamePostEditor())
42 ->setContentSourceFromRequest($request)
43 ->setContinueOnNoEffect(true)
44 ->setContinueOnMissingFields(true)
45 ->applyTransactions($post, $xactions);
47 return id(new AphrontRedirectResponse())
48 ->setURI($cancel_uri);
52 $title = pht('Publish Post');
53 $body = pht('This post will go live once you publish it.');
54 $button = pht('Publish');
56 $title = pht('Unpublish Post');
58 'This post will revert to draft status and no longer be visible '.
60 $button = pht('Unpublish');
63 return $this->newDialog()
65 ->appendParagraph($body)
66 ->addSubmitButton($button)
67 ->addCancelButton($cancel_uri);