'. + 'You can customize what mail you receive from Phabricator here.'. + '
'. + ''. + 'NOTE: If an update makes several changes (like '. + 'adding CCs to a task, closing it, and adding a comment) you will '. + 'still receive an email as long as at least one of the changes '. + 'is set to notify you.'. + '
' + ); + + $mailtags = $preferences->getPreference('mailtags', array()); + + $form + ->appendChild( + $this->buildMailTagCheckboxes( + $this->getDifferentialMailTags(), + $mailtags) + ->setLabel('Differential')) + ->appendChild( + $this->buildMailTagCheckboxes( + $this->getManiphestMailTags(), + $mailtags) + ->setLabel('Maniphest')); + $form ->appendChild( id(new AphrontFormSubmitControl()) - ->setValue('Save')); + ->setValue('Save Preferences')); $panel = new AphrontPanelView(); $panel->setHeader('Email Preferences'); @@ -122,4 +158,55 @@ class PhabricatorUserEmailPreferenceSettingsPanelController $panel, )); } + + private function getMailTags() { + return array( + MetaMTANotificationType::TYPE_DIFFERENTIAL_CC => + "Send me email when a revision's CCs change.", + MetaMTANotificationType::TYPE_DIFFERENTIAL_COMMITTED => + "Send me email when a revision is committed.", + MetaMTANotificationType::TYPE_MANIPHEST_PROJECTS => + "Send me email when a task's associated projects change.", + MetaMTANotificationType::TYPE_MANIPHEST_PRIORITY => + "Send me email when a task's priority changes.", + MetaMTANotificationType::TYPE_MANIPHEST_CC => + "Send me email when a task's CCs change.", + ); + } + + private function getManiphestMailTags() { + return array_select_keys( + $this->getMailTags(), + array( + MetaMTANotificationType::TYPE_MANIPHEST_PROJECTS, + MetaMTANotificationType::TYPE_MANIPHEST_PRIORITY, + MetaMTANotificationType::TYPE_MANIPHEST_CC, + )); + } + + private function getDifferentialMailTags() { + return array_select_keys( + $this->getMailTags(), + array( + MetaMTANotificationType::TYPE_DIFFERENTIAL_CC, + MetaMTANotificationType::TYPE_DIFFERENTIAL_COMMITTED, + )); + } + + private function buildMailTagCheckboxes( + array $tags, + array $prefs) { + + $control = new AphrontFormCheckboxControl(); + foreach ($tags as $key => $label) { + $control->addCheckbox( + 'mailtags['.$key.']', + 1, + $label, + idx($prefs, $key, 1)); + } + + return $control; + } + } diff --git a/src/applications/people/controller/settings/panels/emailpref/__init__.php b/src/applications/people/controller/settings/panels/emailpref/__init__.php index 8a7376d88d..c6bf80fd00 100644 --- a/src/applications/people/controller/settings/panels/emailpref/__init__.php +++ b/src/applications/people/controller/settings/panels/emailpref/__init__.php @@ -7,10 +7,12 @@ phutil_require_module('phabricator', 'aphront/response/redirect'); +phutil_require_module('phabricator', 'applications/metamta/constants/notificationtype'); phutil_require_module('phabricator', 'applications/people/controller/settings/panels/base'); phutil_require_module('phabricator', 'applications/people/storage/preferences'); phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'view/form/base'); +phutil_require_module('phabricator', 'view/form/control/checkbox'); phutil_require_module('phabricator', 'view/form/control/select'); phutil_require_module('phabricator', 'view/form/control/submit'); phutil_require_module('phabricator', 'view/form/error'); diff --git a/src/applications/people/storage/preferences/PhabricatorUserPreferences.php b/src/applications/people/storage/preferences/PhabricatorUserPreferences.php index 193aca39e4..89aa6c9780 100644 --- a/src/applications/people/storage/preferences/PhabricatorUserPreferences.php +++ b/src/applications/people/storage/preferences/PhabricatorUserPreferences.php @@ -24,6 +24,7 @@ class PhabricatorUserPreferences extends PhabricatorUserDAO { const PREFERENCE_RE_PREFIX = 're-prefix'; const PREFERENCE_NO_SELF_MAIL = 'self-mail'; + const PREFERENCE_MAILTAGS = 'mailtags'; protected $userPHID; protected $preferences = array();