3 final class PhamePostArchiveController
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 if ($request->isFormPost()) {
27 $new_value = PhameConstants
::VISIBILITY_ARCHIVED
;
28 $xactions[] = id(new PhamePostTransaction())
29 ->setTransactionType(PhamePostVisibilityTransaction
::TRANSACTIONTYPE
)
30 ->setNewValue($new_value);
32 id(new PhamePostEditor())
34 ->setContentSourceFromRequest($request)
35 ->setContinueOnNoEffect(true)
36 ->setContinueOnMissingFields(true)
37 ->applyTransactions($post, $xactions);
39 return id(new AphrontRedirectResponse())
40 ->setURI($cancel_uri);
43 $title = pht('Archive Post');
45 'If you archive this post, it will only be visible to users who can '.
47 $viewer->renderHandle($post->getBlogPHID()));
48 $button = pht('Archive Post');
50 return $this->newDialog()
52 ->appendParagraph($body)
53 ->addSubmitButton($button)
54 ->addCancelButton($cancel_uri);