1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-13 12:54:53 +01:00
phorge-phorge/src/applications/ponder/editor/PonderAnswerEditor.php
Chad Little eaaba278a9 Convert PonderAnswer to modular transactions
Summary: Fixes T12624. Converts PonderAnswer over to modular transactions.

Test Plan:
- Add an answer
- Edit an answer
- Hide an answer
- Comment on an answer

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12624

Differential Revision: https://secure.phabricator.com/D17811
2017-05-01 12:44:30 -07:00

78 lines
1.9 KiB
PHP

<?php
final class PonderAnswerEditor extends PonderEditor {
public function getEditorObjectsDescription() {
return pht('Ponder Answers');
}
public function getTransactionTypes() {
$types = parent::getTransactionTypes();
$types[] = PhabricatorTransactions::TYPE_COMMENT;
return $types;
}
protected function shouldSendMail(
PhabricatorLiskDAO $object,
array $xactions) {
return true;
}
protected function getMailTo(PhabricatorLiskDAO $object) {
$phids = array();
$phids[] = $object->getAuthorPHID();
$phids[] = $this->requireActor()->getPHID();
$question = id(new PonderQuestionQuery())
->setViewer($this->requireActor())
->withIDs(array($object->getQuestionID()))
->executeOne();
$phids[] = $question->getAuthorPHID();
return $phids;
}
protected function shouldPublishFeedStory(
PhabricatorLiskDAO $object,
array $xactions) {
return true;
}
protected function buildReplyHandler(PhabricatorLiskDAO $object) {
return id(new PonderAnswerReplyHandler())
->setMailReceiver($object);
}
protected function buildMailTemplate(PhabricatorLiskDAO $object) {
$id = $object->getID();
return id(new PhabricatorMetaMTAMail())
->setSubject("ANSR{$id}")
->addHeader('Thread-Topic', "ANSR{$id}");
}
protected function buildMailBody(
PhabricatorLiskDAO $object,
array $xactions) {
$body = parent::buildMailBody($object, $xactions);
// If the user just gave the answer, add the answer text.
foreach ($xactions as $xaction) {
$type = $xaction->getTransactionType();
$new = $xaction->getNewValue();
if ($type == PonderAnswerTransaction::TYPE_CONTENT) {
$body->addRawSection($new);
}
}
$body->addLinkSection(
pht('ANSWER DETAIL'),
PhabricatorEnv::getProductionURI($object->getURI()));
return $body;
}
}