diff options
Diffstat (limited to 'rt/lib/RT/Shredder/Plugin')
-rw-r--r-- | rt/lib/RT/Shredder/Plugin/Attachments.pm | 2 | ||||
-rw-r--r-- | rt/lib/RT/Shredder/Plugin/Base.pm | 2 | ||||
-rw-r--r-- | rt/lib/RT/Shredder/Plugin/Base/Dump.pm | 2 | ||||
-rw-r--r-- | rt/lib/RT/Shredder/Plugin/Base/Search.pm | 2 | ||||
-rw-r--r-- | rt/lib/RT/Shredder/Plugin/Objects.pm | 2 | ||||
-rw-r--r-- | rt/lib/RT/Shredder/Plugin/SQLDump.pm | 2 | ||||
-rw-r--r-- | rt/lib/RT/Shredder/Plugin/Summary.pm | 2 | ||||
-rw-r--r-- | rt/lib/RT/Shredder/Plugin/Tickets.pm | 2 | ||||
-rw-r--r-- | rt/lib/RT/Shredder/Plugin/Users.pm | 53 |
9 files changed, 56 insertions, 13 deletions
diff --git a/rt/lib/RT/Shredder/Plugin/Attachments.pm b/rt/lib/RT/Shredder/Plugin/Attachments.pm index 5a573ad27..42518b5c0 100644 --- a/rt/lib/RT/Shredder/Plugin/Attachments.pm +++ b/rt/lib/RT/Shredder/Plugin/Attachments.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) diff --git a/rt/lib/RT/Shredder/Plugin/Base.pm b/rt/lib/RT/Shredder/Plugin/Base.pm index 30fa3f320..be36cdc3f 100644 --- a/rt/lib/RT/Shredder/Plugin/Base.pm +++ b/rt/lib/RT/Shredder/Plugin/Base.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) diff --git a/rt/lib/RT/Shredder/Plugin/Base/Dump.pm b/rt/lib/RT/Shredder/Plugin/Base/Dump.pm index c687c0114..707096ec9 100644 --- a/rt/lib/RT/Shredder/Plugin/Base/Dump.pm +++ b/rt/lib/RT/Shredder/Plugin/Base/Dump.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) diff --git a/rt/lib/RT/Shredder/Plugin/Base/Search.pm b/rt/lib/RT/Shredder/Plugin/Base/Search.pm index e2ba495d9..26e3d160a 100644 --- a/rt/lib/RT/Shredder/Plugin/Base/Search.pm +++ b/rt/lib/RT/Shredder/Plugin/Base/Search.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) diff --git a/rt/lib/RT/Shredder/Plugin/Objects.pm b/rt/lib/RT/Shredder/Plugin/Objects.pm index 4da9f8f7f..7e2aa7a60 100644 --- a/rt/lib/RT/Shredder/Plugin/Objects.pm +++ b/rt/lib/RT/Shredder/Plugin/Objects.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) diff --git a/rt/lib/RT/Shredder/Plugin/SQLDump.pm b/rt/lib/RT/Shredder/Plugin/SQLDump.pm index 7b59feea9..4e29737f5 100644 --- a/rt/lib/RT/Shredder/Plugin/SQLDump.pm +++ b/rt/lib/RT/Shredder/Plugin/SQLDump.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) diff --git a/rt/lib/RT/Shredder/Plugin/Summary.pm b/rt/lib/RT/Shredder/Plugin/Summary.pm index 7442c6d15..4dbfb9417 100644 --- a/rt/lib/RT/Shredder/Plugin/Summary.pm +++ b/rt/lib/RT/Shredder/Plugin/Summary.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) diff --git a/rt/lib/RT/Shredder/Plugin/Tickets.pm b/rt/lib/RT/Shredder/Plugin/Tickets.pm index c6b9b8ede..0e2af36c0 100644 --- a/rt/lib/RT/Shredder/Plugin/Tickets.pm +++ b/rt/lib/RT/Shredder/Plugin/Tickets.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) diff --git a/rt/lib/RT/Shredder/Plugin/Users.pm b/rt/lib/RT/Shredder/Plugin/Users.pm index 7e1c31f77..0073a9e97 100644 --- a/rt/lib/RT/Shredder/Plugin/Users.pm +++ b/rt/lib/RT/Shredder/Plugin/Users.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -108,12 +108,21 @@ Note that found users still B<may have relations> with other objects, for example via Creator or LastUpdatedBy fields, and you most probably want to use C<replace_relations> option. +=head2 no_ticket_transactions - boolean + +If true then plugin looks for users who have created no ticket transactions. +This is especially useful after wiping out tickets. + +Note that found users still B<may have relations> with other objects, +for example via Creator or LastUpdatedBy fields, and you most probably +want to use C<replace_relations> option. + =cut sub SupportArgs { return $_[0]->SUPER::SupportArgs, - qw(status name email member_of not_member_of replace_relations no_tickets); + qw(status name email member_of not_member_of replace_relations no_tickets no_ticket_transactions); } sub TestArgs @@ -209,6 +218,11 @@ sub Run Shredder => $args{'Shredder'}, ); } + if( $self->{'opt'}{'no_ticket_transactions'} ) { + push @filter, $self->FilterWithoutTicketTransactions( + Shredder => $args{'Shredder'}, + ); + } if (@filter) { $self->FetchNext( $objs, 'init' ); @@ -284,11 +298,40 @@ sub _WithoutTickets { my $tickets = RT::Tickets->new( RT->SystemUser ); $tickets->{'allow_deleted_search'} = 1; $tickets->FromSQL( 'Watcher.id = '. $user->id ); - # HACK: we may use Count method which counts all records - # that match condtion, but we really want to know only that - # at least one record exist, so we fetch first row only + + # we could use the Count method which counts all records + # that match, but we really want to know only that + # at least one record exists, so this is faster $tickets->RowsPerPage(1); return !$tickets->First; } +sub FilterWithoutTicketTransactions { + my $self = shift; + my %args = ( + Shredder => undef, + Objects => undef, + @_, + ); + + return sub { + my $user = shift; + $self->_WithoutTicketTransactions( $user ) + }; +} + +sub _WithoutTicketTransactions { + my ($self, $user) = @_; + return unless $user and $user->Id; + my $txns = RT::Transactions->new( RT->SystemUser ); + $txns->Limit(FIELD => 'ObjectType', VALUE => 'RT::Ticket'); + $txns->Limit(FIELD => 'Creator', VALUE => $user->Id); + + # we could use the Count method which counts all records + # that match, but we really want to know only that + # at least one record exists, so this is faster + $txns->RowsPerPage(1); + return !$txns->First; +} + 1; |