Differential D9375 Diff 24738 src/applications/settings/panel/PhabricatorSettingsPanelEmailFormat.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/settings/panel/PhabricatorSettingsPanelEmailFormat.php
| Show All 16 Lines | final class PhabricatorSettingsPanelEmailFormat | ||||
| public function processRequest(AphrontRequest $request) { | public function processRequest(AphrontRequest $request) { | ||||
| $user = $request->getUser(); | $user = $request->getUser(); | ||||
| $preferences = $user->loadPreferences(); | $preferences = $user->loadPreferences(); | ||||
| $pref_re_prefix = PhabricatorUserPreferences::PREFERENCE_RE_PREFIX; | $pref_re_prefix = PhabricatorUserPreferences::PREFERENCE_RE_PREFIX; | ||||
| $pref_vary = PhabricatorUserPreferences::PREFERENCE_VARY_SUBJECT; | $pref_vary = PhabricatorUserPreferences::PREFERENCE_VARY_SUBJECT; | ||||
| $prefs_html_email = PhabricatorUserPreferences::PREFERENCE_HTML_EMAILS; | |||||
| $errors = array(); | $errors = array(); | ||||
| if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
| if (PhabricatorMetaMTAMail::shouldMultiplexAllMail()) { | if (PhabricatorMetaMTAMail::shouldMultiplexAllMail()) { | ||||
| if ($request->getStr($pref_re_prefix) == 'default') { | if ($request->getStr($pref_re_prefix) == 'default') { | ||||
| $preferences->unsetPreference($pref_re_prefix); | $preferences->unsetPreference($pref_re_prefix); | ||||
| } else { | } else { | ||||
| $preferences->setPreference( | $preferences->setPreference( | ||||
| $pref_re_prefix, | $pref_re_prefix, | ||||
| $request->getBool($pref_re_prefix)); | $request->getBool($pref_re_prefix)); | ||||
| } | } | ||||
| if ($request->getStr($pref_vary) == 'default') { | if ($request->getStr($pref_vary) == 'default') { | ||||
| $preferences->unsetPreference($pref_vary); | $preferences->unsetPreference($pref_vary); | ||||
| } else { | } else { | ||||
| $preferences->setPreference( | $preferences->setPreference( | ||||
| $pref_vary, | $pref_vary, | ||||
| $request->getBool($pref_vary)); | $request->getBool($pref_vary)); | ||||
| } | } | ||||
| if ($request->getStr($prefs_html_email) == 'default') { | |||||
| $preferences->unsetPreference($prefs_html_email); | |||||
| } else { | |||||
| $preferences->setPreference( | |||||
| $prefs_html_email, | |||||
| $request->getBool($prefs_html_email)); | |||||
| } | |||||
| } | } | ||||
| $preferences->save(); | $preferences->save(); | ||||
| return id(new AphrontRedirectResponse()) | return id(new AphrontRedirectResponse()) | ||||
| ->setURI($this->getPanelURI('?saved=true')); | ->setURI($this->getPanelURI('?saved=true')); | ||||
| } | } | ||||
| $re_prefix_default = PhabricatorEnv::getEnvConfig('metamta.re-prefix') | $re_prefix_default = PhabricatorEnv::getEnvConfig('metamta.re-prefix') | ||||
| ? pht('Enabled') | ? pht('Enabled') | ||||
| : pht('Disabled'); | : pht('Disabled'); | ||||
| $vary_default = PhabricatorEnv::getEnvConfig('metamta.vary-subjects') | $vary_default = PhabricatorEnv::getEnvConfig('metamta.vary-subjects') | ||||
| ? pht('Vary') | ? pht('Vary') | ||||
| : pht('Do Not Vary'); | : pht('Do Not Vary'); | ||||
| $html_emails_default = 'Plain Text'; | |||||
| $re_prefix_value = $preferences->getPreference($pref_re_prefix); | $re_prefix_value = $preferences->getPreference($pref_re_prefix); | ||||
| if ($re_prefix_value === null) { | if ($re_prefix_value === null) { | ||||
| $re_prefix_value = 'default'; | $re_prefix_value = 'default'; | ||||
| } else { | } else { | ||||
| $re_prefix_value = $re_prefix_value | $re_prefix_value = $re_prefix_value | ||||
| ? 'true' | ? 'true' | ||||
| : 'false'; | : 'false'; | ||||
| } | } | ||||
| $vary_value = $preferences->getPreference($pref_vary); | $vary_value = $preferences->getPreference($pref_vary); | ||||
| if ($vary_value === null) { | if ($vary_value === null) { | ||||
| $vary_value = 'default'; | $vary_value = 'default'; | ||||
| } else { | } else { | ||||
| $vary_value = $vary_value | $vary_value = $vary_value | ||||
| ? 'true' | ? 'true' | ||||
| : 'false'; | : 'false'; | ||||
| } | } | ||||
| $html_emails_value = $preferences->getPreference($prefs_html_email); | |||||
| if ($html_emails_value === null) { | |||||
| $html_emails_value = 'default'; | |||||
| } else { | |||||
| $html_emails_value = $html_emails_value | |||||
| ? 'true' | |||||
| : 'false'; | |||||
| } | |||||
| $form = new AphrontFormView(); | $form = new AphrontFormView(); | ||||
| $form | $form | ||||
| ->setUser($user); | ->setUser($user); | ||||
| if (PhabricatorMetaMTAMail::shouldMultiplexAllMail()) { | if (PhabricatorMetaMTAMail::shouldMultiplexAllMail()) { | ||||
| $html_email_control = id(new AphrontFormSelectControl()) | |||||
| ->setName($prefs_html_email) | |||||
| ->setOptions( | |||||
| array( | |||||
| 'default' => pht('Default (%s)', $html_emails_default), | |||||
| 'true' => pht('Send HTML Email'), | |||||
| 'false' => pht('Send Plain Text Email'), | |||||
| )) | |||||
| ->setValue($html_emails_value); | |||||
| $re_control = id(new AphrontFormSelectControl()) | $re_control = id(new AphrontFormSelectControl()) | ||||
| ->setName($pref_re_prefix) | ->setName($pref_re_prefix) | ||||
| ->setOptions( | ->setOptions( | ||||
| array( | array( | ||||
| 'default' => pht('Use Server Default (%s)', $re_prefix_default), | 'default' => pht('Use Server Default (%s)', $re_prefix_default), | ||||
| 'true' => pht('Enable "Re:" prefix'), | 'true' => pht('Enable "Re:" prefix'), | ||||
| 'false' => pht('Disable "Re:" prefix'), | 'false' => pht('Disable "Re:" prefix'), | ||||
| )) | )) | ||||
| ->setValue($re_prefix_value); | ->setValue($re_prefix_value); | ||||
| $vary_control = id(new AphrontFormSelectControl()) | $vary_control = id(new AphrontFormSelectControl()) | ||||
| ->setName($pref_vary) | ->setName($pref_vary) | ||||
| ->setOptions( | ->setOptions( | ||||
| array( | array( | ||||
| 'default' => pht('Use Server Default (%s)', $vary_default), | 'default' => pht('Use Server Default (%s)', $vary_default), | ||||
| 'true' => pht('Vary Subjects'), | 'true' => pht('Vary Subjects'), | ||||
| 'false' => pht('Do Not Vary Subjects'), | 'false' => pht('Do Not Vary Subjects'), | ||||
| )) | )) | ||||
| ->setValue($vary_value); | ->setValue($vary_value); | ||||
| } else { | } else { | ||||
| $html_email_control = id(new AphrontFormStaticControl()) | |||||
| ->setValue('Server Default ('.$html_emails_default.')'); | |||||
| $re_control = id(new AphrontFormStaticControl()) | $re_control = id(new AphrontFormStaticControl()) | ||||
| ->setValue('Server Default ('.$re_prefix_default.')'); | ->setValue('Server Default ('.$re_prefix_default.')'); | ||||
| $vary_control = id(new AphrontFormStaticControl()) | $vary_control = id(new AphrontFormStaticControl()) | ||||
| ->setValue('Server Default ('.$vary_default.')'); | ->setValue('Server Default ('.$vary_default.')'); | ||||
| } | } | ||||
| $form | $form | ||||
| ->appendRemarkupInstructions( | ->appendRemarkupInstructions( | ||||
| pht( | pht( | ||||
| 'These settings fine-tune some technical aspects of how email is '. | 'These settings fine-tune some technical aspects of how email is '. | ||||
| 'formatted. You may be able to adjust them to make mail more '. | 'formatted. You may be able to adjust them to make mail more '. | ||||
| 'useful or improve threading.')); | 'useful or improve threading.')); | ||||
| if (!PhabricatorMetaMTAMail::shouldMultiplexAllMail()) { | if (!PhabricatorMetaMTAMail::shouldMultiplexAllMail()) { | ||||
| $form->appendRemarkupInstructions( | $form->appendRemarkupInstructions( | ||||
| pht( | pht( | ||||
| 'NOTE: This install of Phabricator is configured to send a '. | 'NOTE: This install of Phabricator is configured to send a '. | ||||
| 'single mail message to all recipients, so all settings are '. | 'single mail message to all recipients, so all settings are '. | ||||
| 'locked at the server default value.')); | 'locked at the server default value.')); | ||||
| } | } | ||||
| $form | $form | ||||
| ->appendRemarkupInstructions( | |||||
epriestley: Label this control and add explanatory text. | |||||
| pht( | |||||
| "You can use the **HTML Email** setting to control whether ". | |||||
| "Phabricator send you HTML email (which has more color and ". | |||||
| "formatting) or plain text email (which is more compatible).\n". | |||||
| "\n". | |||||
| "WARNING: This feature is new and experimental! If you enable ". | |||||
| "it, mail may not render properly and replying to mail may not ". | |||||
| "work as well.")) | |||||
| ->appendChild( | |||||
| $html_email_control | |||||
| ->setLabel(pht('HTML Email'))) | |||||
| ->appendRemarkupInstructions('') | ->appendRemarkupInstructions('') | ||||
| ->appendRemarkupInstructions( | ->appendRemarkupInstructions( | ||||
| pht( | pht( | ||||
| 'The **Add "Re:" Prefix** setting adds "Re:" in front of all '. | 'The **Add "Re:" Prefix** setting adds "Re:" in front of all '. | ||||
| 'messages, even if they are not replies. If you use **Mail.app** on '. | 'messages, even if they are not replies. If you use **Mail.app** on '. | ||||
| 'Mac OS X, this may improve mail threading.'. | 'Mac OS X, this may improve mail threading.'. | ||||
| "\n\n". | "\n\n". | ||||
| "| Setting | Example Mail Subject\n". | "| Setting | Example Mail Subject\n". | ||||
| ▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines | |||||
Label this control and add explanatory text.