~ubuntu-branches/ubuntu/oneiric/request-tracker3.8/oneiric-updates

« back to all changes in this revision

Viewing changes to lib/RT/Search/Googleish.pm

  • Committer: Bazaar Package Importer
  • Author(s): Dominic Hargreaves, Dominic Hargreaves, Christian Perrier
  • Date: 2009-06-16 21:46:59 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090616214659-5ji9k1n3qyc2br3n
Tags: 3.8.4-1
[ Dominic Hargreaves ]
* Add missing comma in Depends (fixes FTBFS on etch)
* Update debconf translations: pt.po, ja.po, sv.po, it.po, cs.po, ru.po
  (Closes: #519885, #519922, #520603, #520759, #521199, #521926)
* Document preference for not using SQLite in production
  (Closes: #512750)

[ Christian Perrier ]
* Debconf templates and debian/control reviewed by the debian-l10n-
  english team as part of the Smith review project.
  (Closes: #522367, #520959)
* [Debconf translation updates]
  - Japanese. Closes: #522896
  - German. Closes: #520958
  - Portuguese. Closes: #523481
  - Galician. Closes: #524256
  - Galician. Closes: #524256
  - Spanish. Closes: #524449
  - Italian. Closes: #524715
  - Russian. Closes: #524894
  - Swedish. Closes: #525171
  - French. Closes: #525281

[ Dominic Hargreaves ]
* Don't tell dbconfig to comment out unused variables, since this
  breaks MySQL and Postgres database configuration (Closes: #523090)
* Update Standards-Version (no changes)
* Switch dependency on sysklogd to rsyslog (Closes: #526914)
* New upstream release; includes
  - Minor security fix (Closes: #533069)
  - Add missing Postgres index (Closes: #512653)
* Patch webmux.pl to provide a better error message when the wrong
  major version of RT is in @INC (for example in a mod_perl context).
  (Closes: #518692)
* Add some more example Exim 4 configuration (Closes: #238345)
* Don't apply database ACLs in databases managed by dbconfig-common.
* Remove unused ACL patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
package RT::Search::Googleish;
68
68
 
69
69
use strict;
 
70
use warnings;
70
71
use base qw(RT::Search);
71
72
 
 
73
use Regexp::Common qw/delimited/;
 
74
my $re_delim = qr[$RE{delimited}{-delim=>qq{\'\"}}];
72
75
 
73
76
# sub _Init {{{
74
77
sub _Init {
91
94
sub QueryToSQL {
92
95
    my $self     = shift;
93
96
    my $query    = shift || $self->Argument;
94
 
    # Trim leading or trailing whitespace
95
 
    $query =~ s/^\s+(.*)\s+$/$1/g;
96
 
    my @keywords = split /\s+/, $query;
 
97
 
 
98
    my @keywords = grep length, map { s/^\s+//; s/\s+$//; $_ }
 
99
        split /((?:fultext:)?$re_delim|\s+)/o, $query;
 
100
 
97
101
    my (
98
102
        @tql_clauses,  @owner_clauses, @queue_clauses,
99
103
        @user_clauses, @id_clauses,    @status_clauses
102
106
    for my $key (@keywords) {
103
107
 
104
108
        # Is this a ticket number? If so, go to it.
 
109
        # But look into subject as well
105
110
        if ( $key =~ m/^\d+$/ ) {
106
 
            push @id_clauses, "id = '$key'";
107
 
        }
108
 
 
109
 
        elsif ($key =~ /^fulltext:(.*?)$/i) {
 
111
            push @id_clauses, "id = '$key'", "Subject LIKE '$key'";
 
112
        }
 
113
 
 
114
        # if it's quoted string then search it "as is" in subject or fulltext
 
115
        elsif ( $key =~ /^(fulltext:)?($re_delim)$/io ) {
 
116
            if ( $1 ) {
 
117
                push @tql_clauses, "Content LIKE $2";
 
118
            } else {
 
119
                push @tql_clauses, "Subject LIKE $2";
 
120
            }
 
121
        }
 
122
 
 
123
        elsif ( $key =~ /^fulltext:(.*?)$/i ) {
110
124
            $key = $1;
111
125
            $key =~ s/['\\].*//g;
112
126
            push @tql_clauses, "Content LIKE '$key'";
154
168
    for my $queue (@{ $self->{'Queues'} }) {
155
169
        my $QueueObj = RT::Queue->new($self->TicketsObj->CurrentUser);
156
170
        $QueueObj->Load($queue) or next;
157
 
        my $quoted_queue = $Queue->Name;
 
171
        my $quoted_queue = $QueueObj->Name;
158
172
        $quoted_queue =~ s/'/\\'/g;
159
173
        push @queue_clauses, "Queue = '$quoted_queue'";
160
174
    }
178
192
  my $self = shift;
179
193
  my $tql = $self->QueryToSQL($self->Argument);
180
194
 
181
 
  $RT::Logger->crit($tql);
 
195
  $RT::Logger->debug($tql);
182
196
 
183
197
  $self->TicketsObj->FromSQL($tql);
184
198
  return(1);