X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FScripCondition.pm;h=b88612db4772fe451b1025bf7765050681b6a1ce;hp=e0eedf5e9fbf6caca4f4cdedeadace27a12220ec;hb=de9d037528895f7151a9aead6724ce2df95f9586;hpb=73a6a80a9ca5edbd43d139b7cb25bfee4abfd35e diff --git a/rt/lib/RT/ScripCondition.pm b/rt/lib/RT/ScripCondition.pm index e0eedf5e9..b88612db4 100755 --- a/rt/lib/RT/ScripCondition.pm +++ b/rt/lib/RT/ScripCondition.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -75,28 +75,22 @@ use warnings; use base 'RT::Record'; -sub Table {'ScripConditions'} - +sub Table {'ScripConditions'} -sub _Init { - my $self = shift; - $self->{'table'} = "ScripConditions"; - return ($self->SUPER::_Init(@_)); -} sub _Accessible { my $self = shift; my %Cols = ( Name => 'read', - Description => 'read', - ApplicableTransTypes => 'read', - ExecModule => 'read', - Argument => 'read', - Creator => 'read/auto', - Created => 'read/auto', - LastUpdatedBy => 'read/auto', - LastUpdated => 'read/auto' - ); + Description => 'read', + ApplicableTransTypes => 'read', + ExecModule => 'read', + Argument => 'read', + Creator => 'read/auto', + Created => 'read/auto', + LastUpdatedBy => 'read/auto', + LastUpdated => 'read/auto' + ); return($self->SUPER::_Accessible(@_, %Cols)); } @@ -135,16 +129,16 @@ Loads a condition takes a name or ScripCondition id. sub Load { my $self = shift; my $identifier = shift; - + unless (defined $identifier) { - return (undef); - } - + return (undef); + } + if ($identifier !~ /\D/) { - return ($self->SUPER::LoadById($identifier)); + return ($self->SUPER::LoadById($identifier)); } else { - return ($self->LoadByCol('Name', $identifier)); + return ($self->LoadByCol('Name', $identifier)); } } @@ -160,24 +154,24 @@ Loads the Condition module in question. sub LoadCondition { my $self = shift; my %args = ( TransactionObj => undef, - TicketObj => undef, - @_ ); - - #TODO: Put this in an eval + TicketObj => undef, + @_ ); + + #TODO: Put this in an eval $self->ExecModule =~ /^(\w+)$/; my $module = $1; my $type = "RT::Condition::". $module; - - eval "require $type" || die "Require of $type failed.\n$@\n"; - - $self->{'Condition'} = $type->new ( 'ScripConditionObj' => $self, - 'TicketObj' => $args{'TicketObj'}, - 'ScripObj' => $args{'ScripObj'}, - 'TransactionObj' => $args{'TransactionObj'}, - 'Argument' => $self->Argument, - 'ApplicableTransTypes' => $self->ApplicableTransTypes, - CurrentUser => $self->CurrentUser - ); + + $type->require or die "Require of $type condition module failed.\n$@\n"; + + $self->{'Condition'} = $type->new ( 'ScripConditionObj' => $self, + 'TicketObj' => $args{'TicketObj'}, + 'ScripObj' => $args{'ScripObj'}, + 'TransactionObj' => $args{'TransactionObj'}, + 'Argument' => $self->Argument, + 'ApplicableTransTypes' => $self->ApplicableTransTypes, + CurrentUser => $self->CurrentUser + ); } @@ -209,16 +203,6 @@ sub IsApplicable { } -sub DESTROY { - my $self=shift; - $self->{'Condition'} = undef; -} - - - - - - =head2 id @@ -360,29 +344,60 @@ sub _CoreAccessible { { id => - {read => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''}, + {read => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''}, Name => - {read => 1, write => 1, sql_type => 12, length => 200, is_blob => 0, is_numeric => 0, type => 'varchar(200)', default => ''}, + {read => 1, write => 1, sql_type => 12, length => 200, is_blob => 0, is_numeric => 0, type => 'varchar(200)', default => ''}, Description => - {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''}, + {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''}, ExecModule => - {read => 1, write => 1, sql_type => 12, length => 60, is_blob => 0, is_numeric => 0, type => 'varchar(60)', default => ''}, + {read => 1, write => 1, sql_type => 12, length => 60, is_blob => 0, is_numeric => 0, type => 'varchar(60)', default => ''}, Argument => - {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varbinary(255)', default => ''}, + {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varbinary(255)', default => ''}, ApplicableTransTypes => - {read => 1, write => 1, sql_type => 12, length => 60, is_blob => 0, is_numeric => 0, type => 'varchar(60)', default => ''}, + {read => 1, write => 1, sql_type => 12, length => 60, is_blob => 0, is_numeric => 0, type => 'varchar(60)', default => ''}, Creator => - {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'}, + {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'}, Created => - {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''}, + {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''}, LastUpdatedBy => - {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'}, + {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'}, LastUpdated => - {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''}, + {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''}, } }; +sub PreInflate { + my $class = shift; + my ($importer, $uid, $data) = @_; + + $class->SUPER::PreInflate( $importer, $uid, $data ); + + return not $importer->SkipBy( "Name", $class, $uid, $data ); +} + +sub __DependsOn { + my $self = shift; + my %args = ( + Shredder => undef, + Dependencies => undef, + @_, + ); + my $deps = $args{'Dependencies'}; + +# 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 ); +} + RT::Base->_ImportOverlays(); 1;