diff --git a/resources/sql/autopatches/20140722.appname.php b/resources/sql/autopatches/20140722.appname.php --- a/resources/sql/autopatches/20140722.appname.php +++ b/resources/sql/autopatches/20140722.appname.php @@ -74,35 +74,9 @@ /* -( User preferences )--------------------------------------------------- */ -echo pht('Migrating user preferences...')."\n"; -$table = new PhabricatorUserPreferences(); -$conn_w = $table->establishConnection('w'); -$pref_pinned = PhabricatorUserPreferences::PREFERENCE_APP_PINNED; - -foreach (new LiskMigrationIterator(new PhabricatorUser()) as $user) { - $user_preferences = $user->loadPreferences(); - - $old_pinned_apps = $user_preferences->getPreference($pref_pinned); - $new_pinned_apps = array(); - if (!$old_pinned_apps) { - continue; - } - - foreach ($old_pinned_apps as $pinned_app) { - $new_pinned_apps[] = idx($map, $pinned_app, $pinned_app); - } - - $user_preferences - ->setPreference($pref_pinned, $new_pinned_apps); - - queryfx( - $conn_w, - 'UPDATE %T SET preferences = %s WHERE id = %d', - $user_preferences->getTableName(), - json_encode($user_preferences->getPreferences()), - $user_preferences->getID()); -} +// This originally migrated pinned applications in user preferences, but was +// removed to simplify preference changes after about 22 months. /* -( Dashboard installs )------------------------------------------------- */ diff --git a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php --- a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php @@ -151,10 +151,9 @@ $display_start = $start_day->format('U'); $display_end = $next->format('U'); - $preferences = $viewer->loadPreferences(); - $pref_week_day = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY; + $start_of_week = $viewer->getUserSetting( + PhabricatorWeekStartDaySetting::SETTINGKEY); - $start_of_week = $preferences->getPreference($pref_week_day, 0); $end_of_week = ($start_of_week + 6) % 7; $first_of_month = $start_day->format('w'); diff --git a/src/applications/config/controller/PhabricatorConfigWelcomeController.php b/src/applications/config/controller/PhabricatorConfigWelcomeController.php --- a/src/applications/config/controller/PhabricatorConfigWelcomeController.php +++ b/src/applications/config/controller/PhabricatorConfigWelcomeController.php @@ -141,8 +141,14 @@ $content); $settings_href = PhabricatorEnv::getURI('/settings/'); - $prefs = $viewer->loadPreferences()->getPreferences(); - $have_settings = !empty($prefs); + + $preferences = id(new PhabricatorUserPreferencesQuery()) + ->setViewer($viewer) + ->withUsers(array($viewer)) + ->executeOne(); + + $have_settings = ($preferences && $preferences->getPreferences()); + if ($have_settings) { $content = pht( "=== Adjust Account Settings ===\n\n". diff --git a/src/applications/conpherence/view/ConpherenceThreadListView.php b/src/applications/conpherence/view/ConpherenceThreadListView.php --- a/src/applications/conpherence/view/ConpherenceThreadListView.php +++ b/src/applications/conpherence/view/ConpherenceThreadListView.php @@ -72,14 +72,6 @@ $epoch = $data['epoch']; $image = $data['image']; $dom_id = $thread->getPHID().'-nav-item'; - $glyph_pref = PhabricatorUserPreferences::PREFERENCE_TITLES; - $preferences = $user->loadPreferences(); - if ($preferences->getPreference($glyph_pref) == 'glyph') { - $glyph = id(new PhabricatorConpherenceApplication()) - ->getTitleGlyph().' '; - } else { - $glyph = null; - } return id(new ConpherenceMenuItemView()) ->setUser($user) @@ -93,7 +85,7 @@ ->addSigil('conpherence-menu-click') ->setMetadata( array( - 'title' => $glyph.$data['title'], + 'title' => $data['title'], 'id' => $dom_id, 'threadID' => $thread->getID(), )); diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php --- a/src/applications/differential/controller/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/DifferentialRevisionViewController.php @@ -375,18 +375,19 @@ $crumbs->addTextCrumb($object_id, '/'.$object_id); $crumbs->setBorder(true); - $prefs = $viewer->loadPreferences(); - $pref_filetree = PhabricatorUserPreferences::PREFERENCE_DIFF_FILETREE; + $filetree_on = $viewer->compareUserSetting( + PhabricatorShowFiletreeSetting::SETTINGKEY, + PhabricatorShowFiletreeSetting::VALUE_ENABLE_FILETREE); + $nav = null; - if ($prefs->getPreference($pref_filetree)) { - $collapsed = $prefs->getPreference( - PhabricatorUserPreferences::PREFERENCE_NAV_COLLAPSED, - false); + if ($filetree_on) { + $collapsed_key = PhabricatorUserPreferences::PREFERENCE_NAV_COLLAPSED; + $collapsed_value = $viewer->getUserSetting($collapsed_key); $nav = id(new DifferentialChangesetFileTreeSideNavBuilder()) ->setTitle('D'.$revision->getID()) ->setBaseURI(new PhutilURI('/D'.$revision->getID())) - ->setCollapsed((bool)$collapsed) + ->setCollapsed((bool)$collapsed_value) ->build($changesets); } diff --git a/src/applications/differential/parser/DifferentialChangesetParser.php b/src/applications/differential/parser/DifferentialChangesetParser.php --- a/src/applications/differential/parser/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/DifferentialChangesetParser.php @@ -150,11 +150,14 @@ } public static function getDefaultRendererForViewer(PhabricatorUser $viewer) { - $prefs = $viewer->loadPreferences(); - $pref_unified = PhabricatorUserPreferences::PREFERENCE_DIFF_UNIFIED; - if ($prefs->getPreference($pref_unified) == 'unified') { + $is_unified = $viewer->compareUserSetting( + PhabricatorUnifiedDiffsSetting::SETTINGKEY, + PhabricatorUnifiedDiffsSetting::VALUE_ALWAYS_UNIFIED); + + if ($is_unified) { return '1up'; } + return null; } diff --git a/src/applications/differential/query/DifferentialInlineCommentQuery.php b/src/applications/differential/query/DifferentialInlineCommentQuery.php --- a/src/applications/differential/query/DifferentialInlineCommentQuery.php +++ b/src/applications/differential/query/DifferentialInlineCommentQuery.php @@ -175,9 +175,10 @@ $viewer = $this->getViewer(); - $pref = $viewer->loadPreferences()->getPreference( - PhabricatorUserPreferences::PREFERENCE_DIFF_GHOSTS); - if ($pref == 'disabled') { + $no_ghosts = $viewer->compareUserSetting( + PhabricatorOlderInlinesSetting::SETTINGKEY, + PhabricatorOlderInlinesSetting::VALUE_GHOST_INLINES_DISABLED); + if ($no_ghosts) { return $inlines; } diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -325,14 +325,15 @@ $add_comment = $this->renderAddCommentPanel($commit, $audit_requests); - $prefs = $viewer->loadPreferences(); - $pref_filetree = PhabricatorUserPreferences::PREFERENCE_DIFF_FILETREE; + $filetree_on = $viewer->compareUserSetting( + PhabricatorShowFiletreeSetting::SETTINGKEY, + PhabricatorShowFiletreeSetting::VALUE_ENABLE_FILETREE); + $pref_collapse = PhabricatorUserPreferences::PREFERENCE_NAV_COLLAPSED; - $show_filetree = $prefs->getPreference($pref_filetree); - $collapsed = $prefs->getPreference($pref_collapse); + $collapsed = $viewer->getUserSetting($pref_collapse); $nav = null; - if ($show_changesets && $show_filetree) { + if ($show_changesets && $filetree_on) { $nav = id(new DifferentialChangesetFileTreeSideNavBuilder()) ->setTitle($commit->getDisplayName()) ->setBaseURI(new PhutilURI($commit->getURI())) diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php --- a/src/applications/people/storage/PhabricatorUser.php +++ b/src/applications/people/storage/PhabricatorUser.php @@ -506,6 +506,11 @@ return null; } + public function compareUserSetting($key, $value) { + $actual = $this->getUserSetting($key); + return ($actual == $value); + } + public function loadPreferences() { if ($this->preferences) { return $this->preferences; diff --git a/src/applications/policy/query/PhabricatorPolicyQuery.php b/src/applications/policy/query/PhabricatorPolicyQuery.php --- a/src/applications/policy/query/PhabricatorPolicyQuery.php +++ b/src/applications/policy/query/PhabricatorPolicyQuery.php @@ -201,8 +201,7 @@ $default_limit = 5; // If possible, show the user's 10 most recently used projects. - $preferences = $viewer->loadPreferences(); - $favorites = $preferences->getPreference($pref_key); + $favorites = $viewer->getUserSetting($pref_key); if (!is_array($favorites)) { $favorites = array(); } diff --git a/src/applications/search/engine/PhabricatorProfilePanelEngine.php b/src/applications/search/engine/PhabricatorProfilePanelEngine.php --- a/src/applications/search/engine/PhabricatorProfilePanelEngine.php +++ b/src/applications/search/engine/PhabricatorProfilePanelEngine.php @@ -385,8 +385,7 @@ $collapse_key = PhabricatorUserPreferences::PREFERENCE_PROFILE_MENU_COLLAPSED; - $preferences = $viewer->loadPreferences(); - $is_collapsed = $preferences->getPreference($collapse_key, false); + $is_collapsed = $viewer->getUserSetting($collapse_key); if ($is_collapsed) { $nav->addClass('phui-profile-menu-collapsed'); diff --git a/src/view/form/control/PhabricatorRemarkupControl.php b/src/view/form/control/PhabricatorRemarkupControl.php --- a/src/view/form/control/PhabricatorRemarkupControl.php +++ b/src/view/form/control/PhabricatorRemarkupControl.php @@ -260,15 +260,14 @@ ), $buttons); - $monospaced_textareas = null; - $monospaced_textareas_class = null; - - $monospaced_textareas = $viewer - ->loadPreferences() - ->getPreference( - PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS); - if ($monospaced_textareas == 'enabled') { + $use_monospaced = $viewer->compareUserSetting( + PhabricatorMonospacedTextareasSetting::SETTINGKEY, + PhabricatorMonospacedTextareasSetting::VALUE_TEXT_MONOSPACED); + + if ($use_monospaced) { $monospaced_textareas_class = 'PhabricatorMonospaced'; + } else { + $monospaced_textareas_class = null; } $this->setCustomClass( diff --git a/src/view/page/PhabricatorStandardPageView.php b/src/view/page/PhabricatorStandardPageView.php --- a/src/view/page/PhabricatorStandardPageView.php +++ b/src/view/page/PhabricatorStandardPageView.php @@ -133,7 +133,7 @@ public function getDurableColumnVisible() { $column_key = PhabricatorUserPreferences::PREFERENCE_CONPHERENCE_COLUMN; - return (bool)$this->getUserPreference($column_key, 0); + return (bool)$this->getUserPreference($column_key, false); } public function addQuicksandConfig(array $config) { @@ -164,12 +164,11 @@ } public function getTitle() { - $glyph_key = PhabricatorUserPreferences::PREFERENCE_TITLES; - if ($this->getUserPreference($glyph_key) == 'text') { - $use_glyph = false; - } else { - $use_glyph = true; - } + $glyph_key = PhabricatorTitleGlyphsSetting::SETTINGKEY; + $glyph_on = PhabricatorTitleGlyphsSetting::VALUE_TITLE_GLYPHS; + $glyph_setting = $this->getUserPreference($glyph_key, $glyph_on); + + $use_glyph = ($glyph_setting == $glyph_on); $title = parent::getTitle(); @@ -362,8 +361,8 @@ if ($request) { $user = $request->getUser(); if ($user) { - $monospaced = $user->loadPreferences()->getPreference( - PhabricatorUserPreferences::PREFERENCE_MONOSPACED); + $monospaced = $user->getUserSetting( + PhabricatorMonospacedFontSetting::SETTINGKEY); } } @@ -834,7 +833,7 @@ return $default; } - return $user->loadPreferences()->getPreference($key, $default); + return $user->getUserSetting($key); } public function produceAphrontResponse() { diff --git a/src/view/phui/calendar/PHUICalendarMonthView.php b/src/view/phui/calendar/PHUICalendarMonthView.php --- a/src/view/phui/calendar/PHUICalendarMonthView.php +++ b/src/view/phui/calendar/PHUICalendarMonthView.php @@ -574,10 +574,10 @@ } private function getWeekStartAndEnd() { - $preferences = $this->getViewer()->loadPreferences(); - $pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY; + $viewer = $this->getViewer(); + $week_key = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY; - $week_start = $preferences->getPreference($pref_week_start, 0); + $week_start = $viewer->getUserSetting($week_key); $week_end = ($week_start + 6) % 7; return array($week_start, $week_end);