colchange.cgi 4.56 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
use vars qw(
  @legal_keywords
);
31

32
use Bugzilla;
33
use Bugzilla::Constants;
34
use Bugzilla::User;
35
require "globals.pl";
36

37
Bugzilla->login();
38

39
GetVersionTable();
40

41
my $cgi = Bugzilla->cgi;
42 43
my $template = Bugzilla->template;
my $vars = {};
44

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
        if (defined $cgi->param('splitheader')) {
99
            $splitheader = $cgi->param('splitheader')? 1: 0;
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 109 110 111 112
    if ($list) {
        $cgi->send_cookie(-name => 'COLUMNLIST',
                          -value => $list,
                          -expires => 'Fri, 01-Jan-2038 00:00:00 GMT');
    }
    else {
        $cgi->remove_cookie('COLUMNLIST');
    }
113 114 115 116 117 118 119 120
    if ($splitheader) {
        $cgi->send_cookie(-name => 'SPLITHEADER',
                          -value => $splitheader,
                          -expires => 'Fri, 01-Jan-2038 00:00:00 GMT');
    }
    else {
        $cgi->remove_cookie('SPLITHEADER');
    }
121

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

    # 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.
128 129 130
    if ($ENV{'SERVER_SOFTWARE'} =~ /Microsoft-IIS/
        || $ENV{'SERVER_SOFTWARE'} =~ /Sun ONE Web/)
    {
131 132
      print $cgi->header(-type => "text/html",
                         -refresh => "0; URL=$vars->{'redirect_url'}");
133 134
    }
    else {
135 136 137
      print $cgi->redirect($vars->{'redirect_url'});
    }
    
138 139
    $template->process("global/message.html.tmpl", $vars)
      || ThrowTemplateError($template->error());
140
    exit;
terry%netscape.com's avatar
terry%netscape.com committed
141 142
}

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

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

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

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