Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / phame / controller / post / PhamePostArchiveController.php
blob093e7019bfc1373f990df5a32558dd3397c3a2ab
1 <?php
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())
10 ->setViewer($viewer)
11 ->withIDs(array($id))
12 ->requireCapabilities(
13 array(
14 PhabricatorPolicyCapability::CAN_VIEW,
15 PhabricatorPolicyCapability::CAN_EDIT,
17 ->executeOne();
18 if (!$post) {
19 return new Aphront404Response();
22 $cancel_uri = $post->getViewURI();
24 if ($request->isFormPost()) {
25 $xactions = array();
27 $new_value = PhameConstants::VISIBILITY_ARCHIVED;
28 $xactions[] = id(new PhamePostTransaction())
29 ->setTransactionType(PhamePostVisibilityTransaction::TRANSACTIONTYPE)
30 ->setNewValue($new_value);
32 id(new PhamePostEditor())
33 ->setActor($viewer)
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');
44 $body = pht(
45 'If you archive this post, it will only be visible to users who can '.
46 'edit %s.',
47 $viewer->renderHandle($post->getBlogPHID()));
48 $button = pht('Archive Post');
50 return $this->newDialog()
51 ->setTitle($title)
52 ->appendParagraph($body)
53 ->addSubmitButton($button)
54 ->addCancelButton($cancel_uri);