colchange.cgi 4.32 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;
terry%netscape.com's avatar
terry%netscape.com committed
25

26 27
use lib qw(.);

28 29 30 31 32 33
use vars qw(
  @legal_keywords
  $buffer
  $template
  $vars
);
34

35
use Bugzilla;
36
use Bugzilla::Constants;
37 38
require "CGI.pl";

39
Bugzilla->login();
40

41
GetVersionTable();
42

43 44
my $cgi = Bugzilla->cgi;

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

if (Param("useclassification")) {
    push(@masterlist, "classification");
}

56
push(@masterlist, ("product", "component", "version", "op_sys"));
57

58 59 60
if (Param("usevotes")) {
    push (@masterlist, "votes");
}
61 62 63
if (Param("usebugaliases")) {
    unshift(@masterlist, "alias");
}
64 65 66 67 68
if (Param("usetargetmilestone")) {
    push(@masterlist, "target_milestone");
}
if (Param("useqacontact")) {
    push(@masterlist, "qa_contact");
69
    push(@masterlist, "qa_contact_realname");
70 71 72 73
}
if (Param("usestatuswhiteboard")) {
    push(@masterlist, "status_whiteboard");
}
74 75 76
if (@::legal_keywords) {
    push(@masterlist, "keywords");
}
77

78 79
if (UserInGroup(Param("timetrackinggroup"))) {
    push(@masterlist, ("estimated_time", "remaining_time", "actual_time",
80
                       "percentage_complete", "deadline")); 
81 82
}

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

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

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

    $cgi->send_cookie(-name => 'COLUMNLIST',
                      -value => $list,
                      -expires => 'Fri, 01-Jan-2038 00:00:00 GMT');
    $cgi->send_cookie(-name => 'SPLITHEADER',
109
                      -value => $cgi->param('splitheader'),
110 111
                      -expires => 'Fri, 01-Jan-2038 00:00:00 GMT');

112
    $vars->{'message'} = "change_columns";
113
    $vars->{'redirect_url'} = "buglist.cgi?".$cgi->param('rememberedquery');
114 115 116 117

    # 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.
118 119 120
    if ($ENV{'SERVER_SOFTWARE'} =~ /Microsoft-IIS/
        || $ENV{'SERVER_SOFTWARE'} =~ /Sun ONE Web/)
    {
121 122
      print $cgi->header(-type => "text/html",
                         -refresh => "0; URL=$vars->{'redirect_url'}");
123 124
    }
    else {
125 126 127
      print $cgi->redirect($vars->{'redirect_url'});
    }
    
128 129
    $template->process("global/message.html.tmpl", $vars)
      || ThrowTemplateError($template->error());
130
    exit;
terry%netscape.com's avatar
terry%netscape.com committed
131 132
}

133 134
if (defined $cgi->cookie('COLUMNLIST')) {
    @collist = split(/ /, $cgi->cookie('COLUMNLIST'));
terry%netscape.com's avatar
terry%netscape.com committed
135
} else {
136
    @collist = DEFAULT_COLUMN_LIST;
terry%netscape.com's avatar
terry%netscape.com committed
137 138
}

139
$vars->{'collist'} = \@collist;
140
$vars->{'splitheader'} = $cgi->cookie('SPLITHEADER') ? 1 : 0;
141

142
$vars->{'buffer'} = $::buffer;
terry%netscape.com's avatar
terry%netscape.com committed
143

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