Differential D20586 Diff 49112 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,417 Lines • ▼ Show 20 Lines | protected function buildMailBody( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
array $xactions) { | array $xactions) { | ||||
$body = id(new PhabricatorMetaMTAMailBody()) | $body = id(new PhabricatorMetaMTAMailBody()) | ||||
->setViewer($this->requireActor()) | ->setViewer($this->requireActor()) | ||||
->setContextObject($object); | ->setContextObject($object); | ||||
$button_label = $this->getObjectLinkButtonLabelForMail($object); | $button_label = $this->getObjectLinkButtonLabelForMail($object); | ||||
$button_uri = $this->getObjectLinkButtonURIForMail($object); | |||||
$this->addHeadersAndCommentsToMailBody( | |||||
$body, | |||||
$xactions, | |||||
$button_label, | |||||
$button_uri); | |||||
$this->addHeadersAndCommentsToMailBody($body, $xactions, $button_label); | |||||
$this->addCustomFieldsToMailBody($body, $object, $xactions); | $this->addCustomFieldsToMailBody($body, $object, $xactions); | ||||
return $body; | return $body; | ||||
} | } | ||||
protected function getObjectLinkButtonLabelForMail() { | protected function getObjectLinkButtonLabelForMail( | ||||
PhabricatorLiskDAO $object) { | |||||
return null; | return null; | ||||
} | } | ||||
protected function getObjectLinkButtonURIForMail( | |||||
PhabricatorLiskDAO $object) { | |||||
// Most objects define a "getURI()" method which does what we want, but | |||||
// this isn't formally part of an interface at time of writing. Try to | |||||
// call the method, expecting an exception if it does not exist. | |||||
try { | |||||
$uri = $object->getURI(); | |||||
return PhabricatorEnv::getProductionURI($uri); | |||||
} catch (Exception $ex) { | |||||
return null; | |||||
} | |||||
} | |||||
/** | /** | ||||
* @task mail | * @task mail | ||||
*/ | */ | ||||
protected function addEmailPreferenceSectionToMailBody( | protected function addEmailPreferenceSectionToMailBody( | ||||
PhabricatorMetaMTAMailBody $body, | PhabricatorMetaMTAMailBody $body, | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
array $xactions) { | array $xactions) { | ||||
$href = PhabricatorEnv::getProductionURI( | $href = PhabricatorEnv::getProductionURI( | ||||
'/settings/panel/emailpreferences/'); | '/settings/panel/emailpreferences/'); | ||||
$body->addLinkSection(pht('EMAIL PREFERENCES'), $href); | $body->addLinkSection(pht('EMAIL PREFERENCES'), $href); | ||||
} | } | ||||
/** | /** | ||||
* @task mail | * @task mail | ||||
*/ | */ | ||||
protected function addHeadersAndCommentsToMailBody( | protected function addHeadersAndCommentsToMailBody( | ||||
PhabricatorMetaMTAMailBody $body, | PhabricatorMetaMTAMailBody $body, | ||||
array $xactions, | array $xactions, | ||||
$object_label = null, | $object_label = null, | ||||
$object_href = null) { | $object_uri = null) { | ||||
// First, remove transactions which shouldn't be rendered in mail. | // First, remove transactions which shouldn't be rendered in mail. | ||||
foreach ($xactions as $key => $xaction) { | foreach ($xactions as $key => $xaction) { | ||||
if ($xaction->shouldHideForMail($xactions)) { | if ($xaction->shouldHideForMail($xactions)) { | ||||
unset($xactions[$key]); | unset($xactions[$key]); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | protected function addHeadersAndCommentsToMailBody( | ||||
} | } | ||||
$headers_text = implode("\n", $headers); | $headers_text = implode("\n", $headers); | ||||
$body->addRawPlaintextSection($headers_text); | $body->addRawPlaintextSection($headers_text); | ||||
$headers_html = phutil_implode_html(phutil_tag('br'), $headers_html); | $headers_html = phutil_implode_html(phutil_tag('br'), $headers_html); | ||||
$header_button = null; | $header_button = null; | ||||
if ($object_label !== null) { | if ($object_label !== null && $object_uri !== null) { | ||||
$button_style = array( | $button_style = array( | ||||
'text-decoration: none;', | 'text-decoration: none;', | ||||
'padding: 4px 8px;', | 'padding: 4px 8px;', | ||||
'margin: 0 8px 8px;', | 'margin: 0 8px 8px;', | ||||
'float: right;', | 'float: right;', | ||||
'color: #464C5C;', | 'color: #464C5C;', | ||||
'font-weight: bold;', | 'font-weight: bold;', | ||||
'border-radius: 3px;', | 'border-radius: 3px;', | ||||
'background-color: #F7F7F9;', | 'background-color: #F7F7F9;', | ||||
'background-image: linear-gradient(to bottom,#fff,#f1f0f1);', | 'background-image: linear-gradient(to bottom,#fff,#f1f0f1);', | ||||
'display: inline-block;', | 'display: inline-block;', | ||||
'border: 1px solid rgba(71,87,120,.2);', | 'border: 1px solid rgba(71,87,120,.2);', | ||||
); | ); | ||||
$header_button = phutil_tag( | $header_button = phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'style' => implode(' ', $button_style), | 'style' => implode(' ', $button_style), | ||||
'href' => $object_href, | 'href' => $object_uri, | ||||
), | ), | ||||
$object_label); | $object_label); | ||||
} | } | ||||
$xactions_style = array(); | $xactions_style = array(); | ||||
$header_action = phutil_tag( | $header_action = phutil_tag( | ||||
'td', | 'td', | ||||
▲ Show 20 Lines • Show All 1,808 Lines • Show Last 20 Lines |