@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.

Use EditEngine for Conpherence preferences

Summary: Ref T4103. Only trick here is hiding the panel if Conpherence is not installed.

Test Plan:
- Edited Conpherence preferences.
- Uninstalled Conpherence, saw panel vanish.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4103

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

+23 -58
+1 -1
src/__phutil_library_map__.php
··· 6689 6689 'PhabricatorConfigWelcomeController' => 'PhabricatorConfigController', 6690 6690 'PhabricatorConpherenceApplication' => 'PhabricatorApplication', 6691 6691 'PhabricatorConpherenceNotificationsSetting' => 'PhabricatorSelectSetting', 6692 - 'PhabricatorConpherencePreferencesSettingsPanel' => 'PhabricatorSettingsPanel', 6692 + 'PhabricatorConpherencePreferencesSettingsPanel' => 'PhabricatorEditEngineSettingsPanel', 6693 6693 'PhabricatorConpherenceThreadPHIDType' => 'PhabricatorPHIDType', 6694 6694 'PhabricatorConsoleApplication' => 'PhabricatorApplication', 6695 6695 'PhabricatorConsoleContentSource' => 'PhabricatorContentSource',
+4 -1
src/applications/settings/controller/PhabricatorSettingsMainController.php
··· 80 80 } 81 81 82 82 private function buildPanels() { 83 + $viewer = $this->getViewer(); 83 84 $panels = PhabricatorSettingsPanel::getAllDisplayPanels(); 84 85 85 86 $result = array(); 86 87 foreach ($panels as $key => $panel) { 87 - $panel->setUser($this->user); 88 + $panel 89 + ->setViewer($viewer) 90 + ->setUser($this->user); 88 91 89 92 if (!$panel->isEnabled()) { 90 93 continue;
+2 -56
src/applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php
··· 1 1 <?php 2 2 3 3 final class PhabricatorConpherencePreferencesSettingsPanel 4 - extends PhabricatorSettingsPanel { 4 + extends PhabricatorEditEngineSettingsPanel { 5 5 6 - public function isEnabled() { 7 - return PhabricatorApplication::isClassInstalled( 8 - 'PhabricatorConpherenceApplication'); 9 - } 10 - 11 - public function getPanelKey() { 12 - return 'conpherence'; 13 - } 6 + const PANELKEY = 'conpherence'; 14 7 15 8 public function getPanelName() { 16 9 return pht('Conpherence Preferences'); ··· 18 11 19 12 public function getPanelGroupKey() { 20 13 return PhabricatorSettingsApplicationsPanelGroup::PANELGROUPKEY; 21 - } 22 - 23 - public function processRequest(AphrontRequest $request) { 24 - $user = $request->getUser(); 25 - $preferences = $user->loadPreferences(); 26 - 27 - $pref = PhabricatorUserPreferences::PREFERENCE_CONPH_NOTIFICATIONS; 28 - 29 - if ($request->isFormPost()) { 30 - $notifications = $request->getInt($pref); 31 - $preferences->setPreference($pref, $notifications); 32 - $preferences->save(); 33 - return id(new AphrontRedirectResponse()) 34 - ->setURI($this->getPanelURI('?saved=true')); 35 - } 36 - 37 - $form = id(new AphrontFormView()) 38 - ->setUser($user) 39 - ->appendChild( 40 - id(new AphrontFormSelectControl()) 41 - ->setLabel(pht('Conpherence Notifications')) 42 - ->setName($pref) 43 - ->setValue($preferences->getPreference($pref)) 44 - ->setOptions( 45 - array( 46 - ConpherenceSettings::EMAIL_ALWAYS 47 - => pht('Email Always'), 48 - ConpherenceSettings::NOTIFICATIONS_ONLY 49 - => pht('Notifications Only'), 50 - )) 51 - ->setCaption( 52 - pht( 53 - 'Should Conpherence send emails for updates or '. 54 - 'notifications only? This global setting can be overridden '. 55 - 'on a per-thread basis within Conpherence.'))) 56 - ->appendChild( 57 - id(new AphrontFormSubmitControl()) 58 - ->setValue(pht('Save Preferences'))); 59 - 60 - $form_box = id(new PHUIObjectBoxView()) 61 - ->setHeaderText(pht('Conpherence Preferences')) 62 - ->setForm($form) 63 - ->setFormSaved($request->getBool('saved')); 64 - 65 - return array( 66 - $form_box, 67 - ); 68 14 } 69 15 70 16 }
+6
src/applications/settings/panel/PhabricatorEditEngineSettingsPanel.php
··· 38 38 return $engine->buildResponse(); 39 39 } 40 40 41 + final public function isEnabled() { 42 + // Only enable the panel if it has any fields. 43 + $field_keys = $this->getPanelSettingsKeys(); 44 + return (bool)$field_keys; 45 + } 46 + 41 47 final public function newEditEnginePage() { 42 48 $field_keys = $this->getPanelSettingsKeys(); 43 49 if (!$field_keys) {
+10
src/applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php
··· 12 12 return pht('Conpherence Notifications'); 13 13 } 14 14 15 + public function getSettingPanelKey() { 16 + return PhabricatorConpherencePreferencesSettingsPanel::PANELKEY; 17 + } 18 + 15 19 protected function getControlInstructions() { 16 20 return pht( 17 21 'Choose the default notification behavior for Conpherence rooms.'); 22 + } 23 + 24 + protected function isEnabledForViewer(PhabricatorUser $viewer) { 25 + return PhabricatorApplication::isClassInstalledForViewer( 26 + 'PhabricatorConpherenceApplication', 27 + $viewer); 18 28 } 19 29 20 30 public function getSettingDefaultValue() {