Path: blob/master/src/applications/people/storage/PhabricatorExternalAccountIdentifier.php
12256 views
<?php12final class PhabricatorExternalAccountIdentifier3extends PhabricatorUserDAO4implements5PhabricatorPolicyInterface,6PhabricatorDestructibleInterface {78protected $externalAccountPHID;9protected $providerConfigPHID;10protected $identifierHash;11protected $identifierRaw;1213public function getPHIDType() {14return PhabricatorPeopleExternalIdentifierPHIDType::TYPECONST;15}1617protected function getConfiguration() {18return array(19self::CONFIG_AUX_PHID => true,20self::CONFIG_COLUMN_SCHEMA => array(21'identifierHash' => 'bytes12',22'identifierRaw' => 'text',23),24self::CONFIG_KEY_SCHEMA => array(25'key_identifier' => array(26'columns' => array('providerConfigPHID', 'identifierHash'),27'unique' => true,28),29'key_account' => array(30'columns' => array('externalAccountPHID'),31),32),33) + parent::getConfiguration();34}3536public function save() {37$identifier_raw = $this->getIdentifierRaw();3839$identifier_hash = PhabricatorHash::digestForIndex($identifier_raw);40$this->setIdentifierHash($identifier_hash);4142return parent::save();43}444546/* -( PhabricatorPolicyInterface )----------------------------------------- */4748// TODO: These permissions aren't very good. They should just be the same49// as the associated ExternalAccount. See T13381.5051public function getCapabilities() {52return array(53PhabricatorPolicyCapability::CAN_VIEW,54PhabricatorPolicyCapability::CAN_EDIT,55);56}5758public function getPolicy($capability) {59switch ($capability) {60case PhabricatorPolicyCapability::CAN_VIEW:61return PhabricatorPolicies::getMostOpenPolicy();62case PhabricatorPolicyCapability::CAN_EDIT:63return PhabricatorPolicies::POLICY_NOONE;64}65}6667public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {68return false;69}707172/* -( PhabricatorDestructibleInterface )----------------------------------- */737475public function destroyObjectPermanently(76PhabricatorDestructionEngine $engine) {77$this->delete();78}7980}818283