Ejegg has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/391951 )

Change subject: Don't create CiviMail mailing record in make_thank_you
......................................................................

Don't create CiviMail mailing record in make_thank_you

We don't run make_thank_you on production, so it's pointless.
Also, it's a weird place for it if we want to make subject templates
the same way.

Bug: T167806
Change-Id: If940368f3688555236382c74f8c572b43f4511a0
---
M sites/all/modules/thank_you/generators/RenderTranslatedPage.php
A sites/all/modules/thank_you/generators/ThankYouSubject.php
2 files changed, 42 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/51/391951/1

diff --git a/sites/all/modules/thank_you/generators/RenderTranslatedPage.php 
b/sites/all/modules/thank_you/generators/RenderTranslatedPage.php
index f13922c..8d8a619 100644
--- a/sites/all/modules/thank_you/generators/RenderTranslatedPage.php
+++ b/sites/all/modules/thank_you/generators/RenderTranslatedPage.php
@@ -40,7 +40,6 @@
         }
 
                civicrm_initialize();
-               $civimail_store = new CiviMailStore();
 
                foreach( $languages as $lang ) {
                        try {
@@ -74,8 +73,6 @@
 
                                if (file_put_contents( $file, $page_content )) {
                                        watchdog( 'make-thank-you', "$lang -- 
Wrote translation into $file", null, WATCHDOG_INFO );
-                                       $subject = thank_you_get_subject( $lang 
);
-                                       $civimail_store->addMailing( 
'thank_you', $template_name, $page_content, $subject, $published_revision );
                                } else {
                                        watchdog( 'make-thank-you', "$lang -- 
Could not open $file for writing!", null, WATCHDOG_ERROR );
 
diff --git a/sites/all/modules/thank_you/generators/ThankYouSubject.php 
b/sites/all/modules/thank_you/generators/ThankYouSubject.php
new file mode 100644
index 0000000..d93cba1
--- /dev/null
+++ b/sites/all/modules/thank_you/generators/ThankYouSubject.php
@@ -0,0 +1,42 @@
+<?php namespace thank_you\generators;
+
+class ThankYou extends RenderTranslatedPage {
+       function __construct() {
+               // FIXME: drupal var and settings UI
+               $this->title = 
'Fundraising/Translation/Thank_you_email_20171019';
+               $this->proto_file = __DIR__ . 
'/../templates/html/thank_you.$1.html';
+
+               $this->substitutions = array(
+                       // FIXME: The whitespace coming out of MediaWiki's 
parser is
+                       // unreliable and shouldn't be second-guessed.  We need 
to be more
+                       // robust here.
+                       "/\xc2\xa0/" => ' ', // no-break spaces confuse the 
rest of the replacements
+                       '/(<p>)?\[ifFirstnameAndLastname\]\s*/' => "{% if 
first_name and last_name %}\n\\1",
+                       '/(<p>)?\[elseifFirstnameAndLastname\]\s*/' => "{% else 
%}\n\\1",
+                       '/\s*\[endifFirstnameAndLastname\](<\/p>)?/' => 
"\\1\n{% endif %}",
+
+                       '/\[given name\]/' => '{{ first_name }}',
+                       '/\[first name\]/' => '{{ first_name }}',
+                       '/\[family name\]/' => '{{ last_name }}',
+                       '/\[last name\]/' => '{{ last_name }}',
+
+                       '/\[date\]/' => '{{ receive_date }}',
+
+                       '/\$date/' => '{{ receive_date }}',
+                       '/\[amount\]/' => '{{ (currency ~ " " ~ amount) | 
l10n_currency(locale) }}',
+                       '/\[contributionId\]/' => '{{ transaction_id }}',
+
+                       '/(<p>)?\[ifRecurringProblem\]/' => "{% if 
\"RecurringRestarted\" in contribution_tags %}\n\\1",
+                       '/\[endifRecurringProblem\]<\/p>/' => "</p>\n{% endif 
%}",
+                       '/(<p>)?\[ifRecurring\]\s*/' => "{% if recurring 
%}\n\\1",
+                       '/\s*\[endifRecurring\]\s*(<\/p>)?/' => "\\1\n{% endif 
%}",
+                       '/\[#?unsubscribe ((?:(?!\]).)*)\]/' => '<a href="{{ 
unsubscribe_link | raw }}">$1</a>',
+                       // All of the thank you letter's if...endif blocks 
should be outside p tags, not inside
+                       '/<p>\s*({%\s*if [^}]+})\s*/i' => "\\1\n<p>",
+                       '/\s*{%\s*endif\s*%}\s*<\/p>/i' => "</p>\n{% endif %}",
+                       // Delete paragraphs that just have a break tag
+                       '/\s*<p>\s*<br ?\/?>\s*<\/p>/i' => '',
+                       '/\[#recurringCancel ((?:(?!\]).)*)\]/' => '<a 
href="https://wikimediafoundation.org/wiki/Special:LandingCheck?landing_page=Cancel_or_change_recurring_payments&basic=true&language={{
 locale }}">$1</a>',
+               );
+       }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/391951
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If940368f3688555236382c74f8c572b43f4511a0
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <ej...@ejegg.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to