diff options
author | matthew <matthew> | 2009-09-10 09:10:55 +0000 |
---|---|---|
committer | matthew <matthew> | 2009-09-10 09:10:55 +0000 |
commit | 6338e522eedcbb6c43266c1aa526f1008234eab2 (patch) | |
tree | 1a253e55702414d3dfdd2afe0fa2072e4ba282dd /bin/send-questionnaires | |
parent | cdaae9dbf5631ee7c8bf6822fcc0ced0b91de8a6 (diff) |
send-questionnaires using shared functions like rest (not sure how I missed it).
Email creation in English locale so that Date header is correct.
Diffstat (limited to 'bin/send-questionnaires')
-rwxr-xr-x | bin/send-questionnaires | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/bin/send-questionnaires b/bin/send-questionnaires index 623a57390..95ff90552 100755 --- a/bin/send-questionnaires +++ b/bin/send-questionnaires @@ -6,7 +6,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: send-questionnaires,v 1.13 2009-09-02 08:32:58 louise Exp $ +# $Id: send-questionnaires,v 1.14 2009-09-10 09:10:55 matthew Exp $ use strict; require 5.8.0; @@ -16,6 +16,7 @@ use FindBin; use lib "$FindBin::Bin/../perllib"; use lib "$FindBin::Bin/../../perllib"; use File::Slurp; +use CronFns; use Page; use mySociety::AuthToken; @@ -38,16 +39,9 @@ BEGIN { ); } -die "Either no arguments, --nomail or --verbose" if (@ARGV>1); -my $nomail = 0; -my $verbose = 0; -$nomail = 1 if (@ARGV==1 && $ARGV[0] eq '--nomail'); -$verbose = 1 if (@ARGV==1 && $ARGV[0] eq '--verbose'); -$verbose = 1 if $nomail; - -mySociety::Locale::negotiate_language('en-gb,English,en_GB|nb,Norwegian,nb_NO'); # XXX Testing -mySociety::Locale::gettext_domain('FixMyStreet'); -mySociety::Locale::change(); +my ($verbose, $nomail) = CronFns::options(); +my $site = CronFns::site(mySociety::Config::get('BASE_URL')); +CronFns::language($site); # Select all problems that need a questionnaire email sending my $unsent = select_all( @@ -87,13 +81,14 @@ foreach my $row (@$unsent) { my $sender = mySociety::Config::get('CONTACT_EMAIL'); $sender =~ s/team/fms-DO-NOT-REPLY/; - my $email = mySociety::Email::construct_email({ - _template_ => _($template), + $template = _($template); + my $email = mySociety::Locale::in_gb_locale { mySociety::Email::construct_email({ + _template_ => $template, _parameters_ => \%h, To => [ [ $row->{email}, $row->{name} ] ], From => [ $sender, mySociety::Config::get('CONTACT_NAME') ], 'Message-ID' => sprintf('<ques-%s-%s@mysociety.org>', time(), unpack('h*', random_bytes(5, 1))), - }); + }) }; print "Sending questionnaire $id, problem $row->{id}, token $token to $row->{email}\n" if $verbose; |