aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App.pm36
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/AlertType.pm2
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm6
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm3
4 files changed, 34 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index 1664f0f30..bf95c8e17 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -348,7 +348,7 @@ sub send_email {
}
sub send_email_cron {
- my ( $c, $params, $env_from, $env_to, $nomail ) = @_;
+ my ( $c, $params, $env_from, $env_to, $nomail, $cobrand, $lang_code ) = @_;
return 1 if $c->is_abuser( $env_to );
@@ -356,15 +356,31 @@ sub send_email_cron {
unpack('h*', random_bytes(5, 1)), FixMyStreet->config('EMAIL_DOMAIN')
);
- $params->{_parameters_}->{signature} = '';
- #$params->{_parameters_}->{signature} = $c->view('Email')->render(
- # $c, 'signature.txt', {
- # additional_template_paths => [
- # FixMyStreet->path_to( 'templates', 'email', $c->cobrand->moniker, $c->stash->{lang_code} )->stringify,
- # FixMyStreet->path_to( 'templates', 'email', $c->cobrand->moniker )->stringify,
- # ]
- # }
- #);
+ # This is all to set the path for the templates processor so we can override
+ # signature and site names in emails using templates in the old style emails.
+ # It's a bit involved as not everywhere we use it knows about the cobrand so
+ # we can't assume there will be one.
+ my $include_path = FixMyStreet->path_to( 'templates', 'email', 'default' )->stringify;
+ if ( $cobrand ) {
+ $include_path =
+ FixMyStreet->path_to( 'templates', 'email', $cobrand->moniker )->stringify . ':'
+ . $include_path;
+ if ( $lang_code ) {
+ $include_path =
+ FixMyStreet->path_to( 'templates', 'email', $cobrand->moniker, $lang_code )->stringify . ':'
+ . $include_path;
+ }
+ }
+ my $tt = Template->new({
+ INCLUDE_PATH => $include_path
+ });
+ my ($sig, $site_name);
+ $tt->process( 'signature.txt', $params, \$sig );
+ $params->{_parameters_}->{signature} = $sig;
+
+ $tt->process( 'site_name.txt', $params, \$site_name );
+ my $site_title = $cobrand ? $cobrand->site_title : '';
+ $params->{_parameters_}->{site_name} = $site_name || $site_title;
$params->{_line_indent} = '';
my $email = mySociety::Locale::in_gb_locale { mySociety::Email::construct_email($params) };
diff --git a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
index 545b54c60..984e698e0 100644
--- a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
@@ -271,6 +271,8 @@ sub _send_aggregated_alert_email(%) {
$sender,
[ $data{alert_email} ],
0,
+ $cobrand,
+ $data{lang}
);
if ($result == mySociety::EmailUtil::EMAIL_SUCCESS) {
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index 5499af474..a7c1bebae 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -438,7 +438,7 @@ sub send_reports {
lastupdate => \'ms_current_timestamp()',
} );
if ( $cobrand->report_sent_confirmation_email && !$h{anonymous_report}) {
- _send_report_sent_email( $row, \%h, $nomail );
+ _send_report_sent_email( $row, \%h, $nomail, $cobrand );
}
debug_print("send successful: OK", $row->id) if $debug_mode;
} else {
@@ -491,6 +491,7 @@ sub _send_report_sent_email {
my $row = shift;
my $h = shift;
my $nomail = shift;
+ my $cobrand = shift;
my $template = 'confirm_report_sent.txt';
my $template_path = FixMyStreet->path_to( "templates", "email", $row->cobrand, $row->lang, $template )->stringify;
@@ -509,7 +510,8 @@ sub _send_report_sent_email {
},
mySociety::Config::get('CONTACT_EMAIL'),
[ $row->user->email ],
- $nomail
+ $nomail,
+ $cobrand
);
}
diff --git a/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm b/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
index 6f2c19b5e..3c68fba26 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
@@ -107,7 +107,8 @@ sub send_questionnaires_period {
},
$sender,
[ $row->user->email ],
- $params->{nomail}
+ $params->{nomail},
+ $cobrand
);
if ($result == mySociety::EmailUtil::EMAIL_SUCCESS) {
print " ...success\n" if $params->{verbose};