aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/gettext-extract2
-rwxr-xr-xbin/send-alerts4
m---------commonlib0
-rw-r--r--perllib/FixMyStreet/Alert.pm339
-rwxr-xr-xweb/alert.cgi24
-rwxr-xr-xweb/confirm.cgi10
-rwxr-xr-xweb/reports.cgi4
-rwxr-xr-xweb/rss.cgi14
-rwxr-xr-xweb/tms-signup.cgi1
9 files changed, 368 insertions, 30 deletions
diff --git a/bin/gettext-extract b/bin/gettext-extract
index fb3406984..b354c11f2 100755
--- a/bin/gettext-extract
+++ b/bin/gettext-extract
@@ -40,7 +40,7 @@ PO=locale/FixMyStreet.po
rm -f $PO
# Extract from Perl
-xgettext --add-comments=TRANS --language=Perl --keyword=_ --keyword=nget:1,2 --from-code=utf-8 -o $PO commonlib/perllib/mySociety/*.pm perllib/*.pm web/*.cgi bin/send-* db/alert_types_eha.pl
+xgettext --add-comments=TRANS --language=Perl --keyword=_ --keyword=nget:1,2 --from-code=utf-8 -o $PO perllib/*.pm perllib/FixMyStreet/*.pm web/*.cgi bin/send-* db/alert_types_eha.pl
# Fix headers
TEMP=`tempfile`
diff --git a/bin/send-alerts b/bin/send-alerts
index 57eeb16ae..c52af4059 100755
--- a/bin/send-alerts
+++ b/bin/send-alerts
@@ -21,7 +21,7 @@ use CronFns;
use mySociety::Config;
use mySociety::DBHandle qw(dbh);
-use mySociety::Alert;
+use FixMyStreet::Alert;
BEGIN {
mySociety::Config::set_file("$FindBin::Bin/../conf/general");
@@ -37,5 +37,5 @@ BEGIN {
my $site = CronFns::site(mySociety::Config::get('BASE_URL'));
CronFns::language($site);
my $testing_email = mySociety::Config::get('TESTING_EMAIL');
-mySociety::Alert::email_alerts($testing_email);
+FixMyStreet::Alert::email_alerts($testing_email);
diff --git a/commonlib b/commonlib
-Subproject 13e2591319b761789a41a302bd2de54d454776e
+Subproject e0ffea0186a31514b0a05efd30fc76e83f68d3d
diff --git a/perllib/FixMyStreet/Alert.pm b/perllib/FixMyStreet/Alert.pm
new file mode 100644
index 000000000..ea56029ef
--- /dev/null
+++ b/perllib/FixMyStreet/Alert.pm
@@ -0,0 +1,339 @@
+#!/usr/bin/perl -w
+#
+# FixMyStreet::Alert.pm
+# Alerts by email or RSS.
+#
+# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+#
+# $Id: Alert.pm,v 1.71 2010-01-06 16:50:27 louise Exp $
+
+package FixMyStreet::Alert::Error;
+
+use Error qw(:try);
+
+@FixMyStreet::Alert::Error::ISA = qw(Error::Simple);
+
+package FixMyStreet::Alert;
+
+use strict;
+use Error qw(:try);
+use File::Slurp;
+use FindBin;
+use POSIX qw(strftime);
+use XML::RSS;
+
+use Cobrand;
+use mySociety::AuthToken;
+use mySociety::Config;
+use mySociety::DBHandle qw(dbh);
+use mySociety::Email;
+use mySociety::EmailUtil;
+use mySociety::Gaze;
+use mySociety::GeoUtil;
+use mySociety::Locale;
+use mySociety::MaPit;
+use mySociety::Random qw(random_bytes);
+use mySociety::Sundries qw(ordinal);
+use mySociety::Web qw(ent);
+
+# Add a new alert
+sub create ($$$$;@) {
+ my ($email, $alert_type, $cobrand, $cobrand_data, @params) = @_;
+ my $already = 0;
+ if (0==@params) {
+ ($already) = dbh()->selectrow_array('select id from alert where alert_type=? and email=? limit 1',
+ {}, $alert_type, $email);
+ } elsif (1==@params) {
+ ($already) = dbh()->selectrow_array('select id from alert where alert_type=? and email=? and parameter=? limit 1',
+ {}, $alert_type, $email, @params);
+ } elsif (2==@params) {
+ ($already) = dbh()->selectrow_array('select id from alert where alert_type=? and email=? and parameter=? and parameter2=? limit 1',
+ {}, $alert_type, $email, @params);
+ }
+ return $already if $already;
+
+ my $id = dbh()->selectrow_array("select nextval('alert_id_seq');");
+ my $lang = $mySociety::Locale::lang;
+ if (0==@params) {
+ dbh()->do('insert into alert (id, alert_type, email, lang, cobrand, cobrand_data)
+ values (?, ?, ?, ?, ?, ?)', {}, $id, $alert_type, $email, $lang, $cobrand, $cobrand_data);
+ } elsif (1==@params) {
+ dbh()->do('insert into alert (id, alert_type, parameter, email, lang, cobrand, cobrand_data)
+ values (?, ?, ?, ?, ?, ?, ?)', {}, $id, $alert_type, @params, $email, $lang, $cobrand, $cobrand_data);
+ } elsif (2==@params) {
+ dbh()->do('insert into alert (id, alert_type, parameter, parameter2, email, lang, cobrand, cobrand_data)
+ values (?, ?, ?, ?, ?, ?, ?, ?)', {}, $id, $alert_type, @params, $email, $lang, $cobrand, $cobrand_data);
+ }
+ dbh()->commit();
+ return $id;
+}
+
+sub confirm ($) {
+ my $id = shift;
+ dbh()->do("update alert set confirmed=1, whendisabled=null where id=?", {}, $id);
+ dbh()->commit();
+}
+
+# Delete an alert
+sub delete ($) {
+ my $id = shift;
+ dbh()->do('update alert set whendisabled = ms_current_timestamp() where id = ?', {}, $id);
+ dbh()->commit();
+}
+
+# This makes load of assumptions, but still should be useful
+#
+# Child must have confirmed, id, email, state(!) columns
+# If parent/child, child table must also have name and text
+# and foreign key to parent must be PARENT_id
+
+sub email_alerts ($) {
+ my ($testing_email) = @_;
+ my $url;
+ my $q = dbh()->prepare("select * from alert_type where ref != 'local_problems'");
+ $q->execute();
+ my $testing_email_clause = '';
+ while (my $alert_type = $q->fetchrow_hashref) {
+ my $ref = $alert_type->{ref};
+ my $head_table = $alert_type->{head_table};
+ my $item_table = $alert_type->{item_table};
+ my $testing_email_clause = "and $item_table.email <> '$testing_email'" if $testing_email;
+ my $query = 'select alert.id as alert_id, alert.email as alert_email, alert.lang as alert_lang, alert.cobrand as alert_cobrand,
+ alert.cobrand_data as alert_cobrand_data, alert.parameter as alert_parameter, alert.parameter2 as alert_parameter2, ';
+ if ($head_table) {
+ $query .= "
+ $item_table.id as item_id, $item_table.name as item_name, $item_table.text as item_text,
+ $head_table.*
+ from alert
+ inner join $item_table on alert.parameter::integer = $item_table.${head_table}_id
+ inner join $head_table on alert.parameter::integer = $head_table.id";
+ } else {
+ $query .= " $item_table.*,
+ $item_table.id as item_id
+ from alert, $item_table";
+ }
+ $query .= "
+ where alert_type='$ref' and whendisabled is null and $item_table.confirmed >= whensubscribed
+ and $item_table.confirmed >= ms_current_timestamp() - '7 days'::interval
+ and (select whenqueued from alert_sent where alert_sent.alert_id = alert.id and alert_sent.parameter::integer = $item_table.id) is null
+ and $item_table.email <> alert.email
+ $testing_email_clause
+ and $alert_type->{item_where}
+ and alert.confirmed = 1
+ order by alert.id, $item_table.confirmed";
+ # XXX Ugh - needs work
+ $query =~ s/\?/alert.parameter/ if ($query =~ /\?/);
+ $query =~ s/\?/alert.parameter2/ if ($query =~ /\?/);
+ $query = dbh()->prepare($query);
+ $query->execute();
+ my $last_alert_id;
+ my %data = ( template => $alert_type->{template}, data => '' );
+ while (my $row = $query->fetchrow_hashref) {
+ # Cobranded and non-cobranded messages can share a database. In this case, the conf file
+ # should specify a vhost to send the reports for each cobrand, so that they don't get sent
+ # more than once if there are multiple vhosts running off the same database. The email_host
+ # call checks if this is the host that sends mail for this cobrand.
+ next unless (Cobrand::email_host($row->{alert_cobrand}));
+ dbh()->do('insert into alert_sent (alert_id, parameter) values (?,?)', {}, $row->{alert_id}, $row->{item_id});
+ if ($last_alert_id && $last_alert_id != $row->{alert_id}) {
+ _send_aggregated_alert_email(%data);
+ %data = ( template => $alert_type->{template}, data => '' );
+ }
+
+ $url = Cobrand::base_url_for_emails($row->{alert_cobrand}, $row->{alert_cobrand_data});
+ if ($row->{item_text}) {
+ $data{problem_url} = $url . "/report/" . $row->{id};
+ $data{data} .= $row->{item_name} . ' : ' if $row->{item_name};
+ $data{data} .= $row->{item_text} . "\n\n------\n\n";
+ } else {
+ $data{data} .= $url . "/report/" . $row->{id} . " - $row->{title}\n\n";
+ }
+ if (!$data{alert_email}) {
+ %data = (%data, %$row);
+ if ($ref eq 'area_problems' || $ref eq 'council_problems' || $ref eq 'ward_problems') {
+ my $va_info = mySociety::MaPit::get_voting_area_info($row->{alert_parameter});
+ $data{area_name} = $va_info->{name};
+ }
+ if ($ref eq 'ward_problems') {
+ my $va_info = mySociety::MaPit::get_voting_area_info($row->{alert_parameter2});
+ $data{ward_name} = $va_info->{name};
+ }
+ }
+ $data{cobrand} = $row->{alert_cobrand};
+ $data{cobrand_data} = $row->{alert_cobrand_data};
+ $data{lang} = $row->{alert_lang};
+ $last_alert_id = $row->{alert_id};
+ }
+ if ($last_alert_id) {
+ _send_aggregated_alert_email(%data);
+ }
+ }
+
+ # Nearby done separately as the table contains the parameters
+ my $template = dbh()->selectrow_array("select template from alert_type where ref = 'local_problems'");
+ my $query = "select * from alert where alert_type='local_problems' and whendisabled is null and confirmed=1 order by id";
+ $query = dbh()->prepare($query);
+ $query->execute();
+ while (my $alert = $query->fetchrow_hashref) {
+ next unless (Cobrand::email_host($alert->{cobrand}));
+ my $e = $alert->{parameter};
+ my $n = $alert->{parameter2};
+ $url = Cobrand::base_url_for_emails($alert->{cobrand}, $alert->{cobrand_data});
+ my ($site_restriction, $site_id) = Cobrand::site_restriction($alert->{cobrand}, $alert->{cobrand_data});
+ my ($lat, $lon) = mySociety::GeoUtil::national_grid_to_wgs84($e, $n, 'G');
+ my $d = mySociety::Gaze::get_radius_containing_population($lat, $lon, 200000);
+ $d = int($d*10+0.5)/10;
+ my $testing_email_clause = "and problem.email <> '$testing_email'" if $testing_email;
+ my %data = ( template => $template, data => '', alert_id => $alert->{id}, alert_email => $alert->{email}, lang => $alert->{lang}, cobrand => $alert->{cobrand}, cobrand_data => $alert->{cobrand_data} );
+ my $q = "select * from problem_find_nearby(?, ?, ?) as nearby, problem
+ where nearby.problem_id = problem.id and problem.state in ('confirmed', 'fixed')
+ and problem.confirmed >= ? and problem.confirmed >= ms_current_timestamp() - '7 days'::interval
+ and (select whenqueued from alert_sent where alert_sent.alert_id = ? and alert_sent.parameter::integer = problem.id) is null
+ and problem.email <> ?
+ $testing_email_clause
+ $site_restriction
+ order by confirmed desc";
+ $q = dbh()->prepare($q);
+ $q->execute($e, $n, $d, $alert->{whensubscribed}, $alert->{id}, $alert->{email});
+ while (my $row = $q->fetchrow_hashref) {
+ dbh()->do('insert into alert_sent (alert_id, parameter) values (?,?)', {}, $alert->{id}, $row->{id});
+ $data{data} .= $url . "/report/" . $row->{id} . " - $row->{title}\n\n";
+ }
+ _send_aggregated_alert_email(%data) if $data{data};
+ }
+}
+
+sub _send_aggregated_alert_email(%) {
+ my %data = @_;
+ Cobrand::set_lang_and_domain($data{cobrand}, $data{lang}, 1);
+
+ $data{unsubscribe_url} = Cobrand::base_url_for_emails($data{cobrand}, $data{cobrand_data}) . '/A/'
+ . mySociety::AuthToken::store('alert', { id => $data{alert_id}, type => 'unsubscribe', email => $data{alert_email} } );
+ my $template = "$FindBin::Bin/../templates/emails/$data{template}";
+ if ($data{cobrand}) {
+ my $template_cobrand = "$FindBin::Bin/../templates/emails/$data{cobrand}/$data{template}";
+ $template = $template_cobrand if -e $template_cobrand;
+ }
+ $template = File::Slurp::read_file($template);
+ my $sender = Cobrand::contact_email($data{cobrand});
+ my $sender_name = Cobrand::contact_name($data{cobrand});
+ (my $from = $sender) =~ s/team/fms-DO-NOT-REPLY/; # XXX
+ my $email = mySociety::Email::construct_email({
+ _template_ => _($template),
+ _parameters_ => \%data,
+ From => [ $from, _($sender_name) ],
+ To => $data{alert_email},
+ 'Message-ID' => sprintf('<alert-%s-%s@mysociety.org>', time(), unpack('h*', random_bytes(5, 1))),
+ });
+
+ my $result = mySociety::EmailUtil::send_email($email, $sender, $data{alert_email});
+ if ($result == mySociety::EmailUtil::EMAIL_SUCCESS) {
+ dbh()->commit();
+ } else {
+ dbh()->rollback();
+ throw FixMyStreet::Alert::Error("Failed to send alert $data{alert_id}!");
+ }
+}
+
+sub generate_rss ($$$;$$$$) {
+ my ($type, $xsl, $qs, $db_params, $title_params, $cobrand, $http_q) = @_;
+ $db_params ||= [];
+ my $url = Cobrand::base_url($cobrand);
+ my $cobrand_data = Cobrand::extra_data($cobrand, $http_q);
+ my $q = dbh()->prepare('select * from alert_type where ref=?');
+ $q->execute($type);
+ my $alert_type = $q->fetchrow_hashref;
+ my ($site_restriction, $site_id) = Cobrand::site_restriction($cobrand, $cobrand_data);
+ throw FixMyStreet::Alert::Error('Unknown alert type') unless $alert_type;
+
+ # Do our own encoding
+
+ my $rss = new XML::RSS( version => '2.0', encoding => 'UTF-8',
+ stylesheet=> $xsl, encode_output => undef );
+ $rss->add_module(prefix=>'georss', uri=>'http://www.georss.org/georss');
+
+ # XXX: Not generic
+ # Only apply a site restriction if the alert uses the problem table
+ $site_restriction = '' unless $alert_type->{item_table} eq 'problem';
+ my $query = 'select * from ' . $alert_type->{item_table} . ' where '
+ . ($alert_type->{head_table} ? $alert_type->{head_table}.'_id=? and ' : '')
+ . $alert_type->{item_where} . $site_restriction . ' order by '
+ . $alert_type->{item_order};
+ $query .= ' limit 20' unless $type =~ /^all/;
+ $q = dbh()->prepare($query);
+ if ($query =~ /\?/) {
+ throw FixMyStreet::Alert::Error('Missing parameter') unless @$db_params;
+ $q->execute(@$db_params);
+ } else {
+ $q->execute();
+ }
+
+ my @months = ('', 'January','February','March','April','May','June',
+ 'July','August','September','October','November','December');
+ while (my $row = $q->fetchrow_hashref) {
+ # XXX: How to do this properly? name might be null in comment table, hence needing this
+ my $pubDate;
+ $row->{name} ||= 'anonymous';
+ # And we want pretty dates... :-/
+ if ($row->{confirmed}) {
+ $row->{confirmed} =~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/;
+ $pubDate = mySociety::Locale::in_gb_locale {
+ strftime("%a, %d %b %Y %H:%M:%S %z", $6, $5, $4, $3, $2-1, $1-1900, -1, -1, 0)
+ };
+ $row->{confirmed} = ordinal($3+0) . ' ' . $months[$2];
+ }
+
+ (my $title = _($alert_type->{item_title})) =~ s/{{(.*?)}}/$row->{$1}/g;
+ (my $link = $alert_type->{item_link}) =~ s/{{(.*?)}}/$row->{$1}/g;
+ (my $desc = _($alert_type->{item_description})) =~ s/{{(.*?)}}/$row->{$1}/g;
+ my $cobrand_url = Cobrand::url($cobrand, $url . $link, $http_q);
+ my %item = (
+ title => ent($title),
+ link => $cobrand_url,
+ guid => $cobrand_url,
+ description => ent(ent($desc)) # Yes, double-encoded, really.
+ );
+ $item{pubDate} = $pubDate if $pubDate;
+
+ # XXX: Not-very-generic extensions, at all
+ my $display_photos = Cobrand::allow_photo_display($cobrand);
+ if ($display_photos && $row->{photo}) {
+ $item{description} .= ent("\n<br><img src=\"". Cobrand::url($cobrand, $url, $http_q) . "/photo?id=$row->{id}\">");
+ }
+ $item{description} .= ent("\n<br><a href='$cobrand_url'>Report on FixMyStreet</a>");
+
+ if ($row->{easting} && $row->{northing}) {
+ my ($lat,$lon) = mySociety::GeoUtil::national_grid_to_wgs84($row->{easting}, $row->{northing}, 'G');
+ $item{georss} = { point => "$lat $lon" };
+ }
+ $rss->add_item( %item );
+ }
+
+ my $row = {};
+ if ($alert_type->{head_sql_query}) {
+ $q = dbh()->prepare($alert_type->{head_sql_query});
+ if ($alert_type->{head_sql_query} =~ /\?/) {
+ $q->execute(@$db_params);
+ } else {
+ $q->execute();
+ }
+ $row = $q->fetchrow_hashref;
+ }
+ foreach (keys %$title_params) {
+ $row->{$_} = $title_params->{$_};
+ }
+ (my $title = _($alert_type->{head_title})) =~ s/{{(.*?)}}/$row->{$1}/g;
+ (my $link = $alert_type->{head_link}) =~ s/{{(.*?)}}/$row->{$1}/g;
+ (my $desc = _($alert_type->{head_description})) =~ s/{{(.*?)}}/$row->{$1}/g;
+ $rss->channel(
+ title => ent($title), link => "$url$link$qs", description => ent($desc),
+ language => 'en-gb'
+ );
+
+ my $out = $rss->as_string;
+ my $uri = Cobrand::url($cobrand, $ENV{SCRIPT_URI}, $http_q);
+ $out =~ s{<link>(.*?)</link>}{"<link>" . Cobrand::url($cobrand, $1, $http_q) . "</link><uri>$uri</uri>"}e;
+
+ return $out;
+}
diff --git a/web/alert.cgi b/web/alert.cgi
index c6a6eb647..46eef082b 100755
--- a/web/alert.cgi
+++ b/web/alert.cgi
@@ -13,7 +13,7 @@ use Standard;
use Digest::SHA1 qw(sha1_hex);
use Error qw(:try);
use CrossSell;
-use mySociety::Alert;
+use FixMyStreet::Alert;
use mySociety::AuthToken;
use mySociety::Config;
use mySociety::DBHandle qw(select_all);
@@ -446,8 +446,8 @@ sub alert_signed_input {
my $out;
my $cobrand = Page::get_cobrand($q);
if ($signed_email eq sha1_hex("$id-$email-$salt-$secret")) {
- my $alert_id = mySociety::Alert::create($email, 'new_updates', $cobrand, '', $id);
- mySociety::Alert::confirm($alert_id);
+ my $alert_id = FixMyStreet::Alert::create($email, 'new_updates', $cobrand, '', $id);
+ FixMyStreet::Alert::confirm($alert_id);
$out = $q->p(_('You have successfully subscribed to that alert.'));
my $cobrand = Page::get_cobrand($q);
my $display_advert = Cobrand::allow_crosssell_adverts($cobrand);
@@ -476,14 +476,14 @@ sub alert_token {
my $message;
my $display_advert = Cobrand::allow_crosssell_adverts($cobrand);
if ($type eq 'subscribe') {
- mySociety::Alert::confirm($id);
+ FixMyStreet::Alert::confirm($id);
$message = _('You have successfully confirmed your alert.');
$out = $q->p($message);
if ($display_advert) {
$out .= CrossSell::display_advert($q, $email);
}
} elsif ($type eq 'unsubscribe') {
- mySociety::Alert::delete($id);
+ FixMyStreet::Alert::delete($id);
$message = _('You have successfully deleted your alert.');
$out = $q->p($message);
if ($display_advert) {
@@ -517,22 +517,22 @@ sub alert_do_subscribe {
my $cobrand_data = Cobrand::extra_alert_data($cobrand, $q);
if ($type eq 'updates') {
my $id = $q->param('id');
- $alert_id = mySociety::Alert::create($email, 'new_updates', $cobrand, $cobrand_data, $id);
+ $alert_id = FixMyStreet::Alert::create($email, 'new_updates', $cobrand, $cobrand_data, $id);
} elsif ($type eq 'problems') {
- $alert_id = mySociety::Alert::create($email, 'new_problems', $cobrand, $cobrand_data);
+ $alert_id = FixMyStreet::Alert::create($email, 'new_problems', $cobrand, $cobrand_data);
} elsif ($type eq 'local') {
my $feed = $q->param('feed');
if ($feed =~ /^area:(?:\d+:)?(\d+)/) {
- $alert_id = mySociety::Alert::create($email, 'area_problems', $cobrand, $cobrand_data, $1);
+ $alert_id = FixMyStreet::Alert::create($email, 'area_problems', $cobrand, $cobrand_data, $1);
} elsif ($feed =~ /^council:(\d+)/) {
- $alert_id = mySociety::Alert::create($email, 'council_problems', $cobrand, $cobrand_data, $1, $1);
+ $alert_id = FixMyStreet::Alert::create($email, 'council_problems', $cobrand, $cobrand_data, $1, $1);
} elsif ($feed =~ /^ward:(\d+):(\d+)/) {
- $alert_id = mySociety::Alert::create($email, 'ward_problems', $cobrand, $cobrand_data, $1, $2);
+ $alert_id = FixMyStreet::Alert::create($email, 'ward_problems', $cobrand, $cobrand_data, $1, $2);
} elsif ($feed =~ /^local:(\d+):(\d+)/) {
- $alert_id = mySociety::Alert::create($email, 'local_problems', $cobrand, $cobrand_data, $1, $2);
+ $alert_id = FixMyStreet::Alert::create($email, 'local_problems', $cobrand, $cobrand_data, $1, $2);
}
} else {
- throw mySociety::Alert::Error('Invalid type');
+ throw FixMyStreet::Alert::Error('Invalid type');
}
my %h = ();
diff --git a/web/confirm.cgi b/web/confirm.cgi
index 8e51a4555..ba2b6ee67 100755
--- a/web/confirm.cgi
+++ b/web/confirm.cgi
@@ -12,7 +12,7 @@ use strict;
use Standard;
use Digest::SHA1 qw(sha1_hex);
use CrossSell;
-use mySociety::Alert;
+use FixMyStreet::Alert;
use mySociety::AuthToken;
use mySociety::Random qw(random_bytes);
@@ -115,8 +115,8 @@ sub confirm_update {
# Subscribe updater to email updates if requested
if ($add_alert) {
- my $alert_id = mySociety::Alert::create($email, 'new_updates', $cobrand, $cobrand_data, $problem_id);
- mySociety::Alert::confirm($alert_id);
+ my $alert_id = FixMyStreet::Alert::create($email, 'new_updates', $cobrand, $cobrand_data, $problem_id);
+ FixMyStreet::Alert::confirm($alert_id);
}
return $out;
@@ -178,8 +178,8 @@ $q->p('<a href="/report/' . $id . '">' . _('View your report') . '</a>.');
}
# Subscribe problem reporter to email updates
- my $alert_id = mySociety::Alert::create($email, 'new_updates', $cobrand, $cobrand_data, $id);
- mySociety::Alert::confirm($alert_id);
+ my $alert_id = FixMyStreet::Alert::create($email, 'new_updates', $cobrand, $cobrand_data, $id);
+ FixMyStreet::Alert::confirm($alert_id);
return $out;
}
diff --git a/web/reports.cgi b/web/reports.cgi
index 4faee63f9..fe4213be4 100755
--- a/web/reports.cgi
+++ b/web/reports.cgi
@@ -12,7 +12,7 @@
use strict;
use Standard;
use URI::Escape;
-use mySociety::Alert;
+use FixMyStreet::Alert;
use mySociety::MaPit;
use mySociety::Web qw(ent NewURL);
use mySociety::VotingArea;
@@ -117,7 +117,7 @@ sub main {
}
print $q->header( -type => 'application/xml; charset=utf-8' );
my $xsl = Cobrand::feed_xsl($cobrand);
- my $out = mySociety::Alert::generate_rss($type, $xsl, "/$url", \@params, \%title_params, $cobrand, $q);
+ my $out = FixMyStreet::Alert::generate_rss($type, $xsl, "/$url", \@params, \%title_params, $cobrand, $q);
$out =~ s/matthew.fixmystreet/emptyhomes.matthew.fixmystreet/g if $q->{site} eq 'emptyhomes';
print $out;
return;
diff --git a/web/rss.cgi b/web/rss.cgi
index 5386526df..effa15f08 100755
--- a/web/rss.cgi
+++ b/web/rss.cgi
@@ -12,7 +12,7 @@ use strict;
use Error qw(:try);
use Standard;
use URI::Escape;
-use mySociety::Alert;
+use FixMyStreet::Alert;
use mySociety::MaPit;
use mySociety::GeoUtil;
use mySociety::Gaze;
@@ -34,20 +34,20 @@ sub main {
return;
}
my $qs = 'report/' . $id;
- $out = mySociety::Alert::generate_rss($type, $xsl, $qs, [$id], undef, $cobrand, $q);
+ $out = FixMyStreet::Alert::generate_rss($type, $xsl, $qs, [$id], undef, $cobrand, $q);
} elsif ($type eq 'new_problems' || $type eq 'new_fixed_problems') {
- $out = mySociety::Alert::generate_rss($type, $xsl, '', undef, undef, $cobrand, $q);
+ $out = FixMyStreet::Alert::generate_rss($type, $xsl, '', undef, undef, $cobrand, $q);
} elsif ($type eq 'council_problems') {
my $id = $q->param('id');
my $qs = '/'.$id;
- $out = mySociety::Alert::generate_rss($type, $xsl, $qs, [$id], undef, $cobrand. $q);
+ $out = FixMyStreet::Alert::generate_rss($type, $xsl, $qs, [$id], undef, $cobrand. $q);
} elsif ($type eq 'area_problems') {
my $id = $q->param('id');
my $va_info = mySociety::MaPit::call('area', $id);
my $qs = '/'.$id;
- $out = mySociety::Alert::generate_rss($type, $xsl, $qs, [$id], { NAME => $va_info->{name} }, $cobrand, $q);
+ $out = FixMyStreet::Alert::generate_rss($type, $xsl, $qs, [$id], { NAME => $va_info->{name} }, $cobrand, $q);
} elsif ($type eq 'all_problems') {
- $out = mySociety::Alert::generate_rss($type, $xsl, '', undef, undef, $cobrand, $q);
+ $out = FixMyStreet::Alert::generate_rss($type, $xsl, '', undef, undef, $cobrand, $q);
} else {
my $base = mySociety::Config::get('BASE_URL');
print $q->redirect($base . '/alert');
@@ -114,6 +114,6 @@ sub rss_local_problems {
}
my $xsl = Cobrand::feed_xsl($cobrand);
- return mySociety::Alert::generate_rss('local_problems', $xsl, $qs, [$e, $n, $d], undef, $cobrand, $q);
+ return FixMyStreet::Alert::generate_rss('local_problems', $xsl, $qs, [$e, $n, $d], undef, $cobrand, $q);
}
diff --git a/web/tms-signup.cgi b/web/tms-signup.cgi
index 2bafd1543..44099417f 100755
--- a/web/tms-signup.cgi
+++ b/web/tms-signup.cgi
@@ -12,7 +12,6 @@ use strict;
use Standard;
use Digest::SHA1 qw(sha1_hex);
use CrossSell;
-use mySociety::Alert;
use mySociety::AuthToken;
use mySociety::Config;
use mySociety::EmailUtil qw(is_valid_email);