Differential D20011 Diff 47810 src/applications/auth/controller/contact/PhabricatorAuthContactNumberPrimaryController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/controller/contact/PhabricatorAuthContactNumberPrimaryController.php
- This file was added.
| <?php | |||||
| final class PhabricatorAuthContactNumberPrimaryController | |||||
| extends PhabricatorAuthContactNumberController { | |||||
| public function handleRequest(AphrontRequest $request) { | |||||
| $viewer = $request->getViewer(); | |||||
| $id = $request->getURIData('id'); | |||||
| $number = id(new PhabricatorAuthContactNumberQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withIDs(array($id)) | |||||
| ->requireCapabilities( | |||||
| array( | |||||
| PhabricatorPolicyCapability::CAN_VIEW, | |||||
| PhabricatorPolicyCapability::CAN_EDIT, | |||||
| )) | |||||
| ->executeOne(); | |||||
| if (!$number) { | |||||
| return new Aphront404Response(); | |||||
| } | |||||
| $id = $number->getID(); | |||||
| $cancel_uri = $number->getURI(); | |||||
| if ($number->isDisabled()) { | |||||
| return $this->newDialog() | |||||
| ->setTitle(pht('Number Disabled')) | |||||
| ->appendParagraph( | |||||
| pht( | |||||
| 'You can not make a disabled number your primary contact number.')) | |||||
| ->addCancelButton($cancel_uri); | |||||
| } | |||||
| if ($number->getIsPrimary()) { | |||||
| return $this->newDialog() | |||||
| ->setTitle(pht('Number Already Primary')) | |||||
| ->appendParagraph( | |||||
| pht( | |||||
| 'This contact number is already your primary contact number.')) | |||||
| ->addCancelButton($cancel_uri); | |||||
| } | |||||
amckinley: Maybe just don't show the button? | |||||
Done Inline Actions(I think there's significant value in having the UI remain consistent, even though remotely reasonable users probably won't end up here.) epriestley: (I think there's significant value in having the UI remain consistent, even though remotely… | |||||
| if ($request->isFormPost()) { | |||||
| $xactions = array(); | |||||
| $xactions[] = id(new PhabricatorAuthContactNumberTransaction()) | |||||
| ->setTransactionType( | |||||
| PhabricatorAuthContactNumberPrimaryTransaction::TRANSACTIONTYPE) | |||||
| ->setNewValue(true); | |||||
| $editor = id(new PhabricatorAuthContactNumberEditor()) | |||||
| ->setActor($viewer) | |||||
| ->setContentSourceFromRequest($request) | |||||
| ->setContinueOnNoEffect(true) | |||||
| ->setContinueOnMissingFields(true); | |||||
| $editor->applyTransactions($number, $xactions); | |||||
| return id(new AphrontRedirectResponse())->setURI($cancel_uri); | |||||
| } | |||||
| $number_display = phutil_tag( | |||||
| 'strong', | |||||
| array(), | |||||
| $number->getDisplayName()); | |||||
| return $this->newDialog() | |||||
| ->setTitle(pht('Set Primary Contact Number')) | |||||
| ->appendParagraph( | |||||
| pht( | |||||
| 'Designate %s as your primary contact number?', | |||||
| $number_display)) | |||||
Not Done Inline Actions"Designate" amckinley: "Designate" | |||||
| ->addSubmitButton(pht('Make Primary')) | |||||
| ->addCancelButton($cancel_uri); | |||||
| } | |||||
| } | |||||
Maybe just don't show the button?