long_list.cgi 3.81 KB
Newer Older
1
#!/usr/bin/perl -wT
2
# -*- Mode: perl; indent-tabs-mode: nil -*-
terry%netscape.com's avatar
terry%netscape.com committed
3
#
4 5 6 7 8 9 10 11 12 13
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
terry%netscape.com's avatar
terry%netscape.com committed
14
# The Original Code is the Bugzilla Bug Tracking System.
15
#
terry%netscape.com's avatar
terry%netscape.com committed
16
# The Initial Developer of the Original Code is Netscape Communications
17 18 19 20
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
terry%netscape.com's avatar
terry%netscape.com committed
21
# Contributor(s): Terry Weissman <terry@mozilla.org>
22
#                 Gervase Markham <gerv@gerv.net>
terry%netscape.com's avatar
terry%netscape.com committed
23

24
use strict;
25 26
use lib qw(.);

27 28
use Bugzilla;

29 30
require "CGI.pl";

31
use vars qw($userid @legal_keywords %FORM);
32

33 34
# Use global template variables.
use vars qw($template $vars);
35

36
ConnectToDatabase();
37

38 39
quietly_check_login();

40 41
GetVersionTable();

42 43
my $cgi = Bugzilla->cgi;

44 45 46
my $generic_query = "
  SELECT 
    bugs.bug_id, 
47
    IFNULL(bugs.alias,''), 
48
    products.name, 
49 50 51 52 53 54 55
    bugs.version, 
    bugs.rep_platform,
    bugs.op_sys, 
    bugs.bug_status, 
    bugs.resolution, 
    bugs.priority,
    bugs.bug_severity, 
56
    components.name, 
57 58 59 60 61 62 63
    assign.login_name, 
    report.login_name,
    bugs.bug_file_loc, 
    bugs.short_desc, 
    bugs.target_milestone,
    bugs.qa_contact, 
    bugs.status_whiteboard, 
64 65
    bugs.keywords,
    bugs.estimated_time,
66 67
    bugs.remaining_time,
    date_format(creation_ts,'%Y.%m.%d %H:%i')
68 69 70
  FROM bugs,profiles assign,profiles report, products, components
  WHERE assign.userid = bugs.assigned_to AND report.userid = bugs.reporter
    AND bugs.product_id=products.id AND bugs.component_id=components.id";
71 72 73 74 75 76 77 78 79

my $buglist = $::FORM{'buglist'} || 
              $::FORM{'bug_id'}  || 
              $::FORM{'id'}      || "";

my @bugs;

foreach my $bug_id (split(/[:,]/, $buglist)) {
    detaint_natural($bug_id) || next;
80 81
    CanSeeBug($bug_id, $::userid) || next;
    SendSQL("$generic_query AND bugs.bug_id = $bug_id");
terry%netscape.com's avatar
terry%netscape.com committed
82

83 84 85
    my %bug;
    my @row = FetchSQLData();

86
    foreach my $field ("bug_id", "alias", "product", "version", "rep_platform",
87 88 89
                       "op_sys", "bug_status", "resolution", "priority",
                       "bug_severity", "component", "assigned_to", "reporter",
                       "bug_file_loc", "short_desc", "target_milestone",
90
                       "qa_contact", "status_whiteboard", "keywords", 
91
                       "estimated_time", "remaining_time", "creation_ts") 
92 93 94 95 96 97 98 99 100 101
    {
        $bug{$field} = shift @row;
    }
    
    if ($bug{'bug_id'}) {
        $bug{'comments'} = GetComments($bug{'bug_id'});
        $bug{'qa_contact'} = $bug{'qa_contact'} > 0 ? 
                                          DBID_to_name($bug{'qa_contact'}) : "";

        push (@bugs, \%bug);
102
    }
103 104 105 106 107 108

    if (UserInGroup(Param("timetrackinggroup"))) {
        SendSQL("SELECT SUM(work_time) FROM longdescs WHERE bug_id=$bug_id");

        $bug{'actual_time'} = FetchSQLData();
    }
terry%netscape.com's avatar
terry%netscape.com committed
109
}
110 111 112 113 114 115 116 117 118 119 120 121 122 123

# Add the list of bug hashes to the variables
$vars->{'bugs'} = \@bugs;

$vars->{'use_keywords'} = 1 if (@::legal_keywords);

$vars->{'str2time'} = \&str2time;

# Work out a sensible filename for Content-Disposition.
# Sadly, I don't think we can tell if this was a named query.
my @time = localtime(time());
my $date = sprintf "%04d-%02d-%02d", 1900+$time[5],$time[4]+1,$time[3];
my $filename = "bugs-$date.html";

124
print $cgi->header(-content_disposition => "inline; filename=$filename");
125 126

# Generate and return the UI (HTML page) from the appropriate template.
127 128
$template->process("bug/show-multiple.html.tmpl", $vars)
  || ThrowTemplateError($template->error());