Differential D20057 Diff 47892 src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Show First 20 Lines • Show All 3,280 Lines • ▼ Show 20 Lines | foreach ($xactions as $xaction) { | ||||
// transaction. | // transaction. | ||||
// Some mail, like Differential undraft mail or "!history" mail, may | // Some mail, like Differential undraft mail or "!history" mail, may | ||||
// have two or more comments. In these cases, we'll put the first | // have two or more comments. In these cases, we'll put the first | ||||
// "alice added a comment." transaction in the header normally, but | // "alice added a comment." transaction in the header normally, but | ||||
// move the other transactions down so they provide context above the | // move the other transactions down so they provide context above the | ||||
// actual comment. | // actual comment. | ||||
$comment = $xaction->getBodyForMail(); | $comment = $this->getBodyForTextMail($xaction); | ||||
if ($comment !== null) { | if ($comment !== null) { | ||||
$is_comment = true; | $is_comment = true; | ||||
$comments[] = array( | $comments[] = array( | ||||
'xaction' => $xaction, | 'xaction' => $xaction, | ||||
'comment' => $comment, | 'comment' => $comment, | ||||
'initial' => !$seen_comment, | 'initial' => !$seen_comment, | ||||
); | ); | ||||
} else { | } else { | ||||
$is_comment = false; | $is_comment = false; | ||||
} | } | ||||
if (!$is_comment || !$seen_comment) { | if (!$is_comment || !$seen_comment) { | ||||
$header = $xaction->getTitleForTextMail(); | $header = $this->getTitleForTextMail($xaction); | ||||
if ($header !== null) { | if ($header !== null) { | ||||
$headers[] = $header; | $headers[] = $header; | ||||
} | } | ||||
$header_html = $xaction->getTitleForHTMLMail(); | $header_html = $this->getTitleForHTMLMail($xaction); | ||||
if ($header_html !== null) { | if ($header_html !== null) { | ||||
$headers_html[] = $header_html; | $headers_html[] = $header_html; | ||||
} | } | ||||
} | } | ||||
if ($xaction->hasChangeDetailsForMail()) { | if ($xaction->hasChangeDetailsForMail()) { | ||||
$details[] = $xaction; | $details[] = $xaction; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | protected function addHeadersAndCommentsToMailBody( | ||||
foreach ($comments as $spec) { | foreach ($comments as $spec) { | ||||
$xaction = $spec['xaction']; | $xaction = $spec['xaction']; | ||||
$comment = $spec['comment']; | $comment = $spec['comment']; | ||||
$is_initial = $spec['initial']; | $is_initial = $spec['initial']; | ||||
// If this is not the first comment in the mail, add the header showing | // If this is not the first comment in the mail, add the header showing | ||||
// who wrote the comment immediately above the comment. | // who wrote the comment immediately above the comment. | ||||
if (!$is_initial) { | if (!$is_initial) { | ||||
$header = $xaction->getTitleForTextMail(); | $header = $this->getTitleForTextMail($xaction); | ||||
if ($header !== null) { | if ($header !== null) { | ||||
$body->addRawPlaintextSection($header); | $body->addRawPlaintextSection($header); | ||||
} | } | ||||
$header_html = $xaction->getTitleForHTMLMail(); | $header_html = $this->getTitleForHTMLMail($xaction); | ||||
if ($header_html !== null) { | if ($header_html !== null) { | ||||
$body->addRawHTMLSection($header_html); | $body->addRawHTMLSection($header_html); | ||||
} | } | ||||
} | } | ||||
$body->addRemarkupSection(null, $comment); | $body->addRemarkupSection(null, $comment); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,569 Lines • ▼ Show 20 Lines | $mfa_xaction = id(clone $template) | ||||
->setTransactionType($type_mfa) | ->setTransactionType($type_mfa) | ||||
->setNewValue(true); | ->setNewValue(true); | ||||
array_unshift($xactions, $mfa_xaction); | array_unshift($xactions, $mfa_xaction); | ||||
return $xactions; | return $xactions; | ||||
} | } | ||||
private function getTitleForTextMail( | |||||
PhabricatorApplicationTransaction $xaction) { | |||||
$type = $xaction->getTransactionType(); | |||||
$xtype = $this->getModularTransactionType($type); | |||||
if ($xtype) { | |||||
$xtype = clone $xtype; | |||||
$xtype->setStorage($xaction); | |||||
$comment = $xtype->getTitleForTextMail(); | |||||
if ($comment !== false) { | |||||
amckinley: This feels weird... How is this different from `if ($comment)`? | |||||
epriestleyAuthorUnsubmitted Done Inline ActionsYeah, I'm cheating a bit here:
This diff is more of a "try to limit scope creep" sort of change than a crowning jewel of perfect programming. (if ($comment) is also different for the comment "0".) epriestley: Yeah, I'm cheating a bit here:
- Returning a comment means "that comment".
- Returning… | |||||
return $comment; | |||||
} | |||||
} | |||||
return $xaction->getTitleForTextMail(); | |||||
} | |||||
private function getBodyForHTMLMail( | |||||
PhabricatorApplicationTransaction $xaction) { | |||||
$type = $xaction->getTransactionType(); | |||||
$xtype = $this->getModularTransactionType($type); | |||||
if ($xtype) { | |||||
$xtype = clone $xtype; | |||||
$xtype->setStorage($xaction); | |||||
$comment = $xtype->getTitleForHTMLMail(); | |||||
if ($comment !== false) { | |||||
return $comment; | |||||
} | |||||
} | |||||
return $xaction->getTitleForHTMLMail(); | |||||
} | |||||
private function getBodyForTextMail( | |||||
PhabricatorApplicationTransaction $xaction) { | |||||
$type = $xaction->getTransactionType(); | |||||
$xtype = $this->getModularTransactionType($type); | |||||
if ($xtype) { | |||||
$xtype = clone $xtype; | |||||
$xtype->setStorage($xaction); | |||||
$comment = $xtype->getBodyForTextMail(); | |||||
if ($comment !== false) { | |||||
return $comment; | |||||
} | |||||
} | |||||
return $xaction->getBodyForMail(); | |||||
} | |||||
} | } |
This feels weird... How is this different from if ($comment)?