Differential D16104 Diff 38752 src/applications/phame/controller/post/PhamePostArchiveController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phame/controller/post/PhamePostArchiveController.php
- This file was added.
| <?php | |||||
| final class PhamePostArchiveController extends PhamePostController { | |||||
| public function handleRequest(AphrontRequest $request) { | |||||
| $viewer = $request->getViewer(); | |||||
| $id = $request->getURIData('id'); | |||||
| $post = id(new PhamePostQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withIDs(array($id)) | |||||
| ->requireCapabilities( | |||||
| array( | |||||
| PhabricatorPolicyCapability::CAN_VIEW, | |||||
| PhabricatorPolicyCapability::CAN_EDIT, | |||||
| )) | |||||
| ->executeOne(); | |||||
| if (!$post) { | |||||
| return new Aphront404Response(); | |||||
| } | |||||
| $cancel_uri = $post->getViewURI(); | |||||
| if ($request->isFormPost()) { | |||||
| $xactions = array(); | |||||
| $new_value = PhameConstants::VISIBILITY_ARCHIVED; | |||||
| $xactions[] = id(new PhamePostTransaction()) | |||||
| ->setTransactionType(PhamePostTransaction::TYPE_VISIBILITY) | |||||
| ->setNewValue($new_value); | |||||
| id(new PhamePostEditor()) | |||||
| ->setActor($viewer) | |||||
| ->setContentSourceFromRequest($request) | |||||
| ->setContinueOnNoEffect(true) | |||||
| ->setContinueOnMissingFields(true) | |||||
| ->applyTransactions($post, $xactions); | |||||
| return id(new AphrontRedirectResponse()) | |||||
| ->setURI($cancel_uri); | |||||
| } | |||||
| $title = pht('Archive Post'); | |||||
| $body = pht( | |||||
| 'This post will revert to archived status and no longer be visible '. | |||||
| 'to other users or members of this blog.'); | |||||
| $button = pht('Archive Post'); | |||||
| return $this->newDialog() | |||||
| ->setTitle($title) | |||||
| ->appendParagraph($body) | |||||
| ->addSubmitButton($button) | |||||
| ->addCancelButton($cancel_uri); | |||||
| } | |||||
| } | |||||