query.cgi 14.4 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
#
# 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>
21
#                 David Gardiner <david.gardiner@unisa.edu.au>
terry%netscape.com's avatar
terry%netscape.com committed
22

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

26
require "CGI.pl";
terry%netscape.com's avatar
terry%netscape.com committed
27

28
# Shut up misguided -w warnings about "used only once":
terry%netscape.com's avatar
terry%netscape.com committed
29

30 31 32 33
use vars @::legal_resolution,
  @::legal_product,
  @::legal_bug_status,
  @::legal_priority,
34
  @::legal_opsys,
35 36 37 38
  @::legal_platform,
  @::legal_components,
  @::legal_versions,
  @::legal_severity,
39
  @::legal_target_milestone,
40
  @::log_columns,
41 42
  %::versions,
  %::components,
43 44 45 46
  %::FORM;


if (defined $::FORM{"GoAheadAndLogIn"}) {
terry%netscape.com's avatar
terry%netscape.com committed
47 48
    # We got here from a login page, probably from relogin.cgi.  We better
    # make sure the password is legit.
49
    confirm_login();
terry%netscape.com's avatar
terry%netscape.com committed
50 51
}

52 53
if (!defined $::COOKIE{"DEFAULTQUERY"}) {
    $::COOKIE{"DEFAULTQUERY"} = Param("defaultquery");
terry%netscape.com's avatar
terry%netscape.com committed
54 55
}

56 57
if (!defined $::buffer || $::buffer eq "") {
    $::buffer = $::COOKIE{"DEFAULTQUERY"};
terry%netscape.com's avatar
terry%netscape.com committed
58 59
}

60 61 62 63 64
my %default;
my %type;

foreach my $name ("bug_status", "resolution", "assigned_to", "rep_platform",
                  "priority", "bug_severity", "product", "reporter", "op_sys",
65 66
                  "component", "version", "chfield", "chfieldfrom",
                  "chfieldto", "chfieldvalue",
67
                  "email1", "emailtype1", "emailreporter1",
68
                  "emailassigned_to1", "emailcc1", "emailqa_contact1",
69
                  "email2", "emailtype2", "emailreporter2",
70
                  "emailassigned_to2", "emailcc2", "emailqa_contact2") {
71 72
    $default{$name} = "";
    $type{$name} = 0;
terry%netscape.com's avatar
terry%netscape.com committed
73 74
}

75 76 77 78 79 80 81 82 83 84 85 86 87 88

foreach my $item (split(/\&/, $::buffer)) {
    my @el = split(/=/, $item);
    my $name = $el[0];
    my $value;
    if ($#el > 0) {
        $value = url_decode($el[1]);
    } else {
        $value = "";
    }
    if (defined $default{$name}) {
        if ($default{$name} ne "") {
            $default{$name} .= "|$value";
            $type{$name} = 1;
terry%netscape.com's avatar
terry%netscape.com committed
89
        } else {
90
            $default{$name} = $value;
terry%netscape.com's avatar
terry%netscape.com committed
91 92 93
        }
    }
}
94 95
                  

96 97 98 99 100
if ($default{'chfieldto'} eq "") {
    $default{'chfieldto'} = "Now";
}


101 102

my $namelist = "";
terry%netscape.com's avatar
terry%netscape.com committed
103

104 105 106 107 108
foreach my $i (sort (keys %::COOKIE)) {
    if ($i =~ /^QUERY_/) {
        if ($::COOKIE{$i} ne "") {
            my $name = substr($i, 6); 
            $namelist .= "<OPTION>$name";
terry%netscape.com's avatar
terry%netscape.com committed
109 110 111 112
        }
    }
}

113 114 115 116
print "Set-Cookie: BUGLIST=
Content-type: text/html\n\n";

GetVersionTable();
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136

