summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Shredder
diff options
context:
space:
mode:
Diffstat (limited to 'rt/lib/RT/Shredder')
-rw-r--r--rt/lib/RT/Shredder/Constants.pm2
-rw-r--r--rt/lib/RT/Shredder/Dependencies.pm2
-rw-r--r--rt/lib/RT/Shredder/Dependency.pm2
-rw-r--r--rt/lib/RT/Shredder/Exceptions.pm2
-rw-r--r--rt/lib/RT/Shredder/POD.pm2
-rw-r--r--rt/lib/RT/Shredder/Plugin.pm2
-rw-r--r--rt/lib/RT/Shredder/Plugin/Attachments.pm2
-rw-r--r--rt/lib/RT/Shredder/Plugin/Base.pm2
-rw-r--r--rt/lib/RT/Shredder/Plugin/Base/Dump.pm2
-rw-r--r--rt/lib/RT/Shredder/Plugin/Base/Search.pm2
-rw-r--r--rt/lib/RT/Shredder/Plugin/Objects.pm2
-rw-r--r--rt/lib/RT/Shredder/Plugin/SQLDump.pm2
-rw-r--r--rt/lib/RT/Shredder/Plugin/Summary.pm2
-rw-r--r--rt/lib/RT/Shredder/Plugin/Tickets.pm2
-rw-r--r--rt/lib/RT/Shredder/Plugin/Users.pm53
-rw-r--r--rt/lib/RT/Shredder/Record.pm174
16 files changed, 62 insertions, 193 deletions
diff --git a/rt/lib/RT/Shredder/Constants.pm b/rt/lib/RT/Shredder/Constants.pm
index 82445a7f2..11a1731dc 100644
--- a/rt/lib/RT/Shredder/Constants.pm
+++ b/rt/lib/RT/Shredder/Constants.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/Dependencies.pm b/rt/lib/RT/Shredder/Dependencies.pm
index a78fd0cac..b0e620e47 100644
--- a/rt/lib/RT/Shredder/Dependencies.pm
+++ b/rt/lib/RT/Shredder/Dependencies.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/Dependency.pm b/rt/lib/RT/Shredder/Dependency.pm
index ad72f3bac..63ee8ea8c 100644
--- a/rt/lib/RT/Shredder/Dependency.pm
+++ b/rt/lib/RT/Shredder/Dependency.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/Exceptions.pm b/rt/lib/RT/Shredder/Exceptions.pm
index da0464dd1..7d44300cf 100644
--- a/rt/lib/RT/Shredder/Exceptions.pm
+++ b/rt/lib/RT/Shredder/Exceptions.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/POD.pm b/rt/lib/RT/Shredder/POD.pm
index c6aaeb1eb..26e4aad62 100644
--- a/rt/lib/RT/Shredder/POD.pm
+++ b/rt/lib/RT/Shredder/POD.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.pm b/rt/lib/RT/Shredder/Plugin.pm
index 2c7a79009..c9eb86c9d 100644
--- a/rt/lib/RT/Shredder/Plugin.pm
+++ b/rt/lib/RT/Shredder/Plugin.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/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;
diff --git a/rt/lib/RT/Shredder/Record.pm b/rt/lib/RT/Shredder/Record.pm
deleted file mode 100644
index 1e777ba6f..000000000
--- a/rt/lib/RT/Shredder/Record.pm
+++ /dev/null
@@ -1,174 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
-# <sales@bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
-#
-#
-# LICENSE:
-#
-# This work is made available to you under the terms of Version 2 of
-# the GNU General Public License. A copy of that license should have
-# been provided with this software, but in any event can be snarfed
-# from www.gnu.org.
-#
-# This work is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301 or visit their web page on the internet at
-# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-#
-#
-# CONTRIBUTION SUBMISSION POLICY:
-#
-# (The following paragraph is not intended to limit the rights granted
-# to you to modify and distribute this software under the terms of
-# the GNU General Public License and is only of importance to you if
-# you choose to contribute your changes and enhancements to the
-# community by submitting them to Best Practical Solutions, LLC.)
-#
-# By intentionally submitting any modifications, corrections or
-# derivatives to this work, or any other work intended for use with
-# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-# you are the copyright holder for those contributions and you grant
-# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
-# royalty-free, perpetual, license to use, copy, create derivative
-# works based on those contributions, and sublicense and distribute
-# those contributions and any derivatives thereof.
-#
-# END BPS TAGGED BLOCK }}}
-
-package RT::Record;
-use RT::Record ();
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-
-=head2 _AsInsertQuery
-
-Returns INSERT query string that duplicates current record and
-can be used to insert record back into DB after delete.
-
-=cut
-
-sub _AsInsertQuery
-{
- my $self = shift;
-
- my $dbh = $RT::Handle->dbh;
-
- my $res = "INSERT INTO ". $dbh->quote_identifier( $self->Table );
- my $values = $self->{'values'};
- $res .= "(". join( ",", map { $dbh->quote_identifier( $_ ) } sort keys %$values ) .")";
- $res .= " VALUES";
- $res .= "(". join( ",", map { $dbh->quote( $values->{$_} ) } sort keys %$values ) .")";
- $res .= ";";
-
- return $res;
-}
-
-sub BeforeWipeout { return 1 }
-
-=head2 Dependencies
-
-Returns L<RT::Shredder::Dependencies> object.
-
-=cut
-
-sub Dependencies
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Flags => RT::Shredder::Constants::DEPENDS_ON,
- @_,
- );
-
- unless( $self->id ) {
- RT::Shredder::Exception->throw('Object is not loaded');
- }
-
- my $deps = RT::Shredder::Dependencies->new();
- if( $args{'Flags'} & RT::Shredder::Constants::DEPENDS_ON ) {
- $self->__DependsOn( %args, Dependencies => $deps );
- }
- return $deps;
-}
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Object custom field values
- my $objs = $self->CustomFieldValues;
- $objs->{'find_expired_rows'} = 1;
- push( @$list, $objs );
-
-# Object attributes
- $objs = $self->Attributes;
- push( @$list, $objs );
-
-# Transactions
- $objs = RT::Transactions->new( $self->CurrentUser );
- $objs->Limit( FIELD => 'ObjectType', VALUE => ref $self );
- $objs->Limit( FIELD => 'ObjectId', VALUE => $self->id );
- push( @$list, $objs );
-
-# Links
- if ( $self->can('Links') ) {
- # make sure we don't skip any record
- no warnings 'redefine';
- local *RT::Links::IsValidLink = sub { 1 };
-
- foreach ( qw(Base Target) ) {
- my $objs = $self->Links( $_ );
- $objs->_DoSearch;
- push @$list, $objs->ItemsArrayRef;
- }
- }
-
-# ACE records
- $objs = RT::ACL->new( $self->CurrentUser );
- $objs->LimitToObject( $self );
- push( @$list, $objs );
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return;
-}
-
-# implement proxy method because some RT classes
-# override Delete method
-sub __Wipeout
-{
- my $self = shift;
- my $msg = $self->UID ." wiped out";
- $self->SUPER::Delete;
- $RT::Logger->info( $msg );
- return;
-}
-
-1;