summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Search
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2011-06-14 05:14:01 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2011-06-14 05:14:01 +0200
commit79542d43011ee798f0b9b72976b6cb0ef033b84f (patch)
tree061c2aad27ba71bb2a7a881e044fd4de298e03ba /Bugzilla/Search
parentb394ae8af69ff1ac1f725bb517d91caa92861ae2 (diff)
downloadbugzilla-79542d43011ee798f0b9b72976b6cb0ef033b84f.tar.gz
bugzilla-79542d43011ee798f0b9b72976b6cb0ef033b84f.tar.xz
Bug 660866: Allow editing of old "boolean chart" searches using the new
"custom search" UI controls on the advanced search form. r=mkanat, a=mkanat (module owner)
Diffstat (limited to 'Bugzilla/Search')
-rw-r--r--Bugzilla/Search/Clause.pm33
-rw-r--r--Bugzilla/Search/Condition.pm8
2 files changed, 31 insertions, 10 deletions
diff --git a/Bugzilla/Search/Clause.pm b/Bugzilla/Search/Clause.pm
index aa87842af..a068ce5ed 100644
--- a/Bugzilla/Search/Clause.pm
+++ b/Bugzilla/Search/Clause.pm
@@ -44,19 +44,14 @@ sub children {
sub joiner { return $_[0]->{joiner} }
-sub has_children {
- my ($self) = @_;
- return scalar(@{ $self->children }) > 0 ? 1 : 0;
-}
-
-sub has_valid_conditions {
+sub has_translated_conditions {
my ($self) = @_;
my $children = $self->children;
return 1 if grep { $_->isa('Bugzilla::Search::Condition')
&& $_->translated } @$children;
foreach my $child (@$children) {
next if $child->isa('Bugzilla::Search::Condition');
- return 1 if $child->has_valid_conditions;
+ return 1 if $child->has_translated_conditions;
}
return 0;
}
@@ -100,7 +95,7 @@ sub as_string {
my ($self) = @_;
my @strings;
foreach my $child (@{ $self->children }) {
- next if $child->isa(__PACKAGE__) && !$child->has_valid_conditions;
+ next if $child->isa(__PACKAGE__) && !$child->has_translated_conditions;
next if $child->isa('Bugzilla::Search::Condition')
&& !$child->translated;
@@ -119,5 +114,25 @@ sub as_string {
return $sql;
}
+# Search.pm converts URL parameters to Clause objects. This helps do the
+# reverse.
+sub as_params {
+ my ($self) = @_;
+ my @params;
+ foreach my $child (@{ $self->children }) {
+ if ($child->isa(__PACKAGE__)) {
+ my %open_paren = (f => 'OP', n => scalar $child->negate,
+ j => $child->joiner);
+ push(@params, \%open_paren);
+ push(@params, $child->as_params);
+ my %close_paren = (f => 'CP');
+ push(@params, \%close_paren);
+ }
+ else {
+ push(@params, $child->as_params);
+ }
+ }
+ return @params;
+}
-1; \ No newline at end of file
+1;
diff --git a/Bugzilla/Search/Condition.pm b/Bugzilla/Search/Condition.pm
index 8fe05f065..2268da197 100644
--- a/Bugzilla/Search/Condition.pm
+++ b/Bugzilla/Search/Condition.pm
@@ -55,6 +55,12 @@ sub as_string {
return $term;
}
+sub as_params {
+ my ($self) = @_;
+ return { f => $self->field, o => $self->operator, v => $self->value,
+ n => scalar $self->negate };
+}
+
sub negate {
my ($self, $value) = @_;
if (@_ == 2) {
@@ -73,4 +79,4 @@ sub condition {
value => $value });
}
-1; \ No newline at end of file
+1;