[MediaWiki-commits] [Gerrit] wikimedia...crm[master]: Get thank you email subject from template files
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/391975 ) Change subject: Get thank you email subject from template files .. Get thank you email subject from template files This lets us deliberately deploy updates instead of just getting whatever's been translated in DonationInterface. Bug: T167806 Change-Id: I9f52affe4f2d198866d7551411019e06e095fa31 --- M sites/all/modules/thank_you/generators/FindUnconsumedTokens.php M sites/all/modules/thank_you/tests/phpunit/ThankYouTest.php M sites/all/modules/thank_you/thank_you.module 3 files changed, 12 insertions(+), 13 deletions(-) Approvals: XenoRyet: Looks good to me, approved jenkins-bot: Verified diff --git a/sites/all/modules/thank_you/generators/FindUnconsumedTokens.php b/sites/all/modules/thank_you/generators/FindUnconsumedTokens.php index ead9583..f102d2a 100644 --- a/sites/all/modules/thank_you/generators/FindUnconsumedTokens.php +++ b/sites/all/modules/thank_you/generators/FindUnconsumedTokens.php @@ -57,7 +57,7 @@ // TODO: refactor out of this class static function renderLanguage( $lang ) { $params = FindUnconsumedTokens::getRandomTemplateParams( $lang ); -$buf = thank_you_render( $params ); +list($buf, $subj) = thank_you_render( $params ); return $buf; } diff --git a/sites/all/modules/thank_you/tests/phpunit/ThankYouTest.php b/sites/all/modules/thank_you/tests/phpunit/ThankYouTest.php index 03acdda..6bd0e9c 100644 --- a/sites/all/modules/thank_you/tests/phpunit/ThankYouTest.php +++ b/sites/all/modules/thank_you/tests/phpunit/ThankYouTest.php @@ -110,6 +110,11 @@ '@donate.wikimedia.org'; $this->assertEquals( $expectedBounce, $sent['reply_to'] ); $this->assertRegExp( '/\$ 1.23/', $sent['html'] ); + $expectedSubject = file_get_contents( + __DIR__ . + "/../../templates/subject/thank_you.{$this->message['language']}.subject" +); + $this->assertEquals( $expectedSubject, $sent['subject']); } public function testSendThankYouAddCiviMailActivity() { diff --git a/sites/all/modules/thank_you/thank_you.module b/sites/all/modules/thank_you/thank_you.module index 32bc11c..0a84e32 100644 --- a/sites/all/modules/thank_you/thank_you.module +++ b/sites/all/modules/thank_you/thank_you.module @@ -458,14 +458,14 @@ 'locale' => $params['locale'], ); - $email['html'] = thank_you_render( $params ); - - if( $email['html'] == false ){ + list($html, $subject) = thank_you_render($params); + if(!$html || !$subject){ $msg = "HTML rendering of template failed in {$params['locale']}."; throw new WmfException( 'UNKNOWN', $msg, array('thank_you_params' => $params) ); } - $email['subject'] = thank_you_get_subject( $params['locale'] ); + $email['html'] = $html; + $email['subject'] = $subject; $mailer = Mailer::getDefault(); @@ -608,13 +608,6 @@ ); } return $civi_queue_record; -} -/** - * Get the translated email subject - */ -function thank_you_get_subject( $locale ) { - $subj_msg = "donate_interface-email-subject"; - return Translation::get_translated_message( $subj_msg, $locale ); } function thank_you_settings_form() { @@ -911,7 +904,8 @@ $page_content = $template->render( 'html' ); $page_content = str_replace( '', '', $page_content ); -return $page_content; +$subject = $template->render( 'subject' ); +return array($page_content, $subject); } function build_unsub_link( $contributionId, $emailAddr, $language ) { -- To view, visit https://gerrit.wikimedia.org/r/391975 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9f52affe4f2d198866d7551411019e06e095fa31 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: master Gerrit-Owner: EjeggGerrit-Reviewer: XenoRyet Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] wikimedia...crm[master]: Get thank you email subject from template files
Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/391975 ) Change subject: Get thank you email subject from template files .. Get thank you email subject from template files This lets us deliberately deploy updates instead of just getting whatever's been translated in DonationInterface. Bug: T167806 Change-Id: I9f52affe4f2d198866d7551411019e06e095fa31 --- M sites/all/modules/thank_you/generators/FindUnconsumedTokens.php M sites/all/modules/thank_you/tests/phpunit/ThankYouTest.php M sites/all/modules/thank_you/thank_you.module 3 files changed, 12 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm refs/changes/75/391975/1 diff --git a/sites/all/modules/thank_you/generators/FindUnconsumedTokens.php b/sites/all/modules/thank_you/generators/FindUnconsumedTokens.php index ead9583..f102d2a 100644 --- a/sites/all/modules/thank_you/generators/FindUnconsumedTokens.php +++ b/sites/all/modules/thank_you/generators/FindUnconsumedTokens.php @@ -57,7 +57,7 @@ // TODO: refactor out of this class static function renderLanguage( $lang ) { $params = FindUnconsumedTokens::getRandomTemplateParams( $lang ); -$buf = thank_you_render( $params ); +list($buf, $subj) = thank_you_render( $params ); return $buf; } diff --git a/sites/all/modules/thank_you/tests/phpunit/ThankYouTest.php b/sites/all/modules/thank_you/tests/phpunit/ThankYouTest.php index 03acdda..6bd0e9c 100644 --- a/sites/all/modules/thank_you/tests/phpunit/ThankYouTest.php +++ b/sites/all/modules/thank_you/tests/phpunit/ThankYouTest.php @@ -110,6 +110,11 @@ '@donate.wikimedia.org'; $this->assertEquals( $expectedBounce, $sent['reply_to'] ); $this->assertRegExp( '/\$ 1.23/', $sent['html'] ); + $expectedSubject = file_get_contents( + __DIR__ . + "/../../templates/subject/thank_you.{$this->message['language']}.subject" +); + $this->assertEquals( $expectedSubject, $sent['subject']); } public function testSendThankYouAddCiviMailActivity() { diff --git a/sites/all/modules/thank_you/thank_you.module b/sites/all/modules/thank_you/thank_you.module index 32bc11c..0a84e32 100644 --- a/sites/all/modules/thank_you/thank_you.module +++ b/sites/all/modules/thank_you/thank_you.module @@ -458,14 +458,14 @@ 'locale' => $params['locale'], ); - $email['html'] = thank_you_render( $params ); - - if( $email['html'] == false ){ + list($html, $subject) = thank_you_render($params); + if(!$html || !$subject){ $msg = "HTML rendering of template failed in {$params['locale']}."; throw new WmfException( 'UNKNOWN', $msg, array('thank_you_params' => $params) ); } - $email['subject'] = thank_you_get_subject( $params['locale'] ); + $email['html'] = $html; + $email['subject'] = $subject; $mailer = Mailer::getDefault(); @@ -608,13 +608,6 @@ ); } return $civi_queue_record; -} -/** - * Get the translated email subject - */ -function thank_you_get_subject( $locale ) { - $subj_msg = "donate_interface-email-subject"; - return Translation::get_translated_message( $subj_msg, $locale ); } function thank_you_settings_form() { @@ -911,7 +904,8 @@ $page_content = $template->render( 'html' ); $page_content = str_replace( '', '', $page_content ); -return $page_content; +$subject = $template->render( 'subject' ); +return array($page_content, $subject); } function build_unsub_link( $contributionId, $emailAddr, $language ) { -- To view, visit https://gerrit.wikimedia.org/r/391975 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9f52affe4f2d198866d7551411019e06e095fa31 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: master Gerrit-Owner: Ejegg___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits