@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Modernize "favorite project policies" setting

Summary:
Ref T4103. Convert this into a proper internal setting and use transactions to mutate it.

Also remove some no-longer-used old non-modular settings constants.

Test Plan:
- Used policy dropdown, saw recently-used projects.
- Selected some new projects, saw them appear.
- Grepped for all removed constants.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4103

Differential Revision: https://secure.phabricator.com/D16027

+33 -37
+2
src/__phutil_library_map__.php
··· 3031 3031 'PhabricatorPolicyEditField' => 'applications/transactions/editfield/PhabricatorPolicyEditField.php', 3032 3032 'PhabricatorPolicyException' => 'applications/policy/exception/PhabricatorPolicyException.php', 3033 3033 'PhabricatorPolicyExplainController' => 'applications/policy/controller/PhabricatorPolicyExplainController.php', 3034 + 'PhabricatorPolicyFavoritesSetting' => 'applications/settings/setting/PhabricatorPolicyFavoritesSetting.php', 3034 3035 'PhabricatorPolicyFilter' => 'applications/policy/filter/PhabricatorPolicyFilter.php', 3035 3036 'PhabricatorPolicyInterface' => 'applications/policy/interface/PhabricatorPolicyInterface.php', 3036 3037 'PhabricatorPolicyManagementShowWorkflow' => 'applications/policy/management/PhabricatorPolicyManagementShowWorkflow.php', ··· 7706 7707 'PhabricatorPolicyEditField' => 'PhabricatorEditField', 7707 7708 'PhabricatorPolicyException' => 'Exception', 7708 7709 'PhabricatorPolicyExplainController' => 'PhabricatorPolicyController', 7710 + 'PhabricatorPolicyFavoritesSetting' => 'PhabricatorInternalSetting', 7709 7711 'PhabricatorPolicyFilter' => 'Phobject', 7710 7712 'PhabricatorPolicyInterface' => 'PhabricatorPHIDInterface', 7711 7713 'PhabricatorPolicyManagementShowWorkflow' => 'PhabricatorPolicyManagementWorkflow',
-9
src/applications/people/storage/PhabricatorUser.php
··· 606 606 $preferences = new PhabricatorUserPreferences(); 607 607 $preferences->setUserPHID($this->getPHID()); 608 608 $preferences->attachUser($this); 609 - 610 - $default_dict = array( 611 - PhabricatorUserPreferences::PREFERENCE_TITLES => 'glyph', 612 - PhabricatorUserPreferences::PREFERENCE_EDITOR => '', 613 - PhabricatorUserPreferences::PREFERENCE_MONOSPACED => '', 614 - PhabricatorUserPreferences::PREFERENCE_DARK_CONSOLE => 0, 615 - ); 616 - 617 - $preferences->setPreferences($default_dict); 618 609 } 619 610 620 611 $this->preferences = $preferences;
+13 -6
src/applications/policy/controller/PhabricatorPolicyEditController.php
··· 281 281 // Save this project as one of the user's most recently used projects, 282 282 // so we'll show it by default in future menus. 283 283 284 - $pref_key = PhabricatorUserPreferences::PREFERENCE_FAVORITE_POLICIES; 285 - 286 - $preferences = $viewer->loadPreferences(); 287 - $favorites = $preferences->getPreference($pref_key); 284 + $favorites_key = PhabricatorPolicyFavoritesSetting::SETTINGKEY; 285 + $favorites = $viewer->getUserSetting($favorites_key); 288 286 if (!is_array($favorites)) { 289 287 $favorites = array(); 290 288 } ··· 293 291 unset($favorites[$project_phid]); 294 292 $favorites[$project_phid] = true; 295 293 296 - $preferences->setPreference($pref_key, $favorites); 297 - $preferences->save(); 294 + $preferences = PhabricatorUserPreferences::loadUserPreferences($viewer); 295 + 296 + $editor = id(new PhabricatorUserPreferencesEditor()) 297 + ->setActor($viewer) 298 + ->setContentSourceFromRequest($request) 299 + ->setContinueOnNoEffect(true) 300 + ->setContinueOnMissingFields(true); 301 + 302 + $xactions = array(); 303 + $xactions[] = $preferences->newTransaction($favorites_key, $favorites); 304 + $editor->applyTransactions($preferences, $xactions); 298 305 299 306 $data = array( 300 307 'phid' => $project->getPHID(),
+1 -1
src/applications/policy/query/PhabricatorPolicyQuery.php
··· 195 195 $viewer = $this->getViewer(); 196 196 197 197 if ($viewer->getPHID()) { 198 - $pref_key = PhabricatorUserPreferences::PREFERENCE_FAVORITE_POLICIES; 198 + $pref_key = PhabricatorPolicyFavoritesSetting::SETTINGKEY; 199 199 200 200 $favorite_limit = 10; 201 201 $default_limit = 5;
+16
src/applications/settings/setting/PhabricatorPolicyFavoritesSetting.php
··· 1 + <?php 2 + 3 + final class PhabricatorPolicyFavoritesSetting 4 + extends PhabricatorInternalSetting { 5 + 6 + const SETTINGKEY = 'policy.favorites'; 7 + 8 + public function getSettingName() { 9 + return pht('Policy Favorites'); 10 + } 11 + 12 + public function getSettingDefaultValue() { 13 + return array(); 14 + } 15 + 16 + }
-20
src/applications/settings/storage/PhabricatorUserPreferences.php
··· 7 7 PhabricatorDestructibleInterface, 8 8 PhabricatorApplicationTransactionInterface { 9 9 10 - const PREFERENCE_MONOSPACED = 'monospaced'; 11 - const PREFERENCE_DARK_CONSOLE = 'dark_console'; 12 - const PREFERENCE_EDITOR = 'editor'; 13 - const PREFERENCE_MULTIEDIT = 'multiedit'; 14 - const PREFERENCE_TITLES = 'titles'; 15 - const PREFERENCE_MONOSPACED_TEXTAREAS = 'monospaced-textareas'; 16 - const PREFERENCE_DATE_FORMAT = 'date-format'; 17 - const PREFERENCE_TIME_FORMAT = 'time-format'; 18 - const PREFERENCE_WEEK_START_DAY = 'week-start-day'; 19 - 20 10 const PREFERENCE_RE_PREFIX = 're-prefix'; 21 11 const PREFERENCE_NO_SELF_MAIL = 'self-mail'; 22 12 const PREFERENCE_NO_MAIL = 'no-mail'; ··· 25 15 const PREFERENCE_HTML_EMAILS = 'html-emails'; 26 16 27 17 const PREFERENCE_NAV_COLLAPSED = 'nav-collapsed'; 28 - const PREFERENCE_NAV_WIDTH = 'nav-width'; 29 18 const PREFERENCE_APP_TILES = 'app-tiles'; 30 19 const PREFERENCE_APP_PINNED = 'app-pinned'; 31 20 32 - const PREFERENCE_DIFF_UNIFIED = 'diff-unified'; 33 - const PREFERENCE_DIFF_FILETREE = 'diff-filetree'; 34 - const PREFERENCE_DIFF_GHOSTS = 'diff-ghosts'; 35 - 36 - const PREFERENCE_CONPH_NOTIFICATIONS = 'conph-notifications'; 37 21 const PREFERENCE_CONPHERENCE_COLUMN = 'conpherence-column'; 38 - 39 - const PREFERENCE_RESOURCE_POSTPROCESSOR = 'resource-postprocessor'; 40 22 const PREFERENCE_DESKTOP_NOTIFICATIONS = 'desktop-notifications'; 41 - 42 23 const PREFERENCE_PROFILE_MENU_COLLAPSED = 'profile-menu.collapsed'; 43 - const PREFERENCE_FAVORITE_POLICIES = 'policy.favorites'; 44 24 45 25 // These are in an unusual order for historic reasons. 46 26 const MAILTAG_PREFERENCE_NOTIFY = 0;
+1 -1
src/view/phui/calendar/PHUICalendarMonthView.php
··· 575 575 576 576 private function getWeekStartAndEnd() { 577 577 $viewer = $this->getViewer(); 578 - $week_key = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY; 578 + $week_key = PhabricatorWeekStartDaySetting::SETTINGKEY; 579 579 580 580 $week_start = $viewer->getUserSetting($week_key); 581 581 $week_end = ($week_start + 6) % 7;