sub GenerateEmailInput {
    my ($id) = (@_);
    my $defstr = value_quote($default{"email$id"});
    my $deftype = $default{"emailtype$id"};
    if ($deftype eq "") {
        $deftype = "substring";
    }
    my $assignedto = ($default{"emailassigned_to$id"} eq "1") ? "checked" : "";
    my $reporter = ($default{"emailreporter$id"} eq "1") ? "checked" : "";
    my $cc = ($default{"emailcc$id"} eq "1") ? "checked" : "";

    if ($assignedto eq "" && $reporter eq "" && $cc eq "") {
        if ($id eq "1") {
            $assignedto = "checked";
        } else {
            $reporter = "checked";
        }
    }

137 138 139 140 141 142 143 144 145 146 147 148 149 150
    my $qapart = "";
    if (Param("useqacontact")) {
        my $qacontact =
            ($default{"emailqa_contact$id"} eq "1") ? "checked" : "";
        $qapart = qq|
<tr>
<td></td>
<td>
<input type="checkbox" name="emailqa_contact$id" value=1 $qacontact>QA Contact
</td>
</tr>
|;
    }

151 152 153 154 155 156
    return qq|
<table border=1 cellspacing=0 cellpadding=0>
<tr><td>
<table cellspacing=0 cellpadding=0>
<tr>
<td rowspan=2 valign=top><a href="helpemailquery.html">Email:</a>
157
<input name="email$id" size="30" value="$defstr">&nbsp;matching as
158 159
<SELECT NAME=emailtype$id>
<OPTION VALUE="regexp">regexp
160
<OPTION VALUE="notregexp">not regexp
161 162 163 164 165 166 167 168 169 170 171 172
<OPTION SELECTED VALUE="substring">substring
<OPTION VALUE="exact">exact
</SELECT>
</td>
<td>
<input type="checkbox" name="emailassigned_to$id" value=1 $assignedto>Assigned To
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="emailreporter$id" value=1 $reporter>Reporter
</td>
173
</tr>$qapart
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
<tr>
<td align=right>(Will match any of the selected fields)</td>
<td>
<input type="checkbox" name="emailcc$id" value=1 $cc>CC &nbsp;&nbsp;
</td>
</tr>
</table>
</table>
|;
}


            


my $emailinput1 = GenerateEmailInput(1);
my $emailinput2 = GenerateEmailInput(2);


193 194 195
# javascript
    
my $jscript = << 'ENDSCRIPT';
196
<script language="Javascript1.2">
197 198 199
<!--
var cpts = new Array();
var vers = new Array();
200 201 202
// Apparently, IE4 chokes on the below, so do nothing if running that.
var agt=navigator.userAgent.toLowerCase();
if ((agt.indexOf("msie") == -1)) {
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
ENDSCRIPT


my $p;
my $v;
my $c;
my $i = 0;
my $j = 0;

foreach $c (@::legal_components) {
    $jscript .= "cpts['$c'] = [];\n";
}

foreach $v (@::legal_versions) {
    $jscript .= "vers['$v'] = [];\n";
}


for $p (@::legal_product) {
222 223 224 225
    if ($::components{$p}) {
        foreach $c (@{$::components{$p}}) {
            $jscript .= "cpts['$c'].push('$p');\n";
        }
226
    }
227 228 229 230 231

    if ($::versions{$p}) {
        foreach $v (@{$::versions{$p}}) {
            $jscript .= "vers['$v'].push('$p');\n";
        }
232 233 234 235
    }
}

$i = 0;
236
$jscript .= q{
237

238
\} // end IE4 choke around
239 240 241
// Only display versions/components valid for selected product(s)

function selectProduct(f) {
242 243
    // Apparently, IE4 chokes on the below, so do nothing if running that.
    var agt=navigator.userAgent.toLowerCase();
244
    if ((agt.indexOf("msie") != -1)) return;
245

246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
    var cnt = 0;
    var i;
    var j;
    for (i=0 ; i<f.product.length ; i++) {
        if (f.product[i].selected) {
            cnt++;
        }
    }
    var doall = (cnt == f.product.length || cnt == 0);

    var csel = new Array();
    for (i=0 ; i<f.component.length ; i++) {
        if (f.component[i].selected) {
            csel[f.component[i].value] = 1;
        }
    }

    f.component.options.length = 0;

    for (c in cpts) {
        var doit = doall;
        for (i=0 ; !doit && i<f.product.length ; i++) {
            if (f.product[i].selected) {
                var p = f.product[i].value;
                for (j in cpts[c]) {
                    var p2 = cpts[c][j];
                    if (p2 == p) {
                        doit = true;
                        break;
                    }
                }
            }
        }
        if (doit) {
            var l = f.component.length;
            f.component[l] = new Option(c, c);
            if (csel[c] != undefined) {
                f.component[l].selected = true;
            }
        }
    }

    var vsel = new Array();
    for (i=0 ; i<f.version.length ; i++) {
        if (f.version[i].selected) {
            vsel[f.version[i].value] = 1;
        }
    }

    f.version.options.length = 0;

    for (v in vers) {
        var doit = doall;
        for (i=0 ; !doit && i<f.product.length ; i++) {
            if (f.product[i].selected) {
                var p = f.product[i].value;
                for (j in vers[v]) {
                    var p2 = vers[v][j];
                    if (p2 == p) {
                        doit = true;
                        break;
                    }
                }
            }
        }
        if (doit) {
            var l = f.version.length;
            f.version[l] = new Option(v, v);
            if (vsel[v] != undefined) {
                f.version[l].selected = true;
            }
        }
    }




}
// -->
325 326 327
</script>

};
328

