Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/storage/PhabricatorUser.php
| <?php | <?php | ||||
| final class PhabricatorUser | final class PhabricatorUser | ||||
| extends PhabricatorUserDAO | extends PhabricatorUserDAO | ||||
| implements | implements | ||||
| PhutilPerson, | PhutilPerson, | ||||
| PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
| PhabricatorCustomFieldInterface { | PhabricatorCustomFieldInterface, | ||||
| PhabricatorDestructableInterface { | |||||
| const SESSION_TABLE = 'phabricator_session'; | const SESSION_TABLE = 'phabricator_session'; | ||||
| const NAMETOKEN_TABLE = 'user_nametoken'; | const NAMETOKEN_TABLE = 'user_nametoken'; | ||||
| const MAXIMUM_USERNAME_LENGTH = 64; | const MAXIMUM_USERNAME_LENGTH = 64; | ||||
| protected $userName; | protected $userName; | ||||
| protected $realName; | protected $realName; | ||||
| protected $sex; | protected $sex; | ||||
| ▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | public function setPassword(PhutilOpaqueEnvelope $envelope) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| // To satisfy PhutilPerson. | // To satisfy PhutilPerson. | ||||
| public function getSex() { | public function getSex() { | ||||
| return $this->sex; | return $this->sex; | ||||
| } | } | ||||
| public function getMonogram() { | |||||
| return '@'.$this->getUsername(); | |||||
| } | |||||
| public function getTranslation() { | public function getTranslation() { | ||||
| try { | try { | ||||
| if ($this->translation && | if ($this->translation && | ||||
| class_exists($this->translation) && | class_exists($this->translation) && | ||||
| is_subclass_of($this->translation, 'PhabricatorTranslation')) { | is_subclass_of($this->translation, 'PhabricatorTranslation')) { | ||||
| return $this->translation; | return $this->translation; | ||||
| } | } | ||||
| } catch (PhutilMissingSymbolException $ex) { | } catch (PhutilMissingSymbolException $ex) { | ||||
| ▲ Show 20 Lines • Show All 659 Lines • ▼ Show 20 Lines | public function getCustomFields() { | ||||
| return $this->assertAttached($this->customFields); | return $this->assertAttached($this->customFields); | ||||
| } | } | ||||
| public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) { | public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) { | ||||
| $this->customFields = $fields; | $this->customFields = $fields; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| /* -( PhabricatorDestructableInterface )----------------------------------- */ | |||||
| public function destroyObjectPermanently( | |||||
| PhabricatorDestructionEngine $engine) { | |||||
| $this->openTransaction(); | |||||
| $this->delete(); | |||||
| $externals = id(new PhabricatorExternalAccount())->loadAllWhere( | |||||
| 'userPHID = %s', | |||||
| $this->getPHID()); | |||||
| foreach ($externals as $external) { | |||||
| $external->delete(); | |||||
| } | |||||
| $prefs = id(new PhabricatorUserPreferences())->loadAllWhere( | |||||
| 'userPHID = %s', | |||||
| $this->getPHID()); | |||||
| foreach ($prefs as $pref) { | |||||
| $pref->delete(); | |||||
| } | |||||
| $profiles = id(new PhabricatorUserProfile())->loadAllWhere( | |||||
| 'userPHID = %s', | |||||
| $this->getPHID()); | |||||
| foreach ($profiles as $profile) { | |||||
| $profile->delete(); | |||||
| } | |||||
| $keys = id(new PhabricatorUserSSHKey())->loadAllWhere( | |||||
| 'userPHID = %s', | |||||
| $this->getPHID()); | |||||
| foreach ($keys as $key) { | |||||
| $key->delete(); | |||||
| } | |||||
| $emails = id(new PhabricatorUserEmail())->loadAllWhere( | |||||
| 'userPHID = %s', | |||||
| $this->getPHID()); | |||||
| foreach ($emails as $email) { | |||||
| $email->delete(); | |||||
| } | |||||
| $sessions = id(new PhabricatorAuthSession())->loadAllWhere( | |||||
| 'userPHID = %s', | |||||
| $this->getPHID()); | |||||
| foreach ($sessions as $session) { | |||||
| $session->delete(); | |||||
| } | |||||
| $factors = id(new PhabricatorAuthFactorConfig())->loadAllWhere( | |||||
| 'userPHID = %s', | |||||
| $this->getPHID()); | |||||
| foreach ($factors as $factor) { | |||||
| $factor->delete(); | |||||
| } | |||||
| $this->saveTransaction(); | |||||
| } | |||||
| } | } | ||||