diff options
Diffstat (limited to 'web')
-rwxr-xr-x | web/confirm.cgi | 46 | ||||
-rwxr-xr-x | web/faq.cgi | 10 | ||||
-rwxr-xr-x | web/index.cgi | 8 |
3 files changed, 42 insertions, 22 deletions
diff --git a/web/confirm.cgi b/web/confirm.cgi index 179b38fdb..d9e4c83ef 100755 --- a/web/confirm.cgi +++ b/web/confirm.cgi @@ -6,12 +6,13 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: confirm.cgi,v 1.40 2008-05-21 15:48:07 matthew Exp $ +# $Id: confirm.cgi,v 1.41 2008-09-17 16:55:58 matthew Exp $ use strict; use Standard; use Digest::SHA1 qw(sha1_hex); use CrossSell; +use mySociety::Alert; use mySociety::AuthToken; use mySociety::Random qw(random_bytes); @@ -23,15 +24,15 @@ sub main { my $token = $q->param('token'); my $type = $q->param('type') || ''; my $tokentype = $type eq 'questionnaire' ? 'update' : $type; - my $id = mySociety::AuthToken::retrieve($tokentype, $token); - if ($id) { + my $data = mySociety::AuthToken::retrieve($tokentype, $token); + if ($data) { if ($type eq 'update') { - $out = confirm_update($q, $id); + $out = confirm_update($q, $data); } elsif ($type eq 'problem') { - $out = confirm_problem($q, $id); + $out = confirm_problem($q, $data); $extra = 'added-problem'; } elsif ($type eq 'questionnaire') { - $out = add_questionnaire($q, $id, $token); + $out = add_questionnaire($q, $data, $token); } dbh()->commit(); } else { @@ -49,13 +50,18 @@ EOF Page::do_fastcgi(\&main); sub confirm_update { - my ($q, $id) = @_; + my ($q, $data) = @_; + + my $id = $data->{id}; + my $add_alert = $data->{add_alert}; + #if (dbh()->selectrow_array('select email from abuse where lower(email)=?', {}, lc($email))) { # dbh()->do("update comment set state='hidden' where id=?", {}, $id); # return $q->p('Sorry, there has been an error confirming your update.'); #} else { - dbh()->do("update comment set state='confirmed' where id=? and state='unconfirmed'", {}, $id); + dbh()->do("update comment set state='confirmed' where id=? and state='unconfirmed'", {}, $id); #} + my ($problem_id, $fixed, $email, $name) = dbh()->selectrow_array( "select problem_id, mark_fixed, email, name from comment where id=?", {}, $id); my $creator_fixed = 0; @@ -70,16 +76,23 @@ sub confirm_update { dbh()->do("update problem set lastupdate = ms_current_timestamp() where id=? and state='confirmed'", {}, $problem_id); } + my $out = ''; if ($creator_fixed > 0 && $q->{site} ne 'emptyhomes') { $out = ask_questionnaire($q->param('token')); } else { $out = $q->p(sprintf(_('You have successfully confirmed your update and you can now <a href="%s">view it on the site</a>.'), "/?id=$problem_id#update_$id")); - if ($fixed) { - $out .= CrossSell::display_advert($q, $email, $name); - } else { - $out .= advertise_updates($q, $problem_id, $email); - } + #if ($fixed) { + $out .= CrossSell::display_advert($q, $email, $name); + #} else { + # $out .= advertise_updates($q, $problem_id, $email); + #} + } + + # Subscribe updater to email updates if requested + if ($add_alert) { + my $alert_id = mySociety::Alert::create($email, 'new_updates', $problem_id); + mySociety::Alert::confirm($alert_id); } return $out; @@ -111,7 +124,12 @@ sub confirm_problem { . sprintf(_('. You can <a href="%s">view the problem on this site</a>.'), "/?id=$id") ); } - $out .= advertise_updates($q, $id, $email); + + # Subscribe problem reporter to email updates + my $alert_id = mySociety::Alert::create($email, 'new_updates', $id); + mySociety::Alert::confirm($alert_id); + + $out .= CrossSell::display_advert($q, $email); return $out; } diff --git a/web/faq.cgi b/web/faq.cgi index 4e3ce614e..cbb7d0039 100755 --- a/web/faq.cgi +++ b/web/faq.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: faq.cgi,v 1.31 2008-05-15 16:09:52 matthew Exp $ +# $Id: faq.cgi,v 1.32 2008-09-17 16:55:58 matthew Exp $ use strict; use Standard -db; @@ -80,10 +80,10 @@ site if you let us, but not your email address; similarly with updates. We will never give or sell your email address to anyone else, unless we are obliged to by law.')), $q->dt(_('Will you send nasty, brutish spam to my email address?')), - $q->dd(_('Never. We will email you four weeks after you submit a -problem, asking for a status update, and we\'ll only ever send you emails -in relation to your problem. You can opt in to receive emails -about updates to a particular problem.')) + $q->dd(_('Never. We will email you if someone leaves an update on a +problem you’ve reported, and send you a questionnaire email four weeks +after you submit a problem, asking for a status update; we’ll only ever +send you emails in relation to your problem.')) ); $out .= $q->h2(_('Organisation Questions')); $out .= $q->dl( diff --git a/web/index.cgi b/web/index.cgi index d0471b81a..757ddfa8d 100755 --- a/web/index.cgi +++ b/web/index.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: index.cgi,v 1.207 2008-09-16 15:48:16 matthew Exp $ +# $Id: index.cgi,v 1.208 2008-09-17 16:55:58 matthew Exp $ use strict; use Standard; @@ -157,7 +157,7 @@ EOF sub submit_update { my $q = shift; - my @vars = qw(id name email update fixed upload_fileid); + my @vars = qw(id name email update fixed upload_fileid add_alert); my %input = map { $_ => $q->param($_) || '' } @vars; my @errors; @@ -206,7 +206,7 @@ sub submit_update { my $base = mySociety::Config::get('BASE_URL'); $base =~ s/matthew/emptyhomes.matthew/ if $q->{site} eq 'emptyhomes'; # XXX Temp $base =~ s/matthew/scambs.matthew/ if $q->{site} eq 'scambs'; # XXX Temp - $h{url} = $base . '/C/' . mySociety::AuthToken::store('update', $id); + $h{url} = $base . '/C/' . mySociety::AuthToken::store('update', { id => $id, add_alert => $input{add_alert} } ); dbh()->commit(); my $out = Page::send_email($q, $input{email}, $input{name}, 'update', %h); @@ -846,6 +846,8 @@ $fixedline <label for="form_photo">Photo:</label> <input type="file" name="photo" id="form_photo"> </div> +<div class="checkbox"><input type="checkbox" name="add_alert" id="form_add_alert" value="1"> +<label for="form_add_alert">Alert me to future updates</label></div> <div class="checkbox"><input type="submit" id="update_post" value="Post"></div> </form> </div> |