terry%netscape.com's avatar
terry%netscape.com committed
329 330 331 332 333 334 335


# Muck the "legal product" list so that the default one is always first (and
# is therefore visibly selected.

# Commented out, until we actually have enough products for this to matter.

336
# set w [lsearch $legal_product $default{"product"}]
terry%netscape.com's avatar
terry%netscape.com committed
337
# if {$w >= 0} {
338
#    set legal_product [concat $default{"product"} [lreplace $legal_product $w $w]]
terry%netscape.com's avatar
terry%netscape.com committed
339 340
# }

341 342 343
PutHeader("Bugzilla Query Page", "Query Page");

push @::legal_resolution, "---"; # Oy, what a hack.
344
push @::legal_target_milestone, "---"; # Oy, what a hack.
terry%netscape.com's avatar
terry%netscape.com committed
345

346 347
print $jscript;

348 349
my @logfields = ("[Bug creation]", @::log_columns);

350
print "
351
<FORM NAME=queryForm METHOD=GET ACTION=\"buglist.cgi\">
terry%netscape.com's avatar
terry%netscape.com committed
352 353 354

<table>
<tr>
355 356 357
<th align=left><A HREF=\"bug_status.html\">Status</a>:</th>
<th align=left><A HREF=\"bug_status.html\">Resolution</a>:</th>
<th align=left><A HREF=\"bug_status.html#rep_platform\">Platform</a>:</th>
358
<th align=left><A HREF=\"bug_status.html#op_sys\">OpSys</a>:</th>
359 360
<th align=left><A HREF=\"bug_status.html#priority\">Priority</a>:</th>
<th align=left><A HREF=\"bug_status.html#severity\">Severity</a>:</th>
terry%netscape.com's avatar
terry%netscape.com committed
361 362
</tr>
<tr>
363 364
<td align=left valign=top>
<SELECT NAME=\"bug_status\" MULTIPLE SIZE=7>
365
@{[make_options(\@::legal_bug_status, $default{'bug_status'}, $type{'bug_status'})]}
366
</SELECT>
terry%netscape.com's avatar
terry%netscape.com committed
367
</td>
368 369
<td align=left valign=top>
<SELECT NAME=\"resolution\" MULTIPLE SIZE=7>
370
@{[make_options(\@::legal_resolution, $default{'resolution'}, $type{'resolution'})]}
371
</SELECT>
terry%netscape.com's avatar
terry%netscape.com committed
372
</td>
373 374
<td align=left valign=top>
<SELECT NAME=\"rep_platform\" MULTIPLE SIZE=7>
375
@{[make_options(\@::legal_platform, $default{'rep_platform'}, $type{'rep_platform'})]}
376
</SELECT>
terry%netscape.com's avatar
terry%netscape.com committed
377
</td>
378
<td align=left valign=top>
379 380 381 382 383
<SELECT NAME=\"op_sys\" MULTIPLE SIZE=7>
@{[make_options(\@::legal_opsys, $default{'op_sys'}, $type{'op_sys'})]}
</SELECT>
</td>
<td align=left valign=top>
384
<SELECT NAME=\"priority\" MULTIPLE SIZE=7>
385
@{[make_options(\@::legal_priority, $default{'priority'}, $type{'priority'})]}
386
</SELECT>
terry%netscape.com's avatar
terry%netscape.com committed
387
</td>
388 389
<td align=left valign=top>
<SELECT NAME=\"bug_severity\" MULTIPLE SIZE=7>
390
@{[make_options(\@::legal_severity, $default{'bug_severity'}, $type{'bug_severity'})]}
391
</SELECT>
terry%netscape.com's avatar
terry%netscape.com committed
392 393 394 395
</tr>
</table>

