Page MenuHomePhabricator

D16022.diff
No OneTemporary

D16022.diff

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 @@
<?php
final class PhabricatorConpherencePreferencesSettingsPanel
- extends PhabricatorSettingsPanel {
+ extends PhabricatorEditEngineSettingsPanel {
- public function isEnabled() {
- return PhabricatorApplication::isClassInstalled(
- 'PhabricatorConpherenceApplication');
- }
-
- public function getPanelKey() {
- return 'conpherence';
- }
+ const PANELKEY = 'conpherence';
public function getPanelName() {
return pht('Conpherence Preferences');
@@ -20,51 +13,4 @@
return PhabricatorSettingsApplicationsPanelGroup::PANELGROUPKEY;
}
- public function processRequest(AphrontRequest $request) {
- $user = $request->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;
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 15, 3:47 AM (6 d, 17 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7223140
Default Alt Text
D16022.diff (5 KB)

Event Timeline