Path: blob/master/src/applications/auth/xaction/PhabricatorAuthContactNumberStatusTransaction.php
12256 views
<?php12final class PhabricatorAuthContactNumberStatusTransaction3extends PhabricatorAuthContactNumberTransactionType {45const TRANSACTIONTYPE = 'status';67public function generateOldValue($object) {8return $object->getStatus();9}1011public function applyInternalEffects($object, $value) {12$object->setStatus($value);13}1415public function getTitle() {16$new = $this->getNewValue();1718if ($new === PhabricatorAuthContactNumber::STATUS_DISABLED) {19return pht(20'%s disabled this contact number.',21$this->renderAuthor());22} else {23return pht(24'%s enabled this contact number.',25$this->renderAuthor());26}27}2829public function validateTransactions($object, array $xactions) {30$errors = array();3132$map = PhabricatorAuthContactNumber::getStatusNameMap();3334foreach ($xactions as $xaction) {35$new_value = $xaction->getNewValue();3637if (!isset($map[$new_value])) {38$errors[] = $this->newInvalidError(39pht(40'Status ("%s") is not a valid contact number status. Valid '.41'status constants are: %s.',42$new_value,43implode(', ', array_keys($map))),44$xaction);45continue;46}4748$mfa_error = $this->newContactNumberMFAError($object, $xaction);49if ($mfa_error) {50$errors[] = $mfa_error;51continue;52}5354// NOTE: Enabling a contact number may cause us to collide with another55// active contact number. However, there might also be a transaction in56// this group that changes the number itself. Since we can't easily57// predict if we'll collide or not, just let the duplicate key logic58// handle it when we do.59}6061return $errors;62}6364}656667