<p>
396 397 398 399 400
$emailinput1<p>
$emailinput2<p>



401
Changed in the <NOBR>last <INPUT NAME=changedin SIZE=2 VALUE=\"$default{'changedin'}\"> days.</NOBR>
402

403 404 405 406 407
<table>
<tr>
<td rowspan=2 align=right>Where the field(s)
</td><td rowspan=2>
<SELECT NAME=\"chfield\" MULTIPLE SIZE=4>
408
@{[make_options(\@logfields, $default{'chfield'}, $type{'chfield'})]}
409 410 411 412 413 414 415 416 417 418 419 420
</SELECT>
</td><td rowspan=2>
changed.
</td><td>
<nobr>dates <INPUT NAME=chfieldfrom SIZE=10 VALUE=\"$default{'chfieldfrom'}\"></nobr>
<nobr>to <INPUT NAME=chfieldto SIZE=10 VALUE=\"$default{'chfieldto'}\"></nobr>
</td>
</tr>
<tr>
<td>changed to value <nobr><INPUT NAME=chfieldvalue SIZE=10> (optional)</nobr>
</td>
</table>
terry%netscape.com's avatar
terry%netscape.com committed
421 422 423 424 425 426


<P>

<table>
<tr>
427 428
<TH ALIGN=LEFT VALIGN=BOTTOM>Program:</th>
<TH ALIGN=LEFT VALIGN=BOTTOM>Version:</th>
429
<TH ALIGN=LEFT VALIGN=BOTTOM><A HREF=describecomponents.cgi>Component:<a></th>
430 431 432 433 434 435 436
";

if (Param("usetargetmilestone")) {
    print "<TH ALIGN=LEFT VALIGN=BOTTOM>Target Milestone:</th>";
}

print "
terry%netscape.com's avatar
terry%netscape.com committed
437 438 439
</tr>
<tr>

440
<td align=left valign=top>
441
<SELECT NAME=\"product\" MULTIPLE SIZE=5 onChange=\"selectProduct(this.form);\">
442 443
@{[make_options(\@::legal_product, $default{'product'}, $type{'product'})]}
</SELECT>
terry%netscape.com's avatar
terry%netscape.com committed
444 445
</td>

446 447
<td align=left valign=top>
<SELECT NAME=\"version\" MULTIPLE SIZE=5>
448
@{[make_options(\@::legal_versions, $default{'version'}, $type{'version'})]}
449
</SELECT>
terry%netscape.com's avatar
terry%netscape.com committed
450 451
</td>

452 453
<td align=left valign=top>
<SELECT NAME=\"component\" MULTIPLE SIZE=5>
454
@{[make_options(\@::legal_components, $default{'component'}, $type{'component'})]}
455
</SELECT>
456
</td>";
terry%netscape.com's avatar
terry%netscape.com committed
457

458 459 460 461 462 463 464 465 466 467
if (Param("usetargetmilestone")) {
    print "
<td align=left valign=top>
<SELECT NAME=\"target_milestone\" MULTIPLE SIZE=5>
@{[make_options(\@::legal_target_milestone, $default{'component'}, $type{'component'})]}
</SELECT>
</td>";
}

print "
terry%netscape.com's avatar
terry%netscape.com committed
468 469 470
</tr>
</table>

471
<table border=0>
472
<tr>
473 474 475 476
<td align=right>Summary:</td>
<td><input name=short_desc size=30></td>
<td><input type=radio name=short_desc_type value=substr checked>Substring</td>
<td><input type=radio name=short_desc_type value=regexp>Regexp</td>
477 478
</tr>
<tr>
479 480 481 482
<td align=right>Description:</td>
<td><input name=long_desc size=30></td>
<td><input type=radio name=long_desc_type value=substr checked>Substring</td>
<td><input type=radio name=long_desc_type value=regexp>Regexp</td>
483
</tr>
484
<tr>
485 486 487
<td align=right>URL:</td>
<td><input name=bug_file_loc size=30></td>
<td><input type=radio name=bug_file_loc_type value=substr checked>Substring</td>
488
<td><input type=radio name=bug_file_loc_type value=regexp>Regexp</td>
489 490 491 492 493 494 495 496 497 498 499 500 501
</tr>";

