colchange.cgi 4.77 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>
23
#                 Max Kanat-Alexander <mkanat@bugzilla.org>
terry%netscape.com's avatar
terry%netscape.com committed
24

25
use strict;
terry%netscape.com's avatar
terry%netscape.com committed
26

27 28
use lib qw(.);

29
use Bugzilla;
30
use Bugzilla::Constants;
31
use Bugzilla::Error;
32
use Bugzilla::User;
33
use Bugzilla::Keyword;
34

35
Bugzilla->login();
36

37
my $cgi = Bugzilla->cgi;
38 39
my $template = Bugzilla->template;
my $vars = {};
40

terry%netscape.com's avatar
terry%netscape.com committed
41 42
# The master list not only says what fields are possible, but what order
# they get displayed in.
43 44 45
my @masterlist = ("opendate", "changeddate", "bug_severity", "priority",
                  "rep_platform", "assigned_to", "assigned_to_realname",
                  "reporter", "reporter_realname", "bug_status",
46 47
                  "resolution");

48
if (Bugzilla->params->{"useclassification"}) {
49 50 51
    push(@masterlist, "classification");
}

52
push(@masterlist, ("product", "component", "version", "op_sys"));
53

54
if (Bugzilla->params->{"usevotes"}) {
55 56
    push (@masterlist, "votes");
}
57
if (Bugzilla->params->{"usebugaliases"}) {
58 59
    unshift(@masterlist, "alias");
}
60
if (Bugzilla->params->{"usetargetmilestone"}) {
61 62
    push(@masterlist, "target_milestone");
}
63
if (Bugzilla->params->{"useqacontact"}) {
64
    push(@masterlist, "qa_contact");
65
    push(@masterlist, "qa_contact_realname");
66
}
67
if (Bugzilla->params->{"usestatuswhiteboard"}) {
68 69
    push(@masterlist, "status_whiteboard");
}
70
if (Bugzilla::Keyword::keyword_count()) {
71 72
    push(@masterlist, "keywords");
}
73

74
if (Bugzilla->user->in_group(Bugzilla->params->{"timetrackinggroup"})) {
75
    push(@masterlist, ("estimated_time", "remaining_time", "actual_time",
76
                       "percentage_complete", "deadline")); 
77 78
}

79
push(@masterlist, ("short_desc", "short_short_desc"));
terry%netscape.com's avatar
terry%netscape.com committed
80

81 82
push(@masterlist, Bugzilla->custom_field_names);

83
$vars->{'masterlist'} = \@masterlist;
terry%netscape.com's avatar
terry%netscape.com committed
84

85
my @collist;
86
if (defined $cgi->param('rememberedquery')) {
87
    my $splitheader = 0;
88
    if (defined $cgi->param('resetit')) {
89
        @collist = DEFAULT_COLUMN_LIST;
terry%netscape.com's avatar
terry%netscape.com committed
90
    } else {
91
        foreach my $i (@masterlist) {
92
            if (defined $cgi->param("column_$i")) {
93
                push @collist, $i;
terry%netscape.com's avatar
terry%netscape.com committed
94 95
            }
        }
96
        if (defined $cgi->param('splitheader')) {
97
            $splitheader = $cgi->param('splitheader')? 1: 0;
98
        }
terry%netscape.com's avatar
terry%netscape.com committed
99
    }
100
    my $list = join(" ", @collist);
101
    my $urlbase = Bugzilla->params->{"urlbase"};
102

103 104 105 106 107 108 109 110
    if ($list) {
        $cgi->send_cookie(-name => 'COLUMNLIST',
                          -value => $list,
                          -expires => 'Fri, 01-Jan-2038 00:00:00 GMT');
    }
    else {
        $cgi->remove_cookie('COLUMNLIST');
    }
111 112 113 114 115 116 117 118
    if ($splitheader) {
        $cgi->send_cookie(-name => 'SPLITHEADER',
                          -value => $splitheader,
                          -expires => 'Fri, 01-Jan-2038 00:00:00 GMT');
    }
    else {
        $cgi->remove_cookie('SPLITHEADER');
    }
119

120
    $vars->{'message'} = "change_columns";
121
    $vars->{'redirect_url'} = "buglist.cgi?".$cgi->param('rememberedquery');
122 123 124 125

    # If we're running on Microsoft IIS, using cgi->redirect discards
    # the Set-Cookie lines -- workaround is to use the old-fashioned 
    # redirection mechanism. See bug 214466 for details.
126 127 128
    if ($ENV{'SERVER_SOFTWARE'} =~ /Microsoft-IIS/
        || $ENV{'SERVER_SOFTWARE'} =~ /Sun ONE Web/)
    {
129 130
      print $cgi->header(-type => "text/html",
                         -refresh => "0; URL=$vars->{'redirect_url'}");
131 132
    }
    else {
133 134 135
      print $cgi->redirect($vars->{'redirect_url'});
    }
    
136 137
    $template->process("global/message.html.tmpl", $vars)
      || ThrowTemplateError($template->error());
138
    exit;
terry%netscape.com's avatar
terry%netscape.com committed
139 140
}

141 142
if (defined $cgi->cookie('COLUMNLIST')) {
    @collist = split(/ /, $cgi->cookie('COLUMNLIST'));
terry%netscape.com's avatar
terry%netscape.com committed
143
} else {
144
    @collist = DEFAULT_COLUMN_LIST;
terry%netscape.com's avatar
terry%netscape.com committed
145 146
}

147
$vars->{'collist'} = \@collist;
148
$vars->{'splitheader'} = $cgi->cookie('SPLITHEADER') ? 1 : 0;
149

150
$vars->{'buffer'} = $cgi->query_string();
terry%netscape.com's avatar
terry%netscape.com committed
151

152
# Generate and return the UI (HTML page) from the appropriate template.
153
print $cgi->header();
154 155
$template->process("list/change-columns.html.tmpl", $vars)
  || ThrowTemplateError($template->error());