Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that the frontend title is used for contribution page details … #15497

Merged
merged 1 commit into from
Oct 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -5045,7 +5045,12 @@ protected function addContributionPageValuesToValuesHeavyHandedly(&$values) {
];
foreach ($valuesToCopy as $valueToCopy) {
if (isset($contributionPageValues[$valueToCopy])) {
$values[$valueToCopy] = $contributionPageValues[$valueToCopy];
if ($valueToCopy === 'title') {
$values[$valueToCopy] = CRM_Contribute_BAO_Contribution_Utils::getContributionPageTitle($this->contribution_page_id);
}
else {
$values[$valueToCopy] = $contributionPageValues[$valueToCopy];
}
}
}
return $values;
Expand Down
13 changes: 13 additions & 0 deletions CRM/Contribute/BAO/Contribution/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,4 +652,17 @@ public static function overrideDefaultCurrency($params) {
$config->defaultCurrency = CRM_Utils_Array::value('currency', $params, $config->defaultCurrency);
}

/**
* Get either the public title if set or the title of a contribution page for use in workflow message template.
* @param int $contribution_page_id
* @return string
*/
public static function getContributionPageTitle($contribution_page_id) {
$title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contribution_page_id, 'frontend_title');
if (empty($title)) {
$title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contribution_page_id, 'title');
}
return $title;
}

}
2 changes: 1 addition & 1 deletion CRM/Contribute/BAO/ContributionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes
);
}

$title = isset($values['title']) ? $values['title'] : CRM_Contribute_PseudoConstant::contributionPage($values['contribution_page_id']);
$title = isset($values['title']) ? $values['title'] : CRM_Contribute_BAO_Contribution_Utils::getContributionPageTitle($values['contribution_page_id']);

// Set email variables explicitly to avoid leaky smarty variables.
// All of these will be assigned to the template, replacing any that might be assigned elsewhere.
Expand Down
2 changes: 2 additions & 0 deletions tests/phpunit/api/v3/ContributionPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ public function testSubmitMembershipBlockNotSeparatePaymentWithEmail() {
$this->callAPISuccess('membership_payment', 'getsingle', ['contribution_id' => $contribution['id']]);
$mut->checkMailLog([
'Membership Type: General',
'Test Frontend title',
]);
$mut->stop();
$mut->clearMessages();
Expand Down Expand Up @@ -1496,6 +1497,7 @@ public function setUpContributionPage($isRecur = FALSE) {
$this->params['is_recur'] = 1;
$this->params['recur_frequency_unit'] = 'month';
}
$this->params['frontend_title'] = 'Test Frontend title';
$contributionPageResult = $this->callAPISuccess($this->_entity, 'create', $this->params);
if (empty($this->_ids['price_set'])) {
$priceSet = $this->callAPISuccess('price_set', 'create', $this->_priceSetParams);
Expand Down