Changeset View
Changeset View
Standalone View
Standalone View
src/applications/settings/storage/PhabricatorUserPreferences.php
| Show All 18 Lines | final class PhabricatorUserPreferences | ||||
| const PREFERENCE_RE_PREFIX = 're-prefix'; | const PREFERENCE_RE_PREFIX = 're-prefix'; | ||||
| const PREFERENCE_NO_SELF_MAIL = 'self-mail'; | const PREFERENCE_NO_SELF_MAIL = 'self-mail'; | ||||
| const PREFERENCE_NO_MAIL = 'no-mail'; | const PREFERENCE_NO_MAIL = 'no-mail'; | ||||
| const PREFERENCE_MAILTAGS = 'mailtags'; | const PREFERENCE_MAILTAGS = 'mailtags'; | ||||
| const PREFERENCE_VARY_SUBJECT = 'vary-subject'; | const PREFERENCE_VARY_SUBJECT = 'vary-subject'; | ||||
| const PREFERENCE_HTML_EMAILS = 'html-emails'; | const PREFERENCE_HTML_EMAILS = 'html-emails'; | ||||
| const PREFERENCE_DIFFUSION_BLAME = 'diffusion-blame'; | |||||
| const PREFERENCE_DIFFUSION_COLOR = 'diffusion-color'; | |||||
| const PREFERENCE_NAV_COLLAPSED = 'nav-collapsed'; | const PREFERENCE_NAV_COLLAPSED = 'nav-collapsed'; | ||||
| const PREFERENCE_NAV_WIDTH = 'nav-width'; | const PREFERENCE_NAV_WIDTH = 'nav-width'; | ||||
| const PREFERENCE_APP_TILES = 'app-tiles'; | const PREFERENCE_APP_TILES = 'app-tiles'; | ||||
| const PREFERENCE_APP_PINNED = 'app-pinned'; | const PREFERENCE_APP_PINNED = 'app-pinned'; | ||||
| const PREFERENCE_DIFF_UNIFIED = 'diff-unified'; | const PREFERENCE_DIFF_UNIFIED = 'diff-unified'; | ||||
| const PREFERENCE_DIFF_FILETREE = 'diff-filetree'; | const PREFERENCE_DIFF_FILETREE = 'diff-filetree'; | ||||
| const PREFERENCE_DIFF_GHOSTS = 'diff-ghosts'; | const PREFERENCE_DIFF_GHOSTS = 'diff-ghosts'; | ||||
| ▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | final class PhabricatorUserPreferences | ||||
| public function save() { | public function save() { | ||||
| PhabricatorUserCache::clearCache( | PhabricatorUserCache::clearCache( | ||||
| PhabricatorUserPreferencesCacheType::KEY_PREFERENCES, | PhabricatorUserPreferencesCacheType::KEY_PREFERENCES, | ||||
| $this->getUserPHID()); | $this->getUserPHID()); | ||||
| return parent::save(); | return parent::save(); | ||||
| } | } | ||||
| /** | |||||
| * Load or create a preferences object for the given user. | |||||
| * | |||||
| * @param PhabricatorUser User to load or create preferences for. | |||||
| */ | |||||
| public static function loadUserPreferences(PhabricatorUser $user) { | |||||
| $preferences = id(new PhabricatorUserPreferencesQuery()) | |||||
| ->setViewer($user) | |||||
| ->withUsers(array($user)) | |||||
| ->executeOne(); | |||||
| if ($preferences) { | |||||
| return $preferences; | |||||
| } | |||||
| return id(new self()) | |||||
| ->setUserPHID($user->getPHID()) | |||||
| ->attachUser($user); | |||||
| } | |||||
| public function newTransaction($key, $value) { | |||||
| $setting_property = PhabricatorUserPreferencesTransaction::PROPERTY_SETTING; | |||||
| $xaction_type = PhabricatorUserPreferencesTransaction::TYPE_SETTING; | |||||
| return id(clone $this->getApplicationTransactionTemplate()) | |||||
| ->setTransactionType($xaction_type) | |||||
| ->setMetadataValue($setting_property, $key) | |||||
| ->setNewValue($value); | |||||
| } | |||||
| /* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
| public function getCapabilities() { | public function getCapabilities() { | ||||
| return array( | return array( | ||||
| PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
| ▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines | |||||