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())
13 ->requireCapabilities(
15 PhabricatorPolicyCapability
::CAN_VIEW
,
16 PhabricatorPolicyCapability
::CAN_EDIT
,
20 return new Aphront404Response();
23 $initiative_uri = '/'.$initiative->getMonogram();
25 $is_close = !$initiative->isClosed();
27 if ($request->isFormPost()) {
28 $type_status = FundInitiativeStatusTransaction
::TRANSACTIONTYPE
;
31 $new_status = FundInitiative
::STATUS_CLOSED
;
33 $new_status = FundInitiative
::STATUS_OPEN
;
36 $xaction = id(new FundInitiativeTransaction())
37 ->setTransactionType($type_status)
38 ->setNewValue($new_status);
40 $editor = id(new FundInitiativeEditor())
42 ->setContentSourceFromRequest($request)
43 ->setContinueOnMissingFields(true);
45 $editor->applyTransactions($initiative, array($xaction));
47 return id(new AphrontRedirectResponse())->setURI($initiative_uri);
51 $title = pht('Close Initiative?');
53 'Really close this initiative? Users will no longer be able to '.
55 $button_text = pht('Close Initiative');
57 $title = pht('Reopen Initiative?');
58 $body = pht('Really reopen this initiative?');
59 $button_text = pht('Reopen Initiative');
62 return $this->newDialog()
64 ->appendParagraph($body)
65 ->addCancelButton($initiative_uri)
66 ->addSubmitButton($button_text);