Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99000327
PhabricatorAuthContactNumberStatusTransaction.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jan 18, 09:01
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Jan 20, 09:01 (1 d, 20 h)
Engine
blob
Format
Raw Data
Handle
23682893
Attached To
rPH Phabricator
PhabricatorAuthContactNumberStatusTransaction.php
View Options
<?php
final
class
PhabricatorAuthContactNumberStatusTransaction
extends
PhabricatorAuthContactNumberTransactionType
{
const
TRANSACTIONTYPE
=
'status'
;
public
function
generateOldValue
(
$object
)
{
return
$object
->
getStatus
();
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setStatus
(
$value
);
}
public
function
getTitle
()
{
$new
=
$this
->
getNewValue
();
if
(
$new
===
PhabricatorAuthContactNumber
::
STATUS_DISABLED
)
{
return
pht
(
'%s disabled this contact number.'
,
$this
->
renderAuthor
());
}
else
{
return
pht
(
'%s enabled this contact number.'
,
$this
->
renderAuthor
());
}
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
$map
=
PhabricatorAuthContactNumber
::
getStatusNameMap
();
foreach
(
$xactions
as
$xaction
)
{
$new_value
=
$xaction
->
getNewValue
();
if
(!
isset
(
$map
[
$new_value
]))
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'Status ("%s") is not a valid contact number status. Valid '
.
'status constants are: %s.'
,
$new_value
,
implode
(
', '
,
array_keys
(
$map
))),
$xaction
);
continue
;
}
$mfa_error
=
$this
->
newContactNumberMFAError
(
$object
,
$xaction
);
if
(
$mfa_error
)
{
$errors
[]
=
$mfa_error
;
continue
;
}
// NOTE: Enabling a contact number may cause us to collide with another
// active contact number. However, there might also be a transaction in
// this group that changes the number itself. Since we can't easily
// predict if we'll collide or not, just let the duplicate key logic
// handle it when we do.
}
return
$errors
;
}
}
Event Timeline
Log In to Comment