Page MenuHomePhabricator

D16018.diff
No OneTemporary

D16018.diff

diff --git a/src/applications/settings/editor/PhabricatorUserPreferencesEditor.php b/src/applications/settings/editor/PhabricatorUserPreferencesEditor.php
--- a/src/applications/settings/editor/PhabricatorUserPreferencesEditor.php
+++ b/src/applications/settings/editor/PhabricatorUserPreferencesEditor.php
@@ -19,6 +19,23 @@
return $types;
}
+ protected function expandTransaction(
+ PhabricatorLiskDAO $object,
+ PhabricatorApplicationTransaction $xaction) {
+
+ $setting_key = $xaction->getMetadataValue(
+ PhabricatorUserPreferencesTransaction::PROPERTY_SETTING);
+
+ $settings = $this->getSettings();
+ $setting = idx($settings, $setting_key);
+ if ($setting) {
+ return $setting->expandSettingTransaction($object, $xaction);
+ }
+
+ return parent::expandTransaction($object, $xaction);
+ }
+
+
protected function getCustomTransactionOldValue(
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
@@ -95,15 +112,7 @@
array $xactions) {
$errors = parent::validateTransaction($object, $type, $xactions);
-
- $actor = $this->getActor();
- $settings = PhabricatorSetting::getAllEnabledSettings($actor);
-
- foreach ($settings as $key => $setting) {
- $setting = clone $setting;
- $setting->setViewer($actor);
- $settings[$key] = $setting;
- }
+ $settings = $this->getSettings();
switch ($type) {
case PhabricatorUserPreferencesTransaction::TYPE_SETTING:
@@ -157,4 +166,17 @@
return $xactions;
}
+ private function getSettings() {
+ $actor = $this->getActor();
+ $settings = PhabricatorSetting::getAllEnabledSettings($actor);
+
+ foreach ($settings as $key => $setting) {
+ $setting = clone $setting;
+ $setting->setViewer($actor);
+ $settings[$key] = $setting;
+ }
+
+ return $settings;
+ }
+
}
diff --git a/src/applications/settings/setting/PhabricatorSetting.php b/src/applications/settings/setting/PhabricatorSetting.php
--- a/src/applications/settings/setting/PhabricatorSetting.php
+++ b/src/applications/settings/setting/PhabricatorSetting.php
@@ -111,4 +111,18 @@
return $value;
}
+ public function expandSettingTransaction($object, $xaction) {
+ return array($xaction);
+ }
+
+ protected function newSettingTransaction($object, $key, $value) {
+ $setting_property = PhabricatorUserPreferencesTransaction::PROPERTY_SETTING;
+ $xaction_type = PhabricatorUserPreferencesTransaction::TYPE_SETTING;
+
+ return id(clone $object->getApplicationTransactionTemplate())
+ ->setTransactionType($xaction_type)
+ ->setMetadataValue($setting_property, $key)
+ ->setNewValue($value);
+ }
+
}
diff --git a/src/applications/settings/setting/PhabricatorTimezoneSetting.php b/src/applications/settings/setting/PhabricatorTimezoneSetting.php
--- a/src/applications/settings/setting/PhabricatorTimezoneSetting.php
+++ b/src/applications/settings/setting/PhabricatorTimezoneSetting.php
@@ -87,4 +87,16 @@
return $option_groups;
}
+ public function expandSettingTransaction($object, $xaction) {
+ // When the user changes their timezone, we also clear any ignored
+ // timezone offset.
+ return array(
+ $xaction,
+ $this->newSettingTransaction(
+ $object,
+ PhabricatorTimezoneIgnoreOffsetSetting::SETTINGKEY,
+ null),
+ );
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Oct 15 2024, 9:44 AM (4 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6712421
Default Alt Text
D16018.diff (3 KB)

Event Timeline