diff options
Diffstat (limited to 'rt/lib/RT/Tickets_Overlay.pm')
-rw-r--r-- | rt/lib/RT/Tickets_Overlay.pm | 76 |
1 files changed, 42 insertions, 34 deletions
diff --git a/rt/lib/RT/Tickets_Overlay.pm b/rt/lib/RT/Tickets_Overlay.pm index 55777b0fb..969d887cf 100644 --- a/rt/lib/RT/Tickets_Overlay.pm +++ b/rt/lib/RT/Tickets_Overlay.pm @@ -101,8 +101,8 @@ my %FIELDS = Filename => ['TRANSFIELD',], TransactionDate => ['TRANSDATE',], Requestor => ['WATCHERFIELD' => 'Requestor',], - CC => ['WATCHERFIELD' => 'Cc',], - AdminCC => ['WATCHERFIELD' => 'AdminCC',], + Cc => ['WATCHERFIELD' => 'Cc',], + AdminCc => ['WATCHERFIELD' => 'AdminCC',], Watcher => ['WATCHERFIELD'], LinkedTo => ['LINKFIELD',], CustomFieldValue =>['CUSTOMFIELD',], @@ -293,12 +293,13 @@ sub _LinkLimit { die "Incorrect Meta Data for $field" unless (defined $meta->[1] and defined $meta->[2]); - my $LinkAlias = $sb->NewAlias ('Links'); + $sb->{_sql_linkalias} = $sb->NewAlias ('Links') + unless defined $sb->{_sql_linkalias}; $sb->_OpenParen(); $sb->_SQLLimit( - ALIAS => $LinkAlias, + ALIAS => $sb->{_sql_linkalias}, FIELD => 'Type', OPERATOR => '=', VALUE => $meta->[2], @@ -309,7 +310,7 @@ sub _LinkLimit { my $matchfield = ( $value =~ /^(\d+)$/ ? "LocalTarget" : "Target" ); $sb->_SQLLimit( - ALIAS => $LinkAlias, + ALIAS => $sb->{_sql_linkalias}, ENTRYAGGREGATOR => 'AND', FIELD => $matchfield, OPERATOR => '=', @@ -317,14 +318,14 @@ sub _LinkLimit { ); #If we're searching on target, join the base to ticket.id - $sb->Join( ALIAS1 => 'main', FIELD1 => $sb->{'primary_key'}, - ALIAS2 => $LinkAlias, FIELD2 => 'LocalBase'); + $sb->_SQLJoin( ALIAS1 => 'main', FIELD1 => $sb->{'primary_key'}, + ALIAS2 => $sb->{_sql_linkalias}, FIELD2 => 'LocalBase'); } elsif ( $meta->[1] eq "From" ) { my $matchfield = ( $value =~ /^(\d+)$/ ? "LocalBase" : "Base" ); $sb->_SQLLimit( - ALIAS => $LinkAlias, + ALIAS => $sb->{_sql_linkalias}, ENTRYAGGREGATOR => 'AND', FIELD => $matchfield, OPERATOR => '=', @@ -332,8 +333,8 @@ sub _LinkLimit { ); #If we're searching on base, join the target to ticket.id - $sb->Join( ALIAS1 => 'main', FIELD1 => $sb->{'primary_key'}, - ALIAS2 => $LinkAlias, FIELD2 => 'LocalTarget'); + $sb->_SQLJoin( ALIAS1 => 'main', FIELD1 => $sb->{'primary_key'}, + ALIAS2 => $sb->{_sql_linkalias}, FIELD2 => 'LocalTarget'); } else { die "Invalid link direction '$meta->[1]' for $field\n"; @@ -462,11 +463,11 @@ sub _TransDateLimit { $sb->_OpenParen; # Join Transactions To Attachments - $sb->Join( ALIAS1 => $sb->{_sql_trattachalias}, FIELD1 => 'TransactionId', + $sb->_SQLJoin( ALIAS1 => $sb->{_sql_trattachalias}, FIELD1 => 'TransactionId', ALIAS2 => $sb->{_sql_transalias}, FIELD2 => 'id'); # Join Transactions to Tickets - $sb->Join( ALIAS1 => 'main', FIELD1 => $sb->{'primary_key'}, # UGH! + $sb->_SQLJoin( ALIAS1 => 'main', FIELD1 => $sb->{'primary_key'}, # UGH! ALIAS2 => $sb->{_sql_transalias}, FIELD2 => 'Ticket'); my $d = new RT::Date( $sb->CurrentUser ); @@ -536,14 +537,6 @@ sub _TransLimit { $sb->_OpenParen; - # Join Transactions To Attachments - $sb->Join( ALIAS1 => $sb->{_sql_trattachalias}, FIELD1 => 'TransactionId', - ALIAS2 => $sb->{_sql_transalias}, FIELD2 => 'id'); - - # Join Transactions to Tickets - $sb->Join( ALIAS1 => 'main', FIELD1 => $sb->{'primary_key'}, # UGH! - ALIAS2 => $sb->{_sql_transalias}, FIELD2 => 'Ticket'); - #Search for the right field $sb->_SQLLimit(ALIAS => $sb->{_sql_trattachalias}, FIELD => $field, @@ -553,6 +546,14 @@ sub _TransLimit { @rest ); + # Join Transactions To Attachments + $sb->_SQLJoin( ALIAS1 => $sb->{_sql_trattachalias}, FIELD1 => 'TransactionId', + ALIAS2 => $sb->{_sql_transalias}, FIELD2 => 'id'); + + # Join Transactions to Tickets + $sb->_SQLJoin( ALIAS1 => 'main', FIELD1 => $sb->{'primary_key'}, # UGH! + ALIAS2 => $sb->{_sql_transalias}, FIELD2 => 'Ticket'); + $sb->_CloseParen; } @@ -615,7 +616,7 @@ sub _WatcherLimit { VALUE => 'RT::Ticket-Role', ENTRYAGGREGATOR => 'AND'); - $self->Join(ALIAS1 => $groups, FIELD1 => 'Instance', + $self->_SQLJoin(ALIAS1 => $groups, FIELD1 => 'Instance', ALIAS2 => 'main', FIELD2 => 'id'); # }}} @@ -630,10 +631,10 @@ sub _WatcherLimit { ENTRYAGGREGATOR => 'AND'); } - $self->Join (ALIAS1 => $groups, FIELD1 => 'id', + $self->_SQLJoin (ALIAS1 => $groups, FIELD1 => 'id', ALIAS2 => $groupmembers, FIELD2 => 'GroupId'); - $self->Join( ALIAS1 => $groupmembers, FIELD1 => 'MemberId', + $self->_SQLJoin( ALIAS1 => $groupmembers, FIELD1 => 'MemberId', ALIAS2 => $users, FIELD2 => 'id'); $self->_CloseParen; @@ -670,7 +671,7 @@ sub _LinkFieldLimit { OPERATOR => '=', VALUE => $restriction->{'TARGET'} ); #If we're searching on target, join the base to ticket.id - $self->Join( ALIAS1 => 'main', FIELD1 => $self->{'primary_key'}, + $self->_SQLJoin( ALIAS1 => 'main', FIELD1 => $self->{'primary_key'}, ALIAS2 => $LinkAlias, FIELD2 => 'LocalBase'); } @@ -691,7 +692,7 @@ sub _LinkFieldLimit { OPERATOR => '=', VALUE => $restriction->{'BASE'} ); #If we're searching on base, join the target to ticket.id - $self->Join( ALIAS1 => 'main', FIELD1 => $self->{'primary_key'}, + $self->_SQLJoin( ALIAS1 => 'main', FIELD1 => $self->{'primary_key'}, ALIAS2 => $LinkAlias, FIELD2 => 'LocalTarget') } @@ -736,8 +737,9 @@ sub _CustomFieldLimit { my $cfid = 0; + # this is pretty inefficient for huge numbers of CFs... while ( my $CustomField = $CF->Next ) { - if ($CustomField->Name eq $field) { + if (lc $CustomField->Name eq lc $field) { $cfid = $CustomField->Id; last; } @@ -758,7 +760,7 @@ sub _CustomFieldLimit { $TicketCFs = $self->{_sql_keywordalias}{$cfid}; } else { $TicketCFs = $self->{_sql_keywordalias}{$cfid} = - $self->Join( TYPE => 'left', + $self->_SQLJoin( TYPE => 'left', ALIAS1 => 'main', FIELD1 => 'id', TABLE2 => 'TicketCustomFieldValues', @@ -860,14 +862,20 @@ sub Limit { Returns a frozen string suitable for handing back to ThawLimits. =cut + +sub _FreezeThawKeys { + 'TicketRestrictions', + 'restriction_index', + 'looking_at_effective_id', + 'looking_at_type' +} + # {{{ sub FreezeLimits sub FreezeLimits { my $self = shift; require FreezeThaw; - return (FreezeThaw::freeze($self->{'TicketRestrictions'}, - $self->{'restriction_index'} - )); + return (FreezeThaw::freeze(@{$self}{$self->_FreezeThawKeys})); } # }}} @@ -894,10 +902,9 @@ sub ThawLimits { #We don't need to die if the thaw fails. eval { - ($self->{'TicketRestrictions'}, - $self->{'restriction_index'} - ) = FreezeThaw::thaw($in); - } + @{$self}{$self->_FreezeThawKeys} = FreezeThaw::thaw($in); + }; + $RT::Logger->error( $@ ) if $@; } @@ -1749,6 +1756,7 @@ sub _Init { $self->{'primary_key'} = "id"; delete $self->{'items_array'}; delete $self->{'item_map'}; + delete $self->{'columns_to_display'}; $self->SUPER::_Init(@_); $self->_InitSQL; |