[Rt-commit] r2398 - in rt/branches/PLATANO-EXPERIMENTAL: . lib/RT
jesse at bestpractical.com
jesse at bestpractical.com
Mon Mar 14 02:35:49 EST 2005
Author: jesse
Date: Mon Mar 14 02:35:49 2005
New Revision: 2398
Modified:
rt/branches/PLATANO-EXPERIMENTAL/ (props changed)
rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm
rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Tickets_Overlay_SQL.pm
Log:
r8502 at hualien: jesse | 2005-03-14 02:28:38 -0500
r6459 at hualien: jesse | 2005-03-06 14:55:49 -0500
r3935 at hualien: jesse | 2005-01-26 12:15:42 -0500
RT-Ticket: 6378
RT-Status: resolved
RT-Update: correspond
Added a flag to allow tools to use the RT API to search for deleted tickets.
(Ruslan)
Modified: rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm (original)
+++ rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm Mon Mar 14 02:35:49 2005
@@ -73,6 +73,10 @@
=begin testing
ok (require RT::Tickets);
+ok( my $testtickets = RT::Tickets->new( $RT::SystemUser ) );
+ok( $testtickets->LimitStatus( VALUE => 'deleted' ) );
+# Should be zero until 'allow_deleted_search'
+ok( $testtickets->Count == 0 );
=end testing
@@ -1344,6 +1348,11 @@
OPERATOR is one of = or !=.
VALUE is a status.
+RT adds Status != 'deleted' until object has
+allow_deleted_search internal property set.
+$tickets->{'allow_deleted_search'} = 1;
+$tickets->LimitStatus( VALUE => 'deleted' );
+
=cut
sub LimitStatus {
@@ -2259,9 +2268,18 @@
my $Ticket = $self->SUPER::Next();
if ( ( defined($Ticket) ) and ( ref($Ticket) ) ) {
- #Make sure we _never_ show deleted tickets
- #TODO we should be doing this in the where clause.
- #but you can't do multiple clauses on the same field just yet :/
+ if ( $Ticket->__Value('Status') eq 'deleted' &&
+ !$self->{'allow_deleted_search'} ) {
+ return($self->Next());
+ }
+ # Since Ticket could be granted with more rights instead
+ # of being revoked, it's ok if queue rights allow
+ # ShowTicket. It seems need another query, but we have
+ # rights cache in Principal::HasRight.
+ elsif ($Ticket->QueueObj->CurrentUserHasRight('ShowTicket') ||
+ $Ticket->CurrentUserHasRight('ShowTicket')) {
+ return($Ticket);
+ }
if ( $Ticket->__Value('Status') eq 'deleted' ) {
return ( $self->Next() );
@@ -2595,5 +2613,24 @@
$self->RedoSearch();
}
+
+=head1 FLAGS
+
+RT::Tickets supports several flags which alter search behavior:
+
+
+allow_deleted_search (Otherwise never show deleted tickets in search results)
+looking_at_type (otherwise limit to type=ticket)
+
+These flags are set by calling
+
+$tickets->{'flagname'} = 1;
+
+BUG: There should be an API for this
+
+=cut
+
1;
+
+
Modified: rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Tickets_Overlay_SQL.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Tickets_Overlay_SQL.pm (original)
+++ rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Tickets_Overlay_SQL.pm Mon Mar 14 02:35:49 2005
@@ -508,8 +508,12 @@
$self->SUPER::Limit( FIELD => 'Type', OPERATOR => '=', VALUE => 'ticket');
}
- # We never ever want to show deleted tickets
- $self->SUPER::Limit(FIELD => 'Status' , OPERATOR => '!=', VALUE => 'deleted');
+ # We don't want deleted tickets unless 'allow_deleted_search' is set
+ unless( $self->{'allow_deleted_search'} ) {
+ $self->SUPER::Limit(FIELD => 'Status',
+ OPERATOR => '!=',
+ VALUE => 'deleted');
+ }
# set SB's dirty flag
More information about the Rt-commit
mailing list