colchange.cgi 4.34 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
use Bugzilla::User;
38 39
require "CGI.pl";

40
Bugzilla->login();
41

42
GetVersionTable();
43

44 45
my $cgi = Bugzilla->cgi;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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