1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-02 18:08:26 +01:00

Allow objects to specify custom policy unlocking behavior, and tasks to have owners unlocked

Summary: Depends on D20256. Ref T13249. See PHI1115. This primarily makes `bin/policy unlock --owner epriestley T123` work. This is important for "Edit Locked" tasks, since changing the edit policy doesn't really do anything.

Test Plan: Hard-locked a task as "alice", reassigned it to myself with `bin/policy unlock --owner epriestley`.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13249

Differential Revision: https://secure.phabricator.com/D20257
This commit is contained in:
epriestley 2019-03-06 20:48:27 -08:00
parent c86dca3ffc
commit 77221bee72
5 changed files with 53 additions and 2 deletions

View file

@ -1784,6 +1784,7 @@ phutil_register_library_map(array(
'ManiphestTaskTitleTransaction' => 'applications/maniphest/xaction/ManiphestTaskTitleTransaction.php',
'ManiphestTaskTransactionType' => 'applications/maniphest/xaction/ManiphestTaskTransactionType.php',
'ManiphestTaskUnblockTransaction' => 'applications/maniphest/xaction/ManiphestTaskUnblockTransaction.php',
'ManiphestTaskUnlockEngine' => 'applications/maniphest/engine/ManiphestTaskUnlockEngine.php',
'ManiphestTransaction' => 'applications/maniphest/storage/ManiphestTransaction.php',
'ManiphestTransactionComment' => 'applications/maniphest/storage/ManiphestTransactionComment.php',
'ManiphestTransactionEditor' => 'applications/maniphest/editor/ManiphestTransactionEditor.php',
@ -4703,6 +4704,7 @@ phutil_register_library_map(array(
'PhabricatorUnitsTestCase' => 'view/__tests__/PhabricatorUnitsTestCase.php',
'PhabricatorUnknownContentSource' => 'infrastructure/contentsource/PhabricatorUnknownContentSource.php',
'PhabricatorUnlockEngine' => 'applications/system/engine/PhabricatorUnlockEngine.php',
'PhabricatorUnlockableInterface' => 'applications/system/interface/PhabricatorUnlockableInterface.php',
'PhabricatorUnsubscribedFromObjectEdgeType' => 'applications/transactions/edges/PhabricatorUnsubscribedFromObjectEdgeType.php',
'PhabricatorUser' => 'applications/people/storage/PhabricatorUser.php',
'PhabricatorUserApproveTransaction' => 'applications/people/xaction/PhabricatorUserApproveTransaction.php',
@ -7419,6 +7421,7 @@ phutil_register_library_map(array(
'PhabricatorEditEngineLockableInterface',
'PhabricatorEditEngineMFAInterface',
'PhabricatorPolicyCodexInterface',
'PhabricatorUnlockableInterface',
),
'ManiphestTaskAssignHeraldAction' => 'HeraldAction',
'ManiphestTaskAssignOtherHeraldAction' => 'ManiphestTaskAssignHeraldAction',
@ -7496,6 +7499,7 @@ phutil_register_library_map(array(
'ManiphestTaskTitleTransaction' => 'ManiphestTaskTransactionType',
'ManiphestTaskTransactionType' => 'PhabricatorModularTransactionType',
'ManiphestTaskUnblockTransaction' => 'ManiphestTaskTransactionType',
'ManiphestTaskUnlockEngine' => 'PhabricatorUnlockEngine',
'ManiphestTransaction' => 'PhabricatorModularTransaction',
'ManiphestTransactionComment' => 'PhabricatorApplicationTransactionComment',
'ManiphestTransactionEditor' => 'PhabricatorApplicationTransactionEditor',

View file

@ -0,0 +1,14 @@
<?php
final class ManiphestTaskUnlockEngine
extends PhabricatorUnlockEngine {
public function newUnlockOwnerTransactions($object, $user) {
return array(
$this->newTransaction($object)
->setTransactionType(ManiphestTaskOwnerTransaction::TRANSACTIONTYPE)
->setNewValue($user->getPHID()),
);
}
}

View file

@ -21,7 +21,8 @@ final class ManiphestTask extends ManiphestDAO
PhabricatorEditEngineSubtypeInterface,
PhabricatorEditEngineLockableInterface,
PhabricatorEditEngineMFAInterface,
PhabricatorPolicyCodexInterface {
PhabricatorPolicyCodexInterface,
PhabricatorUnlockableInterface {
const MARKUP_FIELD_DESCRIPTION = 'markup:desc';
@ -649,4 +650,12 @@ final class ManiphestTask extends ManiphestDAO
return new ManiphestTaskPolicyCodex();
}
/* -( PhabricatorUnlockableInterface )------------------------------------- */
public function newUnlockEngine() {
return new ManiphestTaskUnlockEngine();
}
}

View file

@ -13,7 +13,13 @@ abstract class PhabricatorUnlockEngine
'PhabricatorApplicationTransactionInterface'));
}
return new PhabricatorDefaultUnlockEngine();
if ($object instanceof PhabricatorUnlockableInterface) {
$engine = $object->newUnlockEngine();
} else {
$engine = new PhabricatorDefaultUnlockEngine();
}
return $engine;
}
public function newUnlockViewTransactions($object, $user) {

View file

@ -0,0 +1,18 @@
<?php
interface PhabricatorUnlockableInterface {
public function newUnlockEngine();
}
// TEMPLATE IMPLEMENTATION /////////////////////////////////////////////////////
/* -( PhabricatorUnlockableInterface )------------------------------------- */
/*
public function newUnlockEngine() {
return new <<<...>>>UnlockEngine();
}
*/