Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/people/storage/PhabricatorExternalAccountIdentifier.php
12256 views
1
<?php
2
3
final class PhabricatorExternalAccountIdentifier
4
extends PhabricatorUserDAO
5
implements
6
PhabricatorPolicyInterface,
7
PhabricatorDestructibleInterface {
8
9
protected $externalAccountPHID;
10
protected $providerConfigPHID;
11
protected $identifierHash;
12
protected $identifierRaw;
13
14
public function getPHIDType() {
15
return PhabricatorPeopleExternalIdentifierPHIDType::TYPECONST;
16
}
17
18
protected function getConfiguration() {
19
return array(
20
self::CONFIG_AUX_PHID => true,
21
self::CONFIG_COLUMN_SCHEMA => array(
22
'identifierHash' => 'bytes12',
23
'identifierRaw' => 'text',
24
),
25
self::CONFIG_KEY_SCHEMA => array(
26
'key_identifier' => array(
27
'columns' => array('providerConfigPHID', 'identifierHash'),
28
'unique' => true,
29
),
30
'key_account' => array(
31
'columns' => array('externalAccountPHID'),
32
),
33
),
34
) + parent::getConfiguration();
35
}
36
37
public function save() {
38
$identifier_raw = $this->getIdentifierRaw();
39
40
$identifier_hash = PhabricatorHash::digestForIndex($identifier_raw);
41
$this->setIdentifierHash($identifier_hash);
42
43
return parent::save();
44
}
45
46
47
/* -( PhabricatorPolicyInterface )----------------------------------------- */
48
49
// TODO: These permissions aren't very good. They should just be the same
50
// as the associated ExternalAccount. See T13381.
51
52
public function getCapabilities() {
53
return array(
54
PhabricatorPolicyCapability::CAN_VIEW,
55
PhabricatorPolicyCapability::CAN_EDIT,
56
);
57
}
58
59
public function getPolicy($capability) {
60
switch ($capability) {
61
case PhabricatorPolicyCapability::CAN_VIEW:
62
return PhabricatorPolicies::getMostOpenPolicy();
63
case PhabricatorPolicyCapability::CAN_EDIT:
64
return PhabricatorPolicies::POLICY_NOONE;
65
}
66
}
67
68
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
69
return false;
70
}
71
72
73
/* -( PhabricatorDestructibleInterface )----------------------------------- */
74
75
76
public function destroyObjectPermanently(
77
PhabricatorDestructionEngine $engine) {
78
$this->delete();
79
}
80
81
}
82
83