aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/CrossSell.pm297
-rw-r--r--perllib/FixMyStreet/App/Controller/Contact.pm5
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Questionnaire.pm12
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm3
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm21
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm7
-rw-r--r--perllib/FixMyStreet/App/Controller/Tokens.pm28
-rw-r--r--perllib/FixMyStreet/App/View/Web.pm16
8 files changed, 48 insertions, 341 deletions
diff --git a/perllib/CrossSell.pm b/perllib/CrossSell.pm
deleted file mode 100644
index 9567c2b38..000000000
--- a/perllib/CrossSell.pm
+++ /dev/null
@@ -1,297 +0,0 @@
-# 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.17 2009-09-10 09:36:42 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);
-use URI::Escape;
-use mySociety::AuthToken;
-use mySociety::Web qw(ent);
-
-sub display_random_hfymp_advert {
- my ($email, $name, $text) = @_;
- $name ||= '';
- my $auth_signature = mySociety::AuthToken::sign_with_shared_secret($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($email) . "&sign=" . uri_escape($auth_signature));
- # Different from PHP version; display this advert if e.g. connection problem
- return '' if $already_signed && $already_signed eq 'already signed';
-
- $email = ent($email);
- $name = ent($name);
- $auth_signature = ent($auth_signature);
- $text =~ s#\[form\]#<form action="http://www.hearfromyourmp.com/" method="post">
-<input type="hidden" name="name" value="$name">
-<input type="hidden" name="email" value="$email">
-<input type="hidden" name="sign" value="$auth_signature">
-<h2><input style="font-size:100%" type="submit" value="#;
- $text =~ s#\[/form\]#"></h2>#;
-
- return '<div id="advert_hfymp">' . $text . '</div>';
-}
-
-sub display_random_gny_advert {
- my ($email, $name, $text) = @_;
- return '<div id="advert_thin">' . $text . '</div>';
-}
-
-sub display_random_twfy_alerts_advert {
- my ($email, $name, $text) = @_;
- my $auth_signature = mySociety::AuthToken::sign_with_shared_secret($email, mySociety::Config::get('AUTH_SHARED_SECRET'));
- $text =~ s#\[button\]#<form action="http://www.theyworkforyou.com/alert/" method="post">
-<input type="hidden" name="email" value="$email">
-<input type="hidden" name="sign" value="$auth_signature">
-<input type="hidden" name="site" value="fms">
-<input style="font-size:150%" type="submit" value="#;
- $text =~ s#\[/button\]#"></p>#;
- return '<div id="advert_thin">' . $text . '</div>';
-}
-
-sub display_hfyc_cheltenham_advert {
- my ($email, $name) = @_;
- $name ||= '';
- my $auth_signature = mySociety::AuthToken::sign_with_shared_secret($email, mySociety::Config::get('AUTH_SHARED_SECRET'));
-
- # See if already signed up
- my $already_signed = get('http://cheltenham.hearfromyourcouncillor.com/authed?email=' . uri_escape($email) . "&sign=" . uri_escape($auth_signature));
- # Different from PHP version; display this advert if e.g. connection problem
- return '' if $already_signed && $already_signed eq 'already signed';
-
- # If not, display advert
- $email = ent($email);
- $name = ent($name);
- $auth_signature = ent($auth_signature);
- my $out = <<EOF;
-<form action="http://cheltenham.hearfromyourcouncillor.com/" method="post">
-<input type="hidden" name="name" value="$name">
-<input type="hidden" name="email" value="$email">
-<input type="hidden" name="sign" value="$auth_signature">
-<div id="advert_thin">
-EOF
-
- my $rand = int(rand(2));
- if ($rand == 0) {
- $out .= "<h2>Cool! You're interested in Cheltenham!</h2>
- <p>We've got an exciting new free service that works exclusively
- for people in Cheltenham. Please sign up to help the charity
- that runs WriteToThem, and to get a sneak preview of our new
- service.</p>";
- } else {
- $out .= "<h2>Get to know your councillors.</h2>
- <p>Local councillors are really important, but hardly anyone knows them.
- Use our new free service to build a low-effort, long term relationship
- with your councillor.</p>";
- }
- $out .= <<EOF;
-<p align="center">
-<input type="submit" value="Sign up to HearFromYourCouncillor">
-</p>
-</div>
-</form>
-EOF
- return ($out, "cheltenhamhfyc$rand");
-}
-
-sub display_democracyclub {
- my (%input) = @_;
- return <<EOF;
-<div id="advert_thin">
-<h2 style="margin-bottom:0">Help make the next election the most accountable ever</h2> <p style="font-size:120%;margin-top:0.5em;"><a href="http://www.democracyclub.org.uk/">Join Democracy Club</a> and have fun keeping an eye on your election candidates. <a href="http://www.democracyclub.org.uk/">Sign me up</a>!
-</div>
-EOF
-}
-
-sub display_news_form {
- my (%input) = @_;
- my %input_h = map { $_ => $input{$_} ? ent($input{$_}) : '' } qw(name email signed_email);
- my $auth_signature = $input_h{signed_email};
- return <<EOF;
-<h1 style="padding-top:0.5em">mySociety newsletter</h1>
-
-<p>Interested in hearing more about FixMyStreet successes? Enter your email
-address below and we&rsquo;ll send you occasional emails about what mySociety
-and our users have been up to.</p>
-
-<form method="post" action="//mysociety.us9.list-manage.com/subscribe/post?u=53d0d2026dea615ed488a8834&id=287dc28511">
-<label style="position: absolute; left: -5000px;">
-Leave this box empty: <input type="text" name="b_53d0d2026dea615ed488a8834_287dc28511" tabindex="-1" value="" />
-</label>
-<label for="name">Name:</label>
-<input type="text" name="NAME" id="name" value="$input_h{name}" size="30">
-<br><label for="email">Email:</label>
-<input type="text" name="EMAIL" id="email" value="$input_h{email}" size="30">
-&nbsp; <input type="submit" name="subscribe" value="Add me to the list">
-</form>
-
-<p>mySociety respects your privacy, and we'll never sell or give away your private
-details. You can unsubscribe at any time.</p>
-EOF
-}
-
-sub display_survey_link {
- return <<EOF;
-<h1 style="padding-top:0.5em">User Survey</h1>
-<p>
-We're running a survey to help us understand who uses our sites. If you have 10-15 minutes to spare then we'd be grateful if you could <a href="http://questions.mysociety.org/S/fms/w/" target="_blank">take part</a>.
-</p>
-EOF
-}
-
-sub display_wtt_link {
- return <<EOF;
-<h1 style="padding-top:0.5em">WriteToThem</h1>
-<p>
-Need to write to a politician? Try <a href="https://writetothem.com">WriteToThem</a> - great
-for campaigns too.
-</p>
-EOF
-}
-
-sub display_app_links {
- return <<EOF;
-<h1>Next time, report your issue quicker.</h1>
-<p>Download our awesome app, and make reporting and monitoring issues on the go a breeze.</p>
-
-<p class="app-links">
-<a href="https://play.google.com/store/apps/details?id=org.mysociety.FixMyStreet">
- <img alt="FixMyStreet Android app on Google Play"
- src="/cobrands/fixmystreet/images/google_play_logo.png" />
-</a><a href="https://itunes.apple.com/gb/app/fixmystreet/id297456545">
- <img alt="FixMyStreet app on the App Store"
- src="/cobrands/fixmystreet/images/itunes_store_logo.png" />
-</a>
-</p>
-
-<p class="desktop-advice">Not on your mobile? No problem! Download now, and the app will be ready to use when you next pick up your phone.</p>
-EOF
-}
-
-# Not currently used, needs more explanation and testing; perhaps in future.
-sub display_gny_groups {
- my ($lon, $lat) = @_;
- my $groups = get("http://www.groupsnearyou.com/rss.php?q=$lon,$lat&category=1&pointonly=1");
- my $out = '';
- my $count = 0;
- while ($groups =~ /<item>\s*<title>New group! (.*?)<\/title>.*?<guid isPermaLink="true">(.*?)<\/guid>.*?<description>(.*?)<\/description>/gs) {
- $out .= "<li><a href='$2'>$1</a> $3";
- $count++;
- }
- return unless $out;
- return <<EOF;
-<h1 style="padding-top:0.5em">$count local groups</h1>
-<ul>
-$out
-</ul>
-EOF
-}
-
-# Choose appropriate advert and display it.
-# $this_site is to stop a site advertising itself.
-sub display_advert ($$;$%) {
- my ($c, $email, $name, %data) = @_;
-
- return '' unless $c->cobrand->moniker eq 'fixmystreet';
-
- $ua->timeout(5);
-
- #if (defined $data{council} && $data{council} eq '2326') {
- # my ($out, $ad) = display_hfyc_cheltenham_advert($email, $name);
- # if ($out) {
- # $c->stash->{scratch} = "advert=$ad";
- # return $out;
- # }
- #}
-
- #if ($data{lat}) {
- # my $out = display_gny_groups($data{lon}, $data{lat});
- # if ($out) {
- # $c->stash->{scratch} = 'advert=gnygroups';
- # return '<div style="margin: 0 5em; border-top: dotted 1px #666666;">'
- # . $out . '</div>';
- # }
- #}
-
- #$c->stash->{scratch} = 'advert=demclub0';
- #return display_democracyclub();
-
-# return <<EOF;
-#<div id="advert_thin">
-#<p>Do you have an issue that&rsquo;s too big for FixMyStreet?
-#It could be time to petition your council. Try our new site:
-#<h2 style="margin-top:0; font-size: 150%">
-#<a href="http://www.petitionyourcouncil.com/">PetitionYourCouncil</a></p>
-#</h2>
-#</div>
-#EOF
-
- #unless (defined $data{done_tms} && $data{done_tms}==1) {
- $c->stash->{scratch} = 'advert=wtt';
- return '<div class="advert-mobile-apps">'
- . display_app_links()
- . '</div>';
-
- $c->stash->{scratch} = 'advert=news';
- my $auth_signature = '';
- unless (defined $data{emailunvalidated} && $data{emailunvalidated}==1) {
- $auth_signature = mySociety::AuthToken::sign_with_shared_secret($email, mySociety::Config::get('AUTH_SHARED_SECRET'));
- }
- return '<div style="margin: 0 5em; border-top: dotted 1px #666666;">'
- . display_news_form(email => $email, name => $name, signed_email => $auth_signature)
- . '</div>';
- #}
-
- my @adverts = (
- [ 'gny0', '<h2>Are you a member of a local group&hellip;</h2> &hellip;which uses the internet to coordinate itself, such as a neighbourhood watch? If so, please help the charity that runs FixMyStreet by <a href="http://www.groupsnearyou.com/add/about/">adding some information about it</a> to our new site, GroupsNearYou.' ],
- [ 'gny1', '<h2>Help us build a map of the world&rsquo;s local communities &ndash;<br><a href="http://www.groupsnearyou.com/add/about/">Add one to GroupsNearYou</a></h2>' ],
- # Since you're interested in your local area, why not
- # start a long term relationship with your MP?
- #[ 'hfymp0', '<h2 style="margin-bottom:0">Get email from your MP in the future</h2> <p style="font-size:120%;margin-top:0;">and have a chance to discuss what they say in a public forum [form]Sign up to HearFromYourMP[/form]' ],
- #[ 'twfy_alerts0', '<h2>Get emailed every time your MP says something in Parliament</h2> [button]Keep an eye on them for free![/button]' ],
- );
- while (@adverts) {
- my $rand = int(rand(scalar @adverts));
- next unless $adverts[$rand];
- my ($advert_id, $advert_text) = @{$adverts[$rand]};
- (my $advert_site = $advert_id) =~ s/\d+$//;
- my $func = "display_random_${advert_site}_advert";
- no strict 'refs';
- my $out = &$func($email, $name, $advert_text);
- use strict 'refs';
- if ($out) {
- $c->stash->{scratch} = "advert=$advert_id";
- return $out;
- }
-
- for (my $i=0; $i<@adverts; $i++) {
- (my $a = $adverts[$i][0]) =~ s/\d+$//;
- delete $adverts[$i] if $advert_site eq $a;
- }
- }
-
- $c->stash->{scratch} = 'advert=pb';
- return <<EOF;
-<div id="advert_thin">
-<h2 style="font-size: 150%">
-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>
-</div>
-EOF
-}
-
-1;
diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm
index f48518d77..222c0c242 100644
--- a/perllib/FixMyStreet/App/Controller/Contact.pm
+++ b/perllib/FixMyStreet/App/Controller/Contact.pm
@@ -41,6 +41,11 @@ Handle contact us form submission
sub submit : Path('submit') : Args(0) {
my ( $self, $c ) = @_;
+ if (my $testing = $c->req->params->{_test_}) {
+ $c->stash->{success} = $c->req->params->{success};
+ return;
+ }
+
$c->res->redirect( '/contact' ) and return unless $c->req->method eq 'POST';
return
diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
index 70edcabe3..f6cc33e74 100755
--- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm
+++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
@@ -67,9 +67,16 @@ token), or the mini own-report one (when we'll have a problem ID).
sub submit : Path('submit') {
my ( $self, $c ) = @_;
- if ( $c->req->params->{token} ) {
+ if (my $token = $c->req->params->{token}) {
+ if ($token eq '_test_') {
+ $c->stash->{been_fixed} = $c->req->params->{been_fixed};
+ $c->stash->{new_state} = $c->req->params->{new_state};
+ $c->stash->{template} = 'questionnaire/completed.html';
+ return;
+ }
$c->forward('submit_standard');
- } elsif ( $c->req->params->{problem} ) {
+ } elsif (my $p = $c->req->params->{problem}) {
+ $c->detach('creator_fixed') if $p eq '_test_';
$c->forward('submit_creator_fixed');
} else {
$c->detach( '/page_error_404_not_found' );
@@ -106,6 +113,7 @@ sub submit_creator_fixed : Private {
}
my $problem = $c->cobrand->problems->find( { id => $c->stash->{problem_id} } );
+ $c->stash->{problem} = $problem;
# you should not be able to answer questionnaires about problems
# that you've not submitted
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index e188a085d..817e2a631 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -168,9 +168,6 @@ sub format_problem_for_display : Private {
}
$c->stash->{extra_name_info} = $problem->bodies_str && $problem->bodies_str eq '2482' ? 1 : 0;
- if ( $c->sessionid && $c->flash->{created_report} ) {
- $c->stash->{created_report} = $c->flash->{created_report};
- }
$c->forward('generate_map_tags');
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index ebc5cc6a0..5021d90e0 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -1132,23 +1132,10 @@ sub redirect_or_confirm_creation : Private {
if ( $report->confirmed ) {
# Subscribe problem reporter to email updates
$c->forward( 'create_reporter_alert' );
- my $report_uri;
-
- if ( $c->cobrand->moniker eq 'fixmybarangay' && $c->user->from_body && $c->stash->{external_source_id}) {
- $report_uri = $c->uri_for( '/report', $report->id, undef, { external_source_id => $c->stash->{external_source_id} } );
- } elsif ( $c->cobrand->never_confirm_reports && $report->non_public ) {
- $c->log->info( 'cobrand was set to always confirm reports and report was non public, success page showed');
- $c->stash->{template} = 'report_created.html';
- return 1;
- } else {
- $report_uri = $c->cobrand->base_url_for_report( $report ) . $report->url;
- }
- $c->log->info($report->user->id . ' was logged in, redirecting to /report/' . $report->id);
- if ( $c->sessionid ) {
- $c->flash->{created_report} = 'loggedin';
- }
- $c->res->redirect($report_uri);
- $c->detach;
+ $c->log->info($report->user->id . ' was logged in, showing confirmation page for ' . $report->id);
+ $c->stash->{created_report} = 'loggedin';
+ $c->stash->{template} = 'tokens/confirm_problem.html';
+ return 1;
}
# otherwise create a confirm token and email it to them.
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index b97420238..f1a1aa821 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -376,11 +376,8 @@ sub redirect_or_confirm_creation : Private {
if ( $update->confirmed ) {
$c->forward( 'update_problem' );
$c->forward( 'signup_for_alerts' );
-
- my $report_uri = $c->cobrand->base_url_for_report( $update->problem ) . $update->problem->url;
- $c->flash->{comment_created} = 1;
- $c->res->redirect($report_uri);
- $c->detach;
+ $c->stash->{template} = 'tokens/confirm_update.html';
+ return 1;
}
# otherwise create a confirm token and email it to them.
diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm
index 44cb2429d..c8a7531d6 100644
--- a/perllib/FixMyStreet/App/Controller/Tokens.pm
+++ b/perllib/FixMyStreet/App/Controller/Tokens.pm
@@ -28,6 +28,16 @@ problem but are not logged in.
sub confirm_problem : Path('/P') {
my ( $self, $c, $token_code ) = @_;
+ if ($token_code eq '_test_') {
+ $c->stash->{report} = {
+ id => 123,
+ title => 'Title of Report',
+ bodies_str => 'True',
+ url => '/report/123',
+ };
+ return;
+ }
+
my $auth_token =
$c->forward( 'load_auth_token', [ $token_code, 'problem' ] );
@@ -37,7 +47,7 @@ sub confirm_problem : Path('/P') {
# Look at all problems, not just cobrand, in case am approving something we don't actually show
my $problem = $c->model('DB::Problem')->find( { id => $problem_id } )
|| $c->detach('token_error');
- $c->stash->{problem} = $problem;
+ $c->stash->{report} = $problem;
if ( $problem->state eq 'unconfirmed' && $auth_token->created < DateTime->now->subtract( months => 1 ) ) {
$c->stash->{template} = 'errors/generic.html';
@@ -83,7 +93,6 @@ sub confirm_problem : Path('/P') {
) if $problem->state eq 'unconfirmed';
# Subscribe problem reporter to email updates
- $c->stash->{report} = $c->stash->{problem};
$c->forward( '/report/new/create_reporter_alert' );
# log the problem creation user in to the site
@@ -135,6 +144,11 @@ alert but are not logged in.
sub confirm_alert : Path('/A') {
my ( $self, $c, $token_code ) = @_;
+ if ($token_code eq '_test_') {
+ $c->stash->{confirm_type} = $c->req->params->{confirm_type};
+ return;
+ }
+
my $auth_token = $c->forward( 'load_auth_token', [ $token_code, 'alert' ] );
# Load the problem
@@ -170,6 +184,16 @@ update but are not logged in.
sub confirm_update : Path('/C') {
my ( $self, $c, $token_code ) = @_;
+ if ($token_code eq '_test_') {
+ $c->stash->{problem} = {
+ id => 123,
+ title => 'Title of Report',
+ bodies_str => 'True',
+ url => '/report/123',
+ };
+ return;
+ }
+
my $auth_token =
$c->forward( 'load_auth_token', [ $token_code, 'comment' ] );
diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm
index 033ad583f..da549ece8 100644
--- a/perllib/FixMyStreet/App/View/Web.pm
+++ b/perllib/FixMyStreet/App/View/Web.pm
@@ -7,7 +7,6 @@ use warnings;
use mySociety::Locale;
use mySociety::Web qw(ent);
use FixMyStreet;
-use CrossSell;
use Utils;
__PACKAGE__->config(
@@ -18,7 +17,7 @@ __PACKAGE__->config(
ENCODING => 'utf8',
render_die => 1,
expose_methods => [
- 'loc', 'nget', 'tprintf', 'display_crosssell_advert', 'prettify_dt',
+ 'loc', 'nget', 'tprintf', 'prettify_dt',
'add_links', 'version', 'decode',
],
FILTERS => {
@@ -79,19 +78,6 @@ sub tprintf {
return sprintf $format, @args;
}
-=head2 display_crosssell_advert
-
- [% display_crosssell_advert( email, name ) %]
-
-Displays a crosssell advert (will be fixmystreet cobrand only).
-
-=cut
-
-sub display_crosssell_advert {
- my ( $self, $c, $email, $name, %data ) = @_;
- return CrossSell::display_advert( $c, $email, $name, %data );
-}
-
=head2 Utils::prettify_dt
[% pretty = prettify_dt( $dt, $short_bool ) %]