diff --git a/src/applications/metamta/constants/MetaMTANotificationType.php b/src/applications/metamta/constants/MetaMTANotificationType.php index a50b9d0f41..b97477ea95 100644 --- a/src/applications/metamta/constants/MetaMTANotificationType.php +++ b/src/applications/metamta/constants/MetaMTANotificationType.php @@ -19,4 +19,9 @@ final class MetaMTANotificationType const TYPE_MANIPHEST_COMMENT = 'maniphest-comment'; const TYPE_MANIPHEST_OTHER = 'maniphest-other'; + const TYPE_PHOLIO_STATUS = 'pholio-status'; + const TYPE_PHOLIO_COMMENT = 'pholio-comment'; + const TYPE_PHOLIO_UPDATED = 'pholio-updated'; + const TYPE_PHOLIO_OTHER = 'pholio-other'; + } diff --git a/src/applications/pholio/storage/PholioTransaction.php b/src/applications/pholio/storage/PholioTransaction.php index bee7340cd9..1a7534a175 100644 --- a/src/applications/pholio/storage/PholioTransaction.php +++ b/src/applications/pholio/storage/PholioTransaction.php @@ -79,6 +79,32 @@ final class PholioTransaction extends PhabricatorApplicationTransaction { return parent::getIcon(); } + public function getMailTags() { + $tags = array(); + switch ($this->getTransactionType()) { + case PholioTransactionType::TYPE_INLINE: + case PhabricatorTransactions::TYPE_COMMENT: + $tags[] = MetaMTANotificationType::TYPE_PHOLIO_COMMENT; + break; + case PholioTransactionType::TYPE_STATUS: + $tags[] = MetaMTANotificationType::TYPE_PHOLIO_STATUS; + break; + case PholioTransactionType::TYPE_NAME: + case PholioTransactionType::TYPE_DESCRIPTION: + case PholioTransactionType::TYPE_IMAGE_NAME: + case PholioTransactionType::TYPE_IMAGE_DESCRIPTION: + case PholioTransactionType::TYPE_IMAGE_SEQUENCE: + case PholioTransactionType::TYPE_IMAGE_FILE: + case PholioTransactionType::TYPE_IMAGE_REPLACE: + $tags[] = MetaMTANotificationType::TYPE_PHOLIO_UPDATED; + break; + default: + $tags[] = MetaMTANotificationType::TYPE_PHOLIO_OTHER; + break; + } + return $tags; + } + public function getTitle() { $author_phid = $this->getAuthorPHID(); diff --git a/src/applications/settings/panel/PhabricatorSettingsPanelEmailPreferences.php b/src/applications/settings/panel/PhabricatorSettingsPanelEmailPreferences.php index 39082285dd..40d7db687e 100644 --- a/src/applications/settings/panel/PhabricatorSettingsPanelEmailPreferences.php +++ b/src/applications/settings/panel/PhabricatorSettingsPanelEmailPreferences.php @@ -58,6 +58,11 @@ final class PhabricatorSettingsPanelEmailPreferences $all_tags = array_diff_key($all_tags, $this->getManiphestMailTags()); } + $pholio = 'PhabricatorApplicationPholio'; + if (!PhabricatorApplication::isClassInstalled($pholio)) { + $all_tags = array_diff_key($all_tags, $this->getPholioMailTags()); + } + foreach ($all_tags as $key => $label) { $mailtags[$key] = (bool)idx($new_tags, $key, false); } @@ -180,15 +185,18 @@ final class PhabricatorSettingsPanelEmailPreferences "\n\n". '**Phabricator will send an email to your primary account when:**')); - $form - ->appendChild( - $this->buildMailTagCheckboxes( - $this->getDifferentialMailTags(), - $mailtags) - ->setLabel(pht('Differential'))); + if (PhabricatorApplication::isClassInstalledForViewer( + 'PhabricatorApplicationDifferential', $user)) { + $form + ->appendChild( + $this->buildMailTagCheckboxes( + $this->getDifferentialMailTags(), + $mailtags) + ->setLabel(pht('Differential'))); + } - $maniphest = 'PhabricatorApplicationManiphest'; - if (PhabricatorApplication::isClassInstalled($maniphest)) { + if (PhabricatorApplication::isClassInstalledForViewer( + 'PhabricatorApplicationManiphest', $user)) { $form->appendChild( $this->buildMailTagCheckboxes( $this->getManiphestMailTags(), @@ -196,6 +204,15 @@ final class PhabricatorSettingsPanelEmailPreferences ->setLabel(pht('Maniphest'))); } + if (PhabricatorApplication::isClassInstalledForViewer( + 'PhabricatorApplicationPholio', $user)) { + $form->appendChild( + $this->buildMailTagCheckboxes( + $this->getPholioMailTags(), + $mailtags) + ->setLabel(pht('Pholio'))); + } + $form ->appendChild( id(new AphrontFormSubmitControl()) @@ -244,7 +261,14 @@ final class PhabricatorSettingsPanelEmailPreferences pht("A task's associated projects change."), MetaMTANotificationType::TYPE_MANIPHEST_OTHER => pht('Other task activity not listed above occurs.'), - + MetaMTANotificationType::TYPE_PHOLIO_STATUS => + pht("A mock's status changes."), + MetaMTANotificationType::TYPE_PHOLIO_COMMENT => + pht('Someone comments on a mock.'), + MetaMTANotificationType::TYPE_PHOLIO_UPDATED => + pht('Mock images or descriptions change.'), + MetaMTANotificationType::TYPE_PHOLIO_OTHER => + pht('Other mock activity not listed above occurs.'), ); } @@ -276,6 +300,17 @@ final class PhabricatorSettingsPanelEmailPreferences )); } + private function getPholioMailTags() { + return array_select_keys( + $this->getMailTags(), + array( + MetaMTANotificationType::TYPE_PHOLIO_STATUS, + MetaMTANotificationType::TYPE_PHOLIO_COMMENT, + MetaMTANotificationType::TYPE_PHOLIO_UPDATED, + MetaMTANotificationType::TYPE_PHOLIO_OTHER, + )); + } + private function buildMailTagCheckboxes( array $tags, array $prefs) {