Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13991777
D16026.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D16026.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2319,6 +2319,8 @@
'PhabricatorDifferentialManagementWorkflow' => 'applications/differential/management/PhabricatorDifferentialManagementWorkflow.php',
'PhabricatorDifferentialRevisionTestDataGenerator' => 'applications/differential/lipsum/PhabricatorDifferentialRevisionTestDataGenerator.php',
'PhabricatorDiffusionApplication' => 'applications/diffusion/application/PhabricatorDiffusionApplication.php',
+ 'PhabricatorDiffusionBlameSetting' => 'applications/settings/setting/PhabricatorDiffusionBlameSetting.php',
+ 'PhabricatorDiffusionColorSetting' => 'applications/settings/setting/PhabricatorDiffusionColorSetting.php',
'PhabricatorDiffusionConfigOptions' => 'applications/diffusion/config/PhabricatorDiffusionConfigOptions.php',
'PhabricatorDisabledUserController' => 'applications/auth/controller/PhabricatorDisabledUserController.php',
'PhabricatorDisplayPreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorDisplayPreferencesSettingsPanel.php',
@@ -6889,6 +6891,8 @@
'PhabricatorDifferentialManagementWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorDifferentialRevisionTestDataGenerator' => 'PhabricatorTestDataGenerator',
'PhabricatorDiffusionApplication' => 'PhabricatorApplication',
+ 'PhabricatorDiffusionBlameSetting' => 'PhabricatorInternalSetting',
+ 'PhabricatorDiffusionColorSetting' => 'PhabricatorInternalSetting',
'PhabricatorDiffusionConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorDisabledUserController' => 'PhabricatorAuthController',
'PhabricatorDisplayPreferencesSettingsPanel' => 'PhabricatorEditEngineSettingsPanel',
diff --git a/src/applications/diffusion/controller/DiffusionBrowseController.php b/src/applications/diffusion/controller/DiffusionBrowseController.php
--- a/src/applications/diffusion/controller/DiffusionBrowseController.php
+++ b/src/applications/diffusion/controller/DiffusionBrowseController.php
@@ -105,28 +105,31 @@
$path = $drequest->getPath();
- $preferences = $viewer->loadPreferences();
+ $blame_key = PhabricatorDiffusionBlameSetting::SETTINGKEY;
+ $color_key = PhabricatorDiffusionColorSetting::SETTINGKEY;
$show_blame = $request->getBool(
'blame',
- $preferences->getPreference(
- PhabricatorUserPreferences::PREFERENCE_DIFFUSION_BLAME,
- false));
+ $viewer->getUserSetting($blame_key));
+
$show_color = $request->getBool(
'color',
- $preferences->getPreference(
- PhabricatorUserPreferences::PREFERENCE_DIFFUSION_COLOR,
- true));
+ $viewer->getUserSetting($color_key));
$view = $request->getStr('view');
if ($request->isFormPost() && $view != 'raw' && $viewer->isLoggedIn()) {
- $preferences->setPreference(
- PhabricatorUserPreferences::PREFERENCE_DIFFUSION_BLAME,
- $show_blame);
- $preferences->setPreference(
- PhabricatorUserPreferences::PREFERENCE_DIFFUSION_COLOR,
- $show_color);
- $preferences->save();
+ $preferences = PhabricatorUserPreferences::loadUserPreferences($viewer);
+
+ $editor = id(new PhabricatorUserPreferencesEditor())
+ ->setActor($viewer)
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnNoEffect(true)
+ ->setContinueOnMissingFields(true);
+
+ $xactions = array();
+ $xactions[] = $preferences->newTransaction($blame_key, $show_blame);
+ $xactions[] = $preferences->newTransaction($color_key, $show_color);
+ $editor->applyTransactions($preferences, $xactions);
$uri = $request->getRequestURI()
->alter('blame', null)
diff --git a/src/applications/settings/setting/PhabricatorDiffusionBlameSetting.php b/src/applications/settings/setting/PhabricatorDiffusionBlameSetting.php
new file mode 100644
--- /dev/null
+++ b/src/applications/settings/setting/PhabricatorDiffusionBlameSetting.php
@@ -0,0 +1,16 @@
+<?php
+
+final class PhabricatorDiffusionBlameSetting
+ extends PhabricatorInternalSetting {
+
+ const SETTINGKEY = 'diffusion-blame';
+
+ public function getSettingName() {
+ return pht('Diffusion Blame');
+ }
+
+ public function getSettingDefaultValue() {
+ return false;
+ }
+
+}
diff --git a/src/applications/settings/setting/PhabricatorDiffusionColorSetting.php b/src/applications/settings/setting/PhabricatorDiffusionColorSetting.php
new file mode 100644
--- /dev/null
+++ b/src/applications/settings/setting/PhabricatorDiffusionColorSetting.php
@@ -0,0 +1,16 @@
+<?php
+
+final class PhabricatorDiffusionColorSetting
+ extends PhabricatorInternalSetting {
+
+ const SETTINGKEY = 'diffusion-color';
+
+ public function getSettingName() {
+ return pht('Diffusion Color');
+ }
+
+ public function getSettingDefaultValue() {
+ return false;
+ }
+
+}
diff --git a/src/applications/settings/storage/PhabricatorUserPreferences.php b/src/applications/settings/storage/PhabricatorUserPreferences.php
--- a/src/applications/settings/storage/PhabricatorUserPreferences.php
+++ b/src/applications/settings/storage/PhabricatorUserPreferences.php
@@ -24,9 +24,6 @@
const PREFERENCE_VARY_SUBJECT = 'vary-subject';
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_WIDTH = 'nav-width';
const PREFERENCE_APP_TILES = 'app-tiles';
@@ -172,6 +169,34 @@
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 )----------------------------------------- */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 23, 12:47 PM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6719505
Default Alt Text
D16026.diff (6 KB)
Attached To
Mode
D16026: Convert Diffusion blame and color into standard internal settings
Attached
Detach File
Event Timeline
Log In to Comment