diff options
author | Dave Lawrence <dlawrence@mozilla.com> | 2013-09-30 23:20:04 +0200 |
---|---|---|
committer | Dave Lawrence <dlawrence@mozilla.com> | 2013-09-30 23:20:04 +0200 |
commit | fd197e7b5b6631e2bef0d3542548cbc1625a520c (patch) | |
tree | c63decc559040bf1c4c806a4d29f9131747ea974 | |
parent | d1b94d166cebefe30ee84e2f59da2b962726f826 (diff) | |
download | bugzilla-fd197e7b5b6631e2bef0d3542548cbc1625a520c.tar.gz bugzilla-fd197e7b5b6631e2bef0d3542548cbc1625a520c.tar.xz |
Bug 922310 - backport upstream bug 891311 to bmo/4.2 to make request.cgi more intuitive relating to search
-rwxr-xr-x | request.cgi | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/request.cgi b/request.cgi index 1bab9ff45..589d773fb 100755 --- a/request.cgi +++ b/request.cgi @@ -183,22 +183,8 @@ sub queue { # need to display a "status" column in the report because the value for that # column will always be the same. my @excluded_columns = (); - my $do_union = $cgi->param('do_union'); - # Filter requests by status: "pending", "granted", "denied", "all" - # (which means any), or "fulfilled" (which means "granted" or "denied"). - if ($status) { - if ($status eq "+-") { - push(@criteria, "flags.status IN ('+', '-')"); - push(@excluded_columns, 'status') unless $do_union; - } - elsif ($status ne "all") { - push(@criteria, "flags.status = '$status'"); - push(@excluded_columns, 'status') unless $do_union; - } - } - # Filter results by exact email address of requester or requestee. if (defined $cgi->param('requester') && $cgi->param('requester') ne "") { my $requester = $dbh->quote($cgi->param('requester')); @@ -210,23 +196,44 @@ sub queue { if ($cgi->param('requestee') ne "-") { my $requestee = $dbh->quote($cgi->param('requestee')); trick_taint($requestee); # Quoted above - push(@criteria, $dbh->sql_istrcmp('requestees.login_name', - $requestee)); + push(@criteria, $dbh->sql_istrcmp('requestees.login_name', $requestee)); + } + else { + push(@criteria, "flags.requestee_id IS NULL"); } - else { push(@criteria, "flags.requestee_id IS NULL") } push(@excluded_columns, 'requestee') unless $do_union; } - + + # If the user wants requester = foo OR requestee = bar, we have to join + # these criteria separately as all other criteria use AND. + if (@criteria == 2 && $do_union) { + my $union = join(' OR ', @criteria); + @criteria = ("($union)"); + } + + # Filter requests by status: "pending", "granted", "denied", "all" + # (which means any), or "fulfilled" (which means "granted" or "denied"). + if ($status) { + if ($status eq "+-") { + push(@criteria, "flags.status IN ('+', '-')"); + push(@excluded_columns, 'status'); + } + elsif ($status ne "all") { + push(@criteria, "flags.status = '$status'"); + push(@excluded_columns, 'status'); + } + } + # Filter results by exact product or component. if (defined $cgi->param('product') && $cgi->param('product') ne "") { my $product = Bugzilla::Product->check(scalar $cgi->param('product')); push(@criteria, "bugs.product_id = " . $product->id); - push(@excluded_columns, 'product') unless $do_union; + push(@excluded_columns, 'product'); if (defined $cgi->param('component') && $cgi->param('component') ne "") { my $component = Bugzilla::Component->check({ product => $product, name => scalar $cgi->param('component') }); push(@criteria, "bugs.component_id = " . $component->id); - push(@excluded_columns, 'component') unless $do_union; + push(@excluded_columns, 'component'); } } @@ -244,14 +251,11 @@ sub queue { my $quoted_form_type = $dbh->quote($form_type); trick_taint($quoted_form_type); # Already SQL quoted push(@criteria, "flagtypes.name = " . $quoted_form_type); - push(@excluded_columns, 'type') unless $do_union; + push(@excluded_columns, 'type'); } - - # Add the criteria to the query. Do a union if OR is selected. - # Otherwise do an intersection. - my $and_or = $do_union ? ' OR ' : ' AND '; - $query .= " AND (" . join($and_or, @criteria) . ") " if scalar(@criteria); - + + $query .= ' AND ' . join(' AND ', @criteria) if scalar(@criteria); + # Group the records by flag ID so we don't get multiple rows of data # for each flag. This is only necessary because of the code that # removes flags on bugs the user is unauthorized to access. |