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/ACE.pm101
-rw-r--r--rt/lib/RT/Shredder/Attachment.pm136
-rw-r--r--rt/lib/RT/Shredder/CachedGroupMember.pm143
-rw-r--r--rt/lib/RT/Shredder/Constants.pm44
-rw-r--r--rt/lib/RT/Shredder/CustomField.pm126
-rw-r--r--rt/lib/RT/Shredder/CustomFieldValue.pm94
-rw-r--r--rt/lib/RT/Shredder/Dependencies.pm2
-rw-r--r--rt/lib/RT/Shredder/Dependency.pm13
-rw-r--r--rt/lib/RT/Shredder/Exceptions.pm18
-rw-r--r--rt/lib/RT/Shredder/Group.pm185
-rw-r--r--rt/lib/RT/Shredder/GroupMember.pm183
-rw-r--r--rt/lib/RT/Shredder/Link.pm140
-rw-r--r--rt/lib/RT/Shredder/ObjectCustomFieldValue.pm116
-rw-r--r--rt/lib/RT/Shredder/POD.pm6
-rw-r--r--rt/lib/RT/Shredder/Plugin.pm16
-rw-r--r--rt/lib/RT/Shredder/Plugin/Attachments.pm2
-rw-r--r--rt/lib/RT/Shredder/Plugin/Base.pm9
-rw-r--r--rt/lib/RT/Shredder/Plugin/Summary.pm11
-rw-r--r--rt/lib/RT/Shredder/Plugin/Users.pm91
-rw-r--r--rt/lib/RT/Shredder/Principal.pm127
-rw-r--r--rt/lib/RT/Shredder/Queue.pm107
-rw-r--r--rt/lib/RT/Shredder/Record.pm121
-rw-r--r--rt/lib/RT/Shredder/Scrip.pm130
-rw-r--r--rt/lib/RT/Shredder/ScripAction.pm100
-rw-r--r--rt/lib/RT/Shredder/ScripCondition.pm101
-rw-r--r--rt/lib/RT/Shredder/Template.pm120
-rw-r--r--rt/lib/RT/Shredder/Ticket.pm126
-rw-r--r--rt/lib/RT/Shredder/Transaction.pm115
-rw-r--r--rt/lib/RT/Shredder/User.pm191
29 files changed, 125 insertions, 2549 deletions
diff --git a/rt/lib/RT/Shredder/ACE.pm b/rt/lib/RT/Shredder/ACE.pm
deleted file mode 100644
index 57346c0..0000000
--- a/rt/lib/RT/Shredder/ACE.pm
+++ /dev/null
@@ -1,101 +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 }}}
-
-use RT::ACE ();
-package RT::ACE;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Exceptions;
-use RT::Shredder::Constants;
-use RT::Shredder::Dependencies;
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__DependsOn( %args );
-}
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-1;
-
diff --git a/rt/lib/RT/Shredder/Attachment.pm b/rt/lib/RT/Shredder/Attachment.pm
deleted file mode 100644
index 00aecf3..0000000
--- a/rt/lib/RT/Shredder/Attachment.pm
+++ /dev/null
@@ -1,136 +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 }}}
-
-use RT::Attachment ();
-package RT::Attachment;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Exceptions;
-use RT::Shredder::Constants;
-use RT::Shredder::Dependencies;
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Nested attachments
- my $objs = RT::Attachments->new( $self->CurrentUser );
- $objs->Limit(
- FIELD => 'Parent',
- OPERATOR => '=',
- VALUE => $self->Id
- );
- $objs->Limit(
- FIELD => 'id',
- OPERATOR => '!=',
- VALUE => $self->Id
- );
- push( @$list, $objs );
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__DependsOn( %args );
-}
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Parent, nested parts
- if( $self->Parent ) {
- if( $self->ParentObj && $self->ParentId ) {
- push( @$list, $self->ParentObj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no parent attachment #". $self->Parent ." object";
- }
- }
-
-# Transaction
- my $obj = $self->TransactionObj;
- if( defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related transaction #". $self->TransactionId ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-1;
diff --git a/rt/lib/RT/Shredder/CachedGroupMember.pm b/rt/lib/RT/Shredder/CachedGroupMember.pm
deleted file mode 100644
index 646035e..0000000
--- a/rt/lib/RT/Shredder/CachedGroupMember.pm
+++ /dev/null
@@ -1,143 +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 }}}
-
-use RT::CachedGroupMember ();
-package RT::CachedGroupMember;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependency;
-
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# deep memebership
- my $objs = RT::CachedGroupMembers->new( $self->CurrentUser );
- $objs->Limit( FIELD => 'Via', VALUE => $self->Id );
- $objs->Limit( FIELD => 'id', OPERATOR => '!=', VALUE => $self->Id );
- push( @$list, $objs );
-
-# principal lost group membership and lost some rights which he could delegate to
-# some body
-
-# XXX: Here is problem cause HasMemberRecursively would return true allways
-# cause we didn't delete anything yet. :(
- # if pricipal is not member anymore(could be via other groups) then proceed
- if( $self->GroupObj->Object->HasMemberRecursively( $self->MemberObj ) ) {
- my $acl = RT::ACL->new( $self->CurrentUser );
- $acl->LimitToPrincipal( Id => $self->GroupId );
-
- }
-
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-
- return $self->SUPER::__DependsOn( %args );
-}
-
-#TODO: If we plan write export tool we also should fetch parent groups
-# now we only wipeout things.
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
- my $obj = $self->MemberObj;
- if( $obj && $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->MemberId ." object.";
- }
-
- $obj = $self->GroupObj;
- if( $obj && $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->GroupId ." object.";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-1;
diff --git a/rt/lib/RT/Shredder/Constants.pm b/rt/lib/RT/Shredder/Constants.pm
index 64ee0b0..82445a7 100644
--- a/rt/lib/RT/Shredder/Constants.pm
+++ b/rt/lib/RT/Shredder/Constants.pm
@@ -51,15 +51,13 @@ package RT::Shredder::Constants;
use strict;
use warnings;
-use base qw(Exporter);
-
=head1 NAME
RT::Shredder::Constants - RT::Shredder constants that is used to mark state of RT objects.
=head1 DESCRIPTION
-This module exports two group of bit constants.
+This module contains two group of bit constants.
First group is group of flags which are used to clarify dependecies between objects, and
second group is states of RT objects in Shredder cache.
@@ -84,19 +82,12 @@ This flag is used to mark dependencies that can be resolved with changing
value in target object. For example ticket can be created by user we can
change this reference when we delete user.
-=head2 RELATES
-
-This flag is used to validate relationships integrity. Base object
-is valid only when all target objects which are marked with this flags
-exist.
-
=cut
use constant {
- DEPENDS_ON => 0x000001,
- WIPE_AFTER => 0x000010,
- RELATES => 0x000100,
- VARIABLE => 0x001000,
+ DEPENDS_ON => 0x001,
+ WIPE_AFTER => 0x002,
+ VARIABLE => 0x004,
};
=head1 STATES
@@ -112,33 +103,12 @@ Objects with this state are not exist any more in DB, but perl
object is still in memory. This state is used to be shure that
delete query is called once.
-=head2 VALID
-
-Object is marked with this state only when its relationships
-are valid.
-
-=head2 INVALID
-
=cut
use constant {
- ON_STACK => 0x00000,
- IN_WIPING => 0x00001,
- WIPED => 0x00010,
- VALID => 0x00100,
- INVALID => 0x01000,
+ ON_STACK => 0x000,
+ IN_WIPING => 0x010,
+ WIPED => 0x020,
};
-our @EXPORT = qw(
- DEPENDS_ON
- WIPE_AFTER
- RELATES
- VARIABLE
- ON_STACK
- IN_WIPING
- WIPED
- VALID
- INVALID
- );
-
1;
diff --git a/rt/lib/RT/Shredder/CustomField.pm b/rt/lib/RT/Shredder/CustomField.pm
deleted file mode 100644
index a3d542a..0000000
--- a/rt/lib/RT/Shredder/CustomField.pm
+++ /dev/null
@@ -1,126 +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 }}}
-
-use RT::CustomField ();
-package RT::CustomField;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
-
-#TODO: Queues if we wish export tool
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Custom field values
- push( @$list, $self->Values );
-
-# Ticket custom field values
- my $objs = RT::ObjectCustomFieldValues->new( $self->CurrentUser );
- $objs->LimitToCustomField( $self->Id );
- push( @$list, $objs );
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__DependsOn( %args );
-}
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
- my $obj = $self->Object;
-
-# Queue
-# Skip if it's global CF
- if( $self->Queue ) {
- if( $self->QueueObj && $self->QueueObj->Id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related queue #". $self->Queue ." object";
- }
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-1;
-
diff --git a/rt/lib/RT/Shredder/CustomFieldValue.pm b/rt/lib/RT/Shredder/CustomFieldValue.pm
deleted file mode 100644
index 95f136b..0000000
--- a/rt/lib/RT/Shredder/CustomFieldValue.pm
+++ /dev/null
@@ -1,94 +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 }}}
-
-use RT::CustomFieldValue ();
-package RT::CustomFieldValue;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
-
-# No dependencies that should be deleted with record
-# I should decide is TicketCustomFieldValue depends by this or not.
-# Today I think no. What would be tomorrow I don't know.
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
- my $obj = $self->CustomFieldObj;
- if( $obj && defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related CustomField #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->__Relates( %args );
-}
-
-1;
diff --git a/rt/lib/RT/Shredder/Dependencies.pm b/rt/lib/RT/Shredder/Dependencies.pm
index 3ffebfd..a78fd0c 100644
--- a/rt/lib/RT/Shredder/Dependencies.pm
+++ b/rt/lib/RT/Shredder/Dependencies.pm
@@ -107,7 +107,7 @@ sub _PushDependency
@_
);
my $rec = $args{'Shredder'}->PutObject( Object => $args{'TargetObject'} );
- return if $rec->{'State'} & WIPED; # there is no object anymore
+ return if $rec->{'State'} & RT::Shredder::Constants::WIPED; # there is no object anymore
push @{ $self->{'list'} },
RT::Shredder::Dependency->new(
diff --git a/rt/lib/RT/Shredder/Dependency.pm b/rt/lib/RT/Shredder/Dependency.pm
index bdfdfc1..ad72f3b 100644
--- a/rt/lib/RT/Shredder/Dependency.pm
+++ b/rt/lib/RT/Shredder/Dependency.pm
@@ -54,10 +54,9 @@ use RT::Shredder::Constants;
use RT::Shredder::Exceptions;
my %FlagDescs = (
- DEPENDS_ON, 'depends on',
- VARIABLE, 'resolvable dependency',
- WIPE_AFTER, 'delete after',
- RELATES, 'relates with',
+ RT::Shredder::Constants::DEPENDS_ON, 'depends on',
+ RT::Shredder::Constants::VARIABLE, 'resolvable dependency',
+ RT::Shredder::Constants::WIPE_AFTER, 'delete after',
);
sub new
@@ -71,7 +70,7 @@ sub new
sub Set
{
my $self = shift;
- my %args = ( Flags => DEPENDS_ON, @_ );
+ my %args = ( Flags => RT::Shredder::Constants::DEPENDS_ON, @_ );
my @keys = qw(Flags BaseObject TargetObject);
@$self{ @keys } = @args{ @keys };
@@ -81,9 +80,9 @@ sub Set
sub AsString
{
my $self = shift;
- my $res = $self->BaseObject->_AsString;
+ my $res = $self->BaseObject->UID;
$res .= " ". $self->FlagsAsString;
- $res .= " ". $self->TargetObject->_AsString;
+ $res .= " ". $self->TargetObject->UID;
return $res;
}
diff --git a/rt/lib/RT/Shredder/Exceptions.pm b/rt/lib/RT/Shredder/Exceptions.pm
index 85f8800..da0464d 100644
--- a/rt/lib/RT/Shredder/Exceptions.pm
+++ b/rt/lib/RT/Shredder/Exceptions.pm
@@ -67,27 +67,27 @@ use base qw(RT::Shredder::Exception);
my %DESCRIPTION = (
DependenciesLimit => <<END,
-Dependecies list have reached its limit.
+Dependencies list has reached its limit.
See \$RT::DependenciesLimit in RT::Shredder docs.
END
SystemObject => <<END,
-System object was requested for deletion, shredder couldn't
-do that because system would be unusable than.
+System object was selected for deletion, shredder couldn't
+do that because system would be unusable then.
END
CouldntLoadObject => <<END,
-Shredder couldn't load object. Most probably it's not fatal error.
-May be you've used Objects plugin and asked to delete object that
+Shredder couldn't load object. Most likely it's not a fatal error.
+Perhaps you've used the Objects plugin and asked to delete an object that
doesn't exist in the system. If you think that your request was
-correct and it's problem of the Shredder then you can get full error
-message from RT log files and send bug report.
+correct and it's a problem of the Shredder then you can get a full error
+message from RT log files and send a bug report.
END
NoResolver => <<END,
Object has dependency that could be resolved, but resolver
-wasn't defined. You have to re-read documentation of the
-plugin you're using, for example the 'Users' plugin has
+wasn't defined. You have to re-read the documentation of the
+plugin you're using. For example the 'Users' plugin has
option 'replace_relations' argument.
END
);
diff --git a/rt/lib/RT/Shredder/Group.pm b/rt/lib/RT/Shredder/Group.pm
deleted file mode 100644
index 8f93b8f..0000000
--- a/rt/lib/RT/Shredder/Group.pm
+++ /dev/null
@@ -1,185 +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 }}}
-
-use RT::Group ();
-package RT::Group;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
-
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# User is inconsistent without own Equivalence group
- if( $self->Domain eq 'ACLEquivalence' ) {
- # delete user entry after ACL equiv group
- # in other case we will get deep recursion
- my $objs = RT::User->new($self->CurrentUser);
- $objs->Load( $self->Instance );
- $deps->_PushDependency(
- BaseObject => $self,
- Flags => DEPENDS_ON | WIPE_AFTER,
- TargetObject => $objs,
- Shredder => $args{'Shredder'}
- );
- }
-
-# Principal
- $deps->_PushDependency(
- BaseObject => $self,
- Flags => DEPENDS_ON | WIPE_AFTER,
- TargetObject => $self->PrincipalObj,
- Shredder => $args{'Shredder'}
- );
-
-# Group members records
- my $objs = RT::GroupMembers->new( $self->CurrentUser );
- $objs->LimitToMembersOfGroup( $self->PrincipalId );
- push( @$list, $objs );
-
-# Group member records group belongs to
- $objs = RT::GroupMembers->new( $self->CurrentUser );
- $objs->Limit(
- VALUE => $self->PrincipalId,
- FIELD => 'MemberId',
- ENTRYAGGREGATOR => 'OR',
- QUOTEVALUE => 0
- );
- push( @$list, $objs );
-
-# Cached group members records
- push( @$list, $self->DeepMembersObj );
-
-# Cached group member records group belongs to
- $objs = RT::GroupMembers->new( $self->CurrentUser );
- $objs->Limit(
- VALUE => $self->PrincipalId,
- FIELD => 'MemberId',
- ENTRYAGGREGATOR => 'OR',
- QUOTEVALUE => 0
- );
- push( @$list, $objs );
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__DependsOn( %args );
-}
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Equivalence group id inconsistent without User
- if( $self->Domain eq 'ACLEquivalence' ) {
- my $obj = RT::User->new($self->CurrentUser);
- $obj->Load( $self->Instance );
- if( $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "ACLEguvivalence group have no related User #". $self->Instance ." object.";
- }
- }
-
-# Principal
- my $obj = $self->PrincipalObj;
- if( $obj && $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->id ." object.";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-sub BeforeWipeout
-{
- my $self = shift;
- if( $self->Domain eq 'SystemInternal' ) {
- RT::Shredder::Exception::Info->throw('SystemObject');
- }
- return $self->SUPER::BeforeWipeout( @_ );
-}
-
-1;
diff --git a/rt/lib/RT/Shredder/GroupMember.pm b/rt/lib/RT/Shredder/GroupMember.pm
deleted file mode 100644
index 936fb64..0000000
--- a/rt/lib/RT/Shredder/GroupMember.pm
+++ /dev/null
@@ -1,183 +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 }}}
-
-use RT::GroupMember ();
-package RT::GroupMember;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
-
-# No dependencies that should be deleted with record
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
- my $objs = RT::CachedGroupMembers->new( $self->CurrentUser );
- $objs->Limit( FIELD => 'MemberId', VALUE => $self->MemberId );
- $objs->Limit( FIELD => 'ImmediateParentId', VALUE => $self->GroupId );
- push( @$list, $objs );
-
- # XXX: right delegations should be cleaned here
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-
- my $group = $self->GroupObj->Object;
- # XXX: If we delete member of the ticket owner role group then we should also
- # fix ticket object, but only if we don't plan to delete group itself!
- unless( ($group->Type || '') eq 'Owner' &&
- ($group->Domain || '') eq 'RT::Ticket-Role' ) {
- return $self->SUPER::__DependsOn( %args );
- }
-
- # we don't delete group, so we have to fix Ticket and Group
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON | VARIABLE,
- TargetObjects => $group,
- Shredder => $args{'Shredder'}
- );
- $args{'Shredder'}->PutResolver(
- BaseClass => ref $self,
- TargetClass => ref $group,
- Code => sub {
- my %args = (@_);
- my $group = $args{'TargetObject'};
- return if $args{'Shredder'}->GetState( Object => $group ) & (WIPED|IN_WIPING);
- return unless ($group->Type || '') eq 'Owner';
- return unless ($group->Domain || '') eq 'RT::Ticket-Role';
-
- return if $group->MembersObj->Count > 1;
-
- my $group_member = $args{'BaseObject'};
-
- if( $group_member->MemberObj->id == RT->Nobody->id ) {
- RT::Shredder::Exception->throw( "Couldn't delete Nobody from owners role group" );
- }
-
- my( $status, $msg ) = $group->AddMember( RT->Nobody->id );
- RT::Shredder::Exception->throw( $msg ) unless $status;
-
- my $ticket = RT::Ticket->new( $group->CurrentUser );
- $ticket->Load( $group->Instance );
- RT::Shredder::Exception->throw( "Couldn't load ticket" ) unless $ticket->id;
-
- ( $status, $msg ) = $ticket->_Set( Field => 'Owner',
- Value => RT->Nobody->id,
- );
- RT::Shredder::Exception->throw( $msg ) unless $status;
-
- return;
- },
- );
-
- return $self->SUPER::__DependsOn( %args );
-}
-
-
-#TODO: If we plan write export tool we also should fetch parent groups
-# now we only wipeout things.
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
- my $obj = $self->MemberObj;
- if( $obj && $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->MemberId ." object.";
- }
-
- $obj = $self->GroupObj;
- if( $obj && $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->GroupId ." object.";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/rt/lib/RT/Shredder/Link.pm b/rt/lib/RT/Shredder/Link.pm
deleted file mode 100644
index 5180c43..0000000
--- a/rt/lib/RT/Shredder/Link.pm
+++ /dev/null
@@ -1,140 +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 }}}
-
-use RT::Link ();
-package RT::Link;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
-use RT::Shredder::Constants;
-
-use RT::Shredder::Transaction;
-use RT::Shredder::Record;
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# AddLink transactions
- my $map = RT::Ticket->LINKTYPEMAP;
- my $link_meta = $map->{ $self->Type };
- unless ( $link_meta && $link_meta->{'Mode'} && $link_meta->{'Type'} ) {
- RT::Shredder::Exception->throw( 'Wrong link link_meta, no record for '. $self->Type );
- }
- if ( $self->BaseURI->IsLocal ) {
- my $objs = $self->BaseObj->Transactions;
- $objs->Limit(
- FIELD => 'Type',
- OPERATOR => '=',
- VALUE => 'AddLink',
- );
- $objs->Limit( FIELD => 'NewValue', VALUE => $self->Target );
- while ( my ($k, $v) = each %$map ) {
- next unless $v->{'Type'} eq $link_meta->{'Type'};
- next unless $v->{'Mode'} eq $link_meta->{'Mode'};
- $objs->Limit( FIELD => 'Field', VALUE => $k );
- }
- push( @$list, $objs );
- }
-
- my %reverse = ( Base => 'Target', Target => 'Base' );
- if ( $self->TargetURI->IsLocal ) {
- my $objs = $self->TargetObj->Transactions;
- $objs->Limit(
- FIELD => 'Type',
- OPERATOR => '=',
- VALUE => 'AddLink',
- );
- $objs->Limit( FIELD => 'NewValue', VALUE => $self->Base );
- while ( my ($k, $v) = each %$map ) {
- next unless $v->{'Type'} eq $link_meta->{'Type'};
- next unless $v->{'Mode'} eq $reverse{ $link_meta->{'Mode'} };
- $objs->Limit( FIELD => 'Field', VALUE => $k );
- }
- push( @$list, $objs );
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON|WIPE_AFTER,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__DependsOn( %args );
-}
-
-#TODO: Link record has small strength, but should be encountered
-# if we plan write export tool.
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-# FIXME: if link is local then object should exist
-
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/rt/lib/RT/Shredder/ObjectCustomFieldValue.pm b/rt/lib/RT/Shredder/ObjectCustomFieldValue.pm
deleted file mode 100644
index d040f97..0000000
--- a/rt/lib/RT/Shredder/ObjectCustomFieldValue.pm
+++ /dev/null
@@ -1,116 +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 }}}
-
-use RT::ObjectCustomFieldValue ();
-package RT::ObjectCustomFieldValue;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
- return $self->SUPER::__DependsOn( %args );
-}
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Ticket
- my $obj = $self->TicketObj;
- if( defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related Ticket #". $self->id ." object";
- }
-
-# Custom Field
- $obj = $self->CustomFieldObj;
- if( defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related CustomField #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/rt/lib/RT/Shredder/POD.pm b/rt/lib/RT/Shredder/POD.pm
index b2156f9..c6aaeb1 100644
--- a/rt/lib/RT/Shredder/POD.pm
+++ b/rt/lib/RT/Shredder/POD.pm
@@ -59,6 +59,7 @@ sub plugin_html
my $parser = RT::Shredder::POD::HTML->new;
$parser->select('ARGUMENTS', 'USAGE');
$parser->parse_from_file( $file, $out_fh );
+ return;
}
sub plugin_cli
@@ -69,6 +70,7 @@ sub plugin_cli
$parser->select('SYNOPSIS', 'ARGUMENTS', 'USAGE');
$parser->add_selection('NAME') unless $no_name;
$parser->parse_from_file( $file, $out_fh );
+ return;
}
sub shredder_cli
@@ -78,6 +80,7 @@ sub shredder_cli
my $parser = Pod::PlainText->new();
$parser->select('NAME', 'SYNOPSIS', 'USAGE', 'OPTIONS');
$parser->parse_from_file( $file, $out_fh );
+ return;
}
package RT::Shredder::POD::HTML;
@@ -97,6 +100,7 @@ sub command
print $out_fh $expansion;
print $out_fh "</$tag>" if $tag;
print $out_fh "\n";
+ return;
}
sub verbatim
@@ -107,6 +111,7 @@ sub verbatim
print $out_fh $paragraph;
print $out_fh "</pre>";
print $out_fh "\n";
+ return;
}
sub textblock {
@@ -118,6 +123,7 @@ sub textblock {
print $out_fh $expansion;
print $out_fh "</p>";
print $out_fh "\n";
+ return;
}
sub interior_sequence {
diff --git a/rt/lib/RT/Shredder/Plugin.pm b/rt/lib/RT/Shredder/Plugin.pm
index 9ee2b93..2c7a790 100644
--- a/rt/lib/RT/Shredder/Plugin.pm
+++ b/rt/lib/RT/Shredder/Plugin.pm
@@ -103,6 +103,7 @@ sub _Init
my $self = shift;
my %args = ( @_ );
$self->{'opt'} = \%args;
+ return;
}
=head2 List
@@ -137,7 +138,7 @@ sub List
delete $res{'Base'};
foreach my $name( keys %res ) {
my $class = join '::', qw(RT Shredder Plugin), $name;
- unless( eval "require $class" ) {
+ unless( $class->require ) {
delete $res{ $name };
next;
}
@@ -161,6 +162,8 @@ Other arguments are sent to the constructor of the plugin
Returns C<$status> and C<$message>. On errors status
is C<false> value.
+In scalar context, returns $status only.
+
=cut
sub LoadByName
@@ -169,17 +172,16 @@ sub LoadByName
my $name = shift or return (0, "Name not specified");
$name =~ /^\w+(::\w+)*$/ or return (0, "Invalid plugin name");
- local $@;
my $plugin = "RT::Shredder::Plugin::$name";
- eval "require $plugin" or return( 0, $@ );
- return( 0, "Plugin '$plugin' has no method new") unless $plugin->can('new');
+ $plugin->require or return( 0, "Failed to load $plugin" );
+ return wantarray ? ( 0, "Plugin '$plugin' has no method new") : 0 unless $plugin->can('new');
my $obj = eval { $plugin->new( @_ ) };
- return( 0, $@ ) if $@;
- return( 0, 'constructor returned empty object' ) unless $obj;
+ return wantarray ? ( 0, $@ ) : 0 if $@;
+ return wantarray ? ( 0, 'constructor returned empty object' ) : 0 unless $obj;
$self->Rebless( $obj );
- return( 1, "successfuly load plugin" );
+ return wantarray ? ( 1, "successfuly load plugin" ) : 1;
}
=head2 LoadByString
diff --git a/rt/lib/RT/Shredder/Plugin/Attachments.pm b/rt/lib/RT/Shredder/Plugin/Attachments.pm
index c33ffe8..5a573ad 100644
--- a/rt/lib/RT/Shredder/Plugin/Attachments.pm
+++ b/rt/lib/RT/Shredder/Plugin/Attachments.pm
@@ -132,7 +132,7 @@ sub Run
}
return (0, "Internal error: '". $sth->err ."'. Please send bug report.") if $sth->err;
- map { $_ = "RT::Attachment-$_" } @objs;
+ @objs = map {"RT::Attachment-$_"} @objs;
return (1, @objs);
}
diff --git a/rt/lib/RT/Shredder/Plugin/Base.pm b/rt/lib/RT/Shredder/Plugin/Base.pm
index a8acf39..30fa3f3 100644
--- a/rt/lib/RT/Shredder/Plugin/Base.pm
+++ b/rt/lib/RT/Shredder/Plugin/Base.pm
@@ -61,14 +61,14 @@ sub new
{
my $proto = shift;
my $self = bless( {}, ref $proto || $proto );
- $self->_Init( @_ );
- return $self;
+ return $self->_Init( @_ );
}
sub _Init
{
my $self = shift;
$self->{'opt'} = { @_ };
+ return $self;
}
=head1 USAGE
@@ -125,8 +125,9 @@ sub HasSupportForArgs
foreach my $a( @args ) {
push @unsupported, $a unless grep $_ eq $a, $self->SupportArgs;
}
- return( 1 ) unless @unsupported;
- return( 0, "Plugin doesn't support argument(s): @unsupported" ) if @unsupported;
+ return( 0, "Plugin doesn't support argument(s): @unsupported" )
+ if @unsupported;
+ return( 1 );
}
=head3 TestArgs
diff --git a/rt/lib/RT/Shredder/Plugin/Summary.pm b/rt/lib/RT/Shredder/Plugin/Summary.pm
index bd21284..7442c6d 100644
--- a/rt/lib/RT/Shredder/Plugin/Summary.pm
+++ b/rt/lib/RT/Shredder/Plugin/Summary.pm
@@ -76,7 +76,6 @@ sub Run
my $method = 'WriteDown'. $class;
$method = 'WriteDownDefault' unless $self->can($method);
return $self->$method( %args );
- return 1;
}
my %skip_refs_to = ();
@@ -114,8 +113,8 @@ sub WriteDownPrincipal { return 1 }
sub WriteDownGroup {
my $self = shift;
my %args = ( Object => undef, @_ );
- if ( $args{'Object'}->Domain =~ /-Role$/ ) {
- return $skip_refs_to{ $args{'Object'}->_AsString } = 1;
+ if ( $args{'Object'}->RoleClass ) {
+ return $skip_refs_to{ $args{'Object'}->UID } = 1;
}
return $self->WriteDownDefault( %args );
}
@@ -142,7 +141,7 @@ sub WriteDownScrip {
my $props = $self->_MakeHash( $args{'Object'} );
$props->{'Action'} = $args{'Object'}->ActionObj->Name;
$props->{'Condition'} = $args{'Object'}->ConditionObj->Name;
- $props->{'Template'} = $args{'Object'}->TemplateObj->Name;
+ $props->{'Template'} = $args{'Object'}->Template;
$props->{'Queue'} = $args{'Object'}->QueueObj->Name || 'global';
return $self->_WriteDownHash( $args{'Object'}, $props );
@@ -154,7 +153,7 @@ sub _MakeHash {
foreach (grep exists $hash->{$_}, qw(Creator LastUpdatedBy)) {
my $method = $_ .'Obj';
my $u = $obj->$method();
- $hash->{ $_ } = $u->EmailAddress || $u->Name || $u->_AsString;
+ $hash->{ $_ } = $u->EmailAddress || $u->Name || $u->UID;
}
return $hash;
}
@@ -171,7 +170,7 @@ sub _WriteDownHash {
my ($self, $obj, $hash) = @_;
return (0, 'no handle') unless my $fh = $self->{'opt'}{'file_handle'};
- print $fh "=== ". $obj->_AsString ." ===\n"
+ print $fh "=== ". $obj->UID ." ===\n"
or return (0, "Couldn't write to filehandle");
foreach my $key( sort keys %$hash ) {
diff --git a/rt/lib/RT/Shredder/Plugin/Users.pm b/rt/lib/RT/Shredder/Plugin/Users.pm
index 2f6fbd9..7e1c31f 100644
--- a/rt/lib/RT/Shredder/Plugin/Users.pm
+++ b/rt/lib/RT/Shredder/Plugin/Users.pm
@@ -79,6 +79,11 @@ be selected for deletion. Identifier is name of user defined group
or id of a group, as well C<Privileged> or <unprivileged> can used
to select people from system groups.
+=head2 not_member_of - group identifier
+
+Like member_of, but selects users who are not members of the provided
+group.
+
=head2 replace_relations - user identifier
When you delete a user there could be minor links to them in the RT database.
@@ -108,7 +113,7 @@ want to use C<replace_relations> option.
sub SupportArgs
{
return $_[0]->SUPER::SupportArgs,
- qw(status name email member_of replace_relations no_tickets);
+ qw(status name email member_of not_member_of replace_relations no_tickets);
}
sub TestArgs
@@ -128,19 +133,22 @@ sub TestArgs
if( $args{'name'} ) {
$args{'name'} = $self->ConvertMaskToSQL( $args{'name'} );
}
- if( $args{'member_of'} ) {
- my $group = RT::Group->new( RT->SystemUser );
- if ( $args{'member_of'} =~ /^(Everyone|Privileged|Unprivileged)$/i ) {
- $group->LoadSystemInternalGroup( $args{'member_of'} );
- }
- else {
- $group->LoadUserDefinedGroup( $args{'member_of'} );
- }
- unless ( $group->id ) {
- return (0, "Couldn't load group '$args{'member_of'}'" );
- }
- $args{'member_of'} = $group->id;
+ if( $args{'member_of'} or $args{'not_member_of'} ) {
+ foreach my $group_option ( qw(member_of not_member_of) ){
+ next unless $args{$group_option};
+ my $group = RT::Group->new( RT->SystemUser );
+ if ( $args{$group_option} =~ /^(Everyone|Privileged|Unprivileged)$/i ) {
+ $group->LoadSystemInternalGroup( $args{$group_option} );
+ }
+ else {
+ $group->LoadUserDefinedGroup( $args{$group_option} );
+ }
+ unless ( $group->id ) {
+ return (0, "Couldn't load group '$args{$group_option}'" );
+ }
+ $args{$group_option} = $group->id;
+ }
}
if( $args{'replace_relations'} ) {
my $uid = $args{'replace_relations'};
@@ -183,20 +191,38 @@ sub Run
$objs->Limit( FIELD => 'Name',
OPERATOR => 'MATCHES',
VALUE => $self->{'opt'}{'name'},
+ CASESENSITIVE => 0,
);
}
if( $self->{'opt'}{'member_of'} ) {
$objs->MemberOfGroup( $self->{'opt'}{'member_of'} );
}
+ my @filter;
+ if( $self->{'opt'}{'not_member_of'} ) {
+ push @filter, $self->FilterNotMemberOfGroup(
+ Shredder => $args{'Shredder'},
+ GroupId => $self->{'opt'}{'not_member_of'},
+ );
+ }
if( $self->{'opt'}{'no_tickets'} ) {
- return $self->FilterWithoutTickets(
+ push @filter, $self->FilterWithoutTickets(
Shredder => $args{'Shredder'},
- Objects => $objs,
);
- } else {
- if( $self->{'opt'}{'limit'} ) {
- $objs->RowsPerPage( $self->{'opt'}{'limit'} );
+ }
+
+ if (@filter) {
+ $self->FetchNext( $objs, 'init' );
+ my @res;
+ USER: while ( my $user = $self->FetchNext( $objs ) ) {
+ for my $filter (@filter) {
+ next USER unless $filter->($user);
+ }
+ push @res, $user;
+ last if $self->{'opt'}{'limit'} && @res >= $self->{'opt'}{'limit'};
}
+ $objs = \@res;
+ } elsif ( $self->{'opt'}{'limit'} ) {
+ $objs->RowsPerPage( $self->{'opt'}{'limit'} );
}
return (1, $objs);
}
@@ -221,6 +247,23 @@ sub SetResolvers
return (1);
}
+sub FilterNotMemberOfGroup {
+ my $self = shift;
+ my %args = (
+ Shredder => undef,
+ GroupId => undef,
+ @_,
+ );
+
+ my $group = RT::Group->new(RT->SystemUser);
+ $group->Load($args{'GroupId'});
+
+ return sub {
+ my $user = shift;
+ not $group->HasMemberRecursively($user->id);
+ };
+}
+
sub FilterWithoutTickets {
my $self = shift;
my %args = (
@@ -228,15 +271,11 @@ sub FilterWithoutTickets {
Objects => undef,
@_,
);
- my $users = $args{Objects};
- $self->FetchNext( $users, 'init' );
- my @res;
- while ( my $user = $self->FetchNext( $users ) ) {
- push @res, $user if $self->_WithoutTickets( $user );
- return (1, \@res) if $self->{'opt'}{'limit'} && @res >= $self->{'opt'}{'limit'};
- }
- return (1, \@res);
+ return sub {
+ my $user = shift;
+ $self->_WithoutTickets( $user )
+ };
}
sub _WithoutTickets {
diff --git a/rt/lib/RT/Shredder/Principal.pm b/rt/lib/RT/Shredder/Principal.pm
deleted file mode 100644
index 226a78c..0000000
--- a/rt/lib/RT/Shredder/Principal.pm
+++ /dev/null
@@ -1,127 +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 }}}
-
-use RT::Principal ();
-package RT::Principal;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Exceptions;
-use RT::Shredder::Constants;
-use RT::Shredder::Dependencies;
-
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Group or User
-# Could be wiped allready
- my $obj = $self->Object;
- if( defined $obj->id ) {
- push( @$list, $obj );
- }
-
-# Access Control List
- my $objs = RT::ACL->new( $self->CurrentUser );
- $objs->Limit(
- FIELD => 'PrincipalId',
- OPERATOR => '=',
- VALUE => $self->Id
- );
- push( @$list, $objs );
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__DependsOn( %args );
-}
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
- my $obj = $self->Object;
- if( defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related ". $self->Type ." #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/rt/lib/RT/Shredder/Queue.pm b/rt/lib/RT/Shredder/Queue.pm
deleted file mode 100644
index 58904f1..0000000
--- a/rt/lib/RT/Shredder/Queue.pm
+++ /dev/null
@@ -1,107 +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 }}}
-
-use RT::Queue ();
-package RT::Queue;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Tickets
- my $objs = RT::Tickets->new( $self->CurrentUser );
- $objs->{'allow_deleted_search'} = 1;
- $objs->Limit( FIELD => 'Queue', VALUE => $self->Id );
- push( @$list, $objs );
-
-# Queue role groups( Cc, AdminCc )
- $objs = RT::Groups->new( $self->CurrentUser );
- $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role' );
- $objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
- push( @$list, $objs );
-
-# Scrips
- $objs = RT::Scrips->new( $self->CurrentUser );
- $objs->LimitToQueue( $self->id );
- push( @$list, $objs );
-
-# Templates
- $objs = $self->Templates;
- push( @$list, $objs );
-
-# Custom Fields
- $objs = RT::CustomFields->new( $self->CurrentUser );
- $objs->SetContextObject( $self );
- $objs->LimitToQueue( $self->id );
- push( @$list, $objs );
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__DependsOn( %args );
-}
-
-1;
diff --git a/rt/lib/RT/Shredder/Record.pm b/rt/lib/RT/Shredder/Record.pm
index 684176c..1e777ba 100644
--- a/rt/lib/RT/Shredder/Record.pm
+++ b/rt/lib/RT/Shredder/Record.pm
@@ -46,8 +46,8 @@
#
# END BPS TAGGED BLOCK }}}
-use RT::Record ();
package RT::Record;
+use RT::Record ();
use strict;
use warnings;
@@ -56,14 +56,6 @@ use warnings FATAL => 'redefine';
use RT::Shredder::Constants;
use RT::Shredder::Exceptions;
-=head2 _AsString
-
-Returns string in format ClassName-ObjectId.
-
-=cut
-
-sub _AsString { return ref($_[0]) ."-". $_[0]->id }
-
=head2 _AsInsertQuery
Returns INSERT query string that duplicates current record and
@@ -100,7 +92,7 @@ sub Dependencies
my $self = shift;
my %args = (
Shredder => undef,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
@_,
);
@@ -109,12 +101,9 @@ sub Dependencies
}
my $deps = RT::Shredder::Dependencies->new();
- if( $args{'Flags'} & DEPENDS_ON ) {
+ if( $args{'Flags'} & RT::Shredder::Constants::DEPENDS_ON ) {
$self->__DependsOn( %args, Dependencies => $deps );
}
- if( $args{'Flags'} & RELATES ) {
- $self->__Relates( %args, Dependencies => $deps );
- }
return $deps;
}
@@ -145,12 +134,13 @@ sub __DependsOn
push( @$list, $objs );
# Links
- if ( $self->can('_Links') ) {
- # XXX: We don't use Links->Next as it's dies when object
- # is linked to object that doesn't exist
- # also, ->Next skip links to deleted tickets :(
+ 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( $_ );
+ my $objs = $self->Links( $_ );
$objs->_DoSearch;
push @$list, $objs->ItemsArrayRef;
}
@@ -163,111 +153,22 @@ sub __DependsOn
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
return;
}
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
- if( $self->_Accessible( 'Creator', 'read' ) ) {
- my $obj = RT::Principal->new( $self->CurrentUser );
- $obj->Load( $self->Creator );
-
- if( $obj && defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- push @{ $rec->{'Description'} },
- "Have no related User(Creator) #". $self->Creator ." object";
- }
- }
-
- if( $self->_Accessible( 'LastUpdatedBy', 'read' ) ) {
- my $obj = RT::Principal->new( $self->CurrentUser );
- $obj->Load( $self->LastUpdatedBy );
-
- if( $obj && defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- push @{ $rec->{'Description'} },
- "Have no related User(LastUpdatedBy) #". $self->LastUpdatedBy ." object";
- }
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-
- # cause of this $self->SUPER::__Relates should be called last
- # in overridden subs
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $rec->{'State'} |= VALID unless( $rec->{'State'} & INVALID );
-
- return;
-}
-
# implement proxy method because some RT classes
# override Delete method
sub __Wipeout
{
my $self = shift;
- my $msg = $self->_AsString ." wiped out";
+ my $msg = $self->UID ." wiped out";
$self->SUPER::Delete;
$RT::Logger->info( $msg );
return;
}
-sub ValidateRelations
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- @_
- );
- unless( $args{'Shredder'} ) {
- $args{'Shredder'} = RT::Shredder->new();
- }
-
- my $rec = $args{'Shredder'}->PutObject( Object => $self );
- return if( $rec->{'State'} & VALID );
- $self = $rec->{'Object'};
-
- $self->_ValidateRelations( %args, Flags => RELATES );
- $rec->{'State'} |= VALID unless( $rec->{'State'} & INVALID );
-
- return;
-}
-
-sub _ValidateRelations
-{
- my $self = shift;
- my %args = ( @_ );
-
- my $deps = $self->Dependencies( %args );
-
- $deps->ValidateRelations( %args );
-
- return;
-}
-
1;
diff --git a/rt/lib/RT/Shredder/Scrip.pm b/rt/lib/RT/Shredder/Scrip.pm
deleted file mode 100644
index c3a1e7d..0000000
--- a/rt/lib/RT/Shredder/Scrip.pm
+++ /dev/null
@@ -1,130 +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 }}}
-
-use RT::Scrip ();
-package RT::Scrip;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# No dependencies that should be deleted with record
-# Scrip actions and conditions should be exported in feature with it.
-
- return $self->SUPER::__DependsOn( %args );
-}
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Queue
- my $obj = $self->QueueObj;
- if( defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related Queue #". $self->id ." object";
- }
-
-# Condition
- $obj = $self->ConditionObj;
- if( defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related ScripCondition #". $self->id ." object";
- }
-# Action
- $obj = $self->ActionObj;
- if( defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related ScripAction #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/rt/lib/RT/Shredder/ScripAction.pm b/rt/lib/RT/Shredder/ScripAction.pm
deleted file mode 100644
index baa3d2a..0000000
--- a/rt/lib/RT/Shredder/ScripAction.pm
+++ /dev/null
@@ -1,100 +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 }}}
-
-use RT::ScripAction ();
-package RT::ScripAction;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Scrips
- my $objs = RT::Scrips->new( $self->CurrentUser );
- $objs->Limit( FIELD => 'ScripAction', VALUE => $self->Id );
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON,
- TargetObjects => $objs,
- Shredder => $args{'Shredder'}
- );
-
- return $self->SUPER::__DependsOn( %args );
-}
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# TODO: Check here for exec module
-
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/rt/lib/RT/Shredder/ScripCondition.pm b/rt/lib/RT/Shredder/ScripCondition.pm
deleted file mode 100644
index 9598b43..0000000
--- a/rt/lib/RT/Shredder/ScripCondition.pm
+++ /dev/null
@@ -1,101 +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 }}}
-
-use RT::ScripCondition ();
-package RT::ScripCondition;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Scrips
- my $objs = RT::Scrips->new( $self->CurrentUser );
- $objs->Limit( FIELD => 'ScripCondition', VALUE => $self->Id );
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON,
- TargetObjects => $objs,
- Shredder => $args{'Shredder'}
- );
-
- return $self->SUPER::__DependsOn( %args );
-}
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# TODO: Check here for exec module
-
- return $self->SUPER::__Relates( %args );
-}
-
-
-1;
diff --git a/rt/lib/RT/Shredder/Template.pm b/rt/lib/RT/Shredder/Template.pm
deleted file mode 100644
index a23477e..0000000
--- a/rt/lib/RT/Shredder/Template.pm
+++ /dev/null
@@ -1,120 +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 }}}
-
-use RT::Template ();
-package RT::Template;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
-
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Scrips
- my $objs = RT::Scrips->new( $self->CurrentUser );
- $objs->Limit( FIELD => 'Template', VALUE => $self->Id );
- push( @$list, $objs );
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'},
- );
-
- return $self->SUPER::__DependsOn( %args );
-}
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Queue
- my $obj = $self->QueueObj;
- if( $obj && defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related Queue #". $self->id ." object";
- }
-
-# TODO: Users(Creator, LastUpdatedBy)
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/rt/lib/RT/Shredder/Ticket.pm b/rt/lib/RT/Shredder/Ticket.pm
deleted file mode 100644
index d34131b..0000000
--- a/rt/lib/RT/Shredder/Ticket.pm
+++ /dev/null
@@ -1,126 +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 }}}
-
-use RT::Ticket ();
-package RT::Ticket;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Tickets which were merged in
- my $objs = RT::Tickets->new( $self->CurrentUser );
- $objs->{'allow_deleted_search'} = 1;
- $objs->Limit( FIELD => 'EffectiveId', VALUE => $self->Id );
- $objs->Limit( FIELD => 'id', OPERATOR => '!=', VALUE => $self->Id );
- push( @$list, $objs );
-
-# Ticket role groups( Owner, Requestors, Cc, AdminCc )
- $objs = RT::Groups->new( $self->CurrentUser );
- $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Ticket-Role' );
- $objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
- push( @$list, $objs );
-
-#TODO: Users, Queues if we wish export tool
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-
- return $self->SUPER::__DependsOn( %args );
-}
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Queue
- my $obj = $self->QueueObj;
- if( $obj && defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related Queue #". $self->Queue ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/rt/lib/RT/Shredder/Transaction.pm b/rt/lib/RT/Shredder/Transaction.pm
deleted file mode 100644
index a8593c6..0000000
--- a/rt/lib/RT/Shredder/Transaction.pm
+++ /dev/null
@@ -1,115 +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 }}}
-
-use RT::Transaction ();
-package RT::Transaction;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Attachments
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON,
- TargetObjects => $self->Attachments,
- Shredder => $args{'Shredder'}
- );
-
- return $self->SUPER::__DependsOn( %args );
-}
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Ticket
- my $obj = $self->TicketObj;
- if( $obj && defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related Ticket #". $self->id ." object";
- }
-
-# TODO: Users(Creator, LastUpdatedBy)
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/rt/lib/RT/Shredder/User.pm b/rt/lib/RT/Shredder/User.pm
deleted file mode 100644
index cf001a8..0000000
--- a/rt/lib/RT/Shredder/User.pm
+++ /dev/null
@@ -1,191 +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 }}}
-
-use RT::User ();
-package RT::User;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
-
-my @OBJECTS = qw(
- Attachments
- CachedGroupMembers
- CustomFields
- CustomFieldValues
- GroupMembers
- Groups
- Links
- Principals
- Queues
- ScripActions
- ScripConditions
- Scrips
- Templates
- ObjectCustomFieldValues
- Tickets
- Transactions
- Users
-);
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Principal
- $deps->_PushDependency(
- BaseObject => $self,
- Flags => DEPENDS_ON | WIPE_AFTER,
- TargetObject => $self->PrincipalObj,
- Shredder => $args{'Shredder'}
- );
-
-# ACL equivalence group
-# don't use LoadACLEquivalenceGroup cause it may not exists any more
- my $objs = RT::Groups->new( $self->CurrentUser );
- $objs->Limit( FIELD => 'Domain', VALUE => 'ACLEquivalence' );
- $objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
- push( @$list, $objs );
-
-# Cleanup user's membership
- $objs = RT::GroupMembers->new( $self->CurrentUser );
- $objs->Limit( FIELD => 'MemberId', VALUE => $self->Id );
- push( @$list, $objs );
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-
-# TODO: Almost all objects has Creator, LastUpdatedBy and etc. fields
-# which are references on users(Principal actualy)
- my @var_objs;
- foreach( @OBJECTS ) {
- my $class = "RT::$_";
- foreach my $method ( qw(Creator LastUpdatedBy) ) {
- my $objs = $class->new( $self->CurrentUser );
- next unless $objs->NewItem->_Accessible( $method => 'read' );
- $objs->Limit( FIELD => $method, VALUE => $self->id );
- push @var_objs, $objs;
- }
- }
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => DEPENDS_ON | VARIABLE,
- TargetObjects => \@var_objs,
- Shredder => $args{'Shredder'}
- );
-
- return $self->SUPER::__DependsOn( %args );
-}
-
-sub __Relates
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Principal
- my $obj = $self->PrincipalObj;
- if( $obj && defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related ACL equivalence Group object";
- }
-
- $obj = RT::Group->new( RT->SystemUser );
- $obj->LoadACLEquivalenceGroup( $self->PrincipalObj );
- if( $obj && defined $obj->id ) {
- push( @$list, $obj );
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-sub BeforeWipeout
-{
- my $self = shift;
- if( $self->Name =~ /^(RT_System|Nobody)$/ ) {
- RT::Shredder::Exception::Info->throw('SystemObject');
- }
- return $self->SUPER::BeforeWipeout( @_ );
-}
-
-1;