1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Add email preferences to Pholio

Summary: Fixes T5386, adds a base set of email preferences to Pholio

Test Plan: Turned on, tested and got email, turned off, tested and saw notifications.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5386

Differential Revision: https://secure.phabricator.com/D9644
This commit is contained in:
Chad Little 2014-06-21 12:01:05 -07:00
parent 6844b61a05
commit c9a195369f
3 changed files with 75 additions and 9 deletions

View file

@ -19,4 +19,9 @@ final class MetaMTANotificationType
const TYPE_MANIPHEST_COMMENT = 'maniphest-comment'; const TYPE_MANIPHEST_COMMENT = 'maniphest-comment';
const TYPE_MANIPHEST_OTHER = 'maniphest-other'; 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';
} }

View file

@ -79,6 +79,32 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
return parent::getIcon(); 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() { public function getTitle() {
$author_phid = $this->getAuthorPHID(); $author_phid = $this->getAuthorPHID();

View file

@ -58,6 +58,11 @@ final class PhabricatorSettingsPanelEmailPreferences
$all_tags = array_diff_key($all_tags, $this->getManiphestMailTags()); $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) { foreach ($all_tags as $key => $label) {
$mailtags[$key] = (bool)idx($new_tags, $key, false); $mailtags[$key] = (bool)idx($new_tags, $key, false);
} }
@ -180,15 +185,18 @@ final class PhabricatorSettingsPanelEmailPreferences
"\n\n". "\n\n".
'**Phabricator will send an email to your primary account when:**')); '**Phabricator will send an email to your primary account when:**'));
$form if (PhabricatorApplication::isClassInstalledForViewer(
->appendChild( 'PhabricatorApplicationDifferential', $user)) {
$this->buildMailTagCheckboxes( $form
$this->getDifferentialMailTags(), ->appendChild(
$mailtags) $this->buildMailTagCheckboxes(
->setLabel(pht('Differential'))); $this->getDifferentialMailTags(),
$mailtags)
->setLabel(pht('Differential')));
}
$maniphest = 'PhabricatorApplicationManiphest'; if (PhabricatorApplication::isClassInstalledForViewer(
if (PhabricatorApplication::isClassInstalled($maniphest)) { 'PhabricatorApplicationManiphest', $user)) {
$form->appendChild( $form->appendChild(
$this->buildMailTagCheckboxes( $this->buildMailTagCheckboxes(
$this->getManiphestMailTags(), $this->getManiphestMailTags(),
@ -196,6 +204,15 @@ final class PhabricatorSettingsPanelEmailPreferences
->setLabel(pht('Maniphest'))); ->setLabel(pht('Maniphest')));
} }
if (PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorApplicationPholio', $user)) {
$form->appendChild(
$this->buildMailTagCheckboxes(
$this->getPholioMailTags(),
$mailtags)
->setLabel(pht('Pholio')));
}
$form $form
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
@ -244,7 +261,14 @@ final class PhabricatorSettingsPanelEmailPreferences
pht("A task's associated projects change."), pht("A task's associated projects change."),
MetaMTANotificationType::TYPE_MANIPHEST_OTHER => MetaMTANotificationType::TYPE_MANIPHEST_OTHER =>
pht('Other task activity not listed above occurs.'), 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( private function buildMailTagCheckboxes(
array $tags, array $tags,
array $prefs) { array $prefs) {