1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-25 21:19:21 +01:00
phorge-phorge/src/applications/project/xaction/PhabricatorProjectLockTransaction.php
epriestley 7e29ec2e2a Move the "Can Lock Projects" check from requireCapabilities() to transaction validation
Summary: Depends on D19584. Ref T13164. This check is an //extra// check: you need EDIT //and// this capability. Thus, we can do it in validation without issues.

Test Plan:
  - This code isn't reachable today: all methods of applying this transaction do a separate check for "Can Lock" upfront.
  - Commented out the "Can Lock" check in the LockController, tried to lock as a user without permission. Was rejected with a policy exception.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13164

Differential Revision: https://secure.phabricator.com/D19585
2018-08-16 10:56:00 -07:00

64 lines
1.3 KiB
PHP

<?php
final class PhabricatorProjectLockTransaction
extends PhabricatorProjectTransactionType {
const TRANSACTIONTYPE = 'project:locked';
public function generateOldValue($object) {
return (int)$object->getIsMembershipLocked();
}
public function applyInternalEffects($object, $value) {
$object->setIsMembershipLocked($value);
}
public function getTitle() {
$new = $this->getNewValue();
if ($new) {
return pht(
"%s locked this project's membership.",
$this->renderAuthor());
} else {
return pht(
"%s unlocked this project's membership.",
$this->renderAuthor());
}
}
public function getTitleForFeed() {
$new = $this->getNewValue();
if ($new) {
return pht(
'%s locked %s membership.',
$this->renderAuthor(),
$this->renderObject());
} else {
return pht(
'%s unlocked %s membership.',
$this->renderAuthor(),
$this->renderObject());
}
}
public function getIcon() {
$new = $this->getNewValue();
if ($new) {
return 'fa-lock';
} else {
return 'fa-unlock';
}
}
public function validateTransactions($object, array $xactions) {
if ($xactions) {
$this->requireApplicationCapability(
ProjectCanLockProjectsCapability::CAPABILITY);
}
return array();
}
}