[Rt-commit] rt branch, 4.2/merge-shredder-overlays, created. rt-4.0.1-408-gd290d60
Alex Vandiver
alexmv at bestpractical.com
Tue Aug 16 16:31:58 EDT 2011
The branch, 4.2/merge-shredder-overlays has been created
at d290d606ab2608c51d232bd0ae189bb5c81d1d3b (commit)
- Log -----------------------------------------------------------------
commit 19a4e5c504eda3b805ba33fd05c645b5964fcd84
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue Aug 16 14:33:23 2011 -0400
Pack bitmask constants more densely
diff --git a/lib/RT/Shredder/Constants.pm b/lib/RT/Shredder/Constants.pm
index 430be25..ec9cb56 100644
--- a/lib/RT/Shredder/Constants.pm
+++ b/lib/RT/Shredder/Constants.pm
@@ -93,10 +93,10 @@ exist.
=cut
use constant {
- DEPENDS_ON => 0x000001,
- WIPE_AFTER => 0x000010,
- RELATES => 0x000100,
- VARIABLE => 0x001000,
+ DEPENDS_ON => 0x01,
+ WIPE_AFTER => 0x02,
+ RELATES => 0x04,
+ VARIABLE => 0x08,
};
=head1 STATES
@@ -122,11 +122,11 @@ are valid.
=cut
use constant {
- ON_STACK => 0x00000,
- IN_WIPING => 0x00001,
- WIPED => 0x00010,
- VALID => 0x00100,
- INVALID => 0x01000,
+ ON_STACK => 0x00,
+ IN_WIPING => 0x01,
+ WIPED => 0x02,
+ VALID => 0x04,
+ INVALID => 0x08,
};
our @EXPORT = qw(
commit 920c48abd1585ccc0a9b6fb28a50c8032d066413
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue Aug 16 14:34:19 2011 -0400
Make two bitfields not overlap, to reduce changes of mixing them
diff --git a/lib/RT/Shredder/Constants.pm b/lib/RT/Shredder/Constants.pm
index ec9cb56..1dff449 100644
--- a/lib/RT/Shredder/Constants.pm
+++ b/lib/RT/Shredder/Constants.pm
@@ -93,10 +93,10 @@ exist.
=cut
use constant {
- DEPENDS_ON => 0x01,
- WIPE_AFTER => 0x02,
- RELATES => 0x04,
- VARIABLE => 0x08,
+ DEPENDS_ON => 0x001,
+ WIPE_AFTER => 0x002,
+ RELATES => 0x004,
+ VARIABLE => 0x008,
};
=head1 STATES
@@ -122,11 +122,11 @@ are valid.
=cut
use constant {
- ON_STACK => 0x00,
- IN_WIPING => 0x01,
- WIPED => 0x02,
- VALID => 0x04,
- INVALID => 0x08,
+ ON_STACK => 0x000,
+ IN_WIPING => 0x010,
+ WIPED => 0x020,
+ VALID => 0x040,
+ INVALID => 0x080,
};
our @EXPORT = qw(
commit d95a0e75f54069ee297696f1550e71441f4cdc34
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue Aug 16 14:34:48 2011 -0400
Make shredder constants no longer exported
This pollutes their namespace less, in preparation for moving __Relates
and __DependsOn into the main RT object packages
diff --git a/lib/RT/Shredder.pm b/lib/RT/Shredder.pm
index 8648bdc..c2f265a 100644
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@ -416,7 +416,10 @@ sub PutObject
}
my $str = $obj->_AsString;
- return ($self->{'cache'}->{ $str } ||= { State => ON_STACK, Object => $obj } );
+ return ($self->{'cache'}->{ $str } ||= {
+ State => RT::Shredder::Constants::ON_STACK,
+ Object => $obj
+ } );
}
=head4 GetObject, GetState, GetRecord( String => ''| Object => '' )
@@ -538,7 +541,7 @@ sub WipeoutAll
my $self = $_[0];
while ( my ($k, $v) = each %{ $self->{'cache'} } ) {
- next if $v->{'State'} & (WIPED | IN_WIPING);
+ next if $v->{'State'} & (RT::Shredder::Constants::WIPED | RT::Shredder::Constants::IN_WIPING);
$self->Wipeout( Object => $v->{'Object'} );
}
}
@@ -570,9 +573,9 @@ sub _Wipeout
my $record = $args{'CacheRecord'};
$record = $self->PutObject( Object => $args{'Object'} ) unless $record;
- return if $record->{'State'} & (WIPED | IN_WIPING);
+ return if $record->{'State'} & (RT::Shredder::Constants::WIPED | RT::Shredder::Constants::IN_WIPING);
- $record->{'State'} |= IN_WIPING;
+ $record->{'State'} |= RT::Shredder::Constants::IN_WIPING;
my $object = $record->{'Object'};
$self->DumpObject( Object => $object, State => 'before any action' );
@@ -583,25 +586,25 @@ sub _Wipeout
my $deps = $object->Dependencies( Shredder => $self );
$deps->List(
- WithFlags => DEPENDS_ON | VARIABLE,
+ WithFlags => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::VARIABLE,
Callback => sub { $self->ApplyResolvers( Dependency => $_[0] ) },
);
$self->DumpObject( Object => $object, State => 'after resolvers' );
$deps->List(
- WithFlags => DEPENDS_ON,
- WithoutFlags => WIPE_AFTER | VARIABLE,
+ WithFlags => RT::Shredder::Constants::DEPENDS_ON,
+ WithoutFlags => RT::Shredder::Constants::WIPE_AFTER | RT::Shredder::Constants::VARIABLE,
Callback => sub { $self->_Wipeout( Object => $_[0]->TargetObject ) },
);
$self->DumpObject( Object => $object, State => 'after wiping dependencies' );
$object->__Wipeout;
- $record->{'State'} |= WIPED; delete $record->{'Object'};
+ $record->{'State'} |= RT::Shredder::Constants::WIPED; delete $record->{'Object'};
$self->DumpObject( Object => $object, State => 'after wipeout' );
$deps->List(
- WithFlags => DEPENDS_ON | WIPE_AFTER,
- WithoutFlags => VARIABLE,
+ WithFlags => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::WIPE_AFTER,
+ WithoutFlags => RT::Shredder::Constants::VARIABLE,
Callback => sub { $self->_Wipeout( Object => $_[0]->TargetObject ) },
);
$self->DumpObject( Object => $object, State => 'after late dependencies' );
@@ -615,7 +618,7 @@ sub ValidateRelations
my %args = ( @_ );
foreach my $record( values %{ $self->{'cache'} } ) {
- next if( $record->{'State'} & VALID );
+ next if( $record->{'State'} & RT::Shredder::Constants::VALID );
$record->{'Object'}->ValidateRelations( Shredder => $self );
}
}
diff --git a/lib/RT/Shredder/ACE.pm b/lib/RT/Shredder/ACE.pm
index 7a70c89..e71c037 100644
--- a/lib/RT/Shredder/ACE.pm
+++ b/lib/RT/Shredder/ACE.pm
@@ -71,7 +71,7 @@ sub __DependsOn
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
@@ -91,7 +91,7 @@ sub __Relates
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/Attachment.pm b/lib/RT/Shredder/Attachment.pm
index a15199e..dcf3975 100644
--- a/lib/RT/Shredder/Attachment.pm
+++ b/lib/RT/Shredder/Attachment.pm
@@ -84,7 +84,7 @@ sub __DependsOn
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
@@ -109,7 +109,7 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no parent attachment #". $self->Parent ." object";
}
}
@@ -121,13 +121,13 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related transaction #". $self->TransactionId ." object";
}
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/CachedGroupMember.pm b/lib/RT/Shredder/CachedGroupMember.pm
index 0a6f253..4fce299 100644
--- a/lib/RT/Shredder/CachedGroupMember.pm
+++ b/lib/RT/Shredder/CachedGroupMember.pm
@@ -90,7 +90,7 @@ sub __DependsOn
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
@@ -118,7 +118,7 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related Principal #". $self->MemberId ." object.";
}
@@ -128,13 +128,13 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related Principal #". $self->GroupId ." object.";
}
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/Constants.pm b/lib/RT/Shredder/Constants.pm
index 1dff449..65d164b 100644
--- a/lib/RT/Shredder/Constants.pm
+++ b/lib/RT/Shredder/Constants.pm
@@ -51,8 +51,6 @@ 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.
@@ -129,16 +127,4 @@ use constant {
INVALID => 0x080,
};
-our @EXPORT = qw(
- DEPENDS_ON
- WIPE_AFTER
- RELATES
- VARIABLE
- ON_STACK
- IN_WIPING
- WIPED
- VALID
- INVALID
- );
-
1;
diff --git a/lib/RT/Shredder/CustomField.pm b/lib/RT/Shredder/CustomField.pm
index 49a8a3b..c24c29f 100644
--- a/lib/RT/Shredder/CustomField.pm
+++ b/lib/RT/Shredder/CustomField.pm
@@ -80,7 +80,7 @@ sub __DependsOn
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
@@ -108,14 +108,14 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related queue #". $self->Queue ." object";
}
}
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/CustomFieldValue.pm b/lib/RT/Shredder/CustomFieldValue.pm
index 347379c..4bd9db5 100644
--- a/lib/RT/Shredder/CustomFieldValue.pm
+++ b/lib/RT/Shredder/CustomFieldValue.pm
@@ -78,13 +78,13 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related CustomField #". $self->id ." object";
}
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/Dependencies.pm b/lib/RT/Shredder/Dependencies.pm
index 753364f..e6c4a46 100644
--- a/lib/RT/Shredder/Dependencies.pm
+++ b/lib/RT/Shredder/Dependencies.pm
@@ -106,7 +106,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/lib/RT/Shredder/Dependency.pm b/lib/RT/Shredder/Dependency.pm
index 1de1a93..bb27aa5 100644
--- a/lib/RT/Shredder/Dependency.pm
+++ b/lib/RT/Shredder/Dependency.pm
@@ -53,10 +53,10 @@ 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',
+ RT::Shredder::Constants::RELATES, 'relates with',
);
sub new
@@ -70,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 };
diff --git a/lib/RT/Shredder/Group.pm b/lib/RT/Shredder/Group.pm
index 44aa9f4..0091e04 100644
--- a/lib/RT/Shredder/Group.pm
+++ b/lib/RT/Shredder/Group.pm
@@ -77,7 +77,7 @@ sub __DependsOn
$objs->Load( $self->Instance );
$deps->_PushDependency(
BaseObject => $self,
- Flags => DEPENDS_ON | WIPE_AFTER,
+ Flags => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::WIPE_AFTER,
TargetObject => $objs,
Shredder => $args{'Shredder'}
);
@@ -86,7 +86,7 @@ sub __DependsOn
# Principal
$deps->_PushDependency(
BaseObject => $self,
- Flags => DEPENDS_ON | WIPE_AFTER,
+ Flags => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::WIPE_AFTER,
TargetObject => $self->PrincipalObj,
Shredder => $args{'Shredder'}
);
@@ -121,7 +121,7 @@ sub __DependsOn
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
@@ -148,7 +148,7 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "ACLEguvivalence group have no related User #". $self->Instance ." object.";
}
}
@@ -160,13 +160,13 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related Principal #". $self->id ." object.";
}
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/GroupMember.pm b/lib/RT/Shredder/GroupMember.pm
index 2710887..8ac80c4 100644
--- a/lib/RT/Shredder/GroupMember.pm
+++ b/lib/RT/Shredder/GroupMember.pm
@@ -79,7 +79,7 @@ sub __DependsOn
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
@@ -95,7 +95,7 @@ sub __DependsOn
# we don't delete group, so we have to fix Ticket and Group
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON | VARIABLE,
+ Flags => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::VARIABLE,
TargetObjects => $group,
Shredder => $args{'Shredder'}
);
@@ -105,7 +105,8 @@ sub __DependsOn
Code => sub {
my %args = (@_);
my $group = $args{'TargetObject'};
- return if $args{'Shredder'}->GetState( Object => $group ) & (WIPED|IN_WIPING);
+ return if $args{'Shredder'}->GetState( Object => $group )
+ & (RT::Shredder::Constants::WIPED|RT::Shredder::Constants::IN_WIPING);
return unless ($group->Type || '') eq 'Owner';
return unless ($group->Domain || '') eq 'RT::Ticket-Role';
@@ -157,7 +158,7 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related Principal #". $self->MemberId ." object.";
}
@@ -167,13 +168,13 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related Principal #". $self->GroupId ." object.";
}
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/Link.pm b/lib/RT/Shredder/Link.pm
index 4517f7f..d226749 100644
--- a/lib/RT/Shredder/Link.pm
+++ b/lib/RT/Shredder/Link.pm
@@ -112,7 +112,7 @@ sub __DependsOn
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON|WIPE_AFTER,
+ Flags => RT::Shredder::Constants::DEPENDS_ON|RT::Shredder::Constants::WIPE_AFTER,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/ObjectCustomFieldValue.pm b/lib/RT/Shredder/ObjectCustomFieldValue.pm
index 449063d..9d52d6f 100644
--- a/lib/RT/Shredder/ObjectCustomFieldValue.pm
+++ b/lib/RT/Shredder/ObjectCustomFieldValue.pm
@@ -89,7 +89,7 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related Ticket #". $self->id ." object";
}
@@ -100,13 +100,13 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related CustomField #". $self->id ." object";
}
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/Principal.pm b/lib/RT/Shredder/Principal.pm
index cd75f75..3f69191 100644
--- a/lib/RT/Shredder/Principal.pm
+++ b/lib/RT/Shredder/Principal.pm
@@ -87,7 +87,7 @@ sub __DependsOn
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
@@ -111,13 +111,13 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related ". $self->Type ." #". $self->id ." object";
}
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/Queue.pm b/lib/RT/Shredder/Queue.pm
index 8ee1094..f0a0611 100644
--- a/lib/RT/Shredder/Queue.pm
+++ b/lib/RT/Shredder/Queue.pm
@@ -96,7 +96,7 @@ sub __DependsOn
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/Record.pm b/lib/RT/Shredder/Record.pm
index 17e1179..931a1f1 100644
--- a/lib/RT/Shredder/Record.pm
+++ b/lib/RT/Shredder/Record.pm
@@ -100,7 +100,7 @@ sub Dependencies
my $self = shift;
my %args = (
Shredder => undef,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
@_,
);
@@ -109,10 +109,10 @@ 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 ) {
+ if( $args{'Flags'} & RT::Shredder::Constants::RELATES ) {
$self->__Relates( %args, Dependencies => $deps );
}
return $deps;
@@ -163,7 +163,7 @@ sub __DependsOn
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
@@ -190,7 +190,7 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
push @{ $rec->{'Description'} },
"Have no related User(Creator) #". $self->Creator ." object";
}
@@ -205,7 +205,7 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
push @{ $rec->{'Description'} },
"Have no related User(LastUpdatedBy) #". $self->LastUpdatedBy ." object";
}
@@ -213,7 +213,7 @@ sub __Relates
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
@@ -221,7 +221,8 @@ sub __Relates
# 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 );
+ $rec->{'State'} |= RT::Shredder::Constants::VALID
+ unless $rec->{'State'} & RT::Shredder::Constants::INVALID;
return;
}
@@ -249,11 +250,11 @@ sub ValidateRelations
}
my $rec = $args{'Shredder'}->PutObject( Object => $self );
- return if( $rec->{'State'} & VALID );
+ return if( $rec->{'State'} & RT::Shredder::Constants::VALID );
$self = $rec->{'Object'};
- $self->_ValidateRelations( %args, Flags => RELATES );
- $rec->{'State'} |= VALID unless( $rec->{'State'} & INVALID );
+ $self->_ValidateRelations( %args, Flags => RT::Shredder::Constants::RELATES );
+ $rec->{'State'} |= RT::Shredder::Constants::VALID unless( $rec->{'State'} & RT::Shredder::Constants::INVALID );
return;
}
diff --git a/lib/RT/Shredder/Scrip.pm b/lib/RT/Shredder/Scrip.pm
index 9d4a8f4..a71dff3 100644
--- a/lib/RT/Shredder/Scrip.pm
+++ b/lib/RT/Shredder/Scrip.pm
@@ -92,7 +92,7 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related Queue #". $self->id ." object";
}
@@ -103,7 +103,7 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related ScripCondition #". $self->id ." object";
}
# Action
@@ -113,13 +113,13 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related ScripAction #". $self->id ." object";
}
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/ScripAction.pm b/lib/RT/Shredder/ScripAction.pm
index 34c748f..37f560c 100644
--- a/lib/RT/Shredder/ScripAction.pm
+++ b/lib/RT/Shredder/ScripAction.pm
@@ -73,7 +73,7 @@ sub __DependsOn
$objs->Limit( FIELD => 'ScripAction', VALUE => $self->Id );
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $objs,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/ScripCondition.pm b/lib/RT/Shredder/ScripCondition.pm
index 8349418..14af639 100644
--- a/lib/RT/Shredder/ScripCondition.pm
+++ b/lib/RT/Shredder/ScripCondition.pm
@@ -73,7 +73,7 @@ sub __DependsOn
$objs->Limit( FIELD => 'ScripCondition', VALUE => $self->Id );
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $objs,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/Template.pm b/lib/RT/Shredder/Template.pm
index 9a01332..0feda6c 100644
--- a/lib/RT/Shredder/Template.pm
+++ b/lib/RT/Shredder/Template.pm
@@ -76,7 +76,7 @@ sub __DependsOn
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $list,
Shredder => $args{'Shredder'},
);
@@ -102,7 +102,7 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related Queue #". $self->id ." object";
}
@@ -110,7 +110,7 @@ sub __Relates
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/Ticket.pm b/lib/RT/Shredder/Ticket.pm
index cd8e82f..c2bca88 100644
--- a/lib/RT/Shredder/Ticket.pm
+++ b/lib/RT/Shredder/Ticket.pm
@@ -84,7 +84,7 @@ sub __DependsOn
#TODO: Users, Queues if we wish export tool
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
@@ -110,13 +110,13 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related Queue #". $self->Queue ." object";
}
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/Transaction.pm b/lib/RT/Shredder/Transaction.pm
index df0ac74..55be62e 100644
--- a/lib/RT/Shredder/Transaction.pm
+++ b/lib/RT/Shredder/Transaction.pm
@@ -71,7 +71,7 @@ sub __DependsOn
# Attachments
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $self->Attachments,
Shredder => $args{'Shredder'}
);
@@ -97,7 +97,7 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related Ticket #". $self->id ." object";
}
@@ -105,7 +105,7 @@ sub __Relates
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
diff --git a/lib/RT/Shredder/User.pm b/lib/RT/Shredder/User.pm
index 5267575..ae1b037 100644
--- a/lib/RT/Shredder/User.pm
+++ b/lib/RT/Shredder/User.pm
@@ -91,7 +91,7 @@ sub __DependsOn
# Principal
$deps->_PushDependency(
BaseObject => $self,
- Flags => DEPENDS_ON | WIPE_AFTER,
+ Flags => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::WIPE_AFTER,
TargetObject => $self->PrincipalObj,
Shredder => $args{'Shredder'}
);
@@ -110,7 +110,7 @@ sub __DependsOn
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
@@ -129,7 +129,7 @@ sub __DependsOn
}
$deps->_PushDependencies(
BaseObject => $self,
- Flags => DEPENDS_ON | VARIABLE,
+ Flags => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::VARIABLE,
TargetObjects => \@var_objs,
Shredder => $args{'Shredder'}
);
@@ -155,7 +155,7 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related ACL equivalence Group object";
}
@@ -166,13 +166,13 @@ sub __Relates
} else {
my $rec = $args{'Shredder'}->GetRecord( Object => $self );
$self = $rec->{'Object'};
- $rec->{'State'} |= INVALID;
+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
$rec->{'Description'} = "Have no related Principal #". $self->id ." object";
}
$deps->_PushDependencies(
BaseObject => $self,
- Flags => RELATES,
+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
commit eab8107c3449992f3ff5fabbb94b7dff53cb8a20
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue Aug 16 14:59:26 2011 -0400
Merge RT::Shredder::Record into RT::Record
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index fcc7bed..66592f4 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -67,9 +67,13 @@ use strict;
use warnings;
+use RT::Link;
use RT::Date;
use RT::User;
+use RT::Transactions;
use RT::Attributes;
+use RT::Shredder::Constants;
+use RT::Shredder::Exceptions;
use Encode qw();
our $_TABLE_ATTR = { };
@@ -514,7 +518,6 @@ It takes no options. Arguably, this is a bug
sub _SetLastUpdated {
my $self = shift;
- use RT::Date;
my $now = RT::Date->new( $self->CurrentUser );
$now->SetToNow();
@@ -1296,7 +1299,6 @@ sub _AddLink {
}
# Check if the link already exists - we don't want duplicates
- use RT::Link;
my $old_link = RT::Link->new( $self->CurrentUser );
$old_link->LoadByParams( Base => $args{'Base'},
Type => $args{'Type'},
@@ -1489,7 +1491,6 @@ sub _NewTransaction {
sub Transactions {
my $self = shift;
- use RT::Transactions;
my $transactions = RT::Transactions->new( $self->CurrentUser );
#If the user has no rights, return an empty object
@@ -1937,6 +1938,221 @@ sub WikiBase {
return RT->Config->Get('WebPath'). "/index.html?q=";
}
+=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
+can be used to insert record back into DB after delete.
+
+=cut
+
+sub _AsInsertQuery
+{
+ my $self = shift;
+
+ my $dbh = $RT::Handle->dbh;
+
+ my $res = "INSERT INTO ". $dbh->quote_identifier( $self->Table );
+ my $values = $self->{'values'};
+ $res .= "(". join( ",", map { $dbh->quote_identifier( $_ ) } sort keys %$values ) .")";
+ $res .= " VALUES";
+ $res .= "(". join( ",", map { $dbh->quote( $values->{$_} ) } sort keys %$values ) .")";
+ $res .= ";";
+
+ return $res;
+}
+
+sub BeforeWipeout { return 1 }
+
+=head2 Dependencies
+
+Returns L<RT::Shredder::Dependencies> object.
+
+=cut
+
+sub Dependencies
+{
+ my $self = shift;
+ my %args = (
+ Shredder => undef,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
+ @_,
+ );
+
+ unless( $self->id ) {
+ RT::Shredder::Exception->throw('Object is not loaded');
+ }
+
+ my $deps = RT::Shredder::Dependencies->new();
+ if( $args{'Flags'} & RT::Shredder::Constants::DEPENDS_ON ) {
+ $self->__DependsOn( %args, Dependencies => $deps );
+ }
+ if( $args{'Flags'} & RT::Shredder::Constants::RELATES ) {
+ $self->__Relates( %args, Dependencies => $deps );
+ }
+ return $deps;
+}
+
+sub __DependsOn
+{
+ my $self = shift;
+ my %args = (
+ Shredder => undef,
+ Dependencies => undef,
+ @_,
+ );
+ my $deps = $args{'Dependencies'};
+ my $list = [];
+
+# Object custom field values
+ my $objs = $self->CustomFieldValues;
+ $objs->{'find_expired_rows'} = 1;
+ push( @$list, $objs );
+
+# Object attributes
+ $objs = $self->Attributes;
+ push( @$list, $objs );
+
+# Transactions
+ $objs = RT::Transactions->new( $self->CurrentUser );
+ $objs->Limit( FIELD => 'ObjectType', VALUE => ref $self );
+ $objs->Limit( FIELD => 'ObjectId', VALUE => $self->id );
+ push( @$list, $objs );
+
+# Links
+ if ( $self->can('_Links') ) {
+ # 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 :(
+ foreach ( qw(Base Target) ) {
+ my $objs = $self->_Links( $_ );
+ $objs->_DoSearch;
+ push @$list, $objs->ItemsArrayRef;
+ }
+ }
+
+# ACE records
+ $objs = RT::ACL->new( $self->CurrentUser );
+ $objs->LimitToObject( $self );
+ push( @$list, $objs );
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
+ return;
+}
+
+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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
+ push @{ $rec->{'Description'} },
+ "Have no related User(LastUpdatedBy) #". $self->LastUpdatedBy ." object";
+ }
+ }
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::VALID
+ unless $rec->{'State'} & RT::Shredder::Constants::INVALID;
+
+ return;
+}
+
+# implement proxy method because some RT classes
+# override Delete method
+sub __Wipeout
+{
+ my $self = shift;
+ my $msg = $self->_AsString ." 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'} & RT::Shredder::Constants::VALID );
+ $self = $rec->{'Object'};
+
+ $self->_ValidateRelations( %args, Flags => RT::Shredder::Constants::RELATES );
+ $rec->{'State'} |= RT::Shredder::Constants::VALID unless( $rec->{'State'} & RT::Shredder::Constants::INVALID );
+
+ return;
+}
+
+sub _ValidateRelations
+{
+ my $self = shift;
+ my %args = ( @_ );
+
+ my $deps = $self->Dependencies( %args );
+
+ $deps->ValidateRelations( %args );
+
+ return;
+}
+
RT::Base->_ImportOverlays();
1;
diff --git a/lib/RT/Shredder.pm b/lib/RT/Shredder.pm
index c2f265a..6948903 100644
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@ -210,8 +210,6 @@ BEGIN {
require RT;
- require RT::Shredder::Record;
-
require RT::Shredder::ACE;
require RT::Shredder::Attachment;
require RT::Shredder::CachedGroupMember;
diff --git a/lib/RT/Shredder/Link.pm b/lib/RT/Shredder/Link.pm
index d226749..490ef17 100644
--- a/lib/RT/Shredder/Link.pm
+++ b/lib/RT/Shredder/Link.pm
@@ -58,7 +58,6 @@ use RT::Shredder::Dependencies;
use RT::Shredder::Constants;
use RT::Shredder::Transaction;
-use RT::Shredder::Record;
sub __DependsOn
{
diff --git a/lib/RT/Shredder/Record.pm b/lib/RT/Shredder/Record.pm
deleted file mode 100644
index 931a1f1..0000000
--- a/lib/RT/Shredder/Record.pm
+++ /dev/null
@@ -1,274 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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::Record ();
-package RT::Record;
-
-use strict;
-use warnings;
-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
-can be used to insert record back into DB after delete.
-
-=cut
-
-sub _AsInsertQuery
-{
- my $self = shift;
-
- my $dbh = $RT::Handle->dbh;
-
- my $res = "INSERT INTO ". $dbh->quote_identifier( $self->Table );
- my $values = $self->{'values'};
- $res .= "(". join( ",", map { $dbh->quote_identifier( $_ ) } sort keys %$values ) .")";
- $res .= " VALUES";
- $res .= "(". join( ",", map { $dbh->quote( $values->{$_} ) } sort keys %$values ) .")";
- $res .= ";";
-
- return $res;
-}
-
-sub BeforeWipeout { return 1 }
-
-=head2 Dependencies
-
-Returns L<RT::Shredder::Dependencies> object.
-
-=cut
-
-sub Dependencies
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Flags => RT::Shredder::Constants::DEPENDS_ON,
- @_,
- );
-
- unless( $self->id ) {
- RT::Shredder::Exception->throw('Object is not loaded');
- }
-
- my $deps = RT::Shredder::Dependencies->new();
- if( $args{'Flags'} & RT::Shredder::Constants::DEPENDS_ON ) {
- $self->__DependsOn( %args, Dependencies => $deps );
- }
- if( $args{'Flags'} & RT::Shredder::Constants::RELATES ) {
- $self->__Relates( %args, Dependencies => $deps );
- }
- return $deps;
-}
-
-sub __DependsOn
-{
- my $self = shift;
- my %args = (
- Shredder => undef,
- Dependencies => undef,
- @_,
- );
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-# Object custom field values
- my $objs = $self->CustomFieldValues;
- $objs->{'find_expired_rows'} = 1;
- push( @$list, $objs );
-
-# Object attributes
- $objs = $self->Attributes;
- push( @$list, $objs );
-
-# Transactions
- $objs = RT::Transactions->new( $self->CurrentUser );
- $objs->Limit( FIELD => 'ObjectType', VALUE => ref $self );
- $objs->Limit( FIELD => 'ObjectId', VALUE => $self->id );
- push( @$list, $objs );
-
-# Links
- if ( $self->can('_Links') ) {
- # 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 :(
- foreach ( qw(Base Target) ) {
- my $objs = $self->_Links( $_ );
- $objs->_DoSearch;
- push @$list, $objs->ItemsArrayRef;
- }
- }
-
-# ACE records
- $objs = RT::ACL->new( $self->CurrentUser );
- $objs->LimitToObject( $self );
- push( @$list, $objs );
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return;
-}
-
-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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
- push @{ $rec->{'Description'} },
- "Have no related User(LastUpdatedBy) #". $self->LastUpdatedBy ." object";
- }
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::VALID
- unless $rec->{'State'} & RT::Shredder::Constants::INVALID;
-
- return;
-}
-
-# implement proxy method because some RT classes
-# override Delete method
-sub __Wipeout
-{
- my $self = shift;
- my $msg = $self->_AsString ." 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'} & RT::Shredder::Constants::VALID );
- $self = $rec->{'Object'};
-
- $self->_ValidateRelations( %args, Flags => RT::Shredder::Constants::RELATES );
- $rec->{'State'} |= RT::Shredder::Constants::VALID unless( $rec->{'State'} & RT::Shredder::Constants::INVALID );
-
- return;
-}
-
-sub _ValidateRelations
-{
- my $self = shift;
- my %args = ( @_ );
-
- my $deps = $self->Dependencies( %args );
-
- $deps->ValidateRelations( %args );
-
- return;
-}
-
-1;
commit cd66cc7e46dbce611aed8dfd6fcbb692498916f9
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue Aug 16 15:23:15 2011 -0400
Add new object types which have Creator and LastUpdatedBy
diff --git a/lib/RT/Shredder/User.pm b/lib/RT/Shredder/User.pm
index ae1b037..96e25a5 100644
--- a/lib/RT/Shredder/User.pm
+++ b/lib/RT/Shredder/User.pm
@@ -58,20 +58,26 @@ use RT::Shredder::Exceptions;
use RT::Shredder::Dependencies;
my @OBJECTS = qw(
+ ACL
+ Articles
Attachments
+ Attributes
CachedGroupMembers
- CustomFields
+ Classes
CustomFieldValues
+ CustomFields
GroupMembers
Groups
Links
+ ObjectClasses
+ ObjectCustomFieldValues
+ ObjectCustomFields
Principals
Queues
ScripActions
ScripConditions
Scrips
Templates
- ObjectCustomFieldValues
Tickets
Transactions
Users
commit a1ba1d38b7da4f06fcc39b40be19e2437748850c
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue Aug 16 16:16:17 2011 -0400
Fold RT::Shredder code into core record classes
Previously, we blew methods into the main record classes at run-time
when RT::Shredder was loaded. Instead, fold them into the core instead;
the lazy-loading was a side-effect of the code having originally been
written as an extension, and is no longer necessary.
diff --git a/lib/RT/ACE.pm b/lib/RT/ACE.pm
index 90220cd..c36976f 100644
--- a/lib/RT/ACE.pm
+++ b/lib/RT/ACE.pm
@@ -742,7 +742,45 @@ sub _CoreAccessible {
{read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
}
-};
+}
+
+sub __DependsOn {
+ my $self = shift;
+ my %args = (
+ Shredder => undef,
+ Dependencies => undef,
+ @_,
+ );
+ my $deps = $args{'Dependencies'};
+ my $list = [];
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::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 => RT::Shredder::Constants::RELATES,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
+ return $self->SUPER::__Relates( %args );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
index 1feb632..af1cd4b 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -1044,7 +1044,82 @@ sub _CoreAccessible {
{read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
}
-};
+}
+
+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 => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
+ $rec->{'Description'} = "Have no related transaction #". $self->TransactionId ." object";
+ }
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::RELATES,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
+ return $self->SUPER::__Relates( %args );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/CachedGroupMember.pm b/lib/RT/CachedGroupMember.pm
index c6ef008..d683e0b 100644
--- a/lib/RT/CachedGroupMember.pm
+++ b/lib/RT/CachedGroupMember.pm
@@ -431,7 +431,84 @@ sub _CoreAccessible {
{read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
}
-};
+}
+
+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 => RT::Shredder::Constants::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->MemberObj;
+ if( $obj && $obj->id ) {
+ push( @$list, $obj );
+ } else {
+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
+ $self = $rec->{'Object'};
+ $rec->{'State'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
+ $rec->{'Description'} = "Have no related Principal #". $self->GroupId ." object.";
+ }
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::RELATES,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
+ return $self->SUPER::__Relates( %args );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index c7fdac0..c629674 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -1986,8 +1986,68 @@ sub _CoreAccessible {
{read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
}
-};
+}
+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 => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
+ $rec->{'Description'} = "Have no related queue #". $self->Queue ." object";
+ }
+ }
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::RELATES,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
+ return $self->SUPER::__Relates( %args );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/CustomFieldValue.pm b/lib/RT/CustomFieldValue.pm
index ad39452..813b79e 100644
--- a/lib/RT/CustomFieldValue.pm
+++ b/lib/RT/CustomFieldValue.pm
@@ -326,10 +326,36 @@ sub _CoreAccessible {
{read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
}
-};
-
+}
+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'} |= RT::Shredder::Constants::INVALID;
+ $rec->{'Description'} = "Have no related CustomField #". $self->id ." object";
+ }
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::RELATES,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
+ return $self->__Relates( %args );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/Group.pm b/lib/RT/Group.pm
index 1ee0591..bf59413 100644
--- a/lib/RT/Group.pm
+++ b/lib/RT/Group.pm
@@ -1393,7 +1393,128 @@ sub _CoreAccessible {
{read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
}
-};
+}
+
+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 => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::WIPE_AFTER,
+ TargetObject => $objs,
+ Shredder => $args{'Shredder'}
+ );
+ }
+
+# Principal
+ $deps->_PushDependency(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::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 => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
+ $rec->{'Description'} = "Have no related Principal #". $self->id ." object.";
+ }
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::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( @_ );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/GroupMember.pm b/lib/RT/GroupMember.pm
index 84887ee..0a1b8fa 100644
--- a/lib/RT/GroupMember.pm
+++ b/lib/RT/GroupMember.pm
@@ -485,7 +485,124 @@ sub _CoreAccessible {
{read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
}
-};
+}
+
+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 => RT::Shredder::Constants::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 => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::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 )
+ & (RT::Shredder::Constants::WIPED|RT::Shredder::Constants::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 );
+}
+
+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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
+ $rec->{'Description'} = "Have no related Principal #". $self->GroupId ." object.";
+ }
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::RELATES,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
+ return $self->SUPER::__Relates( %args );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/Link.pm b/lib/RT/Link.pm
index 2056f03..1d088f1 100644
--- a/lib/RT/Link.pm
+++ b/lib/RT/Link.pm
@@ -78,7 +78,7 @@ use base 'RT::Record';
sub Table {'Links'}
use Carp;
use RT::URI;
-
+use RT::Shredder::Constants;
=head2 Create PARAMHASH
@@ -444,7 +444,79 @@ sub _CoreAccessible {
{read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
}
-};
+}
+
+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 => RT::Shredder::Constants::DEPENDS_ON|RT::Shredder::Constants::WIPE_AFTER,
+ 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 = [];
+# FIXME: if link is local then object should exist
+
+ return $self->SUPER::__Relates( %args );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/ObjectCustomFieldValue.pm b/lib/RT/ObjectCustomFieldValue.pm
index c6c7882..a5bf5f6 100644
--- a/lib/RT/ObjectCustomFieldValue.pm
+++ b/lib/RT/ObjectCustomFieldValue.pm
@@ -749,7 +749,61 @@ sub _CoreAccessible {
{read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
}
-};
+}
+
+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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
+ $rec->{'Description'} = "Have no related CustomField #". $self->id ." object";
+ }
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::RELATES,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
+ return $self->SUPER::__Relates( %args );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/Principal.pm b/lib/RT/Principal.pm
index 79d5197..b787cc1 100644
--- a/lib/RT/Principal.pm
+++ b/lib/RT/Principal.pm
@@ -815,7 +815,71 @@ sub _CoreAccessible {
{read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
}
-};
+}
+
+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 => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
+ $rec->{'Description'} = "Have no related ". $self->Type ." #". $self->id ." object";
+ }
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::RELATES,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
+ return $self->SUPER::__Relates( %args );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
index d91e4ee..6b73d46 100644
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@ -1525,9 +1525,53 @@ sub _CoreAccessible {
{read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
}
-};
+}
+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->LimitToQueue( $self->id );
+ push( @$list, $objs );
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
+ return $self->SUPER::__DependsOn( %args );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 66592f4..060bd89 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -73,6 +73,7 @@ use RT::User;
use RT::Transactions;
use RT::Attributes;
use RT::Shredder::Constants;
+use RT::Shredder::Dependencies;
use RT::Shredder::Exceptions;
use Encode qw();
diff --git a/lib/RT/Scrip.pm b/lib/RT/Scrip.pm
index 5d4e5e8..0b2fa28 100644
--- a/lib/RT/Scrip.pm
+++ b/lib/RT/Scrip.pm
@@ -992,7 +992,75 @@ sub _CoreAccessible {
{read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
}
-};
+}
+
+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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
+ $rec->{'Description'} = "Have no related ScripAction #". $self->id ." object";
+ }
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::RELATES,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
+
+ return $self->SUPER::__Relates( %args );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/ScripAction.pm b/lib/RT/ScripAction.pm
index c679a91..257312c 100644
--- a/lib/RT/ScripAction.pm
+++ b/lib/RT/ScripAction.pm
@@ -409,7 +409,46 @@ sub _CoreAccessible {
{read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
}
-};
+}
+
+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 => RT::Shredder::Constants::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 );
+}
+
RT::Base->_ImportOverlays();
diff --git a/lib/RT/ScripCondition.pm b/lib/RT/ScripCondition.pm
index 3f24f2e..2d42244 100644
--- a/lib/RT/ScripCondition.pm
+++ b/lib/RT/ScripCondition.pm
@@ -381,7 +381,45 @@ sub _CoreAccessible {
{read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
}
-};
+}
+
+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 => RT::Shredder::Constants::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 );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/Shredder.pm b/lib/RT/Shredder.pm
index 6948903..471d163 100644
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@ -198,37 +198,8 @@ objects in the cache and backups storage.
our $VERSION = '0.04';
use File::Spec ();
-
-BEGIN {
-# I can't use 'use lib' here since it breakes tests
-# because test suite uses old RT::Shredder setup from
-# RT lib path
-
-### after: push @INC, qw(@RT_LIB_PATH@);
- use RT::Shredder::Constants;
- use RT::Shredder::Exceptions;
-
- require RT;
-
- require RT::Shredder::ACE;
- require RT::Shredder::Attachment;
- require RT::Shredder::CachedGroupMember;
- require RT::Shredder::CustomField;
- require RT::Shredder::CustomFieldValue;
- require RT::Shredder::GroupMember;
- require RT::Shredder::Group;
- require RT::Shredder::Link;
- require RT::Shredder::Principal;
- require RT::Shredder::Queue;
- require RT::Shredder::Scrip;
- require RT::Shredder::ScripAction;
- require RT::Shredder::ScripCondition;
- require RT::Shredder::Template;
- require RT::Shredder::ObjectCustomFieldValue;
- require RT::Shredder::Ticket;
- require RT::Shredder::Transaction;
- require RT::Shredder::User;
-}
+use RT::Shredder::Constants;
+use RT::Shredder::Exceptions;
our @SUPPORTED_OBJECTS = qw(
ACE
diff --git a/lib/RT/Shredder/ACE.pm b/lib/RT/Shredder/ACE.pm
deleted file mode 100644
index e71c037..0000000
--- a/lib/RT/Shredder/ACE.pm
+++ /dev/null
@@ -1,101 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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 => RT::Shredder::Constants::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 => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-1;
-
diff --git a/lib/RT/Shredder/Attachment.pm b/lib/RT/Shredder/Attachment.pm
deleted file mode 100644
index dcf3975..0000000
--- a/lib/RT/Shredder/Attachment.pm
+++ /dev/null
@@ -1,136 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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 => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related transaction #". $self->TransactionId ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-1;
diff --git a/lib/RT/Shredder/CachedGroupMember.pm b/lib/RT/Shredder/CachedGroupMember.pm
deleted file mode 100644
index 4fce299..0000000
--- a/lib/RT/Shredder/CachedGroupMember.pm
+++ /dev/null
@@ -1,143 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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 => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->GroupId ." object.";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-1;
diff --git a/lib/RT/Shredder/CustomField.pm b/lib/RT/Shredder/CustomField.pm
deleted file mode 100644
index c24c29f..0000000
--- a/lib/RT/Shredder/CustomField.pm
+++ /dev/null
@@ -1,126 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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 => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related queue #". $self->Queue ." object";
- }
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-1;
-
diff --git a/lib/RT/Shredder/CustomFieldValue.pm b/lib/RT/Shredder/CustomFieldValue.pm
deleted file mode 100644
index 4bd9db5..0000000
--- a/lib/RT/Shredder/CustomFieldValue.pm
+++ /dev/null
@@ -1,94 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related CustomField #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->__Relates( %args );
-}
-
-1;
diff --git a/lib/RT/Shredder/Group.pm b/lib/RT/Shredder/Group.pm
deleted file mode 100644
index 0091e04..0000000
--- a/lib/RT/Shredder/Group.pm
+++ /dev/null
@@ -1,185 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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 => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::WIPE_AFTER,
- TargetObject => $objs,
- Shredder => $args{'Shredder'}
- );
- }
-
-# Principal
- $deps->_PushDependency(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::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 => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->id ." object.";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::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/lib/RT/Shredder/GroupMember.pm b/lib/RT/Shredder/GroupMember.pm
deleted file mode 100644
index 8ac80c4..0000000
--- a/lib/RT/Shredder/GroupMember.pm
+++ /dev/null
@@ -1,184 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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 => RT::Shredder::Constants::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 => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::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 )
- & (RT::Shredder::Constants::WIPED|RT::Shredder::Constants::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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->GroupId ." object.";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/lib/RT/Shredder/Link.pm b/lib/RT/Shredder/Link.pm
deleted file mode 100644
index 490ef17..0000000
--- a/lib/RT/Shredder/Link.pm
+++ /dev/null
@@ -1,139 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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;
-
-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 => RT::Shredder::Constants::DEPENDS_ON|RT::Shredder::Constants::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/lib/RT/Shredder/ObjectCustomFieldValue.pm b/lib/RT/Shredder/ObjectCustomFieldValue.pm
deleted file mode 100644
index 9d52d6f..0000000
--- a/lib/RT/Shredder/ObjectCustomFieldValue.pm
+++ /dev/null
@@ -1,116 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related CustomField #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/lib/RT/Shredder/Principal.pm b/lib/RT/Shredder/Principal.pm
deleted file mode 100644
index 3f69191..0000000
--- a/lib/RT/Shredder/Principal.pm
+++ /dev/null
@@ -1,127 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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 => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related ". $self->Type ." #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/lib/RT/Shredder/Queue.pm b/lib/RT/Shredder/Queue.pm
deleted file mode 100644
index f0a0611..0000000
--- a/lib/RT/Shredder/Queue.pm
+++ /dev/null
@@ -1,106 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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->LimitToQueue( $self->id );
- push( @$list, $objs );
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__DependsOn( %args );
-}
-
-1;
diff --git a/lib/RT/Shredder/Scrip.pm b/lib/RT/Shredder/Scrip.pm
deleted file mode 100644
index a71dff3..0000000
--- a/lib/RT/Shredder/Scrip.pm
+++ /dev/null
@@ -1,130 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related ScripAction #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/lib/RT/Shredder/ScripAction.pm b/lib/RT/Shredder/ScripAction.pm
deleted file mode 100644
index 37f560c..0000000
--- a/lib/RT/Shredder/ScripAction.pm
+++ /dev/null
@@ -1,100 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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 => RT::Shredder::Constants::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/lib/RT/Shredder/ScripCondition.pm b/lib/RT/Shredder/ScripCondition.pm
deleted file mode 100644
index 14af639..0000000
--- a/lib/RT/Shredder/ScripCondition.pm
+++ /dev/null
@@ -1,101 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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 => RT::Shredder::Constants::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/lib/RT/Shredder/Template.pm b/lib/RT/Shredder/Template.pm
deleted file mode 100644
index 0feda6c..0000000
--- a/lib/RT/Shredder/Template.pm
+++ /dev/null
@@ -1,120 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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 => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Queue #". $self->id ." object";
- }
-
-# TODO: Users(Creator, LastUpdatedBy)
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/lib/RT/Shredder/Ticket.pm b/lib/RT/Shredder/Ticket.pm
deleted file mode 100644
index c2bca88..0000000
--- a/lib/RT/Shredder/Ticket.pm
+++ /dev/null
@@ -1,126 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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 => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Queue #". $self->Queue ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/lib/RT/Shredder/Transaction.pm b/lib/RT/Shredder/Transaction.pm
deleted file mode 100644
index 55be62e..0000000
--- a/lib/RT/Shredder/Transaction.pm
+++ /dev/null
@@ -1,115 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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 => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Ticket #". $self->id ." object";
- }
-
-# TODO: Users(Creator, LastUpdatedBy)
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
- return $self->SUPER::__Relates( %args );
-}
-
-1;
diff --git a/lib/RT/Shredder/User.pm b/lib/RT/Shredder/User.pm
deleted file mode 100644
index 96e25a5..0000000
--- a/lib/RT/Shredder/User.pm
+++ /dev/null
@@ -1,197 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales at 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(
- ACL
- Articles
- Attachments
- Attributes
- CachedGroupMembers
- Classes
- CustomFieldValues
- CustomFields
- GroupMembers
- Groups
- Links
- ObjectClasses
- ObjectCustomFieldValues
- ObjectCustomFields
- Principals
- Queues
- ScripActions
- ScripConditions
- Scrips
- Templates
- 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 => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::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 => RT::Shredder::Constants::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 => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::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;
diff --git a/lib/RT/Template.pm b/lib/RT/Template.pm
index 6f0251d..d7a6718 100644
--- a/lib/RT/Template.pm
+++ b/lib/RT/Template.pm
@@ -941,7 +941,64 @@ sub _CoreAccessible {
{read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
}
-};
+}
+
+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 => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
+ $rec->{'Description'} = "Have no related Queue #". $self->id ." object";
+ }
+
+# TODO: Users(Creator, LastUpdatedBy)
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::RELATES,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
+ return $self->SUPER::__Relates( %args );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index fc6d48a..3d5abf1 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -4178,7 +4178,71 @@ sub _CoreAccessible {
{read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
}
-};
+}
+
+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 => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
+ $rec->{'Description'} = "Have no related Queue #". $self->Queue ." object";
+ }
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::RELATES,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
+ return $self->SUPER::__Relates( %args );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index b032481..7000a60 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -1606,7 +1606,60 @@ sub _CoreAccessible {
{read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
}
-};
+}
+
+sub __DependsOn {
+ my $self = shift;
+ my %args = (
+ Shredder => undef,
+ Dependencies => undef,
+ @_,
+ );
+ my $deps = $args{'Dependencies'};
+ my $list = [];
+
+# Attachments
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
+ $rec->{'Description'} = "Have no related Ticket #". $self->id ." object";
+ }
+
+# TODO: Users(Creator, LastUpdatedBy)
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::RELATES,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
+ return $self->SUPER::__Relates( %args );
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index 3e47d55..154ab64 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -2366,7 +2366,140 @@ sub _CoreAccessible {
{read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
}
-};
+}
+
+sub __DependsOn {
+ my $self = shift;
+ my %args = (
+ Shredder => undef,
+ Dependencies => undef,
+ @_,
+ );
+ my $deps = $args{'Dependencies'};
+ my $list = [];
+
+# Principal
+ $deps->_PushDependency(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::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 => RT::Shredder::Constants::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;
+ my @OBJECTS = qw(
+ ACL
+ Articles
+ Attachments
+ Attributes
+ CachedGroupMembers
+ Classes
+ CustomFieldValues
+ CustomFields
+ GroupMembers
+ Groups
+ Links
+ ObjectClasses
+ ObjectCustomFieldValues
+ ObjectCustomFields
+ Principals
+ Queues
+ ScripActions
+ ScripConditions
+ Scrips
+ Templates
+ Tickets
+ Transactions
+ Users
+ );
+ 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 => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::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'} |= RT::Shredder::Constants::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'} |= RT::Shredder::Constants::INVALID;
+ $rec->{'Description'} = "Have no related Principal #". $self->id ." object";
+ }
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::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( @_ );
+}
RT::Base->_ImportOverlays();
commit d290d606ab2608c51d232bd0ae189bb5c81d1d3b
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue Aug 16 16:31:42 2011 -0400
Remove stub __Relates subs
diff --git a/lib/RT/Link.pm b/lib/RT/Link.pm
index 1d088f1..794a769 100644
--- a/lib/RT/Link.pm
+++ b/lib/RT/Link.pm
@@ -504,19 +504,7 @@ sub __DependsOn {
return $self->SUPER::__DependsOn( %args );
}
-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 );
-}
+# FIXME: __Relates should check if link is local and that object exists
RT::Base->_ImportOverlays();
diff --git a/lib/RT/ObjectCustomFieldValue.pm b/lib/RT/ObjectCustomFieldValue.pm
index a5bf5f6..e7ed866 100644
--- a/lib/RT/ObjectCustomFieldValue.pm
+++ b/lib/RT/ObjectCustomFieldValue.pm
@@ -751,19 +751,6 @@ sub _CoreAccessible {
}
}
-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 = (
diff --git a/lib/RT/Scrip.pm b/lib/RT/Scrip.pm
index 0b2fa28..3aa6fc6 100644
--- a/lib/RT/Scrip.pm
+++ b/lib/RT/Scrip.pm
@@ -994,22 +994,6 @@ sub _CoreAccessible {
}
}
-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 = (
diff --git a/lib/RT/ScripAction.pm b/lib/RT/ScripAction.pm
index 257312c..943a108 100644
--- a/lib/RT/ScripAction.pm
+++ b/lib/RT/ScripAction.pm
@@ -434,21 +434,7 @@ sub __DependsOn {
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 );
-}
-
+# TODO: __Relates should check for exec module
RT::Base->_ImportOverlays();
diff --git a/lib/RT/ScripCondition.pm b/lib/RT/ScripCondition.pm
index 2d42244..3e917e1 100644
--- a/lib/RT/ScripCondition.pm
+++ b/lib/RT/ScripCondition.pm
@@ -406,20 +406,7 @@ sub __DependsOn {
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 );
-}
+# TODO: __Relates should check for exec module
RT::Base->_ImportOverlays();
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list