Path: blob/master/src/applications/metamta/storage/PhabricatorMetaMTAApplicationEmail.php
12256 views
<?php12final class PhabricatorMetaMTAApplicationEmail3extends PhabricatorMetaMTADAO4implements5PhabricatorPolicyInterface,6PhabricatorApplicationTransactionInterface,7PhabricatorDestructibleInterface,8PhabricatorSpacesInterface {910protected $applicationPHID;11protected $address;12protected $configData;13protected $spacePHID;1415private $application = self::ATTACHABLE;1617const CONFIG_DEFAULT_AUTHOR = 'config:default:author';1819protected function getConfiguration() {20return array(21self::CONFIG_AUX_PHID => true,22self::CONFIG_SERIALIZATION => array(23'configData' => self::SERIALIZATION_JSON,24),25self::CONFIG_COLUMN_SCHEMA => array(26'address' => 'sort128',27),28self::CONFIG_KEY_SCHEMA => array(29'key_address' => array(30'columns' => array('address'),31'unique' => true,32),33'key_application' => array(34'columns' => array('applicationPHID'),35),36),37) + parent::getConfiguration();38}3940public function generatePHID() {41return PhabricatorPHID::generateNewPHID(42PhabricatorMetaMTAApplicationEmailPHIDType::TYPECONST);43}4445public static function initializeNewAppEmail(PhabricatorUser $actor) {46return id(new PhabricatorMetaMTAApplicationEmail())47->setSpacePHID($actor->getDefaultSpacePHID())48->setConfigData(array());49}5051public function attachApplication(PhabricatorApplication $app) {52$this->application = $app;53return $this;54}5556public function getApplication() {57return self::assertAttached($this->application);58}5960public function setConfigValue($key, $value) {61$this->configData[$key] = $value;62return $this;63}6465public function getConfigValue($key, $default = null) {66return idx($this->configData, $key, $default);67}6869public function getDefaultAuthorPHID() {70return $this->getConfigValue(self::CONFIG_DEFAULT_AUTHOR);71}7273public function getInUseMessage() {74$applications = PhabricatorApplication::getAllApplications();75$applications = mpull($applications, null, 'getPHID');76$application = idx(77$applications,78$this->getApplicationPHID());79if ($application) {80$message = pht(81'The address %s is configured to be used by the %s Application.',82$this->getAddress(),83$application->getName());84} else {85$message = pht(86'The address %s is configured to be used by an application.',87$this->getAddress());88}8990return $message;91}9293public function newAddress() {94return new PhutilEmailAddress($this->getAddress());95}9697/* -( PhabricatorPolicyInterface )----------------------------------------- */9899100public function getCapabilities() {101return array(102PhabricatorPolicyCapability::CAN_VIEW,103PhabricatorPolicyCapability::CAN_EDIT,104);105}106107public function getPolicy($capability) {108return $this->getApplication()->getPolicy($capability);109}110111public function hasAutomaticCapability(112$capability,113PhabricatorUser $viewer) {114115return $this->getApplication()->hasAutomaticCapability(116$capability,117$viewer);118}119120public function describeAutomaticCapability($capability) {121return $this->getApplication()->describeAutomaticCapability($capability);122}123124125/* -( PhabricatorApplicationTransactionInterface )------------------------- */126127128public function getApplicationTransactionEditor() {129return new PhabricatorMetaMTAApplicationEmailEditor();130}131132public function getApplicationTransactionTemplate() {133return new PhabricatorMetaMTAApplicationEmailTransaction();134}135136137/* -( PhabricatorDestructibleInterface )----------------------------------- */138139140public function destroyObjectPermanently(141PhabricatorDestructionEngine $engine) {142$this->delete();143}144145146/* -( PhabricatorSpacesInterface )----------------------------------------- */147148149public function getSpacePHID() {150return $this->spacePHID;151}152153}154155156