diff options
Diffstat (limited to 'rt/docs/design_docs/cf_search')
-rw-r--r-- | rt/docs/design_docs/cf_search | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/rt/docs/design_docs/cf_search b/rt/docs/design_docs/cf_search new file mode 100644 index 000000000..456a9febb --- /dev/null +++ b/rt/docs/design_docs/cf_search @@ -0,0 +1,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' ); + + } + + # }}} + + } + |