if (Param("usestatuswhiteboard")) {
    print "
<tr>
<td align=right>Status whiteboard:</td>
<td><input name=status_whiteboard size=30></td>
<td><input type=radio name=status_whiteboard_type value=substr checked>Substring</td>
<td><input type=radio name=status_whiteboard_type value=regexp>Regexp</td>
</tr>";
}

print "
502
</table>
terry%netscape.com's avatar
terry%netscape.com committed
503 504 505 506 507
<p>



<BR>
508
<INPUT TYPE=radio NAME=cmdtype VALUE=doit CHECKED> Run this query
509 510
<BR>
";
terry%netscape.com's avatar
terry%netscape.com committed
511

512 513
if ($namelist ne "") {
    print "
514 515 516
<table cellspacing=0 cellpadding=0><tr>
<td><INPUT TYPE=radio NAME=cmdtype VALUE=editnamed> Load the remembered query:</td>
<td rowspan=3><select name=namedcmd>$namelist</select>
terry%netscape.com's avatar
terry%netscape.com committed
517
</tr><tr>
518
<td><INPUT TYPE=radio NAME=cmdtype VALUE=runnamed> Run the remembered query:</td>
terry%netscape.com's avatar
terry%netscape.com committed
519
</tr><tr>
520
<td><INPUT TYPE=radio NAME=cmdtype VALUE=forgetnamed> Forget the remembered query:</td>
terry%netscape.com's avatar
terry%netscape.com committed
521 522 523
</tr></table>"
}

524
print "
525
<INPUT TYPE=radio NAME=cmdtype VALUE=asdefault> Remember this as the default query
terry%netscape.com's avatar
terry%netscape.com committed
526
<BR>
527 528
<INPUT TYPE=radio NAME=cmdtype VALUE=asnamed> Remember this query, and name it:
<INPUT TYPE=text NAME=newqueryname>
terry%netscape.com's avatar
terry%netscape.com committed
529 530 531 532 533 534 535 536
<BR>

<NOBR><B>Sort By:</B>
<SELECT NAME=\"order\">
  <OPTION>Bug Number
  <OPTION SELECTED>\"Importance\"
  <OPTION>Assignee
</SELECT></NOBR>
537
<INPUT TYPE=\"submit\" VALUE=\"Submit query\">
terry%netscape.com's avatar
terry%netscape.com committed
538
<INPUT TYPE=\"reset\" VALUE=\"Reset back to the default query\">
539
<INPUT TYPE=hidden name=form_name VALUE=query>
terry%netscape.com's avatar
terry%netscape.com committed
540 541 542 543
<BR>Give me a <A HREF=\"help.html\">clue</A> about how to use this form.
</CENTER>
</FORM>

544
";
terry%netscape.com's avatar
terry%netscape.com committed
545 546


547 548 549 550 551 552
quietly_check_login();

if (UserInGroup("tweakparams")) {
    print "<a href=editparams.cgi>Edit Bugzilla operating parameters</a><br>\n";
}
if (UserInGroup("editcomponents")) {
553
    print "<a href=editcomponents.cgi>Edit Bugzilla components</a><br>\n";
554
}
555
if (defined $::COOKIE{"Bugzilla_login"}) {
556
    print "<a href=relogin.cgi>Log in as someone besides <b>$::COOKIE{'Bugzilla_login'}</b></a><br>\n";
terry%netscape.com's avatar
terry%netscape.com committed
557
}
558 559
print "<a href=changepassword.cgi>Change your password.</a><br>\n";
print "<a href=\"enter_bug.cgi\">Create a new bug.</a><br>\n";
560
print "<a href=\"createaccount.cgi\">Open a new Bugzilla account</a><br>\n";
561
print "<a href=\"reports.cgi\">Bug reports</a><br>\n";