]> git.donarmstrong.com Git - debbugs.git/blobdiff - cgi/common.pl
[project @ 2002-10-21 06:32:48 by doogie]
[debbugs.git] / cgi / common.pl
index ccced58b2756240c8a3e5b1726828549c837d9a8..1e255ee7fae2d7c449fd1567179152d00786f028 100644 (file)
@@ -9,6 +9,13 @@ my %common_include = ();
 my %common_exclude = ();
 my $common_raw_sort = 0;
 my $common_bug_reverse = 0;
+my $common_pending_reverse = 0;
+my $common_severity_reverse = 0;
+
+my @common_pending_include = ();
+my @common_pending_exclude = ();
+my @common_severity_include = ();
+my @common_severity_exclude = ();
 
 my $debug = 0;
 
@@ -20,6 +27,36 @@ sub set_option {
     if ($opt eq "include") { %common_include = %{$val}; }
     if ($opt eq "raw") { $common_raw_sort = $val; }
     if ($opt eq "bug-rev") { $common_bug_reverse = $val; }
+    if ($opt eq "pend-rev") { $common_pending_reverse = $val; }
+    if ($opt eq "sev-rev") { $common_severity_reverse = $val; }
+    if ($opt eq "pend-exc") {
+       my @vals;
+       @vals = ( $val ) if (ref($val) eq "" && $val );
+       @vals = ( $$val ) if (ref($val) eq "SCALAR" && $$val );
+       @vals = @{$val} if (ref($val) eq "ARRAY" );
+       @common_pending_exclude = @vals if (@vals);
+    }
+    if ($opt eq "pend-inc") {
+       my @vals;
+       @vals = ( $val, ) if (ref($val) eq "" && $val );
+       @vals = ( $$val, ) if (ref($val) eq "SCALAR" && $$val );
+       @vals = @{$val} if (ref($val) eq "ARRAY" );
+       @common_pending_include = @vals if (@vals);
+    }
+    if ($opt eq "sev-exc") {
+       my @vals;
+       @vals = ( $val ) if (ref($val) eq "" && $val );
+       @vals = ( $$val ) if (ref($val) eq "SCALAR" && $$val );
+       @vals = @{$val} if (ref($val) eq "ARRAY" );
+       @common_severity_exclude = @vals if (@vals);
+    }
+    if ($opt eq "sev-inc") {
+       my @vals;
+       @vals = ( $val ) if (ref($val) eq "" && $val );
+       @vals = ( $$val ) if (ref($val) eq "SCALAR" && $$val );
+       @vals = @{$val} if (ref($val) eq "ARRAY" );
+       @common_severity_include = @vals if (@vals);
+    }
 }
 
 sub readparse {
@@ -94,7 +131,8 @@ sub htmlindexentrystatus {
                . "<strong>" . htmlsanit($status{"package"}) . "</strong></a>;\n"
                if (length($status{"package"}));
     $result .= $showseverity;
-    $result .= "Reported by: " . htmlsanit($status{originator});
+    $result .= "Reported by: <a href=\"" . submitterurl($status{originator})
+               . "\">" . htmlsanit($status{originator}) . "</a>";
     $result .= ";\nTags: <strong>" 
                 . htmlsanit(join(", ", sort(split(/\s+/, $status{tags}))))
                 . "</strong>"
@@ -126,11 +164,13 @@ sub htmlindexentrystatus {
             $daysold = $daysold - $yearsold * 364;
 
             $result .= ";\n $font";
-            $result .= "1 year and " if ($yearsold == 1);
-            $result .= "$yearsold years and " if ($yearsold > 1);
-            $result .= "1 day old" if ($daysold == 1);
-            $result .= "$daysold days old" if ($daysold != 1);
-            $result .= "$efont";
+            my @age;
+            push @age, "1 year" if ($yearsold == 1);
+            push @age, "$yearsold years" if ($yearsold > 1);
+            push @age, "1 day" if ($daysold == 1);
+            push @age, "$daysold days" if ($daysold > 1);
+            $result .= join(" and ", @age);
+            $result .= " old$efont";
         }
     }
 
@@ -211,9 +251,22 @@ sub bugurl {
     return urlsanit($debbugs::gCGIDomain . "bugreport.cgi" . "?" . "$params");
 }
 
-sub packageurl {
+sub dlurl {
+    my $ref = shift;
+    my $params = "bug=$ref";
+    my $filename = '';
+    foreach my $val (@_) {
+       $params .= "\&$1=$2" if ($val =~ /^(msg|att)=([0-9]+)/);
+       $filename = $1 if ($val =~ /^filename=(.*)$/);
+    }
+    $params .= "&archive=yes" if ($common_archive);
+
+    return urlsanit($debbugs::gCGIDomain . "bugreport.cgi/$filename?$params");
+}
+
+sub mboxurl {
     my $ref = shift;
-    return urlsanit($debbugs::gCGIDomain . "package.cgi" . "?" . "package=$ref");
+    return urlsanit($debbugs::gCGIDomain . "bugreport.cgi" . "?" . "bug=$ref&mbox=yes");
 }
 
 sub allbugs {
@@ -292,8 +345,21 @@ sub htmlizebugs {
     if ($common_raw_sort) {
        $result .= "<UL>\n" . join("", @rawsort ) . "</UL>\n";
     } else {
-    foreach my $pending (qw(pending forwarded pending-fixed fixed done)) {
-        foreach my $severity(@debbugs::gSeverityList) {
+       my @pendingList = qw(pending forwarded pending-fixed fixed done);
+       @pendingList = @common_pending_include if @common_pending_include;
+       @pendingList = reverse @pendingList if $common_pending_reverse;
+#print STDERR join(",",@pendingList)."\n";
+#print STDERR join(",",@common_pending_include).":$#common_pending_include\n";
+    foreach my $pending (@pendingList) {
+       next if grep( /^$pending$/, @common_pending_exclude);
+       my @severityList = @debbugs::gSeverityList;
+       @severityList = @common_severity_include if @common_severity_include;
+       @severityList = reverse @severityList if $common_severity_reverse;
+#print STDERR join(",",@severityList)."\n";
+
+#        foreach my $severity(@debbugs::gSeverityList) {
+        foreach my $severity(@severityList) {
+           next if grep( /^$severity$/, @common_severity_exclude);
             $severity = $debbugs::gDefaultSeverity if ($severity eq '');
             next unless defined $section{${pending} . "_" . ${severity}};
             $result .= "<HR><H2>$debbugs::gSeverityDisplay{$severity} - $displayshowpending{$pending}</H2>\n";
@@ -427,26 +493,36 @@ sub getmaintainers {
 }
 
 my $_pkgsrc;
+my $_pkgcomponent;
 sub getpkgsrc {
     return $_pkgsrc if $_pkgsrc;
     my %pkgsrc;
+    my %pkgcomponent;
 
     open(MM,"$gPackageSource") or &quit("open $gPackageSource: $!");
     while(<MM>) {
-       next unless m/^(\S+)\s+(\S.*\S)\s*$/;
-       ($a,$b)=($1,$2);
+       next unless m/^(\S+)\s+(\S+)\s+(\S.*\S)\s*$/;
+       ($a,$b,$c)=($1,$2,$3);
        $a =~ y/A-Z/a-z/;
-       $pkgsrc{$a}= $b;
+       $pkgsrc{$a}= $c;
+       $pkgcomponent{$a}= $b;
     }
     close(MM);
     $_pkgsrc = \%pkgsrc;
+    $_pkgcomponent = \%pkgcomponent;
     return $_pkgsrc;
 }
 
+sub getpkgcomponent {
+    return $_pkgcomponent if $_pkgcomponent;
+    getpkgsrc();
+    return $_pkgcomponent;
+}
+
 sub getbugdir {
     my ( $bugnum, $ext ) = @_;
     my $archdir = sprintf "%02d", $bugnum % 100;
-    foreach ( ( "$gSpoolDir/db-h/$archdir", "$gSpoolDir/db", "$gSpoolDir/archive/$archdir" ) ) {
+    foreach ( ( "$gSpoolDir/db-h/$archdir", "$gSpoolDir/db", "$gSpoolDir/archive/$archdir", "/debian/home/joeyh/tmp/infomagic-95/$archdir" ) ) {
        return $_ if ( -r "$_/$bugnum.$ext" );
     }
     return undef;
@@ -484,7 +560,7 @@ sub getbugstatus {
 
 sub getsrcpkgs {
     my $src = shift;
-
+    return () if !$src;
     my %pkgsrc = %{getpkgsrc()};
     my @pkgs;
     foreach ( keys %pkgsrc ) {