diff options
Diffstat (limited to 'Kernel/Modules')
-rw-r--r-- | Kernel/Modules/AdminDefaultTo.pm | 36 | ||||
-rw-r--r-- | Kernel/Modules/AdminDefaultToTemplates.pm | 55 |
2 files changed, 54 insertions, 37 deletions
diff --git a/Kernel/Modules/AdminDefaultTo.pm b/Kernel/Modules/AdminDefaultTo.pm index 448bb2f..485cd13 100644 --- a/Kernel/Modules/AdminDefaultTo.pm +++ b/Kernel/Modules/AdminDefaultTo.pm @@ -12,7 +12,13 @@ package Kernel::Modules::AdminDefaultTo; use strict; use warnings; -use Kernel::System::DefaultTo; +our @ObjectDependencies = qw( + Kernel::Config + Kernel::Output::HTML::Layout + Kernel::System::DB + Kernel::System::Web::Request + Kernel::System::DefaultTo +); sub new { my ( $Type, %Param ) = @_; @@ -22,12 +28,11 @@ sub new { bless( $Self, $Type ); # check all needed objects - for my $Needed (qw(ParamObject DBObject LayoutObject ConfigObject LogObject)) { + for my $Needed (qw(ParamObject DBObject LayoutObject ConfigObject)) { if ( !$Self->{$Needed} ) { $Self->{LayoutObject}->FatalError( Message => "Got no $Needed!" ); } } - $Self->{DefaultToObject} = Kernel::System::DefaultTo->new(%Param); return $Self; } @@ -40,7 +45,8 @@ sub Run { # ------------------------------------------------------------ # if ( $Self->{Subaction} eq 'Change' ) { my $ID = $Self->{ParamObject}->GetParam( Param => 'ID' ) || ''; - my %Data = $Self->{DefaultToObject}->Get( + my $DefaultToObject = $Kernel::OM->Get('Kernel::System::DefaultTo'); + my %Data = $DefaultToObject->Get( ID => $ID, ); @@ -62,10 +68,10 @@ sub Run { # change action # ------------------------------------------------------------ # elsif ( $Self->{Subaction} eq 'ChangeAction' ) { - # challenge token check for write action $Self->{LayoutObject}->ChallengeTokenCheck(); + my $DefaultToObject = $Kernel::OM->Get('Kernel::System::DefaultTo'); my @NewIDs = $Self->{ParamObject}->GetArray( Param => 'IDs' ); my ( %GetParam, %Errors ); for my $Parameter (qw(ID Title RemoveDefault AddNew NewAddress @@ -79,7 +85,7 @@ sub Run { $Errors{TitleInvalid} = 'ServerError' if !$GetParam{Title}; # check if a DefaultTo entry exist with this title - my $TitleExists = $Self->{DefaultToObject}->TitleExistsCheck( + my $TitleExists = $DefaultToObject->TitleExistsCheck( Title => $GetParam{Title}, ID => $GetParam{ID} ); @@ -92,7 +98,7 @@ sub Run { # if no errors occurred if ( !%Errors ) { - if ( $Self->{DefaultToObject}->Update( + if ( $DefaultToObject->Update( %GetParam, UserID => $Self->{UserID}, ) @@ -153,10 +159,10 @@ sub Run { # add action # ------------------------------------------------------------ # elsif ( $Self->{Subaction} eq 'AddAction' ) { - # challenge token check for write action $Self->{LayoutObject}->ChallengeTokenCheck(); + my $DefaultToObject = $Kernel::OM->Get('Kernel::System::DefaultTo'); my @NewIDs = $Self->{ParamObject}->GetArray( Param => 'IDs' ); my ( %GetParam, %Errors ); @@ -169,7 +175,7 @@ sub Run { $Errors{TitleInvalid} = 'ServerError' if !$GetParam{Title}; # check if a DefaultTo entry exists with this title - my $TitleExists = $Self->{DefaultToObject}->TitleExistsCheck( Title => $GetParam{Title} ); + my $TitleExists = $DefaultToObject->TitleExistsCheck( Title => $GetParam{Title} ); if ($TitleExists) { $Errors{TitleExists} = 1; $Errors{TitleInvalid} = 'ServerError'; @@ -179,7 +185,7 @@ sub Run { if ( !%Errors ) { # add DefaultTo entry - my $ID = $Self->{DefaultToObject}->Add( + my $ID = $DefaultToObject->Add( %GetParam, UserID => $Self->{UserID}, ); @@ -219,13 +225,13 @@ sub Run { # delete action # ------------------------------------------------------------ # elsif ( $Self->{Subaction} eq 'Delete' ) { - # challenge token check for write action $Self->{LayoutObject}->ChallengeTokenCheck(); + my $DefaultToObject = $Kernel::OM->Get('Kernel::System::DefaultTo'); my $ID = $Self->{ParamObject}->GetParam( Param => 'ID' ); - my $Delete = $Self->{DefaultToObject}->Delete( + my $Delete = $DefaultToObject->Delete( ID => $ID, ); if ( !$Delete ) { @@ -321,11 +327,13 @@ sub _Overview { Name => 'OverviewResult', Data => \%Param, ); - my %List = $Self->{DefaultToObject}->List(); + + my $DefaultToObject = $Kernel::OM->Get('Kernel::System::DefaultTo'); + my %List = $DefaultToObject->List(); for my $ID ( sort { $List{$a} cmp $List{$b} } keys %List ) { - my %DefaultTo = $Self->{DefaultToObject}->Get( + my %DefaultTo = $DefaultToObject->Get( ID => $ID, ); diff --git a/Kernel/Modules/AdminDefaultToTemplates.pm b/Kernel/Modules/AdminDefaultToTemplates.pm index 12c5826..af49b00 100644 --- a/Kernel/Modules/AdminDefaultToTemplates.pm +++ b/Kernel/Modules/AdminDefaultToTemplates.pm @@ -12,8 +12,13 @@ package Kernel::Modules::AdminDefaultToTemplates; use strict; use warnings; -use Kernel::System::DefaultTo; -use Kernel::System::StandardTemplate; +our @ObjectDependencies = qw( + Kernel::Output::HTML::Layout + Kernel::System::DB + Kernel::System::DefaultTo + Kernel::System::StandardTemplate + Kernel::System::Web::Request +); sub new { my ( $Type, %Param ) = @_; @@ -23,16 +28,12 @@ sub new { bless( $Self, $Type ); # check all needed objects - for (qw(ParamObject DBObject QueueObject LayoutObject ConfigObject LogObject)) { + for (qw(ParamObject DBObject LayoutObject)) { if ( !$Self->{$_} ) { $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); } } - $Self->{DefaultToObject} = Kernel::System::DefaultTo->new(%Param); - $Self->{StandardTemplateObject} = - Kernel::System::StandardTemplate->new(%Param); - return $Self; } @@ -46,15 +47,17 @@ sub Run { # get template data my $ID = $Self->{ParamObject}->GetParam( Param => 'ID' ); - my %StandardTemplateData = $Self->{StandardTemplateObject}->StandardTemplateGet( ID => $ID ); + my $StandardTemplateObject = $Kernel::OM->Get('Kernel::System::StandardTemplate'); + my %StandardTemplateData = $StandardTemplateObject->StandardTemplateGet( ID => $ID ); my $StandardTemplateType = $Self->{LayoutObject}->{LanguageObject}->Translate( $StandardTemplateData{TemplateType}, ); my $Name = $StandardTemplateType . ' - ' . $StandardTemplateData{Name}; # get DefaultTo data - my %DefaultToData = $Self->{DefaultToObject}->List(); - my %Member = $Self->{DefaultToObject}->MappingList( + my $DefaultToObject = $Kernel::OM->Get('Kernel::System::DefaultTo'); + my %DefaultToData = $DefaultToObject->List(); + my %Member = $DefaultToObject->MappingList( TemplateID => $ID, ); @@ -77,16 +80,18 @@ sub Run { elsif ( $Self->{Subaction} eq 'DefaultTo' ) { my $ID = $Self->{ParamObject}->GetParam( Param => 'ID' ); - my %DefaultToData = $Self->{DefaultToObject}->Get( ID => $ID ); + my $DefaultToObject = $Kernel::OM->Get('Kernel::System::DefaultTo'); + my %DefaultToData = $DefaultToObject->Get( ID => $ID ); # get templates - my %StandardTemplateData = $Self->{StandardTemplateObject}->StandardTemplateList( + my $StandardTemplateObject = $Kernel::OM->Get('Kernel::System::StandardTemplate'); + my %StandardTemplateData = $StandardTemplateObject->StandardTemplateList( Valid => 1, ); if (%StandardTemplateData) { for my $StandardTemplateID ( sort keys %StandardTemplateData ) { - my %Data = $Self->{StandardTemplateObject}->StandardTemplateGet( + my %Data = $StandardTemplateObject->StandardTemplateGet( ID => $StandardTemplateID ); $StandardTemplateData{$StandardTemplateID} @@ -97,7 +102,7 @@ sub Run { } # get assigned templates - my %Member = $Self->{DefaultToObject}->MappingList( + my %Member = $DefaultToObject->MappingList( DefaultToID => $ID, ); @@ -124,7 +129,8 @@ sub Run { # get current mapping my $ID = $Self->{ParamObject}->GetParam( Param => 'ID' ); - my %Mapping = $Self->{DefaultToObject}->MappingList( + my $DefaultToObject = $Kernel::OM->Get('Kernel::System::DefaultTo'); + my %Mapping = $DefaultToObject->MappingList( DefaultToID => $ID, ); @@ -139,7 +145,7 @@ sub Run { for my $TemplateID (@TemplatesAll) { if ( $TemplatesSelected{$TemplateID} ) { if ( ! $Mapping{$TemplateID} ) { - $Self->{DefaultToObject}->MappingAdd( + $DefaultToObject->MappingAdd( TemplateID => $TemplateID, DefaultToID => $ID, ); @@ -147,7 +153,7 @@ sub Run { } else { if ( $Mapping{$TemplateID} ) { - $Self->{DefaultToObject}->MappingDelete( + $DefaultToObject->MappingDelete( ID => $Mapping{$TemplateID}, ); } @@ -167,7 +173,8 @@ sub Run { # get current mapping my $ID = $Self->{ParamObject}->GetParam( Param => 'ID' ); - my %Mapping = $Self->{DefaultToObject}->MappingList( + my $DefaultToObject = $Kernel::OM->Get('Kernel::System::DefaultTo'); + my %Mapping = $DefaultToObject->MappingList( TemplateID => $ID, ); @@ -182,7 +189,7 @@ sub Run { for my $DefaultToID (@All) { if ( $Selected{$DefaultToID} ) { if ( ! $Mapping{$DefaultToID} ) { - $Self->{DefaultToObject}->MappingAdd( + $DefaultToObject->MappingAdd( TemplateID => $ID, DefaultToID => $DefaultToID, ); @@ -190,7 +197,7 @@ sub Run { } else { if ( $Mapping{$DefaultToID} ) { - $Self->{DefaultToObject}->MappingDelete( + $DefaultToObject->MappingDelete( ID => $Mapping{$DefaultToID}, ); } @@ -273,14 +280,15 @@ sub _Overview { $Self->{LayoutObject}->Block( Name => 'OverviewResult' ); # get std template list - my %StandardTemplateData = $Self->{StandardTemplateObject}->StandardTemplateList( + my $StandardTemplateObject = $Kernel::OM->Get('Kernel::System::StandardTemplate'); + my %StandardTemplateData = $StandardTemplateObject->StandardTemplateList( Valid => 1, ); # if there are results to show if (%StandardTemplateData) { for my $StandardTemplateID ( sort keys %StandardTemplateData ) { - my %Data = $Self->{StandardTemplateObject}->StandardTemplateGet( + my %Data = $StandardTemplateObject->StandardTemplateGet( ID => $StandardTemplateID, ); $StandardTemplateData{$StandardTemplateID} @@ -315,7 +323,8 @@ sub _Overview { } # get queue data - my %DefaultToData = $Self->{DefaultToObject}->List(); + my $DefaultToObject = $Kernel::OM->Get('Kernel::System::DefaultTo'); + my %DefaultToData = $DefaultToObject->List(); # if there are results to show if (%DefaultToData) { |