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 @@ -6689,7 +6689,7 @@ 'PhabricatorConfigWelcomeController' => 'PhabricatorConfigController', 'PhabricatorConpherenceApplication' => 'PhabricatorApplication', 'PhabricatorConpherenceNotificationsSetting' => 'PhabricatorSelectSetting', - 'PhabricatorConpherencePreferencesSettingsPanel' => 'PhabricatorSettingsPanel', + 'PhabricatorConpherencePreferencesSettingsPanel' => 'PhabricatorEditEngineSettingsPanel', 'PhabricatorConpherenceThreadPHIDType' => 'PhabricatorPHIDType', 'PhabricatorConsoleApplication' => 'PhabricatorApplication', 'PhabricatorConsoleContentSource' => 'PhabricatorContentSource', diff --git a/src/applications/settings/controller/PhabricatorSettingsMainController.php b/src/applications/settings/controller/PhabricatorSettingsMainController.php --- a/src/applications/settings/controller/PhabricatorSettingsMainController.php +++ b/src/applications/settings/controller/PhabricatorSettingsMainController.php @@ -80,11 +80,14 @@ } private function buildPanels() { + $viewer = $this->getViewer(); $panels = PhabricatorSettingsPanel::getAllDisplayPanels(); $result = array(); foreach ($panels as $key => $panel) { - $panel->setUser($this->user); + $panel + ->setViewer($viewer) + ->setUser($this->user); if (!$panel->isEnabled()) { continue; diff --git a/src/applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php b/src/applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php --- a/src/applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php @@ -1,16 +1,9 @@ getUser(); - $preferences = $user->loadPreferences(); - - $pref = PhabricatorUserPreferences::PREFERENCE_CONPH_NOTIFICATIONS; - - if ($request->isFormPost()) { - $notifications = $request->getInt($pref); - $preferences->setPreference($pref, $notifications); - $preferences->save(); - return id(new AphrontRedirectResponse()) - ->setURI($this->getPanelURI('?saved=true')); - } - - $form = id(new AphrontFormView()) - ->setUser($user) - ->appendChild( - id(new AphrontFormSelectControl()) - ->setLabel(pht('Conpherence Notifications')) - ->setName($pref) - ->setValue($preferences->getPreference($pref)) - ->setOptions( - array( - ConpherenceSettings::EMAIL_ALWAYS - => pht('Email Always'), - ConpherenceSettings::NOTIFICATIONS_ONLY - => pht('Notifications Only'), - )) - ->setCaption( - pht( - 'Should Conpherence send emails for updates or '. - 'notifications only? This global setting can be overridden '. - 'on a per-thread basis within Conpherence.'))) - ->appendChild( - id(new AphrontFormSubmitControl()) - ->setValue(pht('Save Preferences'))); - - $form_box = id(new PHUIObjectBoxView()) - ->setHeaderText(pht('Conpherence Preferences')) - ->setForm($form) - ->setFormSaved($request->getBool('saved')); - - return array( - $form_box, - ); - } - } diff --git a/src/applications/settings/panel/PhabricatorEditEngineSettingsPanel.php b/src/applications/settings/panel/PhabricatorEditEngineSettingsPanel.php --- a/src/applications/settings/panel/PhabricatorEditEngineSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorEditEngineSettingsPanel.php @@ -38,6 +38,12 @@ return $engine->buildResponse(); } + final public function isEnabled() { + // Only enable the panel if it has any fields. + $field_keys = $this->getPanelSettingsKeys(); + return (bool)$field_keys; + } + final public function newEditEnginePage() { $field_keys = $this->getPanelSettingsKeys(); if (!$field_keys) { diff --git a/src/applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php b/src/applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php --- a/src/applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php +++ b/src/applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php @@ -12,11 +12,21 @@ return pht('Conpherence Notifications'); } + public function getSettingPanelKey() { + return PhabricatorConpherencePreferencesSettingsPanel::PANELKEY; + } + protected function getControlInstructions() { return pht( 'Choose the default notification behavior for Conpherence rooms.'); } + protected function isEnabledForViewer(PhabricatorUser $viewer) { + return PhabricatorApplication::isClassInstalledForViewer( + 'PhabricatorConpherenceApplication', + $viewer); + } + public function getSettingDefaultValue() { return self::VALUE_CONPHERENCE_EMAIL; }