Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/editor/ManiphestTransactionEditor.php
| <?php | <?php | ||||
| final class ManiphestTransactionEditor | final class ManiphestTransactionEditor | ||||
| extends PhabricatorApplicationTransactionEditor { | extends PhabricatorApplicationTransactionEditor { | ||||
| private $heraldEmailPHIDs = array(); | private $heraldEmailPHIDs = array(); | ||||
| public function getEditorApplicationClass() { | public function getEditorApplicationClass() { | ||||
| return 'PhabricatorManiphestApplication'; | return 'PhabricatorManiphestApplication'; | ||||
| } | } | ||||
| public function getEditorObjectsDescription() { | public function getEditorObjectsDescription() { | ||||
| return pht('Maniphest Tasks'); | return pht('Maniphest Tasks'); | ||||
| } | } | ||||
| protected function getTransactionNotificationWorkerClass() { | |||||
| return 'PhabricatorManiphestTransactionNotificationWorker'; | |||||
| } | |||||
| public function getTransactionTypes() { | public function getTransactionTypes() { | ||||
| $types = parent::getTransactionTypes(); | $types = parent::getTransactionTypes(); | ||||
| $types[] = PhabricatorTransactions::TYPE_COMMENT; | $types[] = PhabricatorTransactions::TYPE_COMMENT; | ||||
| $types[] = PhabricatorTransactions::TYPE_EDGE; | $types[] = PhabricatorTransactions::TYPE_EDGE; | ||||
| $types[] = ManiphestTransaction::TYPE_PRIORITY; | $types[] = ManiphestTransaction::TYPE_PRIORITY; | ||||
| $types[] = ManiphestTransaction::TYPE_STATUS; | $types[] = ManiphestTransaction::TYPE_STATUS; | ||||
| $types[] = ManiphestTransaction::TYPE_TITLE; | $types[] = ManiphestTransaction::TYPE_TITLE; | ||||
| ▲ Show 20 Lines • Show All 377 Lines • ▼ Show 20 Lines | final class ManiphestTransactionEditor | ||||
| protected function shouldSendMail( | protected function shouldSendMail( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| array $xactions) { | array $xactions) { | ||||
| $xactions = mfilter($xactions, 'shouldHide', true); | $xactions = mfilter($xactions, 'shouldHide', true); | ||||
| return $xactions; | return $xactions; | ||||
| } | } | ||||
| protected function getMailSubjectPrefix() { | |||||
| return PhabricatorEnv::getEnvConfig('metamta.maniphest.subject-prefix'); | |||||
| } | |||||
| protected function getMailThreadID(PhabricatorLiskDAO $object) { | |||||
| return 'maniphest-task-'.$object->getPHID(); | |||||
| } | |||||
| protected function getMailTo(PhabricatorLiskDAO $object) { | protected function getMailTo(PhabricatorLiskDAO $object) { | ||||
| return array( | return array( | ||||
| $object->getOwnerPHID(), | $object->getOwnerPHID(), | ||||
| $this->getActingAsPHID(), | $this->getActingAsPHID(), | ||||
| ); | ); | ||||
| } | } | ||||
| protected function getMailCC(PhabricatorLiskDAO $object) { | protected function getMailCC(PhabricatorLiskDAO $object) { | ||||
| $phids = array(); | $phids = array(); | ||||
| foreach (parent::getMailCC($object) as $phid) { | foreach (parent::getMailCC($object) as $phid) { | ||||
| $phids[] = $phid; | $phids[] = $phid; | ||||
| } | } | ||||
| foreach ($this->heraldEmailPHIDs as $phid) { | foreach ($this->heraldEmailPHIDs as $phid) { | ||||
| $phids[] = $phid; | $phids[] = $phid; | ||||
| } | } | ||||
| return $phids; | return $phids; | ||||
| } | } | ||||
| // FIXME: Move it to a ManiphestTransaction? | |||||
| // This is currently duplicated in ManiphestTransactionNotificationWorker! | |||||
| // And also needed in email preferences. TODO: Find a place to put this stuff | |||||
| public function getMailTagsMap() { | public function getMailTagsMap() { | ||||
| return array( | return array( | ||||
| ManiphestTransaction::MAILTAG_STATUS => | ManiphestTransaction::MAILTAG_STATUS => | ||||
| pht("A task's status changes."), | pht("A task's status changes."), | ||||
| ManiphestTransaction::MAILTAG_OWNER => | ManiphestTransaction::MAILTAG_OWNER => | ||||
| pht("A task's owner changes."), | pht("A task's owner changes."), | ||||
| ManiphestTransaction::MAILTAG_PRIORITY => | ManiphestTransaction::MAILTAG_PRIORITY => | ||||
| pht("A task's priority changes."), | pht("A task's priority changes."), | ||||
| ManiphestTransaction::MAILTAG_CC => | ManiphestTransaction::MAILTAG_CC => | ||||
| pht("A task's subscribers change."), | pht("A task's subscribers change."), | ||||
| ManiphestTransaction::MAILTAG_PROJECTS => | ManiphestTransaction::MAILTAG_PROJECTS => | ||||
| pht("A task's associated projects change."), | pht("A task's associated projects change."), | ||||
| ManiphestTransaction::MAILTAG_UNBLOCK => | ManiphestTransaction::MAILTAG_UNBLOCK => | ||||
| pht('One of the tasks a task is blocked by changes status.'), | pht('One of the tasks a task is blocked by changes status.'), | ||||
| ManiphestTransaction::MAILTAG_COLUMN => | ManiphestTransaction::MAILTAG_COLUMN => | ||||
| pht('A task is moved between columns on a workboard.'), | pht('A task is moved between columns on a workboard.'), | ||||
| ManiphestTransaction::MAILTAG_COMMENT => | ManiphestTransaction::MAILTAG_COMMENT => | ||||
| pht('Someone comments on a task.'), | pht('Someone comments on a task.'), | ||||
| ManiphestTransaction::MAILTAG_OTHER => | ManiphestTransaction::MAILTAG_OTHER => | ||||
| pht('Other task activity not listed above occurs.'), | pht('Other task activity not listed above occurs.'), | ||||
| ); | ); | ||||
| } | } | ||||
| protected function buildReplyHandler(PhabricatorLiskDAO $object) { | |||||
| return id(new ManiphestReplyHandler()) | |||||
| ->setMailReceiver($object); | |||||
| } | |||||
| protected function buildMailTemplate(PhabricatorLiskDAO $object) { | |||||
| $id = $object->getID(); | |||||
| $title = $object->getTitle(); | |||||
| return id(new PhabricatorMetaMTAMail()) | |||||
| ->setSubject("T{$id}: {$title}") | |||||
| ->addHeader('Thread-Topic', "T{$id}: ".$object->getOriginalTitle()); | |||||
| } | |||||
| protected function buildMailBody( | |||||
| PhabricatorLiskDAO $object, | |||||
| array $xactions) { | |||||
| $body = parent::buildMailBody($object, $xactions); | |||||
| if ($this->getIsNewObject()) { | |||||
| $body->addTextSection( | |||||
| pht('TASK DESCRIPTION'), | |||||
| $object->getDescription()); | |||||
| } | |||||
| $body->addLinkSection( | |||||
| pht('TASK DETAIL'), | |||||
| PhabricatorEnv::getProductionURI('/T'.$object->getID())); | |||||
| $board_phids = array(); | |||||
| $type_column = ManiphestTransaction::TYPE_PROJECT_COLUMN; | |||||
| foreach ($xactions as $xaction) { | |||||
| if ($xaction->getTransactionType() == $type_column) { | |||||
| $new = $xaction->getNewValue(); | |||||
| $project_phid = idx($new, 'projectPHID'); | |||||
| if ($project_phid) { | |||||
| $board_phids[] = $project_phid; | |||||
| } | |||||
| } | |||||
| } | |||||
| if ($board_phids) { | |||||
| $projects = id(new PhabricatorProjectQuery()) | |||||
| ->setViewer($this->requireActor()) | |||||
| ->withPHIDs($board_phids) | |||||
| ->execute(); | |||||
| foreach ($projects as $project) { | |||||
| $body->addLinkSection( | |||||
| pht('WORKBOARD'), | |||||
| PhabricatorEnv::getProductionURI( | |||||
| '/project/board/'.$project->getID().'/')); | |||||
| } | |||||
| } | |||||
| return $body; | |||||
| } | |||||
| protected function shouldPublishFeedStory( | protected function shouldPublishFeedStory( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| array $xactions) { | array $xactions) { | ||||
| return $this->shouldSendMail($object, $xactions); | return $this->shouldSendMail($object, $xactions); | ||||
| } | } | ||||
| protected function supportsSearch() { | protected function supportsSearch() { | ||||
| return true; | return true; | ||||
| ▲ Show 20 Lines • Show All 167 Lines • Show Last 20 Lines | |||||