mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-14 19:02:41 +01:00
943c62d1e9
Summary: Ref T1191. - Adds definitions for missing keys and keys with wrong uniqueness. Generally, I defined these before fixing the key query to actually pull all keys and support uniqueness. - Moves "key uniqueness" to note severity; this is fixable (probably?) and there are no remaining issues. - Moves "Missing Key" to note severity; missing keys are fixable and all remaining missing keys are really missing (either missing edge keys, or missing PHID keys): {F210089} - Moves "Surplus Key" to note seveirty; surplus keys are fixable all remaining surplus keys are really surplus (duplicate key in Harbormaster, key on unused column in Worker): {F210090} Test Plan: - Vetted missing/surplus/unique messages. - 146 issues remaining. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T1191 Differential Revision: https://secure.phabricator.com/D10590
81 lines
2 KiB
PHP
81 lines
2 KiB
PHP
<?php
|
|
|
|
final class PhabricatorTokenGiven extends PhabricatorTokenDAO
|
|
implements PhabricatorPolicyInterface {
|
|
|
|
protected $authorPHID;
|
|
protected $objectPHID;
|
|
protected $tokenPHID;
|
|
|
|
private $object = self::ATTACHABLE;
|
|
|
|
public function getConfiguration() {
|
|
return array(
|
|
self::CONFIG_KEY_SCHEMA => array(
|
|
'key_all' => array(
|
|
'columns' => array('objectPHID', 'authorPHID'),
|
|
'unique' => true,
|
|
),
|
|
'key_author' => array(
|
|
'columns' => array('authorPHID'),
|
|
),
|
|
'key_token' => array(
|
|
'columns' => array('tokenPHID'),
|
|
),
|
|
),
|
|
) + parent::getConfiguration();
|
|
}
|
|
|
|
public function attachObject(PhabricatorTokenReceiverInterface $object) {
|
|
$this->object = $object;
|
|
return $this;
|
|
}
|
|
|
|
public function getObject() {
|
|
return $this->assertAttached($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;
|
|
}
|
|
}
|
|
|
|
public function describeAutomaticCapability($capability) {
|
|
switch ($capability) {
|
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
|
return pht(
|
|
'A token inherits the policies of the object it is awarded to.');
|
|
case PhabricatorPolicyCapability::CAN_EDIT:
|
|
return pht(
|
|
'The user who gave a token can always edit it.');
|
|
}
|
|
return null;
|
|
}
|
|
|
|
|
|
}
|