aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/send-alerts6
-rwxr-xr-xbin/send-questionnaires-eha19
-rwxr-xr-xbin/send-reports31
3 files changed, 24 insertions, 32 deletions
diff --git a/bin/send-alerts b/bin/send-alerts
index ef272ae6f..f282efaaf 100755
--- a/bin/send-alerts
+++ b/bin/send-alerts
@@ -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-alerts,v 1.2 2007-06-15 14:57:51 matthew Exp $
+# $Id: send-alerts,v 1.3 2009-07-10 15:17:28 matthew Exp $
use strict;
require 5.8.0;
@@ -15,6 +15,7 @@ require 5.8.0;
use FindBin;
use lib "$FindBin::Bin/../perllib";
use lib "$FindBin::Bin/../../perllib";
+use CronFns;
use mySociety::Config;
use mySociety::DBHandle qw(dbh);
@@ -31,5 +32,8 @@ BEGIN {
);
}
+my $site = CronFns::site(mySociey::Config::get('BASE_URL'));
+CronFns::language($site);
+
mySociety::Alert::email_alerts();
diff --git a/bin/send-questionnaires-eha b/bin/send-questionnaires-eha
index 4df5c293f..055db39f7 100755
--- a/bin/send-questionnaires-eha
+++ b/bin/send-questionnaires-eha
@@ -6,7 +6,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: send-questionnaires-eha,v 1.2 2009-05-27 15:27:18 matthew Exp $
+# $Id: send-questionnaires-eha,v 1.3 2009-07-10 15:17:28 matthew Exp $
use strict;
require 5.8.0;
@@ -16,12 +16,13 @@ use FindBin;
use lib "$FindBin::Bin/../perllib";
use lib "$FindBin::Bin/../../perllib";
use File::Slurp;
+use CronFns;
-use Page;
use mySociety::AuthToken;
use mySociety::Config;
use mySociety::DBHandle qw(dbh select_all);
use mySociety::Email;
+use mySociety::Locale;
use mySociety::MaPit;
use mySociety::EmailUtil;
use mySociety::Random qw(random_bytes);
@@ -37,12 +38,10 @@ 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;
+# Set up site, language etc.
+my ($verbose, $nomail) = CronFns::options();
+my $site = CronFns::site(mySociety::Config::get('BASE_URL'))
+CronFns::language($site);
send_q('4 weeks');
send_q('26 weeks');
@@ -55,7 +54,7 @@ sub send_q {
(my $template = $period) =~ s/ //;
$template = File::Slurp::read_file("$FindBin::Bin/../templates/emails/questionnaire-eha-$template");
- my $query = "select id, category, title, detail, name, email
+ my $query = "select id, category, title, detail, name, email, lang
from problem
where state in ('confirmed', 'fixed')
and whensent is not null
@@ -73,6 +72,8 @@ sub send_q {
foreach my $row (@$unsent) {
my %h = map { $_ => $row->{$_} } qw/name title detail category/;
+ mySociety::Locale::change($row->{lang});
+
my $id = dbh()->selectrow_array("select nextval('questionnaire_id_seq');");
dbh()->do('insert into questionnaire (id, problem_id, whensent)
values (?, ?, ms_current_timestamp())', {}, $id, $row->{id});
diff --git a/bin/send-reports b/bin/send-reports
index 458244310..723228fa6 100755
--- a/bin/send-reports
+++ b/bin/send-reports
@@ -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-reports,v 1.69 2009-06-10 14:27:54 matthew Exp $
+# $Id: send-reports,v 1.70 2009-07-10 15:17:28 matthew Exp $
use strict;
require 5.8.0;
@@ -18,6 +18,7 @@ use lib "$FindBin::Bin/../../perllib";
use Error qw(:try);
use File::Slurp;
use CGI; # Trying awkward kludge
+use CronFns;
use EastHantsWSDL;
use mySociety::Config;
@@ -42,30 +43,14 @@ BEGIN {
use mySociety::Dress; # Has to come after the BEGIN, my poor coding
-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;
-
+# Set up site, language etc.
+my ($verbose, $nomail) = CronFns::options();
my $base_url = mySociety::Config::get('BASE_URL');
-my $site = 'fixmystreet';
-$site = 'emptyhomes' if $base_url =~ 'emptyhomes';
-
-# First, let's pick the right language
-if ($site eq 'emptyhomes') {
- mySociety::Locale::negotiate_language('en-gb,English,en_GB|cy,Cymraeg,cy_GB');
- mySociety::Locale::gettext_domain('FixMyStreet-EmptyHomes');
- mySociety::Locale::change();
-} else {
- mySociety::Locale::negotiate_language('en-gb,English,en_GB|nb,Norwegian,nb_NO'); # XXX Testing
- mySociety::Locale::gettext_domain('FixMyStreet');
- mySociety::Locale::change();
-}
+my $site = CronFns::site($base_url);
+CronFns::language($site);
my $query = "SELECT id, council, category, title, detail, name, email, phone,
- used_map, easting, northing, (photo is not null) as has_photo
+ used_map, easting, northing, (photo is not null) as has_photo, lang
FROM problem WHERE state in ('confirmed','fixed') AND whensent IS NULL
AND council IS NOT NULL";
my $unsent = dbh()->selectall_arrayref($query, { Slice => {} });
@@ -82,6 +67,8 @@ foreach my $row (@$unsent) {
my $send_email = 0;
my $send_web = 0;
+ mySociety::Locale::change($row->{lang});
+
# Template variables for the email
my %h = map { $_ => $row->{$_} } qw/title detail name email phone category easting northing/;
$h{url} = $base_url . '/report/' . $row->{id};