@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
at upstream/main 80 lines 1.7 kB view raw
1<?php 2 3final class PhabricatorCalendarEventPolicyCodex 4 extends PhabricatorPolicyCodex { 5 6 public function getPolicyShortName() { 7 $object = $this->getObject(); 8 9 if (!$object->isImportedEvent()) { 10 return null; 11 } 12 13 return pht('Uses Import Policy'); 14 } 15 16 public function getPolicyIcon() { 17 $object = $this->getObject(); 18 19 if (!$object->isImportedEvent()) { 20 return null; 21 } 22 23 return 'fa-download'; 24 } 25 26 public function getPolicyTagClasses() { 27 $object = $this->getObject(); 28 29 if (!$object->isImportedEvent()) { 30 return array(); 31 } 32 33 return array( 34 'policy-adjusted-special', 35 ); 36 } 37 38 public function getPolicySpecialRuleDescriptions() { 39 $object = $this->getObject(); 40 41 $rules = array(); 42 $rules[] = $this->newRule() 43 ->setDescription( 44 pht('The host of an event can always view and edit it.')); 45 46 $rules[] = $this->newRule() 47 ->setCapabilities( 48 array( 49 PhabricatorPolicyCapability::CAN_VIEW, 50 )) 51 ->setDescription( 52 pht('Users who are invited to an event can always view it.')); 53 54 55 $rules[] = $this->newRule() 56 ->setCapabilities( 57 array( 58 PhabricatorPolicyCapability::CAN_VIEW, 59 )) 60 ->setIsActive($object->isImportedEvent()) 61 ->setDescription( 62 pht( 63 'Imported events can only be viewed by users who can view '. 64 'the import source.')); 65 66 $rules[] = $this->newRule() 67 ->setCapabilities( 68 array( 69 PhabricatorPolicyCapability::CAN_EDIT, 70 )) 71 ->setIsActive($object->isImportedEvent()) 72 ->setDescription( 73 pht( 74 'Imported events can not be edited.')); 75 76 return $rules; 77 } 78 79 80}