@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.

at recaptime-dev/main 99 lines 2.0 kB view raw
1<?php 2 3final class PhabricatorPolicyRef 4 extends Phobject { 5 6 private $viewer; 7 private $policy; 8 9 public function setViewer(PhabricatorUser $viewer) { 10 $this->viewer = $viewer; 11 return $this; 12 } 13 14 public function getViewer() { 15 return $this->viewer; 16 } 17 18 public function setPolicy(PhabricatorPolicy $policy) { 19 $this->policy = $policy; 20 return $this; 21 } 22 23 public function getPolicy() { 24 return $this->policy; 25 } 26 27 public function getPolicyDisplayName() { 28 $policy = $this->getPolicy(); 29 return $policy->getFullName(); 30 } 31 32 public function newTransactionLink( 33 $mode, 34 PhabricatorApplicationTransaction $xaction) { 35 36 $policy = $this->getPolicy(); 37 38 if ($policy->isCustomPolicy()) { 39 $uri = urisprintf( 40 '/transactions/%s/%s/', 41 $mode, 42 $xaction->getPHID()); 43 $workflow = true; 44 } else { 45 $uri = $policy->getHref(); 46 $workflow = false; 47 } 48 49 return $this->newLink($uri, $workflow); 50 } 51 52 public function newCapabilityLink($object, $capability) { 53 $policy = $this->getPolicy(); 54 55 $uri = urisprintf( 56 '/policy/explain/%s/%s/', 57 $object->getPHID(), 58 $capability); 59 60 return $this->newLink($uri, true); 61 } 62 63 private function newLink($uri, $workflow) { 64 $policy = $this->getPolicy(); 65 $name = $policy->getName(); 66 67 if ($uri !== null) { 68 $name = javelin_tag( 69 'a', 70 array( 71 'href' => $uri, 72 'sigil' => ($workflow ? 'workflow' : null), 73 ), 74 $name); 75 } 76 77 $hint = $this->getPolicyTypeHint(); 78 if ($hint !== null) { 79 $name = pht('%s (%s)', $name, $hint); 80 } 81 82 return $name; 83 } 84 85 private function getPolicyTypeHint() { 86 $policy = $this->getPolicy(); 87 88 if ($policy->isProjectPolicy()) { 89 return pht('Project'); 90 } 91 92 if ($policy->isMaskedPolicy()) { 93 return pht('You do not have permission to view policy details.'); 94 } 95 96 return null; 97 } 98 99}