Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phrequent/storage/PhrequentUserTime.php
<?php | <?php | ||||
/** | |||||
* @group phrequent | |||||
*/ | |||||
final class PhrequentUserTime extends PhrequentDAO | final class PhrequentUserTime extends PhrequentDAO | ||||
implements PhabricatorPolicyInterface { | implements PhabricatorPolicyInterface { | ||||
protected $userPHID; | protected $userPHID; | ||||
protected $objectPHID; | protected $objectPHID; | ||||
protected $note; | protected $note; | ||||
protected $dateStarted; | protected $dateStarted; | ||||
protected $dateEnded; | protected $dateEnded; | ||||
private $preemptingEvents = self::ATTACHABLE; | |||||
public function getCapabilities() { | public function getCapabilities() { | ||||
return array( | return array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
); | ); | ||||
} | } | ||||
public function getPolicy($capability) { | public function getPolicy($capability) { | ||||
$policy = PhabricatorPolicies::POLICY_NOONE; | $policy = PhabricatorPolicies::POLICY_NOONE; | ||||
switch ($capability) { | switch ($capability) { | ||||
case PhabricatorPolicyCapability::CAN_VIEW: | case PhabricatorPolicyCapability::CAN_VIEW: | ||||
$policy = PhabricatorPolicies::POLICY_USER; | // Since it's impossible to perform any meaningful computations with | ||||
break; | // time if a user can't view some of it, visibility on tracked time is | ||||
// unrestricted. If we eventually lock it down, it should be per-user. | |||||
// This doesn't mean that users can tracked objects. | |||||
btrahan: sentence seems off | |||||
epriestleyAuthorUnsubmitted Not Done Inline Actionsi do not sentence good epriestley: i do not sentence good | |||||
return PhabricatorPolicies::getMostOpenPolicy(); | |||||
} | } | ||||
return $policy; | return $policy; | ||||
} | } | ||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | ||||
return ($viewer->getPHID() == $this->getUserPHID()); | return ($viewer->getPHID() == $this->getUserPHID()); | ||||
} | } | ||||
public function describeAutomaticCapability($capability) { | public function describeAutomaticCapability($capability) { | ||||
return pht( | return null; | ||||
'The user who tracked time can always view it.'); | } | ||||
public function attachPreemptingEvents(array $events) { | |||||
$this->preemptingEvents = $events; | |||||
return $this; | |||||
} | |||||
public function getPreemptingEvents() { | |||||
return $this->assertAttached($this->preemptingEvents); | |||||
} | |||||
public function isPreempted() { | |||||
if ($this->getDateEnded() !== null) { | |||||
return false; | |||||
} | |||||
foreach ($this->getPreemptingEvents() as $event) { | |||||
if ($event->getDateEnded() === null && | |||||
$event->getObjectPHID() != $this->getObjectPHID()) { | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | } | ||||
} | } |
sentence seems off