@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 91 lines 2.8 kB view raw
1<?php 2 3final class PhabricatorAuthContactNumberPrimaryController 4 extends PhabricatorAuthContactNumberController { 5 6 public function handleRequest(AphrontRequest $request) { 7 $viewer = $request->getViewer(); 8 $id = $request->getURIData('id'); 9 10 $sms_auth_factor = new PhabricatorSMSAuthFactor(); 11 if ($sms_auth_factor->isSMSMailerConfigured()) { 12 $number = id(new PhabricatorAuthContactNumberQuery()) 13 ->setViewer($viewer) 14 ->withIDs(array($id)) 15 ->requireCapabilities( 16 array( 17 PhabricatorPolicyCapability::CAN_VIEW, 18 PhabricatorPolicyCapability::CAN_EDIT, 19 )) 20 ->executeOne(); 21 } 22 if (!isset($number) || !$number) { 23 return new Aphront404Response(); 24 } 25 26 $id = $number->getID(); 27 $cancel_uri = $number->getURI(); 28 29 if ($number->isDisabled()) { 30 return $this->newDialog() 31 ->setTitle(pht('Number Disabled')) 32 ->appendParagraph( 33 pht( 34 'You can not make a disabled number your primary contact number.')) 35 ->addCancelButton($cancel_uri); 36 } 37 38 if ($number->getIsPrimary()) { 39 return $this->newDialog() 40 ->setTitle(pht('Number Already Primary')) 41 ->appendParagraph( 42 pht( 43 'This contact number is already your primary contact number.')) 44 ->addCancelButton($cancel_uri); 45 } 46 47 if ($request->isFormOrHisecPost()) { 48 $xactions = array(); 49 50 $xactions[] = id(new PhabricatorAuthContactNumberTransaction()) 51 ->setTransactionType( 52 PhabricatorAuthContactNumberPrimaryTransaction::TRANSACTIONTYPE) 53 ->setNewValue(true); 54 55 $editor = id(new PhabricatorAuthContactNumberEditor()) 56 ->setActor($viewer) 57 ->setContentSourceFromRequest($request) 58 ->setContinueOnNoEffect(true) 59 ->setContinueOnMissingFields(true) 60 ->setCancelURI($cancel_uri); 61 62 try { 63 $editor->applyTransactions($number, $xactions); 64 } catch (PhabricatorApplicationTransactionValidationException $ex) { 65 // This happens when you try to make a number into your primary 66 // number, but you have contact number MFA on your account. 67 return $this->newDialog() 68 ->setTitle(pht('Unable to Make Primary')) 69 ->setValidationException($ex) 70 ->addCancelButton($cancel_uri); 71 } 72 73 return id(new AphrontRedirectResponse())->setURI($cancel_uri); 74 } 75 76 $number_display = phutil_tag( 77 'strong', 78 array(), 79 $number->getDisplayName()); 80 81 return $this->newDialog() 82 ->setTitle(pht('Set Primary Contact Number')) 83 ->appendParagraph( 84 pht( 85 'Designate %s as your primary contact number?', 86 $number_display)) 87 ->addSubmitButton(pht('Make Primary')) 88 ->addCancelButton($cancel_uri); 89 } 90 91}