3 final class PhabricatorUserDisableTransaction
4 extends PhabricatorUserTransactionType
{
6 const TRANSACTIONTYPE
= 'user.disable';
8 public function generateOldValue($object) {
9 return (bool)$object->getIsDisabled();
12 public function generateNewValue($object, $value) {
16 public function applyInternalEffects($object, $value) {
17 $object->setIsDisabled((int)$value);
20 public function getTitle() {
21 $new = $this->getNewValue();
24 '%s disabled this user.',
25 $this->renderAuthor());
28 '%s enabled this user.',
29 $this->renderAuthor());
33 public function shouldHideForFeed() {
34 // Don't publish feed stories about disabling users, since this can be
35 // a sensitive action.
39 public function validateTransactions($object, array $xactions) {
42 foreach ($xactions as $xaction) {
43 $is_disabled = (bool)$object->getIsDisabled();
45 if ((bool)$xaction->getNewValue() === $is_disabled) {
49 // You must have the "Can Disable Users" permission to disable a user.
50 $this->requireApplicationCapability(
51 PeopleDisableUsersCapability
::CAPABILITY
);
53 if ($this->getActingAsPHID() === $object->getPHID()) {
54 $errors[] = $this->newInvalidError(
55 pht('You can not enable or disable your own account.'));
62 public function getRequiredCapabilities(
64 PhabricatorApplicationTransaction
$xaction) {
66 // You do not need to be able to edit users to disable them. Instead, this
67 // requirement is replaced with a requirement that you have the "Can
68 // Disable Users" permission.