diff options
author | Matthew Somerville <matthew@fury.ukcod.org.uk> | 2011-03-23 17:37:05 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@fury.ukcod.org.uk> | 2011-03-23 17:37:05 +0000 |
commit | 197d916501696c1d8811f05f1ef23e2a11d6e1b4 (patch) | |
tree | 931ff98a8202d537393362f36660ff08f1fd432c | |
parent | f10475c5f5a8f7e6a24579c4575c5bb208cc0428 (diff) | |
parent | 9e3f0cc26dbbd0e1b3d9d4aaf89fffec41557027 (diff) |
Merge branch 'master' of ssh://matthew@git.mysociety.org/data/git/public/fixmystreet
-rw-r--r-- | perllib/Page.pm | 22 | ||||
-rwxr-xr-x | web/alert.cgi | 2 | ||||
-rwxr-xr-x | web/import.cgi | 17 | ||||
-rwxr-xr-x | web/index.cgi | 4 | ||||
-rwxr-xr-x | web/tms-signup.cgi | 2 |
5 files changed, 25 insertions, 22 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm index 6c5af0fc5..24c52885a 100644 --- a/perllib/Page.pm +++ b/perllib/Page.pm @@ -392,12 +392,10 @@ sub error_page ($$) { } # send_email TO (NAME) TEMPLATE-NAME PARAMETERS -# TEMPLATE-NAME is currently one of problem, update, alert, tms +# TEMPLATE-NAME is a full filename here. sub send_email { - my ($q, $recipient_email_address, $name, $thing, %h) = @_; - my $file_thing = $thing; - $file_thing = 'empty property' if $q->{site} eq 'emptyhomes' && $thing eq 'problem'; # Needs to be in English - my $template = "$file_thing-confirm"; + my ($q, $recipient_email_address, $name, $template, %h) = @_; + $template = File::Slurp::read_file("$FindBin::Bin/../templates/emails/$template"); my $to = $name ? [[$recipient_email_address, $name]] : $recipient_email_address; my $cobrand = get_cobrand($q); @@ -445,6 +443,19 @@ sub send_email { ); } +} + +# send_confirmation_email TO (NAME) TEMPLATE-NAME PARAMETERS +# TEMPLATE-NAME is currently one of problem, update, alert, tms +sub send_confirmation_email { + my ($q, $recipient_email_address, $name, $thing, %h) = @_; + + my $file_thing = $thing; + $file_thing = 'empty property' if $q->{site} eq 'emptyhomes' && $thing eq 'problem'; # Needs to be in English + my $template = "$file_thing-confirm"; + + send_email($q, $recipient_email_address, $name, $template, %h); + my ($action, $worry); if ($thing eq 'problem') { $action = _('your problem will not be posted'); @@ -469,6 +480,7 @@ if you do not, %s.</p> <p>(Don't worry — %s)</p> EOF + my $cobrand = get_cobrand($q); my %vars = ( action => $action, worry => $worry, diff --git a/web/alert.cgi b/web/alert.cgi index dd4676644..fd30dbf4e 100755 --- a/web/alert.cgi +++ b/web/alert.cgi @@ -605,6 +605,6 @@ sub alert_do_subscribe { $h{url} = Page::base_url_with_lang($q, undef, 1) . '/A/' . mySociety::AuthToken::store('alert', { id => $alert_id, type => 'subscribe', email => $email } ); dbh()->commit(); - return Page::send_email($q, $email, undef, 'alert', %h); + return Page::send_confirmation_email($q, $email, undef, 'alert', %h); } diff --git a/web/import.cgi b/web/import.cgi index ac36b2ee5..371e70f7a 100755 --- a/web/import.cgi +++ b/web/import.cgi @@ -15,8 +15,6 @@ use Utils; use mySociety::AuthToken; use mySociety::Config; use mySociety::EmailUtil; -use mySociety::EvEl; -use mySociety::Locale; sub main { my $q = shift; @@ -112,23 +110,16 @@ sub main { $id, $latitude, $longitude, $input{subject}, $input{detail}, $input{name}, $input{service}, $input{email}, $input{phone}, $photo); - # Send checking email - my $template = File::Slurp::read_file("$FindBin::Bin/../templates/emails/partial"); my $token = mySociety::AuthToken::store('partial', $id); my %h = ( name => $input{name} ? ' ' . $input{name} : '', - url => mySociety::Config::get('BASE_URL') . '/L/' . $token, + url => Page::base_url_with_lang($q, undef, 1) . '/L/' . $token, service => $input{service}, + title => $input{title}, + detail => $input{detail}, ); - my $sender = mySociety::Config::get('CONTACT_EMAIL'); - $sender =~ s/team/fms-DO-NOT-REPLY/; - mySociety::EvEl::send({ - _template_ => $template, - _parameters_ => \%h, - To => $input{name} ? [ [ $input{email}, $input{name} ] ] : $input{email}, - From => [ $sender, 'FixMyStreet' ], - }, $input{email}); + Page::send_email($q, $input{email}, $input{name}, 'partial', %h); dbh()->commit(); print 'SUCCESS'; diff --git a/web/index.cgi b/web/index.cgi index 595c2f3a7..f741e5f5a 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -259,7 +259,7 @@ sub submit_update { $h{url} = $base . '/C/' . mySociety::AuthToken::store('update', { id => $id, add_alert => $input{add_alert} } ); dbh()->commit(); - my $out = Page::send_email($q, $input{rznvy}, $input{name}, 'update', %h); + my $out = Page::send_confirmation_email($q, $input{rznvy}, $input{name}, 'update', %h); return $out; } @@ -432,7 +432,7 @@ Please <a href="/contact">let us know what went on</a> and we\'ll look into it.' $h{url} = $base . '/P/' . mySociety::AuthToken::store('problem', $id); dbh()->commit(); - $out = Page::send_email($q, $input{email}, $input{name}, 'problem', %h); + $out = Page::send_confirmation_email($q, $input{email}, $input{name}, 'problem', %h); } return $out; diff --git a/web/tms-signup.cgi b/web/tms-signup.cgi index 44099417f..5975a324f 100755 --- a/web/tms-signup.cgi +++ b/web/tms-signup.cgi @@ -108,7 +108,7 @@ sub tms_do_subscribe { mobile => $input{mobile}, }); dbh()->commit(); - return Page::send_email($q, $input{email}, $input{name}, 'tms', %h); + return Page::send_confirmation_email($q, $input{email}, $input{name}, 'tms', %h); } sub tms_confirm { |