1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
find all tickets where:
CF Foo
Has values (talk or read) AND
Has values (bar and baz) AND
doesn't have values (bing or bong)
LimitCustomFieldValues {
my %args = ( CustomField => undef,
ClauseId => 'CustomFields',
OPERATOR => undef,
ENTRYAGGREGATOR => undef,
VALUES => undef,
@_) ;
unless ( $self->{'TicketAliases'}{$args{'ClauseId'}}{'CustomField'} ) {
$self->{'TicketAliases'}{$args{'ClauseId'}}{'CustomField'} = $self->NewAlias('CustomFields');
$self->Join(TABLE1 =>$self->{'TicketAliases'}{$args{'ClauseId'}}{'CustomField' },
FIELD1 => 'QueueId',
TABLE2 => 'main', FIELD2 => 'QueueId');
if ($args{'OPERATOR'} =~ /!=|IS/i) {
}
else {
}
}
# {{{ if it's a keyword
elsif ( $TYPES{ $restriction->{'FIELD'} } eq 'CUSTOMFIELD' ) {
my $null_columns_ok;
my $TicketCFs = $self->Join( TYPE => 'left',
ALIAS1 => 'main',
FIELD1 => 'id',
TABLE2 => 'TicketCustomFieldValues',
FIELD2 => 'Ticket' );
foreach my $value ( @{ $restriction->{'VALUES'} } ) {
$self->SUPER::Limit( ALIAS => $TicketCFs,
FIELD => 'Content',
OPERATOR => $restriction->{'OPERATOR'},
VALUE => $value,
QUOTEVALUE => $restriction->{'QUOTEVALUE'},
ENTRYAGGREGATOR => 'AND', );
}
if ( ( $restriction->{'OPERATOR'} =~ /^IS$/i ) or ( $restriction->{'OPERATOR'} eq '!=' ) ) {
$null_columns_ok = 1;
}
#If we're trying to find tickets where the keyword isn't somethng, also check ones where it _IS_ null
if ( $restriction->{'OPERATOR'} eq '!=' ) {
$self->SUPER::Limit( ALIAS => $TicketCFs,
FIELD => 'Content',
OPERATOR => 'IS',
VALUE => 'NULL',
QUOTEVALUE => 0,
ENTRYAGGREGATOR => 'OR', );
}
$self->SUPER::Limit( LEFTJOIN => $TicketCFs,
FIELD => 'CustomField',
VALUE => $restriction->{'CUSTOMFIELD'},
ENTRYAGGREGATOR => 'OR' );
}
# }}}
}
|