Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F686814
PhabricatorUserDisableTransaction.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorUserDisableTransaction.php
View Options
<?php
final
class
PhabricatorUserDisableTransaction
extends
PhabricatorUserTransactionType
{
const
TRANSACTIONTYPE
=
'user.disable'
;
public
function
generateOldValue
(
$object
)
{
return
(
bool
)
$object
->
getIsDisabled
();
}
public
function
generateNewValue
(
$object
,
$value
)
{
return
(
bool
)
$value
;
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setIsDisabled
((
int
)
$value
);
}
public
function
getTitle
()
{
$new
=
$this
->
getNewValue
();
if
(
$new
)
{
return
pht
(
'%s disabled this user.'
,
$this
->
renderAuthor
());
}
else
{
return
pht
(
'%s enabled this user.'
,
$this
->
renderAuthor
());
}
}
public
function
shouldHideForFeed
()
{
// Don't publish feed stories about disabling users, since this can be
// a sensitive action.
return
true
;
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
foreach
(
$xactions
as
$xaction
)
{
$is_disabled
=
(
bool
)
$object
->
getIsDisabled
();
if
((
bool
)
$xaction
->
getNewValue
()
===
$is_disabled
)
{
continue
;
}
// You must have the "Can Disable Users" permission to disable a user.
$this
->
requireApplicationCapability
(
PeopleDisableUsersCapability
::
CAPABILITY
);
if
(
$this
->
getActingAsPHID
()
===
$object
->
getPHID
())
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'You can not enable or disable your own account.'
));
}
}
return
$errors
;
}
public
function
getRequiredCapabilities
(
$object
,
PhabricatorApplicationTransaction
$xaction
)
{
// You do not need to be able to edit users to disable them. Instead, this
// requirement is replaced with a requirement that you have the "Can
// Disable Users" permission.
return
null
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, May 27, 2:11 PM (1 d, 23 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
168730
Default Alt Text
PhabricatorUserDisableTransaction.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment