enter_bug.cgi 8.74 KB
Newer Older
1 2
#!/usr/bonsaitools/bin/perl -w
# -*- 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 14 15 16 17 18 19 20 21
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.0 (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.
# 
# The Original Code is the Bugzilla Bug Tracking System.
# 
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are Copyright (C) 1998
# Netscape Communications Corporation. All Rights Reserved.
# 
# Contributor(s): Terry Weissman <terry@mozilla.org>

22 23
use diagnostics;
use strict;
terry%netscape.com's avatar
terry%netscape.com committed
24

25
require "CGI.pl";
26

27 28 29 30 31 32 33 34 35 36 37 38 39 40
# Shut up misguided -w warnings about "used only once":
use vars @::legal_platform,
    @::buffer,
    @::legal_severity,
    @::legal_opsys,
    @::legal_priority;


if (!defined $::FORM{'product'}) {
    GetVersionTable();
    my @prodlist = keys %::versions;
    if ($#prodlist != 0) {
        print "Content-type: text/html\n\n";
        PutHeader("Enter Bug");
41
        
42 43
        print "<H2>First, you must pick a product on which to enter\n";
        print "a bug.</H2>\n";
44
        print "<table>";
45
        foreach my $p (sort (@prodlist)) {
46 47 48 49 50 51
            if (defined $::proddesc{$p} && $::proddesc{$p} eq '0') {
                # Special hack.  If we stuffed a "0" into proddesc, that means
                # that disallownew was set for this bug, and so we don't want
                # to allow people to specify that product here.
                next;
            }
52
            print "<tr><th align=right valign=top><a href=\"enter_bug.cgi?product=" . url_quote($p) . "\"&$::buffer>$p</a>:</th>\n";
53
            if (defined $::proddesc{$p}) {
54
                print "<td valign=top>$::proddesc{$p}</td>\n";
55 56
            }
            print "</tr>";
57
        }
58
        print "</table>\n";
59
        exit;
60
    }
61
    $::FORM{'product'} = $prodlist[0];
62 63
}

64
my $product = $::FORM{'product'};
terry%netscape.com's avatar
terry%netscape.com committed
65

66
confirm_login();
terry%netscape.com's avatar
terry%netscape.com committed
67

68
print "Content-type: text/html\n\n";
terry%netscape.com's avatar
terry%netscape.com committed
69

70 71 72 73 74 75 76 77 78 79
sub formvalue {
    my ($name, $default) = (@_);
    if (exists $::FORM{$name}) {
        return $::FORM{$name};
    }
    if (defined $default) {
        return $default;
    }
    return "";
}
terry%netscape.com's avatar
terry%netscape.com committed
80

81 82 83 84
sub pickplatform {
    my $value = formvalue("rep_platform");
    if ($value ne "") {
        return $value;
terry%netscape.com's avatar
terry%netscape.com committed
85
    }
86 87 88 89
    for ($ENV{'HTTP_USER_AGENT'}) {
        /Mozilla.*\(Windows/ && do {return "PC";};
        /Mozilla.*\(Macintosh/ && do {return "Macintosh";};
        /Mozilla.*\(Win/ && do {return "PC";};
90 91 92 93 94 95
        /Mozilla.*Linux.*86/ && do {return "PC";};
        /Mozilla.*Linux.*alpha/ && do {return "DEC";};
        /Mozilla.*OSF/ && do {return "DEC";};
        /Mozilla.*HP-UX/ && do {return "HP";};
        /Mozilla.*IRIX/ && do {return "SGI";};
        /Mozilla.*(SunOS|Solaris)/ && do {return "Sun";};
96
        # default
97
        return "Other";
terry%netscape.com's avatar
terry%netscape.com committed
98 99 100
    }
}

101

terry%netscape.com's avatar
terry%netscape.com committed
102

103 104 105 106 107
sub pickversion {
    my $version = formvalue('version');
    if ($version eq "") {
        if ($ENV{'HTTP_USER_AGENT'} =~ m@Mozilla[ /]([^ ]*)@) {
            $version = $1;
terry%netscape.com's avatar
terry%netscape.com committed
108 109 110
        }
    }
    
111 112
    if (lsearch($::versions{$product}, $version) >= 0) {
        return $version;
terry%netscape.com's avatar
terry%netscape.com committed
113
    } else {
114 115 116 117
        if (defined $::COOKIE{"VERSION-$product"}) {
            if (lsearch($::versions{$product},
                        $::COOKIE{"VERSION-$product"}) >= 0) {
                return $::COOKIE{"VERSION-$product"};
terry%netscape.com's avatar
terry%netscape.com committed
118 119 120
            }
        }
    }
121
    return $::versions{$product}->[0];
terry%netscape.com's avatar
terry%netscape.com committed
122 123 124
}


125 126 127 128
sub pickcomponent {
    my $result =formvalue('component');
    if ($result ne "" && lsearch($::components{$product}, $result) < 0) {
        $result = "";
terry%netscape.com's avatar
terry%netscape.com committed
129
    }
130
    return $result;
terry%netscape.com's avatar
terry%netscape.com committed
131 132 133
}


134 135 136
sub pickos {
    if (formvalue('op_sys') ne "") {
        return formvalue('op_sys');
terry%netscape.com's avatar
terry%netscape.com committed
137
    }
138 139 140 141
    for ($ENV{'HTTP_USER_AGENT'}) {
        /Mozilla.*\(.*;.*; IRIX.*\)/    && do {return "IRIX";};
        /Mozilla.*\(.*;.*; 32bit.*\)/   && do {return "Windows 95";};
        /Mozilla.*\(.*;.*; 16bit.*\)/   && do {return "Windows 3.1";};
142 143
        /Mozilla.*\(.*;.*; 68K.*\)/     && do {return "Mac System 8.5";};
        /Mozilla.*\(.*;.*; PPC.*\)/     && do {return "Mac System 8.5";};
144 145 146 147 148
        /Mozilla.*\(.*;.*; OSF.*\)/     && do {return "OSF/1";};
        /Mozilla.*\(.*;.*; Linux.*\)/   && do {return "Linux";};
        /Mozilla.*\(.*;.*; SunOS 5.*\)/ && do {return "Solaris";};
        /Mozilla.*\(.*;.*; SunOS.*\)/   && do {return "SunOS";};
        /Mozilla.*\(.*;.*; SunOS.*\)/   && do {return "SunOS";};
149
        /Mozilla.*\(.*;.*; BSD\/OS.*\)/ && do {return "BSDI";};
150 151 152 153 154
        /Mozilla.*\(Win16.*\)/          && do {return "Windows 3.1";};
        /Mozilla.*\(Win95.*\)/          && do {return "Windows 95";};
        /Mozilla.*\(WinNT.*\)/          && do {return "Windows NT";};
        # default
        return "other";
terry%netscape.com's avatar
terry%netscape.com committed
155 156 157 158
    }
}


159
GetVersionTable();
terry%netscape.com's avatar
terry%netscape.com committed
160

161 162
my $assign_element = GeneratePersonInput('assigned_to', 1,
                                         formvalue('assigned_to'));
163
my $cc_element = GeneratePeopleInput('cc', formvalue('cc'));
terry%netscape.com's avatar
terry%netscape.com committed
164 165


166 167
my $priority = Param('defaultpriority');

168
my $priority_popup = make_popup('priority', \@::legal_priority,
169
                                formvalue('priority', $priority), 0);
170 171 172 173 174
my $sev_popup = make_popup('bug_severity', \@::legal_severity,
                           formvalue('bug_severity', 'normal'), 0);
my $platform_popup = make_popup('rep_platform', \@::legal_platform,
                                pickplatform(), 0);
my $opsys_popup = make_popup('op_sys', \@::legal_opsys, pickos(), 0);
terry%netscape.com's avatar
terry%netscape.com committed
175

176 177
my $component_popup = make_popup('component', $::components{$product},
                                 formvalue('component'), 1);
terry%netscape.com's avatar
terry%netscape.com committed
178

179
PutHeader ("Enter Bug");
terry%netscape.com's avatar
terry%netscape.com committed
180

181
print "
terry%netscape.com's avatar
terry%netscape.com committed
182 183
<FORM NAME=enterForm METHOD=POST ACTION=\"post_bug.cgi\">
<INPUT TYPE=HIDDEN NAME=bug_status VALUE=NEW>
184
<INPUT TYPE=HIDDEN NAME=reporter VALUE=$::COOKIE{'Bugzilla_login'}>
185
<INPUT TYPE=HIDDEN NAME=product VALUE=\""  . value_quote($product) . "\">
terry%netscape.com's avatar
terry%netscape.com committed
186 187 188
  <TABLE CELLSPACING=2 CELLPADDING=0 BORDER=0>
  <TR>
    <td ALIGN=right valign=top><B>Product:</B></td>
189 190 191
    <td valign=top>$product</td>
  </TR>
  <TR>
terry%netscape.com's avatar
terry%netscape.com committed
192
    <td ALIGN=right valign=top><B>Version:</B></td>
193
    <td>" . Version_element(pickversion(), $product) . "</td>
194 195
    <td align=right valign=top><b><a href=\"describecomponents.cgi?product=" .
    url_quote($product) . "\">Component:</b></td>
terry%netscape.com's avatar
terry%netscape.com committed
196 197 198 199 200 201
    <td>$component_popup</td>
  </TR>
  <tr><td>&nbsp<td> <td> <td> <td> <td> </tr>
  <TR>
    <td align=right><b><B><A HREF=\"bug_status.html#rep_platform\">Platform:</A></B></td>
    <TD>$platform_popup</TD>
202
    <TD ALIGN=RIGHT><B><A HREF=\"bug_status.html#op_sys\">OS:</A></B></TD>
terry%netscape.com's avatar
terry%netscape.com committed
203 204 205 206 207
    <TD>$opsys_popup</TD>
    <td align=right valign=top></td>
    <td rowspan=3></td>
    <td></td>
  </TR>
208 209 210
  <TR>";
if (Param('letsubmitterchoosepriority')) {
    print "
terry%netscape.com's avatar
terry%netscape.com committed
211
    <TD ALIGN=RIGHT><B><A HREF=\"bug_status.html#priority\">Priority</A>:</B></TD>
212 213 214 215 216 217
    <TD>$priority_popup</TD>";
} else {
    print '<INPUT TYPE=HIDDEN NAME=priority VALUE="' .
        value_quote($priority) . '">';
}
print "
terry%netscape.com's avatar
terry%netscape.com committed
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
    <TD ALIGN=RIGHT><B><A HREF=\"bug_status.html#severity\">Severity</A>:</B></TD>
    <TD>$sev_popup</TD>
    <td></td>
    <td></td>
  </TR>
  <tr><td>&nbsp<td> <td> <td> <td> <td> </tr>
  <tr>
    <TD ALIGN=RIGHT><B><A HREF=\"bug_status.html#assigned_to\">Assigned To:
        </A></B></TD>
    <TD colspan=5>$assign_element
    (Leave blank to assign to default owner for component)</td>
  </tr>
  <tr>
    <TD ALIGN=RIGHT ><B>Cc:</B></TD>
    <TD colspan=5>$cc_element</TD>
  </tr>
  <tr><td>&nbsp<td> <td> <td> <td> <td> </tr>
  <TR>
    <TD ALIGN=RIGHT><B>URL:</B>
    <TD COLSPAN=5>
238 239 240
      <INPUT NAME=bug_file_loc SIZE=60 value=\"" .
    value_quote(formvalue('bug_file_loc')) .
    "\"></TD>
terry%netscape.com's avatar
terry%netscape.com committed
241 242 243 244
  </TR>
  <TR>
    <TD ALIGN=RIGHT><B>Summary:</B>
    <TD COLSPAN=5>
245 246 247
      <INPUT NAME=short_desc SIZE=60 value=\"" .
    value_quote(formvalue('short_desc')) .
    "\"></TD>
terry%netscape.com's avatar
terry%netscape.com committed
248 249 250 251
  </TR>
  <tr><td>&nbsp<td> <td> <td> <td> <td> </tr>
  <tr>
    <td aligh=right valign=top><B>Description:</b>
252 253 254
    <td colspan=5><TEXTAREA WRAP=HARD NAME=comment ROWS=10 COLS=80>" .
    value_quote(formvalue('comment')) .
    "</TEXTAREA><BR></td>
terry%netscape.com's avatar
terry%netscape.com committed
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
  </tr>
  <tr>
    <td></td>
    <td colspan=5>
       <INPUT TYPE=\"submit\" VALUE=\"    Commit    \">
       &nbsp;&nbsp;&nbsp;&nbsp;
       <INPUT TYPE=\"reset\" VALUE=\"Reset\">
       &nbsp;&nbsp;&nbsp;&nbsp;
       <INPUT TYPE=\"submit\" NAME=maketemplate VALUE=\"Remember values as bookmarkable template\">
    </td>
  </tr>
  </TABLE>
  <INPUT TYPE=hidden name=form_name VALUE=enter_bug>
</FORM>

270 271
Some fields initialized from your user-agent, <b>$ENV{'HTTP_USER_AGENT'}</b>.
If you think it got it wrong, please tell " . Param('maintainer') . " what it should have been.
terry%netscape.com's avatar
terry%netscape.com committed
272

273
</BODY></HTML>";