@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 65 lines 1.8 kB view raw
1<?php 2 3final class PhabricatorAuthContactNumberStatusTransaction 4 extends PhabricatorAuthContactNumberTransactionType { 5 6 const TRANSACTIONTYPE = 'status'; 7 8 public function generateOldValue($object) { 9 return $object->getStatus(); 10 } 11 12 public function applyInternalEffects($object, $value) { 13 $object->setStatus($value); 14 } 15 16 public function getTitle() { 17 $new = $this->getNewValue(); 18 19 if ($new === PhabricatorAuthContactNumber::STATUS_DISABLED) { 20 return pht( 21 '%s disabled this contact number.', 22 $this->renderAuthor()); 23 } else { 24 return pht( 25 '%s enabled this contact number.', 26 $this->renderAuthor()); 27 } 28 } 29 30 public function validateTransactions($object, array $xactions) { 31 $errors = array(); 32 33 $map = PhabricatorAuthContactNumber::getStatusNameMap(); 34 35 foreach ($xactions as $xaction) { 36 $new_value = $xaction->getNewValue(); 37 38 if (!isset($map[$new_value])) { 39 $errors[] = $this->newInvalidError( 40 pht( 41 'Status ("%s") is not a valid contact number status. Valid '. 42 'status constants are: %s.', 43 $new_value, 44 implode(', ', array_keys($map))), 45 $xaction); 46 continue; 47 } 48 49 $mfa_error = $this->newContactNumberMFAError($object, $xaction); 50 if ($mfa_error) { 51 $errors[] = $mfa_error; 52 continue; 53 } 54 55 // NOTE: Enabling a contact number may cause us to collide with another 56 // active contact number. However, there might also be a transaction in 57 // this group that changes the number itself. Since we can't easily 58 // predict if we'll collide or not, just let the duplicate key logic 59 // handle it when we do. 60 } 61 62 return $errors; 63 } 64 65}