]> git.donarmstrong.com Git - debbugs.git/blobdiff - cgi/pkgreport.cgi
[project @ 2001-11-22 01:47:41 by doogie]
[debbugs.git] / cgi / pkgreport.cgi
index 18c72e3f35ce3e1f02977a9367b169d57ba1d254..d2d933994fe39486a32ba9a657010ace5c976a5b 100755 (executable)
@@ -17,16 +17,45 @@ my %param = readparse();
 
 my ($pkg, $src, $maint, $maintenc, $submitter, $severity, $status);
 
-if (defined ($pkg = $param{'pkg'})) {
-} elsif (defined ($src = $param{'src'})) {
-} elsif (defined ($maint = $param{'maint'})) {
-} elsif (defined ($maintenc = $param{'maintenc'})) {
-} elsif (defined ($submitter= $param{'submitter'})) { 
-} elsif (defined ($severity = $param{'severity'})) { 
-       $status = $param{'status'} || 'open';
-} else {
-       quit("You have to choose something to select by");
+my %which = (
+       'pkg' => \$pkg,
+       'src' => \$src,
+       'maint' => \$maint,
+       'maintenc' => \$maintenc,
+       'submitter' => \$submitter,
+       'severity' => \$severity,
+       );
+my @allowedEmpty = ( 'maint' );
+
+my $found;
+foreach ( keys %which ) {
+       $status = $param{'status'} || 'open' if /^severity$/;
+       if (($found = $param{$_})) {
+               ${ $which{$_} } = $found;
+               last;
+       }
+}
+if (!$found) {
+       foreach ( @allowedEmpty ) {
+               if (exists($param{$_})) {
+                       ${ $which{$_} } = '';
+                       $found = 1;
+                       last;
+               }
+       }
 }
+if (!$found) {
+       my $which;
+       if (($which = $param{'which'})) {
+               if (grep( /^\Q$which\E$/, @allowedEmpty)) {
+                       ${ $which{$which} } = $param{'data'};
+                       $found = 1;
+               } elsif (($found = $param{'data'})) {
+                       ${ $which{$which} } = $found if (exists($which{$which}));
+               }
+       }
+}
+quit("You have to choose something to select by") if (!$found);
 
 my $repeatmerged = ($param{'repeatmerged'} || "yes") eq "yes";
 my $archive = ($param{'archive'} || "no") eq "yes";
@@ -78,8 +107,9 @@ if (defined $pkg) {
   @bugs = @{getbugs(sub {my %d=@_; return $pkg eq $d{"pkg"}}, 'package', $pkg)};
 } elsif (defined $src) {
   $tag = "source $src";
-  my %pkgsrc = %{getpkgsrc()};
-  @bugs = @{getbugs(sub {my %d=@_; return $pkg eq $d{"pkg"}}, 'package', getsrcpkgs($src))};
+  my @pkgs = getsrcpkgs($src);
+  push @pkgs, $src if ( !grep(/^\Q$src\E$/, @pkgs) );
+  @bugs = @{getbugs(sub {my %d=@_; return $pkg eq $d{"pkg"}}, 'package', @pkgs)};
 } elsif (defined $maint) {
   my %maintainers = %{getmaintainers()};
   $tag = "maintainer $maint";
@@ -154,14 +184,20 @@ if (defined $pkg || defined $src) {
        if ($pkg) {
                print "You may want to refer to the following packages that are part of the same source:<br>\n";
        } else {
-               print "You may want to refer to the following packages' individual bug pages:<br>\n";
+               print "You may want to refer to the following individual bug pages:<br>\n";
        }
+       push @pkgs, $src if ( $src && !grep(/^\Q$src\E$/, @pkgs) );
        print join( ", ", map( "<A href=\"" . pkgurl($_) . "\">$_</A>", @pkgs ) );
-       print "\n";
+       print ".\n";
     }
     if ($pkg) {
        my $stupidperl = ${debbugs::gPackagePages};
-       printf "<p>You might like to refer to the <a href=\"%s\">%s package page</a>, or to the source package <a href=\"%s\">%s</a>'s bug page.</p>\n", urlsanit("http://${debbugs::gPackagePages}/$pkg"), htmlsanit("$pkg"), urlsanit(srcurl($pkg)), $pkgsrc{$pkg};
+       printf "<p>You might like to refer to the <a href=\"%s\">%s package page</a>", urlsanit("http://${debbugs::gPackagePages}/$pkg"), htmlsanit("$pkg");
+       if ($pkgsrc{ $pkg }) {
+           printf ", or to the source package <a href=\"%s\">%s</a>'s bug page.</p>\n", srcurl($pkg), htmlsanit($pkgsrc{$pkg});
+       } else {
+           printf ".\n";
+       }
     }
 } elsif (defined $maint || defined $maintenc) {
     print "<p>Note that maintainers may use different Maintainer fields for\n";