aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/Cobrand.pm6
-rw-r--r--perllib/Problems.pm10
-rwxr-xr-xweb-admin/index.cgi73
3 files changed, 69 insertions, 20 deletions
diff --git a/perllib/Cobrand.pm b/perllib/Cobrand.pm
index c195ee6d7..4433858bb 100644
--- a/perllib/Cobrand.pm
+++ b/perllib/Cobrand.pm
@@ -7,7 +7,7 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: louise@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: Cobrand.pm,v 1.57 2009-12-22 14:22:09 matthew Exp $
+# $Id: Cobrand.pm,v 1.58 2010-01-06 12:33:25 louise Exp $
package Cobrand;
use strict;
@@ -60,6 +60,10 @@ my %fns = (
'prettify_epoch' => { default => '0' },
# Parameters are FORM_NAME, QUERY. Return HTML for any extra needed elements for FORM_NAME
'form_elements' => { default => "''" },
+ # Parameter is UPDATE_DATA, a reference to a hash of non-cobranded update data. Return cobrand extra data for the update
+ 'cobrand_data_for_generic_update' => { default => "''" },
+ # Parameter is PROBLEM_DATA, a reference to a hash of non-cobranded problem data. Return cobrand extra data for the problem
+ 'cobrand_data_for_generic_problem' => { default => "''" },
# Parameter is QUERY. Return a string of extra data to be stored with a problem
'extra_problem_data' => { default => "''" },
# Parameter is QUERY. Return a string of extra data to be stored with an update
diff --git a/perllib/Problems.pm b/perllib/Problems.pm
index e3ec5dcee..baf4304c2 100644
--- a/perllib/Problems.pm
+++ b/perllib/Problems.pm
@@ -6,7 +6,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Problems.pm,v 1.31 2009-11-19 16:41:57 louise Exp $
+# $Id: Problems.pm,v 1.32 2010-01-06 12:33:25 louise Exp $
#
package Problems;
@@ -348,13 +348,14 @@ sub update_search {
my ($search) = @_;
my $search_n = 0;
$search_n = int($search) if $search =~ /^\d+$/;
- my $updates = select_all("select comment.* from comment, problem where problem.id = comment.problem_id
+ my $updates = select_all("select comment.*, problem.council from comment, problem where problem.id = comment.problem_id
and (comment.id=? or
problem_id=? or comment.email ilike '%'||?||'%' or comment.name ilike '%'||?||'%' or
comment.text ilike '%'||?||'%' or comment.cobrand_data ilike '%'||?||'%')
$site_restriction
order by created", $search_n, $search_n, $search, $search,
$search, $search);
+ return $updates;
}
=item update_counts
@@ -456,7 +457,7 @@ Uses any site_restriction defined by a cobrand.
=cut
sub admin_fetch_update {
my ($id) = @_;
- my $update = dbh()->selectall_arrayref("select comment.* from comment, problem
+ my $update = dbh()->selectall_arrayref("select comment.*, problem.council from comment, problem
where comment.id=?
and problem.id = comment.problem_id
$site_restriction", { Slice=>{} }, $id);
@@ -491,7 +492,8 @@ Uses any site_restriction defined by a cobrand.
sub timeline_updates {
my $updates = select_all("select comment.*,
- extract(epoch from comment.created) as created
+ extract(epoch from comment.created) as created,
+ problem.council
from comment, problem
where comment.problem_id = problem.id
and comment.state='confirmed'
diff --git a/web-admin/index.cgi b/web-admin/index.cgi
index 155dd4839..f187fe871 100755
--- a/web-admin/index.cgi
+++ b/web-admin/index.cgi
@@ -7,10 +7,10 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: index.cgi,v 1.83 2010-01-06 10:56:51 louise Exp $
+# $Id: index.cgi,v 1.84 2010-01-06 12:33:26 louise Exp $
#
-my $rcsid = ''; $rcsid .= '$Id: index.cgi,v 1.83 2010-01-06 10:56:51 louise Exp $';
+my $rcsid = ''; $rcsid .= '$Id: index.cgi,v 1.84 2010-01-06 12:33:26 louise Exp $';
use strict;
@@ -469,11 +469,19 @@ sub admin_reports {
my $results = Problems::problem_search($search);
print $q->start_table({border=>1, cellpadding=>2, cellspacing=>0});
print $q->Tr({}, $q->th({}, ['ID', 'Title', 'Name', 'Email', 'Council', 'Category', 'Anonymous', 'Cobrand', 'Created', 'State', 'When sent', '*']));
-
+ my $cobrand_data;
foreach (@$results) {
my $url = $_->{id};
- $url = $q->a({ -href => Cobrand::base_url_for_emails($_->{cobrand}, $_->{cobrand_data}) . '/report/' . $_->{id} }, $url)
- if $_->{state} eq 'confirmed' || $_->{state} eq 'fixed';
+ if ($_->{state} eq 'confirmed' || $_->{state} eq 'fixed') {
+ # if this is a cobranded admin interface, but we're looking at a generic problem, figure out enough information
+ # to create a URL to the cobranded version of the problem
+ if ($_->{cobrand}) {
+ $cobrand_data = $_->{cobrand_data};
+ } else {
+ $cobrand_data = Cobrand::cobrand_data_for_generic_problem($cobrand, $_);
+ }
+ $url = $q->a({ -href => Cobrand::base_url_for_emails($cobrand, $cobrand_data) . '/report/' . $_->{id} }, $url);
+ }
my $council = $_->{council} || ' ';
my $category = $_->{category} || ' ';
(my $confirmed = $_->{confirmed} || '-') =~ s/ (.*?)\..*/ $1/;
@@ -560,11 +568,17 @@ sub admin_edit_report {
(my $whensent = $_->{whensent} || ' ') =~ s/\..*//;
(my $confirmed = $_->{confirmed} || '-') =~ s/ (.*?)\..*/ $1/;
my $photo = '';
- $photo = '<li><img align="top" src="' . Cobrand::base_url_for_emails($row{cobrand}, $row{cobrand_data}) . '/photo?id=' . $row{id} . '">
+ my $cobrand_data;
+ if ($row{cobrand}) {
+ $cobrand_data = $row{cobrand_data};
+ } else {
+ $cobrand_data = Cobrand::cobrand_data_for_generic_problem($cobrand, \%row);
+ }
+ $photo = '<li><img align="top" src="' . Cobrand::base_url_for_emails($cobrand, $cobrand_data) . '/photo?id=' . $row{id} . '">
<input type="checkbox" id="remove_photo" name="remove_photo" value="1">
<label for="remove_photo">Remove photo (can\'t be undone!)</label>' if $row{photo};
-
- my $url_base = Cobrand::base_url_for_emails($row{cobrand}, $row{cobrand_data});
+
+ my $url_base = Cobrand::base_url_for_emails($cobrand, $cobrand_data);
my $url = $url_base . '/report/' . $row{id};
my $anon = $q->label({-for=>'anonymous'}, 'Anonymous:') . ' ' . $q->popup_menu(-id => 'anonymous', -name => 'anonymous', -values => { 1=>'Yes', 0=>'No' }, -default => $row{anonymous});
@@ -617,10 +631,18 @@ sub admin_show_updates {
print $q->start_table({border=>1, cellpadding=>2, cellspacing=>0});
print $q->Tr({}, $q->th({}, ['ID', 'State', 'Name', 'Email', 'Created', 'Cobrand', 'Text', '*']));
my $base_url = '';
+ my $cobrand_data;
foreach (@$updates) {
my $url = $_->{id};
- $url = $q->a({ -href => Cobrand::base_url_for_emails($_->{cobrand}, $_->{cobrand_data}) . '/report/' . $_->{problem_id} . '#update_' . $_->{id} },
- $url) if $_->{state} eq 'confirmed';
+ if ( $_->{state} eq 'confirmed' ) {
+ if ($_->{cobrand}) {
+ $cobrand_data = $_->{cobrand_data};
+ } else {
+ $cobrand_data = Cobrand::cobrand_data_for_generic_update($cobrand, $_);
+ }
+ $url = $q->a({ -href => Cobrand::base_url_for_emails($cobrand, $cobrand_data) . '/report/' . $_->{problem_id} . '#update_' . $_->{id} },
+ $url);
+ }
my $cobrand = $_->{cobrand} . '<br>' . $_->{cobrand_data};
print $q->Tr({}, $q->td([ $url, $_->{state}, ent($_->{name} || ''),
ent($_->{email}), $_->{created}, $cobrand, ent($_->{text}),
@@ -657,12 +679,18 @@ sub admin_edit_update {
print $status_message;
my $name = $row_h{name};
$name = '' unless $name;
+ my $cobrand_data;
+ if ($row{cobrand}) {
+ $cobrand_data = $row{cobrand_data};
+ } else {
+ $cobrand_data = Cobrand::cobrand_data_for_generic_update($cobrand, \%row);
+ }
my $photo = '';
- $photo = '<li><img align="top" src="' . Cobrand::base_url_for_emails($row{cobrand}, $row{cobrand_data}) . '/photo?c=' . $row{id} . '">
+ $photo = '<li><img align="top" src="' . Cobrand::base_url_for_emails($cobrand, $cobrand_data) . '/photo?c=' . $row{id} . '">
<input type="checkbox" id="remove_photo" name="remove_photo" value="1">
<label for="remove_photo">Remove photo (can\'t be undone!)</label>' if $row{photo};
- my $url = Cobrand::base_url_for_emails($row{cobrand}, $row{cobrand_data}) . '/report/' . $row{problem_id} . '#update_' . $row{id};
+ my $url = Cobrand::base_url_for_emails($cobrand, $cobrand_data) . '/report/' . $row{problem_id} . '#update_' . $row{id};
my $state = $q->label({-for=>'state'}, 'State:') . ' ' . $q->popup_menu(-id => 'state', -name => 'state', -values => { confirmed => 'Confirmed', hidden => 'Hidden', unconfirmed => 'Unconfirmed' }, -default => $row{state});
@@ -689,6 +717,17 @@ EOF
print html_tail($q);
}
+sub get_cobrand_data_from_hash {
+ my ($cobrand, $data) = @_;
+ my $cobrand_data;
+ if ($data->{cobrand}) {
+ $cobrand_data = $data->{cobrand_data};
+ } else {
+ $cobrand_data = Cobrand::cobrand_data_for_generic_problem($cobrand, $data);
+ }
+ return $cobrand_data;
+}
+
sub admin_timeline {
my $q = shift;
my $cobrand = Page::get_cobrand($q);
@@ -728,6 +767,7 @@ sub admin_timeline {
}
my $date = '';
+ my $cobrand_data;
foreach (reverse sort keys %time) {
my $curdate = strftime('%A, %e %B %Y', localtime($_));
if ($date ne $curdate) {
@@ -741,17 +781,20 @@ sub admin_timeline {
if ($type eq 'problemCreated') {
print "Problem $_->{id} created; by " . ent($_->{name}) . " &lt;" . ent($_->{email}) . "&gt;, '" . ent($_->{title}) . "'";
} elsif ($type eq 'problemConfirmed') {
- my $url = Cobrand::base_url_for_emails($_->{cobrand}, $_->{cobrand_data}) . "/report/$_->{id}";
+ $cobrand_data = get_cobrand_data_from_hash($cobrand, $_);
+ my $url = Cobrand::base_url_for_emails($cobrand, $cobrand_data) . "/report/$_->{id}";
print "Problem <a href='$url'>$_->{id}</a> confirmed; by " . ent($_->{name}) ." &lt;" . ent($_->{email}) . "&gt;, '" . ent($_->{title}) ."'";
} elsif ($type eq 'problemSent') {
- my $url = Cobrand::base_url_for_emails($_->{cobrand}, $_->{cobrand_data}) . "/report/$_->{id}";
+ $cobrand_data = get_cobrand_data_from_hash($cobrand, $_);
+ my $url = Cobrand::base_url_for_emails($cobrand, $cobrand_data) . "/report/$_->{id}";
print "Problem <a href='$url'>$_->{id}</a> sent to council $_->{council}; by " . ent($_->{name}) . " &lt;" . ent($_->{email}) . "&gt;, '" . ent($_->{title}) . "'";
} elsif ($type eq 'quesSent') {
print "Questionnaire $_->{id} sent for problem $_->{problem_id}";
} elsif ($type eq 'quesAnswered') {
print "Questionnaire $_->{id} answered for problem $_->{problem_id}, $_->{old_state} to $_->{new_state}";
} elsif ($type eq 'update') {
- my $url = Cobrand::base_url_for_emails($_->{cobrand}, $_->{cobrand_data}) . "/report/$_->{problem_id}#$_->{id}";
+ $cobrand_data = get_cobrand_data_from_hash($cobrand, $_);
+ my $url = Cobrand::base_url_for_emails($cobrand, $cobrand_data) . "/report/$_->{problem_id}#$_->{id}";
my $name = ent($_->{name}) || 'anonymous';
print "Update <a href='$url'>$_->{id}</a> created for problem $_->{problem_id}; by $name &lt;" . ent($_->{email}) . "&gt;";
} elsif ($type eq 'alertSub') {