Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/storage/PhabricatorUser.php
Show First 20 Lines • Show All 481 Lines • ▼ Show 20 Lines | public function getUserSetting($key) { | ||||
if (isset($this->settingCacheKeys[$key])) { | if (isset($this->settingCacheKeys[$key])) { | ||||
return $this->settingCache[$key]; | return $this->settingCache[$key]; | ||||
} | } | ||||
$settings_key = PhabricatorUserPreferencesCacheType::KEY_PREFERENCES; | $settings_key = PhabricatorUserPreferencesCacheType::KEY_PREFERENCES; | ||||
if ($this->getPHID()) { | if ($this->getPHID()) { | ||||
$settings = $this->requireCacheData($settings_key); | $settings = $this->requireCacheData($settings_key); | ||||
} else { | } else { | ||||
$settings = array(); | $settings = $this->loadGlobalSettings(); | ||||
} | } | ||||
// NOTE: To slightly improve performance, we're using all settings here, | // NOTE: To slightly improve performance, we're using all settings here, | ||||
// not just settings that are enabled for the current viewer. It's fine to | // not just settings that are enabled for the current viewer. It's fine to | ||||
// get the value of a setting that we wouldn't let the user edit in the UI. | // get the value of a setting that we wouldn't let the user edit in the UI. | ||||
$defaults = PhabricatorSetting::getAllSettings(); | $defaults = PhabricatorSetting::getAllSettings(); | ||||
if (array_key_exists($key, $settings)) { | if (array_key_exists($key, $settings)) { | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | /* -( Settings )----------------------------------------------------------- */ | ||||
public function getTranslation() { | public function getTranslation() { | ||||
return $this->getUserSetting(PhabricatorTranslationSetting::SETTINGKEY); | return $this->getUserSetting(PhabricatorTranslationSetting::SETTINGKEY); | ||||
} | } | ||||
public function getTimezoneIdentifier() { | public function getTimezoneIdentifier() { | ||||
return $this->getUserSetting(PhabricatorTimezoneSetting::SETTINGKEY); | return $this->getUserSetting(PhabricatorTimezoneSetting::SETTINGKEY); | ||||
} | } | ||||
private function loadGlobalSettings() { | |||||
$cache_key = 'user.settings.global'; | |||||
$cache = PhabricatorCaches::getRequestCache(); | |||||
$settings = $cache->getKey($cache_key); | |||||
if ($settings === null) { | |||||
$preferences = PhabricatorUserPreferences::loadGlobalPreferences($this); | |||||
$settings = $preferences->getPreferences(); | |||||
$cache->setKey($cache_key, $settings); | |||||
} | |||||
return $settings; | |||||
} | |||||
/** | /** | ||||
* Override the user's timezone identifier. | * Override the user's timezone identifier. | ||||
* | * | ||||
* This is primarily useful for unit tests. | * This is primarily useful for unit tests. | ||||
* | * | ||||
* @param string New timezone identifier. | * @param string New timezone identifier. | ||||
* @return this | * @return this | ||||
▲ Show 20 Lines • Show All 952 Lines • Show Last 20 Lines |