aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conf/general-example5
-rw-r--r--perllib/CrossSell.pm65
-rwxr-xr-xweb/alert.cgi9
-rwxr-xr-xweb/confirm.cgi6
-rwxr-xr-xweb/contact.cgi7
-rw-r--r--web/posters/.cvsignore1
-rwxr-xr-xweb/questionnaire.cgi19
7 files changed, 101 insertions, 11 deletions
diff --git a/conf/general-example b/conf/general-example
index f8f89e391..ef9605635 100644
--- a/conf/general-example
+++ b/conf/general-example
@@ -14,7 +14,7 @@
* Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
* Email: francis@mysociety.org; WWW: http://www.mysociety.org
*
- * $Id: general-example,v 1.13 2007-07-07 11:32:44 matthew Exp $
+ * $Id: general-example,v 1.14 2007-07-09 17:40:28 matthew Exp $
*
*/
@@ -44,6 +44,9 @@ define('OPTION_TILES_URL', 'http://tilma.mysociety.org/tileserver/10k-full-londo
define('OPTION_EVEL_URL', 'http://services.mysociety.org/evel');
define('OPTION_GAZE_URL', 'http://gaze.mysociety.org/gaze');
+define('OPTION_AUTH_SHARED_SECRET', '');
+define('OPTION_HEARFROMYOURMP_BASE_URL', '');
+
define('OPTION_SMTP_SMARTHOST', 'localhost');
define('OPTION_FLICKR_API', '');
diff --git a/perllib/CrossSell.pm b/perllib/CrossSell.pm
new file mode 100644
index 000000000..9f471d5f6
--- /dev/null
+++ b/perllib/CrossSell.pm
@@ -0,0 +1,65 @@
+#!/usr/bin/perl -w
+#
+# CrossSell.pm:
+# Adverts from FixMyStreet to another site.
+#
+# Unlike the PHP crosssell script, returns strings rather than prints them;
+# and currently displays the same advert if e.g. there's a connection problem.
+#
+# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
+#
+# $Id: CrossSell.pm,v 1.1 2007-07-09 17:40:28 matthew Exp $
+
+# Config parameters site needs set to call these functions:
+# OPTION_AUTH_SHARED_SECRET
+# OPTION_HEARFROMYOURMP_BASE_URL
+
+package CrossSell;
+
+use strict;
+use LWP::Simple qw($ua get);
+$ua->timeout(5);
+use URI::Escape;
+use mySociety::AuthToken;
+
+# Force site means always display this advert
+sub display_hfymp_advert ($;$$) {
+ my ($user_email, $user_name, $postcode) = @_;
+ my $auth_signature = mySociety::AuthToken::sign_with_shared_secret($user_email, mySociety::Config::get('AUTH_SHARED_SECRET'));
+
+ # See if already signed up
+ my $url = mySociety::Config::get('HEARFROMYOURMP_BASE_URL');
+ my $already_signed = get($url . '/authed?email=' . uri_escape($user_email) . "&sign=" . uri_escape($auth_signature));
+ # Different from PHP version; display this advert if e.g. connection problem
+ return '' if $already_signed eq 'already signed';
+
+ # If not, display advert
+ $url .= '/?email=' . uri_escape($user_email) . '&sign=' . uri_escape($auth_signature);
+ $url .= '&name=' . uri_escape($user_name) if $user_name;
+ $url .= '&pc=' . uri_escape($postcode) if $postcode;
+ return <<EOF;
+<h2 style="padding: 1em; font-size: 200%" align="center">
+Since you're interested in your local area, why not
+start a <a href="$url">long term relationship</a> with your MP?
+</h2>
+EOF
+ return 1;
+}
+
+# Choose appropriate advert and display it.
+# $this_site is to stop a site advertising itself.
+sub display_advert ($;$$) {
+ my ($user_email, $user_name, $postcode) = @_;
+ my $out = display_hfymp_advert($user_email, $user_name, $postcode);
+ # $out ||= display_twfy_alerts_advert($user_email, $postcode);
+ $out ||= <<EOF;
+<h2 style="padding: 1em; font-size: 200%" align="center">
+If you're interested in improving your local area,
+<a href="http://www.pledgebank.com/">use PledgeBank</a> to
+do so with other people!</h2>
+EOF
+ return $out;
+}
+
+1;
diff --git a/web/alert.cgi b/web/alert.cgi
index d482d3513..daa94d8c2 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.7 2007-06-15 14:57:52 matthew Exp $
+# $Id: alert.cgi,v 1.8 2007-07-09 17:40:29 matthew Exp $
use strict;
require 5.8.0;
@@ -17,6 +17,7 @@ use lib "$FindBin::Bin/../perllib";
use lib "$FindBin::Bin/../../perllib";
use Digest::SHA1 qw(sha1_hex);
+use CrossSell;
use Page;
use mySociety::Alert;
use mySociety::AuthToken;
@@ -48,6 +49,7 @@ sub main {
my $alert_id = mySociety::Alert::create($email, 'new_updates', $id);
mySociety::Alert::confirm($alert_id);
$out .= $q->p(_('You have successfully subscribed to that alert.'));
+ $out .= CrossSell::display_advert($email);
} else {
$out = $q->p(_('We could not validate that alert.'));
}
@@ -55,12 +57,15 @@ sub main {
my $data = mySociety::AuthToken::retrieve('alert', $token);
if (my $id = $data->{id}) {
my $type = $data->{type};
+ my $email = $data->{email};
if ($type eq 'subscribe') {
mySociety::Alert::confirm($id);
$out = $q->p(_('You have successfully confirmed your alert.'));
+ $out .= CrossSell::display_advert($email);
} elsif ($type eq 'unsubscribe') {
mySociety::Alert::delete($id);
$out = $q->p(_('You have successfully deleted your alert.'));
+ $out .= CrossSell::display_advert($email);
}
} else {
$out = $q->p(_(<<EOF));
@@ -87,7 +92,7 @@ EOF
}
my %h = ();
$h{url} = mySociety::Config::get('BASE_URL') . '/A/'
- . mySociety::AuthToken::store('alert', { id => $alert_id, type => 'subscribe' } );
+ . mySociety::AuthToken::store('alert', { id => $alert_id, type => 'subscribe', email => $email } );
dbh()->commit();
$out = Page::send_email($email, undef, 'alert', %h);
}
diff --git a/web/confirm.cgi b/web/confirm.cgi
index afc7577f3..da7a6d07f 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.24 2007-06-22 14:24:47 matthew Exp $
+# $Id: confirm.cgi,v 1.25 2007-07-09 17:40:29 matthew Exp $
use strict;
require 5.8.0;
@@ -17,6 +17,7 @@ use lib "$FindBin::Bin/../perllib";
use lib "$FindBin::Bin/../../perllib";
use Digest::SHA1 qw(sha1_hex);
+use CrossSell;
use Page;
use mySociety::AuthToken;
use mySociety::Config;
@@ -149,7 +150,7 @@ EOF
sub add_questionnaire {
my ($q, $id, $token) = @_;
- my $problem_id = dbh()->selectrow_array("select problem_id from comment where id=?", {}, $id);
+ my ($problem_id, $email, $name) = dbh()->selectrow_array("select problem_id, email, name from comment where id=?", {}, $id);
my $reported = $q->param('reported');
$reported = $reported eq 'Yes' ? 't' : ($reported eq 'No' ? 'f' : undef);
return ask_questionnaire($token) unless $reported;
@@ -161,6 +162,7 @@ sub add_questionnaire {
ms_current_timestamp(), ?, 'confirmed', 'fixed');", {}, $problem_id, $reported)
unless $already;
my $out = $q->p(sprintf('Thank you &mdash; you can <a href="%s">view your updated problem</a> on the site.', "/?id=$problem_id"));
+ $out .= CrossSell::display_advert($email, $name);
return $out;
}
diff --git a/web/contact.cgi b/web/contact.cgi
index eaaadcf91..f76f583a1 100755
--- a/web/contact.cgi
+++ b/web/contact.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: contact.cgi,v 1.20 2007-06-15 14:57:52 matthew Exp $
+# $Id: contact.cgi,v 1.21 2007-07-09 17:40:29 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 CrossSell;
use Page;
use mySociety::Config;
use mySociety::DBHandle qw(dbh);
@@ -83,7 +84,9 @@ sub contact_submit {
});
my $result = mySociety::Util::send_email($email, $input{email}, mySociety::Config::get('CONTACT_EMAIL'));
if ($result == mySociety::Util::EMAIL_SUCCESS) {
- return $q->p("Thanks for your feedback. We'll get back to you as soon as we can!");
+ my $out = $q->p("Thanks for your feedback. We'll get back to you as soon as we can!");
+ $out .= CrossSell::display_advert($input{email}, $input{name});
+ return $out;
} else {
return $q->p('Failed to send message. Please try again, or <a href="mailto:' . mySociety::Config::get('CONTACT_EMAIL') . '">email us</a>.');
}
diff --git a/web/posters/.cvsignore b/web/posters/.cvsignore
new file mode 100644
index 000000000..714f73c54
--- /dev/null
+++ b/web/posters/.cvsignore
@@ -0,0 +1 @@
+_Inline
diff --git a/web/questionnaire.cgi b/web/questionnaire.cgi
index c0dbb6dda..45b9d1611 100755
--- a/web/questionnaire.cgi
+++ b/web/questionnaire.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: questionnaire.cgi,v 1.12 2007-06-22 14:20:45 matthew Exp $
+# $Id: questionnaire.cgi,v 1.13 2007-07-09 17:40:29 matthew Exp $
use strict;
require 5.8.0;
@@ -17,6 +17,7 @@ use lib "$FindBin::Bin/../perllib";
use lib "$FindBin::Bin/../../perllib";
use Error qw(:try);
+use CrossSell;
use Page;
use mySociety::AuthToken;
use mySociety::Config;
@@ -134,10 +135,20 @@ sub submit_questionnaire {
if $input{been_fixed} eq 'No' && $input{another} eq 'Yes';
dbh()->commit();
- return <<EOF;
-<p>Thank you very much for filling in our questionnaire.
-<a href="/?id=$problem->{id}">View your report on the site</a></p>
+ if ($new_state eq 'confirmed' || (!$new_state && $problem->{state} eq 'confirmed')) {
+ return <<EOF;
+<p style="font-size:200%">We're sorry to hear that. We have two suggestions: why not try
+<a href="http://www.writetothem.com/">writing direct to your councillor(s)</a>
+or, if it's a problem that could be fixed by lcaol people working together
+why not <a href="http://www.pledgebank.com/new">make and publicise a pledge</a>?
+</p>
+EOF
+ } else {
+ my $out = <<EOF;
+<p>Thank you very much for filling in our questionnaire; glad to hear it's been fixed.</p>
EOF
+ $out .= CrossSell::display_advert($problem->{email}, $problem->{name});
+ }
}
sub display_questionnaire {