Annotation of aphrodite/www/enter_bug, revision 1.1

1.1     ! petejc      1: #!/usr/bonsaitools/bin/perl -w
        !             2: # -*- Mode: perl; indent-tabs-mode: nil -*-
        !             3: #
        !             4: # The contents of this file are subject to the Mozilla Public
        !             5: # License Version 1.1 (the "License"); you may not use this file
        !             6: # except in compliance with the License. You may obtain a copy of
        !             7: # the License at http://www.mozilla.org/MPL/
        !             8: #
        !             9: # Software distributed under the License is distributed on an "AS
        !            10: # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
        !            11: # implied. See the License for the specific language governing
        !            12: # rights and limitations under the License.
        !            13: #
        !            14: # The Original Code is the Bugzilla Bug Tracking System.
        !            15: # 
        !            16: # The Initial Developer of the Original Code is Netscape Communications
        !            17: # Corporation. Portions created by Netscape are Copyright (C) 1998
        !            18: # Netscape Communications Corporation. All Rights Reserved.
        !            19: # 
        !            20: # Contributor(s): Terry Weissman <terry@mozilla.org>
        !            21: #                 Dave Miller <dave@intrec.com>
        !            22: #                 Joe Robins <jmrobins@tgix.com>
        !            23: 
        !            24: 
        !            25: ########################################################################
        !            26: #
        !            27: # enter_bug.cgi
        !            28: # -------------
        !            29: # Displays bug entry form. Bug fields are specified through popup menus, 
        !            30: # drop-down lists, or text fields. Default for these values can be passed
        !            31: # in as parameters to the cgi.
        !            32: #
        !            33: ########################################################################
        !            34: 
        !            35: use diagnostics;
        !            36: use strict;
        !            37: 
        !            38: require "CGI.pl";
        !            39: 
        !            40: # Shut up misguided -w warnings about "used only once".  "use vars" just
        !            41: # doesn't work for me.
        !            42: 
        !            43: sub sillyness {
        !            44:     my $zz;
        !            45:     $zz = $::unconfirmedstate;
        !            46:     $zz = @::legal_opsys;
        !            47:     $zz = @::legal_platform;
        !            48:     $zz = @::legal_priority;
        !            49:     $zz = @::legal_severity;
        !            50: }
        !            51: 
        !            52: # I've moved the call to confirm_login up to here, since if we're using bug
        !            53: # groups to restrict bug entry, we need to know who the user is right from
        !            54: # the start.  If that parameter is turned off, there's still no harm done in
        !            55: # doing it now instead of a bit later.  -JMR, 2/18/00
        !            56: # Except that it will cause people without cookies enabled to have to log
        !            57: # in an extra time.  Only do it here if we really need to.  -terry, 3/10/00
        !            58: if (Param("usebuggroupsentry")) {
        !            59:     confirm_login();
        !            60: }
        !            61: 
        !            62: if (!defined $::FORM{'product'}) {
        !            63:     GetVersionTable();
        !            64:     my @prodlist;
        !            65:     foreach my $p (sort(keys %::versions)) {
        !            66:         if (defined $::proddesc{$p} && $::proddesc{$p} eq '0') {
        !            67:             # Special hack.  If we stuffed a "0" into proddesc, that means
        !            68:             # that disallownew was set for this bug, and so we don't want
        !            69:             # to allow people to specify that product here.
        !            70:             next;
        !            71:         }
        !            72:         if(Param("usebuggroupsentry")
        !            73:            && GroupExists($p)
        !            74:            && !UserInGroup($p)) {
        !            75:           # If we're using bug groups to restrict entry on products, and
        !            76:           # this product has a bug group, and the user is not in that
        !            77:           # group, we don't want to include that product in this list.
        !            78:           next;
        !            79:         }
        !            80:         push(@prodlist, $p);
        !            81:     }
        !            82:     if (1 != @prodlist) {
        !            83:         print "Content-type: text/html\n\n";
        !            84:         PutHeader("Enter Bug");
        !            85:         
        !            86:         print "<H2>First, you must pick a product on which to enter\n";
        !            87:         print "a bug.</H2>\n";
        !            88:         print "<table>";
        !            89:         foreach my $p (@prodlist) {
        !            90:             if (defined $::proddesc{$p} && $::proddesc{$p} eq '0') {
        !            91:                 # Special hack.  If we stuffed a "0" into proddesc, that means
        !            92:                 # that disallownew was set for this bug, and so we don't want
        !            93:                 # to allow people to specify that product here.
        !            94:                 next;
        !            95:             }
        !            96:             if(Param("usebuggroupsentry")
        !            97:                && GroupExists($p)
        !            98:                && !UserInGroup($p)) {
        !            99:                 # If we're using bug groups to restrict entry on products, and
        !           100:                 # this product has a bug group, and the user is not in that
        !           101:                 # group, we don't want to include that product in this list.
        !           102:                 next;
        !           103:             }
        !           104:             print "<tr><th align=right valign=top><a href=\"enter_bug.cgi?product=" . url_quote($p) . "\">$p</a>:</th>\n";
        !           105:             if (defined $::proddesc{$p}) {
        !           106:                 print "<td valign=top>$::proddesc{$p}</td>\n";
        !           107:             }
        !           108:             print "</tr>";
        !           109:         }
        !           110:         print "</table>\n";
        !           111:         PutFooter();
        !           112:         exit;
        !           113:     }
        !           114:     $::FORM{'product'} = $prodlist[0];
        !           115: }
        !           116: 
        !           117: my $product = $::FORM{'product'};
        !           118: 
        !           119: confirm_login();
        !           120: 
        !           121: print "Content-type: text/html\n\n";
        !           122: 
        !           123: sub formvalue {
        !           124:     my ($name, $default) = (@_);
        !           125:     if (exists $::FORM{$name}) {
        !           126:         return $::FORM{$name};
        !           127:     }
        !           128:     if (defined $default) {
        !           129:         return $default;
        !           130:     }
        !           131:     return "";
        !           132: }
        !           133: 
        !           134: sub pickplatform {
        !           135:     my $value = formvalue("rep_platform");
        !           136:     if ($value ne "") {
        !           137:         return $value;
        !           138:     }
        !           139:     if ( Param('usebrowserinfo') ) {
        !           140:         for ($ENV{'HTTP_USER_AGENT'}) {
        !           141:             /Mozilla.*\(Windows/ && do {return "PC";};
        !           142:             /Mozilla.*\(Macintosh/ && do {return "Macintosh";};
        !           143:             /Mozilla.*\(Win/ && do {return "PC";};
        !           144:            /Mozilla.*Windows NT/ && do {return "PC";};
        !           145:             /Mozilla.*Linux.*86/ && do {return "PC";};
        !           146:             /Mozilla.*Linux.*alpha/ && do {return "DEC";};
        !           147:             /Mozilla.*OSF/ && do {return "DEC";};
        !           148:             /Mozilla.*HP-UX/ && do {return "HP";};
        !           149:             /Mozilla.*IRIX/ && do {return "SGI";};
        !           150:             /Mozilla.*(SunOS|Solaris)/ && do {return "Sun";};
        !           151:         }
        !           152:     }
        !           153:     # default
        !           154:     return "Other";
        !           155: }
        !           156: 
        !           157: 
        !           158: 
        !           159: sub pickversion {
        !           160:     my $version = formvalue('version');
        !           161: 
        !           162:     if ( Param('usebrowserinfo') ) {
        !           163:         if ($version eq "") {
        !           164:             if ($ENV{'HTTP_USER_AGENT'} =~ m@Mozilla[ /]([^ ]*)@) {
        !           165:                 $version = $1;
        !           166:             }
        !           167:         }
        !           168:     }
        !           169:     
        !           170:     if (lsearch($::versions{$product}, $version) >= 0) {
        !           171:         return $version;
        !           172:     } else {
        !           173:         if (defined $::COOKIE{"VERSION-$product"}) {
        !           174:             if (lsearch($::versions{$product},
        !           175:                         $::COOKIE{"VERSION-$product"}) >= 0) {
        !           176:                 return $::COOKIE{"VERSION-$product"};
        !           177:             }
        !           178:         }
        !           179:     }
        !           180:     return $::versions{$product}->[0];
        !           181: }
        !           182: 
        !           183: 
        !           184: sub pickcomponent {
        !           185:     my $result =formvalue('component');
        !           186:     if ($result ne "" && lsearch($::components{$product}, $result) < 0) {
        !           187:         $result = "";
        !           188:     }
        !           189:     return $result;
        !           190: }
        !           191: 
        !           192: 
        !           193: sub pickos {
        !           194:     if (formvalue('op_sys') ne "") {
        !           195:         return formvalue('op_sys');
        !           196:     }
        !           197:     if ( Param('usebrowserinfo') ) {
        !           198:         for ($ENV{'HTTP_USER_AGENT'}) {
        !           199:             /Mozilla.*\(.*;.*; IRIX.*\)/    && do {return "IRIX";};
        !           200:             /Mozilla.*\(.*;.*; 32bit.*\)/   && do {return "Windows 95";};
        !           201:             /Mozilla.*\(.*;.*; 16bit.*\)/   && do {return "Windows 3.1";};
        !           202:             /Mozilla.*\(.*;.*; 68K.*\)/     && do {return "Mac System 8.5";};
        !           203:             /Mozilla.*\(.*;.*; PPC.*\)/     && do {return "Mac System 8.5";};
        !           204:             /Mozilla.*\(.*;.*; OSF.*\)/     && do {return "OSF/1";};
        !           205:             /Mozilla.*\(.*;.*; Linux.*\)/   && do {return "Linux";};
        !           206:             /Mozilla.*\(.*;.*; SunOS 5.*\)/ && do {return "Solaris";};
        !           207:             /Mozilla.*\(.*;.*; SunOS.*\)/   && do {return "SunOS";};
        !           208:             /Mozilla.*\(.*;.*; SunOS.*\)/   && do {return "SunOS";};
        !           209:             /Mozilla.*\(.*;.*; BSD\/OS.*\)/ && do {return "BSDI";};
        !           210:             /Mozilla.*\(Win16.*\)/          && do {return "Windows 3.1";};
        !           211:             /Mozilla.*\(Win95.*\)/          && do {return "Windows 95";};
        !           212:             /Mozilla.*\(Win98.*\)/          && do {return "Windows 98";};
        !           213:             /Mozilla.*\(WinNT.*\)/          && do {return "Windows NT";};
        !           214:             /Mozilla.*Windows NT 5.*\)/     && do {return "Windows 2000";};
        !           215:             /Mozilla.*\(Windows.*NT/        && do {return "Windows NT";};
        !           216:         }
        !           217:     }
        !           218:     # default
        !           219:     return "other";
        !           220: }
        !           221: 
        !           222: 
        !           223: GetVersionTable();
        !           224: 
        !           225: my $assign_element = GeneratePersonInput('assigned_to', 1,
        !           226:                                          formvalue('assigned_to'));
        !           227: my $cc_element = GeneratePeopleInput('cc', formvalue('cc'));
        !           228: 
        !           229: 
        !           230: my $priority = Param('defaultpriority');
        !           231: 
        !           232: my $priority_popup = make_popup('priority', \@::legal_priority,
        !           233:                                 formvalue('priority', $priority), 0);
        !           234: my $sev_popup = make_popup('bug_severity', \@::legal_severity,
        !           235:                            formvalue('bug_severity', 'normal'), 0);
        !           236: my $platform_popup = make_popup('rep_platform', \@::legal_platform,
        !           237:                                 pickplatform(), 0);
        !           238: my $opsys_popup = make_popup('op_sys', \@::legal_opsys, pickos(), 0);
        !           239: 
        !           240: if (0 == $::components{$product}) {
        !           241:        print "<H1>Permission Denied</H1>\n";
        !           242:        print "Sorry.  You need to have at least one component for this product\n";
        !           243:        print "in order to create a new bug.  Go to the \"Components\" link to create\n";
        !           244:        print "a new component\n";
        !           245:        print "<P>\n";
        !           246:        PutFooter();
        !           247:        exit;
        !           248: } elsif (1 == @{$::components{$product}}) {
        !           249:     # Only one component; just pick it.
        !           250:     $::FORM{'component'} = $::components{$product}->[0];
        !           251: }
        !           252: 
        !           253: my $component_popup = make_popup('component', $::components{$product},
        !           254:                                  formvalue('component'), 1);
        !           255: 
        !           256: PutHeader ("Enter Bug","Enter Bug","This page lets you enter a new bug into Bugzilla.");
        !           257: 
        !           258: # Modified, -JMR, 2/24,00
        !           259: # If the usebuggroupsentry parameter is set, we need to check and make sure
        !           260: # that the user has permission to enter a bug against this product.
        !           261: # Modified, -DDM, 3/11/00
        !           262: # added GroupExists check so we don't choke on a groupless product
        !           263: if(Param("usebuggroupsentry")
        !           264:    && GroupExists($product)
        !           265:    && !UserInGroup($product)) {
        !           266:   print "<H1>Permission denied.</H1>\n";
        !           267:   print "Sorry; you do not have the permissions necessary to enter\n";
        !           268:   print "a bug against this product.\n";
        !           269:   print "<P>\n";
        !           270:   PutFooter();
        !           271:   exit;
        !           272: }
        !           273: 
        !           274: # Modified, -JMR, 2/18/00
        !           275: # I'm putting in a select box in order to select whether to restrict this bug to
        !           276: # the product's bug group or not, if the usebuggroups parameter is set, and if
        !           277: # this product has a bug group.  This box will default to selected, but can be
        !           278: # turned off if this bug should be world-viewable for some reason.
        !           279: #
        !           280: # To do this, I need to (1) get the bit and description for the bug group from
        !           281: # the database, (2) insert the select box in the giant print statements below,
        !           282: # and (3) update post_bug.cgi to process the additional input field.
        !           283: 
        !           284: # Modified, -DDM, 3/11/00
        !           285: # Only need the bit here, and not the description.  Description is gotten
        !           286: # when the select boxes for all the groups this user has access to are read
        !           287: # in later on.
        !           288: # First we get the bit and description for the group.
        !           289: my $group_bit=0;
        !           290: if(Param("usebuggroups") && GroupExists($product)) {
        !           291:     SendSQL("select bit from groups ".
        !           292:             "where name = ".SqlQuote($product)." ".
        !           293:             "and isbuggroup != 0");
        !           294:     ($group_bit) = FetchSQLData();
        !           295: }
        !           296: 
        !           297: print "
        !           298: <FORM METHOD=POST ACTION=\"post_bug.cgi\">
        !           299: <INPUT TYPE=HIDDEN NAME=reporter VALUE=\"$::COOKIE{'Bugzilla_login'}\">
        !           300: <INPUT TYPE=HIDDEN NAME=product VALUE=\""  . value_quote($product) . "\">
        !           301:   <TABLE CELLSPACING=2 CELLPADDING=0 BORDER=0>";
        !           302: 
        !           303: if (Param("entryheaderhtml")){
        !           304:   print "
        !           305:   <TR>
        !           306:     <td></td>
        !           307:     <td colspan=3>" .
        !           308:   Param("entryheaderhtml") . "\n" .
        !           309:   " </td> 
        !           310:   </TR>
        !           311:   <TR><td><br></td></TR>";
        !           312: }
        !           313: 
        !           314: print "
        !           315:   <TR>
        !           316:     <td ALIGN=right valign=top><B>Reporter:</B></td>
        !           317:     <td valign=top>$::COOKIE{'Bugzilla_login'}</td>
        !           318:     <td ALIGN=right valign=top><B>Product:</B></td>
        !           319:     <td valign=top>$product</td>
        !           320:   </TR>
        !           321:   <TR>
        !           322:     <td ALIGN=right valign=top><B>Version:</B></td>
        !           323:     <td>" . Version_element(pickversion(), $product) . "</td>
        !           324:     <td align=right valign=top><b><a href=\"describecomponents.cgi?product=" .
        !           325:     url_quote($product) . "\">Component:</a></b></td>
        !           326:     <td>$component_popup</td>
        !           327:   </TR>
        !           328:   <tr><td>&nbsp<td> <td> <td> <td> <td> </tr>
        !           329:   <TR>
        !           330:     <td align=right><B><A HREF=\"bug_status.html#rep_platform\">Platform:</A></B></td>
        !           331:     <TD>$platform_popup</TD>
        !           332:     <TD ALIGN=RIGHT><B><A HREF=\"bug_status.html#op_sys\">OS:</A></B></TD>
        !           333:     <TD>$opsys_popup</TD>
        !           334:     <td align=right valign=top></td>
        !           335:     <td rowspan=3></td>
        !           336:     <td></td>
        !           337:   </TR>
        !           338:   <TR>";
        !           339: if (Param('letsubmitterchoosepriority')) {
        !           340:     print "
        !           341:     <TD ALIGN=RIGHT><B><A HREF=\"bug_status.html#priority\">Resolution<br>Priority</A>:</B></TD>
        !           342:     <TD>$priority_popup</TD>";
        !           343: } else {
        !           344:     print '<INPUT TYPE=HIDDEN NAME=priority VALUE="' .
        !           345:         value_quote($priority) . '">';
        !           346: }
        !           347: print "
        !           348:     <TD ALIGN=RIGHT><B><A HREF=\"bug_status.html#severity\">Severity:</A></B></TD>
        !           349:     <TD>$sev_popup</TD>
        !           350:     <td></td>
        !           351:     <td></td>
        !           352:   </TR>
        !           353:   <tr><td>&nbsp<td> <td> <td> <td> <td> </tr>
        !           354: ";
        !           355: 
        !           356: if (UserInGroup("editbugs") || UserInGroup("canconfirm")) {
        !           357:     SendSQL("SELECT votestoconfirm FROM products WHERE product = " .
        !           358:             SqlQuote($product));
        !           359:     if (FetchOneColumn()) {
        !           360:         print qq{
        !           361:   <TR>
        !           362:     <TD ALIGN="right"><B><A HREF="bug_status.html#status">Initial state:</B></A></TD>
        !           363:     <TD COLSPAN="5">
        !           364: };
        !           365:         print BuildPulldown("bug_status",
        !           366:                             [[$::unconfirmedstate], ["NEW"]],
        !           367:                             "NEW");
        !           368:         print "</TD></TR>";
        !           369:     }
        !           370: }
        !           371: 
        !           372: 
        !           373: print "
        !           374:   <tr>
        !           375:     <TD ALIGN=RIGHT><B><A HREF=\"bug_status.html#assigned_to\">Assigned To:</A></B></TD>
        !           376:     <TD colspan=5>$assign_element
        !           377:     (Leave blank to assign to default component owner)</td>
        !           378:   </tr>
        !           379:   <tr>
        !           380:     <TD ALIGN=RIGHT><B>Cc:</B></TD>
        !           381:     <TD colspan=5>$cc_element</TD>
        !           382:   </tr>
        !           383:   <tr><td>&nbsp<td> <td> <td> <td> <td> </tr>
        !           384:   <TR>
        !           385:     <TD ALIGN=RIGHT><B>URL:</B>
        !           386:     <TD COLSPAN=5>
        !           387:       <INPUT NAME=bug_file_loc SIZE=60 value=\"http://" .
        !           388:     value_quote(formvalue('bug_file_loc')) .
        !           389:     "\"></TD>
        !           390:   </TR>
        !           391:   <TR>
        !           392:     <TD ALIGN=RIGHT><B>Summary:</B>
        !           393:     <TD COLSPAN=5>
        !           394:       <INPUT NAME=short_desc SIZE=60 value=\"" .
        !           395:     value_quote(formvalue('short_desc')) .
        !           396:     "\"></TD>
        !           397:   </TR>
        !           398:   <tr><td align=right valign=top><B>Description:</b></td>
        !           399: <!--  </tr> <tr> -->
        !           400:     <td colspan=5><TEXTAREA WRAP=HARD NAME=comment ROWS=10 COLS=80>" .
        !           401:     value_quote(formvalue('comment')) .
        !           402:     "</TEXTAREA><BR></td>
        !           403:   </tr>";
        !           404: 
        !           405: print "
        !           406:   <tr>
        !           407:    <td></td><td colspan=5>
        !           408: ";
        !           409: 
        !           410: if ($::usergroupset ne '0') {
        !           411:     SendSQL("SELECT bit, description FROM groups " .
        !           412:             "WHERE bit & $::usergroupset != 0 " .
        !           413:             "  AND isbuggroup != 0 ORDER BY description");
        !           414:      while (MoreSQLData()) {
        !           415:         my ($bit, $description) = (FetchSQLData());
        !           416:         # Rather than waste time with another Param check and another database
        !           417:         # access, $group_bit will only have a non-zero value if we're using
        !           418:         # bug groups and have  one for this product, so I'll check on that
        !           419:         # instead here.  -JMR, 2/18/00
        !           420:         # Moved this check to this location to fix conflict with existing
        !           421:         # select-box patch.  Also, if $group_bit is 0, it won't match the
        !           422:         # current group, either, so I'll compare it to the current bit
        !           423:         # instead of checking for non-zero. -DDM, 3/11/00
        !           424:         my $check = 0; # default selection
        !           425:         if($group_bit == $bit) {
        !           426:             # In addition, we need to handle the possibility that we're coming
        !           427:             # from a bookmark template.  We'll simply check if we've got a
        !           428:             # parameter called bit-# passed.  If so, then we're coming from a
        !           429:             # template, and we'll use the template value.
        !           430:             $check = formvalue("bit-$bit","1");
        !           431:         }
        !           432:         print BuildPulldown("bit-$bit",
        !           433:                             [["0",
        !           434:                              "People not in the \"$description\" group can see this bug"],
        !           435:                              ["1",
        !           436:                               "Only people in the \"$description\" group can see this bug"]],
        !           437:                             $check);
        !           438:         print "<BR>\n";
        !           439:     }
        !           440: }
        !           441: 
        !           442: print "
        !           443:    </td>
        !           444:   </tr>
        !           445:   <tr>
        !           446:     <td></td>
        !           447:     <td colspan=5>
        !           448:        <INPUT TYPE=\"submit\" VALUE=\"    Commit    \" ONCLICK=\"if (this.form.short_desc.value =='') { alert('Please enter a summary sentence for this bug.'); return false; }\">
        !           449:        &nbsp;&nbsp;&nbsp;&nbsp;
        !           450:        <INPUT TYPE=\"reset\" VALUE=\"Reset\">
        !           451:        &nbsp;&nbsp;&nbsp;&nbsp;
        !           452:        <INPUT TYPE=\"submit\" NAME=maketemplate VALUE=\"Remember values as bookmarkable template\">
        !           453:     </td>
        !           454:   </tr>";
        !           455: 
        !           456: if ( Param('usebrowserinfo') ) {
        !           457:     print "
        !           458:   <tr>
        !           459:     <td></td>
        !           460:     <td colspan=3>
        !           461:      <br>
        !           462:      Some fields initialized from your user-agent, 
        !           463:      <b>$ENV{'HTTP_USER_AGENT'}</b>.  If you think it got it wrong, 
        !           464:      please tell " . Param('maintainer') . " what it should have been.
        !           465:     </td>
        !           466:   </tr>";
        !           467: }
        !           468: print "
        !           469:   </TABLE>
        !           470:   <INPUT TYPE=hidden name=form_name VALUE=enter_bug>
        !           471: </FORM>\n";
        !           472: 
        !           473: PutFooter();
        !           474: 
        !           475: print "</BODY></HTML>\n";
        !           476: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>