Differential D16027 Diff 38579 src/applications/policy/controller/PhabricatorPolicyEditController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/policy/controller/PhabricatorPolicyEditController.php
| Show First 20 Lines • Show All 275 Lines • ▼ Show 20 Lines | if ($request->isFormPost()) { | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withPHIDs(array($project_phid)) | ->withPHIDs(array($project_phid)) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| if ($project) { | if ($project) { | ||||
| // Save this project as one of the user's most recently used projects, | // Save this project as one of the user's most recently used projects, | ||||
| // so we'll show it by default in future menus. | // so we'll show it by default in future menus. | ||||
| $pref_key = PhabricatorUserPreferences::PREFERENCE_FAVORITE_POLICIES; | $favorites_key = PhabricatorPolicyFavoritesSetting::SETTINGKEY; | ||||
| $favorites = $viewer->getUserSetting($favorites_key); | |||||
| $preferences = $viewer->loadPreferences(); | |||||
| $favorites = $preferences->getPreference($pref_key); | |||||
| if (!is_array($favorites)) { | if (!is_array($favorites)) { | ||||
| $favorites = array(); | $favorites = array(); | ||||
| } | } | ||||
| // Add this, or move it to the end of the list. | // Add this, or move it to the end of the list. | ||||
| unset($favorites[$project_phid]); | unset($favorites[$project_phid]); | ||||
| $favorites[$project_phid] = true; | $favorites[$project_phid] = true; | ||||
| $preferences->setPreference($pref_key, $favorites); | $preferences = PhabricatorUserPreferences::loadUserPreferences($viewer); | ||||
| $preferences->save(); | |||||
| $editor = id(new PhabricatorUserPreferencesEditor()) | |||||
| ->setActor($viewer) | |||||
| ->setContentSourceFromRequest($request) | |||||
| ->setContinueOnNoEffect(true) | |||||
| ->setContinueOnMissingFields(true); | |||||
| $xactions = array(); | |||||
| $xactions[] = $preferences->newTransaction($favorites_key, $favorites); | |||||
| $editor->applyTransactions($preferences, $xactions); | |||||
| $data = array( | $data = array( | ||||
| 'phid' => $project->getPHID(), | 'phid' => $project->getPHID(), | ||||
| 'info' => array( | 'info' => array( | ||||
| 'name' => $project->getName(), | 'name' => $project->getName(), | ||||
| 'full' => $project->getName(), | 'full' => $project->getName(), | ||||
| 'icon' => $project->getDisplayIconIcon(), | 'icon' => $project->getDisplayIconIcon(), | ||||
| ), | ), | ||||
| Show All 35 Lines | |||||