@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+25 -2
+18
src/applications/tokens/controller/PhabricatorTokenGiveController.php
··· 14 14 return new Aphront404Response(); 15 15 } 16 16 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 + 17 35 $current = id(new PhabricatorTokenGivenQuery()) 18 36 ->setViewer($viewer) 19 37 ->withAuthorPHIDs(array($viewer->getPHID()))
+7 -2
src/applications/tokens/event/PhabricatorTokenUIEventListener.php
··· 37 37 return null; 38 38 } 39 39 40 + $can_interact = PhabricatorPolicyFilter::canInteract($user, $object); 41 + 40 42 $current = id(new PhabricatorTokenGivenQuery()) 41 43 ->setViewer($user) 42 44 ->withAuthorPHIDs(array($user->getPHID())) ··· 48 50 ->setWorkflow(true) 49 51 ->setHref('/token/give/'.$object->getPHID().'/') 50 52 ->setName(pht('Award Token')) 51 - ->setIcon('fa-trophy'); 53 + ->setIcon('fa-trophy') 54 + ->setDisabled(!$can_interact); 52 55 } else { 53 56 $token_action = id(new PhabricatorActionView()) 54 57 ->setWorkflow(true) 55 58 ->setHref('/token/give/'.$object->getPHID().'/') 56 59 ->setName(pht('Rescind Token')) 57 - ->setIcon('fa-trophy'); 60 + ->setIcon('fa-trophy') 61 + ->setDisabled(!$can_interact); 58 62 } 63 + 59 64 if (!$user->isLoggedIn()) { 60 65 $token_action->setDisabled(true); 61 66 }