Differential D20024 Diff 47821 src/applications/auth/controller/contact/PhabricatorAuthContactNumberDisableController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/controller/contact/PhabricatorAuthContactNumberDisableController.php
| Show All 18 Lines | public function handleRequest(AphrontRequest $request) { | ||||
| if (!$number) { | if (!$number) { | ||||
| return new Aphront404Response(); | return new Aphront404Response(); | ||||
| } | } | ||||
| $is_disable = ($request->getURIData('action') == 'disable'); | $is_disable = ($request->getURIData('action') == 'disable'); | ||||
| $id = $number->getID(); | $id = $number->getID(); | ||||
| $cancel_uri = $number->getURI(); | $cancel_uri = $number->getURI(); | ||||
| if ($request->isFormPost()) { | if ($request->isFormOrHisecPost()) { | ||||
| $xactions = array(); | $xactions = array(); | ||||
| if ($is_disable) { | if ($is_disable) { | ||||
| $new_status = PhabricatorAuthContactNumber::STATUS_DISABLED; | $new_status = PhabricatorAuthContactNumber::STATUS_DISABLED; | ||||
| } else { | } else { | ||||
| $new_status = PhabricatorAuthContactNumber::STATUS_ACTIVE; | $new_status = PhabricatorAuthContactNumber::STATUS_ACTIVE; | ||||
| } | } | ||||
| $xactions[] = id(new PhabricatorAuthContactNumberTransaction()) | $xactions[] = id(new PhabricatorAuthContactNumberTransaction()) | ||||
| ->setTransactionType( | ->setTransactionType( | ||||
| PhabricatorAuthContactNumberStatusTransaction::TRANSACTIONTYPE) | PhabricatorAuthContactNumberStatusTransaction::TRANSACTIONTYPE) | ||||
| ->setNewValue($new_status); | ->setNewValue($new_status); | ||||
| $editor = id(new PhabricatorAuthContactNumberEditor()) | $editor = id(new PhabricatorAuthContactNumberEditor()) | ||||
| ->setActor($viewer) | ->setActor($viewer) | ||||
| ->setContentSourceFromRequest($request) | ->setContentSourceFromRequest($request) | ||||
| ->setContinueOnNoEffect(true) | ->setContinueOnNoEffect(true) | ||||
| ->setContinueOnMissingFields(true); | ->setContinueOnMissingFields(true) | ||||
| ->setCancelURI($cancel_uri); | |||||
| try { | try { | ||||
| $editor->applyTransactions($number, $xactions); | $editor->applyTransactions($number, $xactions); | ||||
| } catch (PhabricatorApplicationTransactionValidationException $ex) { | } catch (PhabricatorApplicationTransactionValidationException $ex) { | ||||
| // This happens when you enable a number which collides with another | // This happens when you enable a number which collides with another | ||||
| // number. | // number. | ||||
| return $this->newDialog() | return $this->newDialog() | ||||
| ->setTitle(pht('Changing Status Failed')) | ->setTitle(pht('Changing Status Failed')) | ||||
| Show All 34 Lines | |||||