+ my $cu = $self->TicketsObj->CurrentUser;
+ for my $sub (map $_->[1], sort {$a->[0] <=> $b->[0]} @GUESS) {
+ local $_ = $val;
+ my $ret = $sub->($val, $quoted, $cu);
+ return $ret if $ret;
+ }
+ return "default";
+}
+
+# $_[0] is $self
+# $_[1] is escaped value without surrounding single quotes
+# $_[2] is a boolean of "was quoted by the user?"
+# ensure this is false before you do smart matching like $_[1] eq "me"
+# $_[3] is escaped subkey, if any (see HandleCf)
+sub HandleDefault { return subject => "Subject LIKE '$_[1]'"; }
+sub HandleSubject { return subject => "Subject LIKE '$_[1]'"; }
+sub HandleFulltext { return content => "Content LIKE '$_[1]'"; }
+sub HandleContent { return content => "Content LIKE '$_[1]'"; }
+sub HandleId { $_[1] =~ s/^#//; return id => "Id = $_[1]"; }
+sub HandleStatus {
+ if ($_[1] =~ /^active$/i and !$_[2]) {
+ return status => map {s/(['\\])/\\$1/g; "Status = '$_'"} RT::Queue->ActiveStatusArray();
+ } elsif ($_[1] =~ /^inactive$/i and !$_[2]) {
+ return status => map {s/(['\\])/\\$1/g; "Status = '$_'"} RT::Queue->InactiveStatusArray();
+ } elsif ($_[1] =~ /^any$/i and !$_[2]) {
+ return 'status';
+ } else {
+ return status => "Status = '$_[1]'";
+ }
+}
+sub HandleOwner {
+ if (!$_[2] and $_[1] eq "me") {
+ return owner => "Owner.id = '__CurrentUser__'";
+ }
+ elsif (!$_[2] and $_[1] =~ /\w+@\w+/) {
+ return owner => "Owner.EmailAddress = '$_[1]'";
+ } else {
+ return owner => "Owner = '$_[1]'";
+ }
+}
+sub HandleWatcher {
+ return watcher => (!$_[2] and $_[1] eq "me") ? "Watcher.id = '__CurrentUser__'" : "Watcher = '$_[1]'";