Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / fund / controller / FundInitiativeCloseController.php
blob97c6de3d97b38a113ccc123e2e2459eb8582205f
1 <?php
3 final class FundInitiativeCloseController
4 extends FundController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
8 $id = $request->getURIData('id');
10 $initiative = id(new FundInitiativeQuery())
11 ->setViewer($viewer)
12 ->withIDs(array($id))
13 ->requireCapabilities(
14 array(
15 PhabricatorPolicyCapability::CAN_VIEW,
16 PhabricatorPolicyCapability::CAN_EDIT,
18 ->executeOne();
19 if (!$initiative) {
20 return new Aphront404Response();
23 $initiative_uri = '/'.$initiative->getMonogram();
25 $is_close = !$initiative->isClosed();
27 if ($request->isFormPost()) {
28 $type_status = FundInitiativeStatusTransaction::TRANSACTIONTYPE;
30 if ($is_close) {
31 $new_status = FundInitiative::STATUS_CLOSED;
32 } else {
33 $new_status = FundInitiative::STATUS_OPEN;
36 $xaction = id(new FundInitiativeTransaction())
37 ->setTransactionType($type_status)
38 ->setNewValue($new_status);
40 $editor = id(new FundInitiativeEditor())
41 ->setActor($viewer)
42 ->setContentSourceFromRequest($request)
43 ->setContinueOnMissingFields(true);
45 $editor->applyTransactions($initiative, array($xaction));
47 return id(new AphrontRedirectResponse())->setURI($initiative_uri);
50 if ($is_close) {
51 $title = pht('Close Initiative?');
52 $body = pht(
53 'Really close this initiative? Users will no longer be able to '.
54 'back it.');
55 $button_text = pht('Close Initiative');
56 } else {
57 $title = pht('Reopen Initiative?');
58 $body = pht('Really reopen this initiative?');
59 $button_text = pht('Reopen Initiative');
62 return $this->newDialog()
63 ->setTitle($title)
64 ->appendParagraph($body)
65 ->addCancelButton($initiative_uri)
66 ->addSubmitButton($button_text);