Skip to content

Commit 9ccef52

Browse files
author
epriestley
committedMar 4, 2017
Prevent awarding/revoking tokens when a task is locked
Summary: Ref T12335. Allows you to lock tasks to keep your precious tokens. Test Plan: - Awarded tokens to an unlocked task. - Locked the task. - Could no longer award/rescind tokens. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12335 Differential Revision: https://secure.phabricator.com/D17461
1 parent d5baf2f commit 9ccef52

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
 

‎src/applications/tokens/controller/PhabricatorTokenGiveController.php

+18
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ public function handleRequest(AphrontRequest $request) {
1414
return new Aphront404Response();
1515
}
1616

17+
$object = id(new PhabricatorObjectQuery())
18+
->setViewer($viewer)
19+
->withPHIDs(array($phid))
20+
->executeOne();
21+
22+
if (!($object instanceof PhabricatorTokenReceiverInterface)) {
23+
return new Aphront400Response();
24+
}
25+
26+
if (!PhabricatorPolicyFilter::canInteract($viewer, $object)) {
27+
$lock = PhabricatorEditEngineLock::newForObject($viewer, $object);
28+
29+
$dialog = $this->newDialog()
30+
->addCancelButton($handle->getURI());
31+
32+
return $lock->willBlockUserInteractionWithDialog($dialog);
33+
}
34+
1735
$current = id(new PhabricatorTokenGivenQuery())
1836
->setViewer($viewer)
1937
->withAuthorPHIDs(array($viewer->getPHID()))

‎src/applications/tokens/event/PhabricatorTokenUIEventListener.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ private function handleActionEvent($event) {
3737
return null;
3838
}
3939

40+
$can_interact = PhabricatorPolicyFilter::canInteract($user, $object);
41+
4042
$current = id(new PhabricatorTokenGivenQuery())
4143
->setViewer($user)
4244
->withAuthorPHIDs(array($user->getPHID()))
@@ -48,14 +50,17 @@ private function handleActionEvent($event) {
4850
->setWorkflow(true)
4951
->setHref('/token/give/'.$object->getPHID().'/')
5052
->setName(pht('Award Token'))
51-
->setIcon('fa-trophy');
53+
->setIcon('fa-trophy')
54+
->setDisabled(!$can_interact);
5255
} else {
5356
$token_action = id(new PhabricatorActionView())
5457
->setWorkflow(true)
5558
->setHref('/token/give/'.$object->getPHID().'/')
5659
->setName(pht('Rescind Token'))
57-
->setIcon('fa-trophy');
60+
->setIcon('fa-trophy')
61+
->setDisabled(!$can_interact);
5862
}
63+
5964
if (!$user->isLoggedIn()) {
6065
$token_action->setDisabled(true);
6166
}

0 commit comments

Comments
 (0)
Failed to load comments.