use vars qw($userid);
package Bugzilla::Search;
+use base qw(Exporter);
+@Bugzilla::Search::EXPORT = qw(IsValidQueryType);
use Bugzilla::Config;
use Bugzilla::Error;
return $self->{'sql'};
}
+# Define if the Query Type passed in is a valid query type that we can deal with
+sub IsValidQueryType
+{
+ my ($queryType) = @_;
+ if (grep { $_ eq $queryType } qw(specific advanced)) {
+ return 1;
+ }
+ return 0;
+}
+
1;
require "CGI.pl";
use Bugzilla::Constants;
+use Bugzilla::Search;
use vars qw(
@CheckOptionValues
# Set cookie to current format as default, but only if the format
# one that we should remember.
-if (grep { $_ eq $vars->{'format'} } qw(specific advanced)) {
+if (IsValidQueryType($vars->{'format'})) {
$cgi->send_cookie(-name => 'DEFAULTFORMAT',
-value => $vars->{'format'},
-expires => "Fri, 01-Jan-2038 00:00:00 GMT");
use Bugzilla;
use Bugzilla::Constants;
+use Bugzilla::Search;
require "CGI.pl";
my @queries = @{Bugzilla->user->queries};
my @newqueries;
foreach my $q (@queries) {
- if ($q->{'query'} !~ /query_format=(advanced|specific)/) {
- if ($q->{'query'} =~ /query_format=&/) {
- $q->{'query'} =~ s/query_format=&/query_format=advanced&/;
- }
- else {
- $q->{'query'} .= '&query_format=advanced';
+ if ($q->{'query'} =~ /query_format=([^&]*)/) {
+ my $format = $1;
+ if (!IsValidQueryType($format)) {
+ if ($format eq "") {
+ $q->{'query'} =~ s/query_format=/query_format=advanced/;
+ }
+ else {
+ $q->{'query'} .= '&query_format=advanced';
+ }
}
+ } else {
+ $q->{'query'} .= '&query_format=advanced';
}
push @newqueries, $q;
}