Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/storage/PhabricatorUserEmail.php
<?php | <?php | ||||
/** | /** | ||||
* @task restrictions Domain Restrictions | * @task restrictions Domain Restrictions | ||||
* @task email Email About Email | * @task email Email About Email | ||||
*/ | */ | ||||
final class PhabricatorUserEmail | final class PhabricatorUserEmail | ||||
extends PhabricatorUserDAO | extends PhabricatorUserDAO | ||||
implements PhabricatorDestructibleInterface { | implements | ||||
PhabricatorDestructibleInterface, | |||||
PhabricatorPolicyInterface { | |||||
protected $userPHID; | protected $userPHID; | ||||
protected $address; | protected $address; | ||||
protected $isVerified; | protected $isVerified; | ||||
protected $isPrimary; | protected $isPrimary; | ||||
protected $verificationCode; | protected $verificationCode; | ||||
private $user = self::ATTACHABLE; | |||||
const MAX_ADDRESS_LENGTH = 128; | const MAX_ADDRESS_LENGTH = 128; | ||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
'address' => 'sort128', | 'address' => 'sort128', | ||||
'isVerified' => 'bool', | 'isVerified' => 'bool', | ||||
Show All 22 Lines | final class PhabricatorUserEmail | ||||
public function save() { | public function save() { | ||||
if (!$this->verificationCode) { | if (!$this->verificationCode) { | ||||
$this->setVerificationCode(Filesystem::readRandomCharacters(24)); | $this->setVerificationCode(Filesystem::readRandomCharacters(24)); | ||||
} | } | ||||
return parent::save(); | return parent::save(); | ||||
} | } | ||||
public function attachUser(PhabricatorUser $user) { | |||||
$this->user = $user; | |||||
return $this; | |||||
} | |||||
public function getUser() { | |||||
return $this->assertAttached($this->user); | |||||
} | |||||
/* -( Domain Restrictions )------------------------------------------------ */ | /* -( Domain Restrictions )------------------------------------------------ */ | ||||
/** | /** | ||||
* @task restrictions | * @task restrictions | ||||
*/ | */ | ||||
public static function isValidAddress($address) { | public static function isValidAddress($address) { | ||||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Lines | |||||
/* -( PhabricatorDestructibleInterface )----------------------------------- */ | /* -( PhabricatorDestructibleInterface )----------------------------------- */ | ||||
public function destroyObjectPermanently( | public function destroyObjectPermanently( | ||||
PhabricatorDestructionEngine $engine) { | PhabricatorDestructionEngine $engine) { | ||||
$this->delete(); | $this->delete(); | ||||
} | } | ||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | |||||
public function getCapabilities() { | |||||
return array( | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
PhabricatorPolicyCapability::CAN_EDIT, | |||||
); | |||||
} | |||||
public function getPolicy($capability) { | |||||
$user = $this->getUser(); | |||||
if ($this->getIsSystemAgent() || $this->getIsMailingList()) { | |||||
return PhabricatorPolicies::POLICY_ADMIN; | |||||
} | |||||
return $user->getPHID(); | |||||
} | |||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | |||||
return false; | |||||
} | |||||
} | } |