Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/storage/PhabricatorUser.php
| Show First 20 Lines • Show All 499 Lines • ▼ Show 20 Lines | if (array_key_exists($key, $settings)) { | ||||
| // Make sure the value is valid before we return it. This makes things | // Make sure the value is valid before we return it. This makes things | ||||
| // more robust when options are changed or removed. | // more robust when options are changed or removed. | ||||
| if (isset($defaults[$key])) { | if (isset($defaults[$key])) { | ||||
| try { | try { | ||||
| id(clone $defaults[$key]) | id(clone $defaults[$key]) | ||||
| ->setViewer($this) | ->setViewer($this) | ||||
| ->assertValidValue($value); | ->assertValidValue($value); | ||||
| $this->settingCacheKeys[$key] = true; | return $this->writeUserSettingCache($key, $value); | ||||
| $this->settingCache[$key] = $value; | |||||
| return $value; | |||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| // Fall through below and return the default value. | // Fall through below and return the default value. | ||||
| } | } | ||||
| } else { | |||||
| // This is an ad-hoc setting with no controlling object. | |||||
| return $this->writeUserSettingCache($key, $value); | |||||
| } | } | ||||
| } | } | ||||
| if (isset($defaults[$key])) { | if (isset($defaults[$key])) { | ||||
| $value = id(clone $defaults[$key]) | $value = id(clone $defaults[$key]) | ||||
| ->setViewer($this) | ->setViewer($this) | ||||
| ->getSettingDefaultValue(); | ->getSettingDefaultValue(); | ||||
| } else { | } else { | ||||
| $value = null; | $value = null; | ||||
| } | } | ||||
| $this->settingCacheKeys[$key] = true; | return $this->writeUserSettingCache($key, $value); | ||||
| $this->settingCache[$key] = $value; | |||||
| return $value; | |||||
| } | } | ||||
| /** | /** | ||||
| * Test if a given setting is set to a particular value. | * Test if a given setting is set to a particular value. | ||||
| * | * | ||||
| * @param const Setting key. | * @param const Setting key. | ||||
| * @param wild Value to compare. | * @param wild Value to compare. | ||||
| Show All 14 Lines | public function clearUserSettingCache() { | ||||
| $this->settingCache = array(); | $this->settingCache = array(); | ||||
| $settings_key = PhabricatorUserPreferencesCacheType::KEY_PREFERENCES; | $settings_key = PhabricatorUserPreferencesCacheType::KEY_PREFERENCES; | ||||
| $this->clearCacheData($settings_key); | $this->clearCacheData($settings_key); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| private function writeUserSettingCache($key, $value) { | |||||
| $this->settingCacheKeys[$key] = true; | |||||
| $this->settingCache[$key] = $value; | |||||
| return $value; | |||||
| } | |||||
| 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); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,025 Lines • Show Last 20 Lines | |||||