mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
When a user changes their timezone, clear their ignored timezone offset
Summary: Ref T4103. We have a couple of settings like this where changing one setting changes another (e.g., enabling DarkConsole makes the console visible). Provide a mechanism to let changing timezone really mean "change timezone, and also clear the timezone offset". Test Plan: Swapped timezones, reconciled them by ignoring the offset, changed timezone again to another zone with the same offset, got asked to reconcile again. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4103 Differential Revision: https://secure.phabricator.com/D16018
This commit is contained in:
parent
2f936094d8
commit
2725fdf800
3 changed files with 57 additions and 9 deletions
|
@ -19,6 +19,23 @@ final class PhabricatorUserPreferencesEditor
|
||||||
return $types;
|
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(
|
protected function getCustomTransactionOldValue(
|
||||||
PhabricatorLiskDAO $object,
|
PhabricatorLiskDAO $object,
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
|
@ -95,15 +112,7 @@ final class PhabricatorUserPreferencesEditor
|
||||||
array $xactions) {
|
array $xactions) {
|
||||||
|
|
||||||
$errors = parent::validateTransaction($object, $type, $xactions);
|
$errors = parent::validateTransaction($object, $type, $xactions);
|
||||||
|
$settings = $this->getSettings();
|
||||||
$actor = $this->getActor();
|
|
||||||
$settings = PhabricatorSetting::getAllEnabledSettings($actor);
|
|
||||||
|
|
||||||
foreach ($settings as $key => $setting) {
|
|
||||||
$setting = clone $setting;
|
|
||||||
$setting->setViewer($actor);
|
|
||||||
$settings[$key] = $setting;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case PhabricatorUserPreferencesTransaction::TYPE_SETTING:
|
case PhabricatorUserPreferencesTransaction::TYPE_SETTING:
|
||||||
|
@ -157,4 +166,17 @@ final class PhabricatorUserPreferencesEditor
|
||||||
return $xactions;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,4 +111,18 @@ abstract class PhabricatorSetting extends Phobject {
|
||||||
return $value;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,4 +87,16 @@ final class PhabricatorTimezoneSetting
|
||||||
return $option_groups;
|
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),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue