[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhrequentUserTime extends PhrequentDAO 4 implements PhabricatorPolicyInterface { 5 6 protected $userPHID; 7 protected $objectPHID; 8 protected $note; 9 protected $dateStarted; 10 protected $dateEnded; 11 12 private $preemptingEvents = self::ATTACHABLE; 13 14 public function getConfiguration() { 15 return array( 16 self::CONFIG_COLUMN_SCHEMA => array( 17 'objectPHID' => 'phid?', 18 'note' => 'text?', 19 'dateStarted' => 'epoch', 20 'dateEnded' => 'epoch?', 21 ), 22 ) + parent::getConfiguration(); 23 } 24 25 public function getCapabilities() { 26 return array( 27 PhabricatorPolicyCapability::CAN_VIEW, 28 ); 29 } 30 31 public function getPolicy($capability) { 32 $policy = PhabricatorPolicies::POLICY_NOONE; 33 34 switch ($capability) { 35 case PhabricatorPolicyCapability::CAN_VIEW: 36 // Since it's impossible to perform any meaningful computations with 37 // time if a user can't view some of it, visibility on tracked time is 38 // unrestricted. If we eventually lock it down, it should be per-user. 39 // (This doesn't mean that users can see tracked objects.) 40 return PhabricatorPolicies::getMostOpenPolicy(); 41 } 42 43 return $policy; 44 } 45 46 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 47 return ($viewer->getPHID() == $this->getUserPHID()); 48 } 49 50 51 public function describeAutomaticCapability($capability) { 52 return null; 53 } 54 55 public function attachPreemptingEvents(array $events) { 56 $this->preemptingEvents = $events; 57 return $this; 58 } 59 60 public function getPreemptingEvents() { 61 return $this->assertAttached($this->preemptingEvents); 62 } 63 64 public function isPreempted() { 65 if ($this->getDateEnded() !== null) { 66 return false; 67 } 68 foreach ($this->getPreemptingEvents() as $event) { 69 if ($event->getDateEnded() === null && 70 $event->getObjectPHID() != $this->getObjectPHID()) { 71 return true; 72 } 73 } 74 return false; 75 } 76 77 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |