help-gnats
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patch for gnatsweb.pl


From: Robert Lupton the Good
Subject: patch for gnatsweb.pl
Date: Mon, 16 Sep 2002 09:55:25 -0400

(This is my "patch.6", and brings me up-to-date, except that I
haven't posted my custom sort calback from gnatsweb-site.pl)

I should mention that all 7 of these patches are designed to be
applied in series; I'd be happy to regenerate them relative to some
baseline if requested.

This patch:
        1/ Check that $fields{$SUBMITTER_ID_FIELD} is defined;
        my site doesn't use it and gnats (otherwise) works fine.

        2/ Fixes the code for "load stored query" to set options
        in scrolling lists as appropriate rather then simply
        inserting the corresponding regexp.  This is especially
        important when using my exact-matches-for-scrolling-selections
        patch.

        3/ Make "load stored query" handle "Ignore Closed" correctly.

        4/ Fix the code that trims stored query cookies.  There
        were two problems:  "field=&" wasn't removed (just "field=;"),
        and the (long) return_url was included.  This URL doesn't
        seem to be needed (if it is, we need to add a regexp to
        strip it's [quoted] "field=&" entries)


                                R


*** /u/gnats/src/Patches/gnatsweb.pl    Fri Sep 13 08:45:31 2002
--- /u/dss/cgi-bin/gnatsweb-v4.pl       Fri Sep 13 17:00:07 2002
***************
*** 1154,1160 ****
    {
      push(@errors, "Synopsis is blank or 'unknown'");
    }
!   if($fields{$SUBMITTER_ID_FIELD} eq 'unknown')
    {
      push(@errors, "Submitter-Id is 'unknown'");
    }
--- 1154,1161 ----
    {
      push(@errors, "Synopsis is blank or 'unknown'");
    }
!   if(defined($fields{$SUBMITTER_ID_FIELD}) &&
!      $fields{$SUBMITTER_ID_FIELD} eq 'unknown')
    {
      push(@errors, "Submitter-Id is 'unknown'");
    }
***************
*** 2004,2009 ****
--- 2005,2037 ----
      print "<td>$_:</td>\n";
  
      # 2nd column is regexp search field
+     #
+     # If we're loading a query the $$values_hash{$_} may contain
+     # a number of options ORd together rather than being a true
+     # regexp.  If this is so, remove them from the value and set
+     # them as defaults for the scrolling list in column 3
+     my $ary_ref = fieldinfo($_, 'values');
+     my @ary_defaults;
+     if (fieldinfo($_, 'fieldtype') =~ 'enum')
+     {
+       my $value = "";
+       if($$values_hash{$_})
+       {
+       foreach (split(/\|/, $$values_hash{$_})) {
+         if (/^\^(.*)\$$/ && grep(/$1/, @$ary_ref))
+         {
+           push @ary_defaults, $_;
+         }
+         else
+         {
+           $value .= "|" if($value);
+           $value .= $_;
+         }
+       }
+       $$values_hash{$_} = $value;
+       }
+     }
+ 
      print "<td>",
            $q->textfield(-name=>$lc_fieldname,
                          -size=>$width, -value=>$$values_hash{$_});
***************
*** 2013,2022 ****
      # one can simply say "not closed".
      if ($_ eq $STATE_FIELD)
      {
        print "<br>",
              $q->checkbox_group(-name=>'ignoreclosed',
                                 -values=>['Ignore Closed'],
!                                -defaults=>['Ignore Closed']),
      }
      print "</td>\n";
  
--- 2041,2062 ----
      # one can simply say "not closed".
      if ($_ eq $STATE_FIELD)
      {
+       my @defaults;
+       if (defined(%$values_hash)) 
+       {
+       if (defined($$values_hash{Ignoreclosed}))
+       {
+         @defaults = $$values_hash{Ignoreclosed};
+       }
+       }
+       else 
+       {
+       @defaults = 'Ignore Closed';
+       }
        print "<br>",
              $q->checkbox_group(-name=>'ignoreclosed',
                                 -values=>['Ignore Closed'],
!                                -defaults=>address@hidden),
      }
      print "</td>\n";
  
***************
*** 2024,2030 ****
      print "<td>";
      if (fieldinfo($_, 'fieldtype') =~ 'enum')
      {
-       my $ary_ref = fieldinfo($_, 'values');
        my $size = scalar(@$ary_ref);
        my %ary_ref_names;
        foreach (@$ary_ref) { $ary_ref_names{"^$_\$"} = "$_"; }
--- 2064,2069 ----
***************
*** 2033,2038 ****
--- 2072,2078 ----
        print $q->scrolling_list(-name=>$lc_fieldname,
                                 -values=>$ary_ref,
                               -labels=>\%ary_ref_names,
+                              -defaults=>address@hidden,
                                 -multiple=>1,
                                 -size=>$size);
      }
***************
*** 2622,2633 ****
  
    # Don't save certain params.
    $q->delete('cmd');
    my $query_string = $q->query_string();
  
    # strip empty params out of $query_string.  in a gnats db with many
    # fields, the query-string will become very long, and may exceed the
    # 4K limit for cookies.
!   $query_string =~ s/\w+=;//g;
  
    if (length($query_string . $global_cookie_path . 
"gnatsweb-query-$queryname") > 4050) {
      # this cookie is going to be longer than 4K, so we'll have to punt
--- 2662,2674 ----
  
    # Don't save certain params.
    $q->delete('cmd');
+   $q->delete('return_url');
    my $query_string = $q->query_string();
  
    # strip empty params out of $query_string.  in a gnats db with many
    # fields, the query-string will become very long, and may exceed the
    # 4K limit for cookies.
!   $query_string =~ s/\w+=[;&]//g;
  
    if (length($query_string . $global_cookie_path . 
"gnatsweb-query-$queryname") > 4050) {
      # this cookie is going to be longer than 4K, so we'll have to punt
***************
*** 2893,2901 ****
        if($key eq "Submitter_id") {
        $key = "Submitter-Id";
        }
!       # I'm guessing here... (RHL)
        $val =~ s/%2A/*/g;
        $val =~ s/%20/ /g;
        $val =~ s/%5B/[/g;
        $val =~ s/%5D/]/g;
        $val =~ s/%5E/^/g;
--- 2934,2943 ----
        if($key eq "Submitter_id") {
        $key = "Submitter-Id";
        }
!       # Undo hex escapes
        $val =~ s/%2A/*/g;
        $val =~ s/%20/ /g;
+       $val =~ s/%24/\$/g;
        $val =~ s/%5B/[/g;
        $val =~ s/%5D/]/g;
        $val =~ s/%5E/^/g;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]