aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlouise <louise>2009-09-28 15:40:56 +0000
committerlouise <louise>2009-09-28 15:40:56 +0000
commit9ecbe326440956f81b414cf28fd61b67e2da35c9 (patch)
treef35161c65463422329e3a90c65d70aeecfc3264a
parentb58694eca361b8a80ff3b9116f90442a74f56934 (diff)
Allow saving of extra data with alerts
-rwxr-xr-xweb/alert.cgi17
-rwxr-xr-xweb/confirm.cgi12
2 files changed, 15 insertions, 14 deletions
diff --git a/web/alert.cgi b/web/alert.cgi
index 8a7c4d0fc..38ea9fd9c 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.49 2009-09-28 12:57:03 louise Exp $
+# $Id: alert.cgi,v 1.50 2009-09-28 15:40:56 louise Exp $
use strict;
use Standard;
@@ -340,7 +340,7 @@ 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);
+ my $alert_id = mySociety::Alert::create($email, 'new_updates', $cobrand, '', $id);
mySociety::Alert::confirm($alert_id);
$out = $q->p(_('You have successfully subscribed to that alert.'));
$out .= CrossSell::display_advert($q, $email);
@@ -390,21 +390,22 @@ sub alert_do_subscribe {
my $alert_id;
my $cobrand = Page::get_cobrand($q);
+ 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, $id);
+ $alert_id = mySociety::Alert::create($email, 'new_updates', $cobrand, $cobrand_data, $id);
} elsif ($type eq 'problems') {
- $alert_id = mySociety::Alert::create($email, 'new_problems', $cobrand);
+ $alert_id = mySociety::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, $1);
+ $alert_id = mySociety::Alert::create($email, 'area_problems', $cobrand, $cobrand_data, $1);
} elsif ($feed =~ /^council:(\d+)/) {
- $alert_id = mySociety::Alert::create($email, 'council_problems', $cobrand, $1, $1);
+ $alert_id = mySociety::Alert::create($email, 'council_problems', $cobrand, $cobrand_data, $1, $1);
} elsif ($feed =~ /^ward:(\d+):(\d+)/) {
- $alert_id = mySociety::Alert::create($email, 'ward_problems', $cobrand, $1, $2);
+ $alert_id = mySociety::Alert::create($email, 'ward_problems', $cobrand, $cobrand_data, $1, $2);
} elsif ($feed =~ /^local:(\d+):(\d+)/) {
- $alert_id = mySociety::Alert::create($email, 'local_problems', $cobrand, $1, $2);
+ $alert_id = mySociety::Alert::create($email, 'local_problems', $cobrand, $cobrand_data, $1, $2);
}
} else {
throw mySociety::Alert::Error('Invalid type');
diff --git a/web/confirm.cgi b/web/confirm.cgi
index 32425de5c..dcc8e48b4 100755
--- a/web/confirm.cgi
+++ b/web/confirm.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: confirm.cgi,v 1.56 2009-09-09 08:32:41 louise Exp $
+# $Id: confirm.cgi,v 1.57 2009-09-28 15:40:56 louise Exp $
use strict;
use Standard;
@@ -59,8 +59,8 @@ sub confirm_update {
$add_alert = $data->{add_alert};
}
- my ($problem_id, $fixed, $email, $name) = dbh()->selectrow_array(
- "select problem_id, mark_fixed, email, name from comment where id=?", {}, $id);
+ my ($problem_id, $fixed, $email, $name, $cobrand_data) = dbh()->selectrow_array(
+ "select problem_id, mark_fixed, email, name, cobrand_data from comment where id=?", {}, $id);
$email = lc($email);
(my $domain = $email) =~ s/^.*\@//;
@@ -101,7 +101,7 @@ sub confirm_update {
# Subscribe updater to email updates if requested
if ($add_alert) {
my $cobrand = Page::get_cobrand($q);
- my $alert_id = mySociety::Alert::create($email, 'new_updates', $cobrand, $problem_id);
+ my $alert_id = mySociety::Alert::create($email, 'new_updates', $cobrand, $cobrand_data, $problem_id);
mySociety::Alert::confirm($alert_id);
}
@@ -111,7 +111,7 @@ sub confirm_update {
sub confirm_problem {
my ($q, $id) = @_;
- my ($council, $email, $name) = dbh()->selectrow_array("select council, email, name from problem where id=?", {}, $id);
+ my ($council, $email, $name, $cobrand_data) = dbh()->selectrow_array("select council, email, name, cobrand_data from problem where id=?", {}, $id);
(my $domain = $email) =~ s/^.*\@//;
if (dbh()->selectrow_array('select email from abuse where lower(email)=? or lower(email)=?', {}, lc($email), lc($domain))) {
@@ -160,7 +160,7 @@ $q->p('<a href="/report/' . $id . '">' . _('View your report') . '</a>.');
# Subscribe problem reporter to email updates
my $cobrand = Page::get_cobrand($q);
- my $alert_id = mySociety::Alert::create($email, 'new_updates', $cobrand, $id);
+ my $alert_id = mySociety::Alert::create($email, 'new_updates', $cobrand, $cobrand_data, $id);
mySociety::Alert::confirm($alert_id);
return $out;