summaryrefslogtreecommitdiffstats
path: root/report.cgi
diff options
context:
space:
mode:
authorJulien Heyman <jheyman@portaildulibre.fr>2012-08-07 23:59:18 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2012-08-07 23:59:18 +0200
commit14d7441b73d32614aa0e086c5f69ac087b939a48 (patch)
tree281660eac457755f199b4600439e2a7973f54612 /report.cgi
parenteb04bb66cee35f39d546403ea4f777b43452cd4d (diff)
downloadbugzilla-14d7441b73d32614aa0e086c5f69ac087b939a48.tar.gz
bugzilla-14d7441b73d32614aa0e086c5f69ac087b939a48.tar.xz
Bug 319598: Add support for saved tabular and graphical reports
r/a=LpSolit
Diffstat (limited to 'report.cgi')
-rwxr-xr-xreport.cgi50
1 files changed, 50 insertions, 0 deletions
diff --git a/report.cgi b/report.cgi
index 83561fde5..5778841b3 100755
--- a/report.cgi
+++ b/report.cgi
@@ -15,6 +15,8 @@ use Bugzilla::Util;
use Bugzilla::Error;
use Bugzilla::Field;
use Bugzilla::Search;
+use Bugzilla::Report;
+use Bugzilla::Token;
use List::MoreUtils qw(uniq);
@@ -34,6 +36,7 @@ if (grep(/^cmd-/, $cgi->param())) {
Bugzilla->login();
my $action = $cgi->param('action') || 'menu';
+my $token = $cgi->param('token');
if ($action eq "menu") {
# No need to do any searching in this case, so bail out early.
@@ -41,6 +44,52 @@ if ($action eq "menu") {
$template->process("reports/menu.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
+
+}
+elsif ($action eq 'add') {
+ my $user = Bugzilla->login(LOGIN_REQUIRED);
+ check_hash_token($token, ['save_report']);
+
+ my $name = clean_text($cgi->param('name'));
+ my $query = $cgi->param('query');
+
+ if (my ($report) = grep{ lc($_->name) eq lc($name) } @{$user->reports}) {
+ $report->set_query($query);
+ $report->update;
+ $vars->{'message'} = "report_updated";
+ } else {
+ my $report = Bugzilla::Report->create({name => $name, query => $query});
+ $vars->{'message'} = "report_created";
+ }
+
+ $user->flush_reports_cache;
+
+ print $cgi->header();
+
+ $vars->{'reportname'} = $name;
+
+ $template->process("global/message.html.tmpl", $vars)
+ || ThrowTemplateError($template->error());
+ exit;
+}
+elsif ($action eq 'del') {
+ my $user = Bugzilla->login(LOGIN_REQUIRED);
+ my $report_id = $cgi->param('saved_report_id');
+ check_hash_token($token, ['delete_report', $report_id]);
+
+ my $report = Bugzilla::Report->check({id => $report_id});
+ $report->remove_from_db();
+
+ $user->flush_reports_cache;
+
+ print $cgi->header();
+
+ $vars->{'message'} = 'report_deleted';
+ $vars->{'reportname'} = $report->name;
+
+ $template->process("global/message.html.tmpl", $vars)
+ || ThrowTemplateError($template->error());
+ exit;
}
# Sanitize the URL, to make URLs shorter.
@@ -209,6 +258,7 @@ $vars->{'width'} = $width if $width;
$vars->{'height'} = $height if $height;
$vars->{'query'} = $query;
+$vars->{'saved_report_id'} = $cgi->param('saved_report_id');
$vars->{'debug'} = $cgi->param('debug');
my $formatparam = $cgi->param('format');