mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 03:12:41 +01:00
49c40d209d
Summary: Features! - Giving tokens. - Taking tokens back. - Not giving tokens. Test Plan: See screenshots. Reviewers: chad, vrana Reviewed By: chad CC: aran, btrahan Maniphest Tasks: T2541 Differential Revision: https://secure.phabricator.com/D4964
54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
<?php
|
|
|
|
final class PhabricatorTokenGiven extends PhabricatorTokenDAO
|
|
implements PhabricatorPolicyInterface {
|
|
|
|
protected $authorPHID;
|
|
protected $objectPHID;
|
|
protected $tokenPHID;
|
|
|
|
private $object;
|
|
|
|
public function attachObject(PhabricatorTokenReceiverInterface $object) {
|
|
$this->object = $object;
|
|
return $this;
|
|
}
|
|
|
|
public function getObject() {
|
|
if ($this->object === null) {
|
|
throw new Exception("Call attachObject() before getObject()!");
|
|
}
|
|
return $this->object;
|
|
}
|
|
|
|
public function getCapabilities() {
|
|
return array(
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
);
|
|
}
|
|
|
|
public function getPolicy($capability) {
|
|
switch ($capability) {
|
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
|
return $this->getObject()->getPolicy($capability);
|
|
default:
|
|
return PhabricatorPolicies::POLICY_NOONE;
|
|
}
|
|
}
|
|
|
|
public function hasAutomaticCapability($capability, PhabricatorUser $user) {
|
|
switch ($capability) {
|
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
|
return $this->getObject()->hasAutomaticCapability(
|
|
$capability,
|
|
$user);
|
|
default:
|
|
if ($user->getPHID() == $this->authorPHID) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|