diff options
author | matthew <matthew> | 2009-08-12 11:55:12 +0000 |
---|---|---|
committer | matthew <matthew> | 2009-08-12 11:55:12 +0000 |
commit | 180a4d2c74b92efefcbcd0a4982f48c64edeaadd (patch) | |
tree | c1c3d2b1b1adba3c4a7ea96fb7a41e3750f32e8f | |
parent | ac736a3f9886f22eb43b7e30ae632bd05c6903f3 (diff) |
Put lang in email confirmation URLs, so we can be sure we stay the same.
-rw-r--r-- | perllib/Page.pm | 25 | ||||
-rwxr-xr-x | web/alert.cgi | 4 | ||||
-rwxr-xr-x | web/index.cgi | 6 |
3 files changed, 23 insertions, 12 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm index 8ccfc762c..efb126d80 100644 --- a/perllib/Page.pm +++ b/perllib/Page.pm @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: Page.pm,v 1.157 2009-08-12 11:14:21 louise Exp $ +# $Id: Page.pm,v 1.158 2009-08-12 11:55:12 matthew Exp $ # package Page; @@ -122,6 +122,22 @@ sub microsite { Memcached::set_namespace(mySociety::Config::get('BCI_DB_NAME') . ":"); } +sub base_url_with_lang { + my $reverse = shift; + my $base = mySociety::Config::get('BASE_URL'); + my $lang = $mySociety::Locale::lang; + if ($reverse && $lang eq 'en-gb') { + $base =~ s{http://}{$&cy.}; + } elsif ($reverse) { + $base =~ s{http://}{$&en.}; + } elsif ($lang eq 'cy') { + $base =~ s{http://}{$&cy.}; + } else { + $base =~ s{http://}{$&en.}; + } + return $base; +} + =item header Q [PARAM VALUE ...] Return HTML for the top of the page, given PARAMs (TITLE is required). @@ -156,13 +172,8 @@ sub header ($%) { close FP; my %vars; if ($q->{site} eq 'emptyhomes') { - my $lang_url = mySociety::Config::get('BASE_URL'); + my $lang_url = base_url_with_lang(1); $lang_url .= $ENV{REQUEST_URI} if $ENV{REQUEST_URI}; - if ($lang eq 'en-gb') { - $lang_url =~ s{http://}{$&cy.}; - } else { - $lang_url =~ s{http://}{$&en.}; - } %vars = ( 'report' => _('Report a problem'), 'reports' => _('All reports'), diff --git a/web/alert.cgi b/web/alert.cgi index fd3d55f25..cb77a8e4c 100755 --- a/web/alert.cgi +++ b/web/alert.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: alert.cgi,v 1.40 2009-07-10 17:50:40 matthew Exp $ +# $Id: alert.cgi,v 1.41 2009-08-12 11:55:13 matthew Exp $ use strict; use Standard; @@ -405,7 +405,7 @@ sub alert_do_subscribe { } my %h = (); - $h{url} = mySociety::Config::get('BASE_URL') . '/A/' + $h{url} = Page::base_url_with_lang() . '/A/' . mySociety::AuthToken::store('alert', { id => $alert_id, type => 'subscribe', email => $email } ); dbh()->commit(); return Page::send_email($q, $email, undef, 'alert', %h); diff --git a/web/index.cgi b/web/index.cgi index 4b15cf168..34befc224 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: index.cgi,v 1.266 2009-08-11 09:28:41 matthew Exp $ +# $Id: index.cgi,v 1.267 2009-08-12 11:55:13 matthew Exp $ use strict; use Standard; @@ -244,7 +244,7 @@ sub submit_update { my %h = (); $h{update} = $input{update}; $h{name} = $input{name} ? $input{name} : _("Anonymous"); - my $base = mySociety::Config::get('BASE_URL'); + my $base = Page::base_url_with_lang(); $base =~ s/matthew/scambs.matthew/ if $q->{site} eq 'scambs'; # XXX Temp $h{url} = $base . '/C/' . mySociety::AuthToken::store('update', { id => $id, add_alert => $input{add_alert} } ); dbh()->commit(); @@ -404,7 +404,7 @@ Please <a href="/contact">let us know what went on</a> and we\'ll look into it.' $h{title} = $input{title}; $h{detail} = $input{detail}; $h{name} = $input{name}; - my $base = mySociety::Config::get('BASE_URL'); + my $base = Page::base_url_with_lang(); $base =~ s/matthew/scambs.matthew/ if $q->{site} eq 'scambs'; # XXX Temp $h{url} = $base . '/P/' . mySociety::AuthToken::store('problem', $id); dbh()->commit(); |