aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2011-06-03 16:41:15 +0100
committerMatthew Somerville <matthew@mysociety.org>2011-06-03 16:41:15 +0100
commit75e4f3e1176d14281d2063fd233626d029c30b1c (patch)
tree9435dfd8a421cc23596bd2c3ebefc019f09e552f /web
parent539206556a45bf5cc03fcb87e2ea1ecdb3a40941 (diff)
Remove questionnaire ported code, move another static page.
Diffstat (limited to 'web')
-rwxr-xr-xweb/iphone/index.cgi73
-rwxr-xr-xweb/questionnaire.cgi338
2 files changed, 0 insertions, 411 deletions
diff --git a/web/iphone/index.cgi b/web/iphone/index.cgi
deleted file mode 100755
index cd5199482..000000000
--- a/web/iphone/index.cgi
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/perl -w -I../../perllib -I../../commonlib/perllib
-
-# iphone/index.cgi:
-# Screenshots of the iPhone FixMyStreet application, showing the flow
-#
-# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
-#
-# $Id: index.cgi,v 1.1 2008-10-29 15:30:15 matthew Exp $
-
-use strict;
-use Standard -db;
-use mySociety::Config;
-use mySociety::Web qw(ent);
-
-# XXX: Ugh, as we're in a subdirectory
-BEGIN {
- mySociety::Config::set_file("$FindBin::Bin/../../conf/general");
-}
-
-my @screens = (
-"iphone-1start.png", 'Click the image to progress through the flow of using the iPhone FixMyStreet application.
-<br>When launched, the user&rsquo;s location automatically gets fetched&hellip;',
-"iphone-2locfound.png", 'They want to take a photo.',
-"iphone-pickpicture1.png", 'The simulator doesn&rsquo;t have a camera, so we&rsquo;re taken to the photo albums. Let&rsquo;s pick Hawaii.',
-"iphone-pickpicture2.png", 'That red clouds photo looks nice.',
-"iphone-pickpicture3.png", 'After any moving or scaling we want, we select the photo.',
-"iphone-3picture.png", 'Okay, now we need to edit the summary of the report.',
-"iphone-editsummary.png", 'Enter some text.',
-"iphone-editsummary2.png", 'And done.',
-"iphone-4subject.png", 'I haven&rsquo;t entered all my details yet, so that&rsquo;s next.',
-"iphone-5details.png", 'Your details are remembered so you only have to enter them once.',
-"iphone-6emailkeyboard.png", 'The iPhone has different keyboards, this is the email one.',
-"iphone-5details.png", 'Right, we need to enter a name.',
-"iphone-editname.png", 'Slightly different keyboard to the email one.',
-"iphone-detailsdone.png", 'Okay, details entered.',
-"iphone-allready.png", 'That&rsquo;s everything, hit Report!',
-"iphone-7uploading.png", 'Uploading&hellip;',
-"iphone-8response.png", 'The simulator always thinks it&rsquo;s in the US, which FixMyStreet won&rsquo;t like very much.',
-"iphone-allready.png", 'Ah well, let&rsquo;s read the About page instead',
-"iphone-9about.png", 'Donate? :)',
-);
-
-sub main {
- my $q = shift;
- print Page::header($q, title=>'FixMyStreet for iPhone screenshots');
- print '<h1>iPhone simulator simulator</h1>';
- my $screens = scalar @screens / 2;
- print <<EOF;
-<script type="text/javascript">
-document.write('<style type="text/css">.vv { display: none; }</style>');
-function show(a) {
- if (a==$screens) b = 1;
- else b = a+1;
- document.getElementById('d' + a).style.display='none';
- document.getElementById('d' + b).style.display='block';
-}
-</script>
-EOF
- for (my $i=0; $i<@screens; $i+=2) {
- my $t = $i/2 + 1;
- my $next = $t + 1;
- print "<div id='d$t'";
- print " class='vv'" if $i>1;
- print ">";
- print "<p>$screens[$i+1]</p>";
- print "<p align='center'><a onclick='show($t);return false' href='#d$next'><img src='$screens[$i]' width=414 border=0 height=770></a></p>";
- print '</div>';
- }
- print Page::footer($q);
-}
-Page::do_fastcgi(\&main);
-
diff --git a/web/questionnaire.cgi b/web/questionnaire.cgi
deleted file mode 100755
index fdb1c08a4..000000000
--- a/web/questionnaire.cgi
+++ /dev/null
@@ -1,338 +0,0 @@
-#!/usr/bin/perl -w -I../perllib
-
-# questionnaire.cgi:
-# Questionnaire for problem creators
-#
-# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
-#
-# $Id: questionnaire.cgi,v 1.53 2009-12-08 17:43:13 louise Exp $
-
-use strict;
-use Standard;
-use Utils;
-use Error qw(:try);
-use CrossSell;
-use mySociety::AuthToken;
-use mySociety::Locale;
-use mySociety::Web qw(ent);
-
-sub main {
- my $q = shift;
- my $out = '';
- if ($q->param('submit')) {
- $out = submit_questionnaire($q);
- } else {
- $out = display_questionnaire($q);
- }
- print Page::header($q,
- title => _('Questionnaire'),
- js => FixMyStreet::Map::header_js(),
- );
- print $out;
- print Page::footer($q);
-}
-Page::do_fastcgi(\&main);
-
-sub check_stuff {
- my $q = shift;
- my $cobrand = Page::get_cobrand($q);
- my $id = mySociety::AuthToken::retrieve('questionnaire', $q->param('token'));
- throw Error::Simple(_("I'm afraid we couldn't validate that token. If you've copied the URL from an email, please check that you copied it exactly.\n")) unless $id;
-
- my $questionnaire = dbh()->selectrow_hashref(
- 'select id, problem_id, whenanswered from questionnaire where id=?', {}, $id);
- my $problem_id = $questionnaire->{problem_id};
- my $problem_url = Cobrand::url($cobrand, "/report/$problem_id", $q);
- my $contact_url = Cobrand::url($cobrand, "/contact", $q);
- throw Error::Simple(sprintf(_("You have already answered this questionnaire. If you have a question, please <a href='%s'>get in touch</a>, or <a href='%s'>view your problem</a>.\n"), $contact_url, $problem_url)) if $questionnaire->{whenanswered};
-
- my $problem = dbh()->selectrow_hashref(
- "select *, extract(epoch from confirmed) as time, extract(epoch from whensent-confirmed) as whensent
- from problem where id=? and state in ('confirmed','fixed')", {}, $problem_id);
- throw Error::Simple(_("I'm afraid we couldn't locate your problem in the database.\n")) unless $problem;
-
- my $num_questionnaire = dbh()->selectrow_array(
- 'select count(*) from questionnaire where problem_id=?', {}, $problem_id);
- my $answered_ever_reported = dbh()->selectrow_array(
- 'select id from questionnaire where problem_id in (select id from problem where email=?) and ever_reported is not null', {}, $problem->{email});
-
- return ($questionnaire, $problem, $num_questionnaire, $answered_ever_reported);
-}
-
-sub submit_questionnaire {
- my $q = shift;
- my $cobrand = Page::get_cobrand($q);
- my $cobrand_data = Cobrand::extra_data($cobrand, $q);
- my @vars = qw(token id been_fixed reported update another);
- my %input = map { $_ => scalar $q->param($_) || '' } @vars;
- my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } @vars;
-
- my ($error, $questionnaire, $num_questionnaire, $problem, $answered_ever_reported);
- try {
- ($questionnaire, $problem, $num_questionnaire, $answered_ever_reported) = check_stuff($q);
- } catch Error::Simple with {
- my $e = shift;
- $error = $e;
- };
-
- if ($error) {
- my %vars = (heading => _('Questionnaire'),
- error => $error->stringify());
- my $template_error = Page::template_include('error', $q, Page::template_root($q), %vars);
- return $template_error if $template_error;
- return $error;
- }
- # EHA questionnaires done for you
- if ($q->{site} eq 'emptyhomes') {
- $input{another} = $num_questionnaire==1 ? 'Yes' : 'No';
- }
-
- my @errors;
- push @errors, _('Please state whether or not the problem has been fixed') unless $input{been_fixed};
- my $ask_ever_reported = Cobrand::ask_ever_reported($cobrand);
- if ($ask_ever_reported) {
- push @errors, _('Please say whether you\'ve ever reported a problem to your council before') unless $input{reported} || $answered_ever_reported;
- }
- push @errors, _('Please indicate whether you\'d like to receive another questionnaire')
- if ($input{been_fixed} eq 'No' || $input{been_fixed} eq 'Unknown') && !$input{another};
- push @errors, _('Please provide some explanation as to why you\'re reopening this report')
- if $input{been_fixed} eq 'No' && $problem->{state} eq 'fixed' && !$input{update};
- return display_questionnaire($q, @errors) if @errors;
-
- my $fh = $q->upload('photo');
- my $image;
- if ($fh) {
- my $err = Page::check_photo($q, $fh);
- push @errors, $err if $err;
- try {
- $image = Page::process_photo($fh) unless $err;
- } catch Error::Simple with {
- my $e = shift;
- push(@errors, "That image doesn't appear to have uploaded correctly ($e), please try again.");
- };
- }
- push @errors, _('Please provide some text as well as a photo')
- if $image && !$input{update};
- return display_questionnaire($q, @errors) if @errors;
-
- my $new_state = '';
- $new_state = 'fixed' if $input{been_fixed} eq 'Yes' && $problem->{state} eq 'confirmed';
- $new_state = 'confirmed' if $input{been_fixed} eq 'No' && $problem->{state} eq 'fixed';
-
- # Record state change, if there was one
- dbh()->do("update problem set state=?, lastupdate=ms_current_timestamp()
- where id=?", {}, $new_state, $problem->{id})
- if $new_state;
-
- # If it's not fixed and they say it's still not been fixed, record time update
- dbh()->do("update problem set lastupdate=ms_current_timestamp()
- where id=?", {}, $problem->{id})
- if $input{been_fixed} eq 'No' && $problem->{state} eq 'confirmed';
-
- # Record questionnaire response
- my $reported = $input{reported}
- ? ($input{reported} eq 'Yes' ? 't' : ($input{reported} eq 'No' ? 'f' : undef))
- : undef;
- dbh()->do('update questionnaire set whenanswered=ms_current_timestamp(),
- ever_reported=?, old_state=?, new_state=? where id=?', {},
- $reported, $problem->{state}, $input{been_fixed} eq 'Unknown'
- ? 'unknown'
- : ($new_state ? $new_state : $problem->{state}),
- $questionnaire->{id});
-
- # Record an update if they've given one, or if there's a state change
- my $name = $problem->{anonymous} ? undef : $problem->{name};
- my $update = $input{update} ? $input{update} : _('Questionnaire filled in by problem reporter');
- Utils::workaround_pg_bytea("insert into comment
- (problem_id, name, email, website, text, state, mark_fixed, mark_open, photo, lang, cobrand, cobrand_data, confirmed)
- values (?, ?, ?, '', ?, 'confirmed', ?, ?, ?, ?, ?, ?, ms_current_timestamp())", 7,
- $problem->{id}, $name, $problem->{email}, $update,
- $new_state eq 'fixed' ? 't' : 'f', $new_state eq 'confirmed' ? 't' : 'f',
- $image, $mySociety::Locale::lang, $cobrand, $cobrand_data
- )
- if $new_state || $input{update};
-
- # If they've said they want another questionnaire, mark as such
- dbh()->do("update problem set send_questionnaire = 't' where id=?", {}, $problem->{id})
- if ($input{been_fixed} eq 'No' || $input{been_fixed} eq 'Unknown') && $input{another} eq 'Yes';
- dbh()->commit();
-
- my $out;
- my $message;
- my $advert_outcome = 1;
- if ($input{been_fixed} eq 'Unknown') {
- $message = _(<<EOF);
-<p>Thank you very much for filling in our questionnaire; if you
-get some more information about the status of your problem, please come back to the
-site and leave an update.</p>
-EOF
- } elsif ($new_state eq 'confirmed' || (!$new_state && $problem->{state} eq 'confirmed')) {
- my $wtt_url = Cobrand::writetothem_url($cobrand, $cobrand_data);
- $wtt_url = "http://www.writetothem.com" if (! $wtt_url);
- $message = sprintf(_(<<EOF), $wtt_url);
-<p style="font-size:150%%">We're sorry to hear that. We have two suggestions: why not try
-<a href="%s">writing direct to your councillor(s)</a>
-or, if it's a problem that could be fixed by local people working together,
-why not <a href="http://www.pledgebank.com/new">make and publicise a pledge</a>?
-</p>
-EOF
- $advert_outcome = 0;
- } else {
- $message = _(<<EOF);
-<p style="font-size:150%">Thank you very much for filling in our questionnaire; glad to hear it's been fixed.</p>
-EOF
- }
- $out = $message;
- my $display_advert = Cobrand::allow_crosssell_adverts($cobrand);
- if ($display_advert && $advert_outcome) {
- $out .= CrossSell::display_advert($q, $problem->{email}, $problem->{name},
- council => $problem->{council});
- }
- my %vars = (message => $message);
- my $template_page = Page::template_include('questionnaire-completed', $q, Page::template_root($q), %vars);
- return $template_page if ($template_page);
- return $out;
-}
-
-sub display_questionnaire {
- my ($q, @errors) = @_;
- my @vars = qw(token id been_fixed reported update another);
- my $cobrand = Page::get_cobrand($q);
- my %input = map { $_ => $q->param($_) || '' } @vars;
- my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } @vars;
-
- my ($error, $questionnaire, $num_questionnaire, $problem, $answered_ever_reported);
- try {
- ($questionnaire, $problem, $num_questionnaire, $answered_ever_reported) = check_stuff($q);
- } catch Error::Simple with {
- my $e = shift;
- $error = $e;
- };
- if ($error) {
- my %vars = (heading => _('Questionnaire'),
- error => $error->stringify());
- my $template_error = Page::template_include('error', $q, Page::template_root($q), %vars);
- return $template_error if $template_error;
- return $error;
- }
- my $reported_date_time = Page::prettify_epoch($q, $problem->{time});
- my $problem_text = Page::display_problem_text($q, $problem);
- my $updates = Page::display_problem_updates($problem->{id}, $q);
-
- my %vars = (
- input_h => \%input_h,
- map_start => FixMyStreet::Map::display_map($q,
- latitude => $problem->{latitude}, longitude => $problem->{longitude},
- pins => [
- [ $problem->{latitude}, $problem->{longitude}, $problem->{state} eq 'fixed'?'green':'red' ],
- ],
- pre => $problem_text, post => $updates
- ),
- map_end => FixMyStreet::Map::display_map_end(0),
- heading => _('Questionnaire'),
- yes => _('Yes'),
- no => _('No'),
- dontknow => _('Don&rsquo;t know'),
- submit => _('Submit questionnaire'),
- cobrand_form_elements => Cobrand::form_elements($cobrand, 'questionnaireForm', $q),
- form_action => Cobrand::url($cobrand, "/questionnaire", $q),
- reported_date_time => $reported_date_time
- );
- $vars{been_fixed} = {
- yes => $input{been_fixed} eq 'Yes' ? ' checked' : '',
- no => $input{been_fixed} eq 'No' ? ' checked' : '',
- unknown => $input{been_fixed} eq 'Unknown' ? ' checked' : '',
- };
- my $allow_photo_upload = Cobrand::allow_photo_upload($cobrand);
- if ($allow_photo_upload) {
- $vars{enctype} = 'enctype="multipart/form-data"';
- }
- if ($q->{site} eq 'emptyhomes') {
- if ($num_questionnaire==1) {
- $vars{blurb_eh} = _(<<EOF);
-<p>Getting empty homes back into use can be difficult. You shouldn't expect
-the property to be back into use yet. But a good council will have started work
-and should have reported what they have done on the website. If you are not
-satisfied with progress or information from the council, now is the right time
-to say. You may also want to try contacting some other people who may be able
-to help. For advice on how to do this and other useful information please
-go to <a href="http://www.emptyhomes.com/getinvolved/campaign.html">http://www.emptyhomes.com/getinvolved/campaign.html</a>.</p>
-EOF
- } else {
- $vars{blurb_eh} = _(<<EOF);
-<p>Getting empty homes back into use can be difficult, but by now a good council
-will have made a lot of progress and reported what they have done on the
-website. Even so properties can remain empty for many months if the owner is
-unwilling or the property is in very poor repair. If nothing has happened or
-you are not satisfied with the progress the council is making, now is the right
-time to say so. We think it's a good idea to contact some other people who
-may be able to help or put pressure on the council For advice on how to do
-this and other useful information please go to <a
-href="http://www.emptyhomes.com/getinvolved/campaign.html">http://www.emptyhomes.com/getinvolved/campaign.html</a>.</p>
-EOF
- }
- }
-
- $vars{blurb_report} = _('The details of your problem are available on the right hand side of this page.');
- $vars{blurb_report2} = _('Please take a look at the updates that have been left.') if $updates;
-
- if (@errors) {
- $vars{errors} = '<ul class="error"><li>' . join('</li><li>', @errors) . '</li></ul>';
- }
- $vars{fixed_question} = '';
- $vars{fixed_question} .= _('An update marked this problem as fixed.') . ' ' if $problem->{state} eq 'fixed';
- $vars{fixed_question} .= _('Has this problem been fixed?') . '</p>';
-
- unless ($answered_ever_reported) {
- my %reported = (
- yes => $input{reported} eq 'Yes' ? ' checked' : '',
- no => $input{reported} eq 'No' ? ' checked' : '',
- );
- my $before = _('Reported before');
- my $first = _('First time');
- $vars{ever_reported} = $q->p(_('Have you ever reported a problem to a council before, or is this your first time?'));
- $vars{ever_reported} .= <<EOF;
-<p>
-<input type="radio" name="reported" id="reported_yes" value="Yes"$reported{yes}>
-<label for="reported_yes">$before</label>
-<input type="radio" name="reported" id="reported_no" value="No"$reported{no}>
-<label for="reported_no">$first</label>
-</p>
-EOF
- }
- $vars{blurb_update} = $q->p(_('If you wish to leave a public update on the problem, please enter it here
-(please note it will not be sent to the council). For example, what was
-your experience of getting the problem fixed?'));
- if ($allow_photo_upload) {
- my $photo = _('Photo:');
- $vars{photo_input} = <<EOF;
-<div id="fileupload_normalUI">
-<label for="form_photo">$photo</label>
-<input type="file" name="photo" id="form_photo">
-</div>
-EOF
- }
- my %another = (
- yes => $input{another} eq 'Yes' ? ' checked' : '',
- no => $input{another} eq 'No' ? ' checked' : '',
- );
- $vars{another_yes} = $another{yes};
- $vars{another_no} = $another{no};
- my $another_qn = _('Would you like to receive another questionnaire in 4 weeks, reminding you to check the status?');
- my $yes = _('Yes');
- my $no = _('No');
- $vars{another_questionnaire} = <<EOF if $q->{site} ne 'emptyhomes';
-<div id="another_qn">
-<p>$another_qn</p>
-<p>
-<input type="radio" name="another" id="another_yes" value="Yes"$another{yes}>
-<label for="another_yes">$yes</label>
-<input type="radio" name="another" id="another_no" value="No"$another{no}>
-<label for="another_no">$no</label>
-</p>
-</div>
-EOF
-
- return Page::template_include('questionnaire', $q, Page::template_root($q), %vars);
-}