Skip to content

Commit

Permalink
Issue #639: align two interface modules with the rel-10_1 versions
Browse files Browse the repository at this point in the history
  • Loading branch information
bschmalhofer committed Nov 16, 2020
1 parent 02f2776 commit 8ba7652
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 74 deletions.
90 changes: 39 additions & 51 deletions Kernel/System/Web/InterfaceInstaller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ package Kernel::System::Web::InterfaceInstaller;

use strict;
use warnings;
use v5.24;
use namespace::autoclean;
use utf8;

# core modules

Expand All @@ -40,7 +43,7 @@ Kernel::System::Web::InterfaceInstaller - the installer web interface
=head1 DESCRIPTION
This module generates the content for F<installer.pl>.
This module prints the HTTP response for F<installer.pl>.
=head1 PUBLIC INTERFACE
Expand All @@ -50,13 +53,18 @@ create the web interface object for 'installer.pl'.
use Kernel::System::Web::InterfaceInstaller;
my $Debug = 0;
my $Interface = Kernel::System::Web::InterfaceInstaller->new( Debug => $Debug );
my $Interface = Kernel::System::Web::InterfaceInstaller->new();
# with debugging enabled
my $Interface = Kernel::System::Web::InterfaceInstaller->new(
Debug => 1
);
=cut

sub new {
my ( $Type, %Param ) = @_;
my $Type = shift;
my %Param = @_;

# start with an empty hash for the new object
my $Self = bless {}, $Type;
Expand All @@ -74,20 +82,12 @@ sub new {
},
);

# debug info
if ( $Self->{Debug} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'debug',
Message => 'Global handle started...',
);
}

return $Self;
}

=head2 Run()
execute the object
execute the object.
$Interface->Run();
Expand All @@ -98,12 +98,13 @@ sub Run {

# get common framework params
my %Param;
{
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');

my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');

$Param{Action} = $ParamObject->GetParam( Param => 'Action' ) || 'Installer';
$Param{Subaction} = $ParamObject->GetParam( Param => 'Subaction' ) || '';
$Param{NextScreen} = $ParamObject->GetParam( Param => 'NextScreen' ) || '';
$Param{Action} = $ParamObject->GetParam( Param => 'Action' ) || 'Installer';
$Param{Subaction} = $ParamObject->GetParam( Param => 'Subaction' ) || '';
$Param{NextScreen} = $ParamObject->GetParam( Param => 'NextScreen' ) || '';
}

$Kernel::OM->ObjectParamAdd(
'Kernel::Output::HTML::Layout' => {
Expand All @@ -115,56 +116,43 @@ sub Run {

# check secure mode
if ( $Kernel::OM->Get('Kernel::Config')->Get('SecureMode') ) {
print $LayoutObject->Header();
print $LayoutObject->Error(
Message => Translatable('SecureMode active!'),
Comment => Translatable(
'If you want to re-run the Installer, disable the SecureMode in the SysConfig.'
print join '',
$LayoutObject->Header(),
$LayoutObject->Error(
Message => Translatable('SecureMode active!'),
Comment => Translatable(
'If you want to re-run installer.pl, then disable the SecureMode in the SysConfig.'
),
),
);
print $LayoutObject->Footer();
$LayoutObject->Footer();

return;
}

# run modules if a version value exists
elsif ( $Kernel::OM->Get('Kernel::System::Main')->Require("Kernel::Modules::$Param{Action}") ) {
if ( $Kernel::OM->Get('Kernel::System::Main')->Require("Kernel::Modules::$Param{Action}") ) {

# proof of concept! - create $GenericObject
# create $GenericObject
my $GenericObject = ( 'Kernel::Modules::' . $Param{Action} )->new(
%Param,
Debug => $Self->{Debug},
);

print $GenericObject->Run();
}

# else print an error screen
else {
return;
}

# create new LayoutObject with '%Param'
print $LayoutObject->Header();
print $LayoutObject->Error(
# print an error screen as the fallback
print join '',
$LayoutObject->Header();
$LayoutObject->Error(
Message => $LayoutObject->{LanguageObject}->Translate( 'Action "%s" not found!', $Param{Action} ),
Comment => Translatable('Please contact the administrator.'),
);
print $LayoutObject->Footer();
}
),
$LayoutObject->Footer();

return;
}

sub DESTROY {
my $Self = shift;

# debug info
if ( $Self->{Debug} ) {

$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'debug',
Message => 'Global handle stopped.',
);
}

return 1;
}

1;
51 changes: 28 additions & 23 deletions Kernel/System/Web/InterfaceMigrateFromOTRS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package Kernel::System::Web::InterfaceMigrateFromOTRS;
use strict;
use warnings;
use v5.24;
use namespace::autoclean;
use utf8;

# core modules
Expand Down Expand Up @@ -94,7 +95,7 @@ sub new {

=head2 Run()
execute the object
execute the object.
$Interface->Run();
Expand All @@ -105,12 +106,13 @@ sub Run {

# get common framework params
my %Param;
{
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');

my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');

$Param{Action} = $ParamObject->GetParam( Param => 'Action' ) || 'MigrateFromOTRS';
$Param{Subaction} = $ParamObject->GetParam( Param => 'Subaction' ) || '';
$Param{NextScreen} = $ParamObject->GetParam( Param => 'NextScreen' ) || '';
$Param{Action} = $ParamObject->GetParam( Param => 'Action' ) || 'MigrateFromOTRS';
$Param{Subaction} = $ParamObject->GetParam( Param => 'Subaction' ) || '';
$Param{NextScreen} = $ParamObject->GetParam( Param => 'NextScreen' ) || '';
}

$Kernel::OM->ObjectParamAdd(
'Kernel::Output::HTML::Layout' => {
Expand All @@ -122,39 +124,42 @@ sub Run {

# check secure mode
if ( $Kernel::OM->Get('Kernel::Config')->Get('SecureMode') ) {
print $LayoutObject->Header();
print $LayoutObject->Error(
Message => Translatable('SecureMode active!'),
Comment => Translatable(
'If you want to re-run the MigrateFromOTRS, disable the SecureMode in the SysConfig.'
print join '',
$LayoutObject->Header(),
$LayoutObject->Error(
Message => Translatable('SecureMode active!'),
Comment => Translatable(
'If you want to re-run migration.pl, then disable the SecureMode in the SysConfig.'
),
),
);
print $LayoutObject->Footer();
$LayoutObject->Footer();

return;
}

# run modules if a version value exists
elsif ( $Kernel::OM->Get('Kernel::System::Main')->Require("Kernel::Modules::$Param{Action}") ) {
if ( $Kernel::OM->Get('Kernel::System::Main')->Require("Kernel::Modules::$Param{Action}") ) {

# create $GenericObject
my $GenericObject = ( 'Kernel::Modules::' . $Param{Action} )->new(
%Param,
Debug => $Self->{Debug},
);

# output filters are not applied for this interface
print $GenericObject->Run();
}

# else print an error screen
else {
return;
}

# create new LayoutObject with '%Param'
print $LayoutObject->Header();
print $LayoutObject->Error(
# print an error screen as the fallback
print join '',
$LayoutObject->Header(),
$LayoutObject->Error(
Message => $LayoutObject->{LanguageObject}->Translate( 'Action "%s" not found!', $Param{Action} ),
Comment => Translatable('Please contact the administrator.'),
);
print $LayoutObject->Footer();
}
),
$LayoutObject->Footer();

return;
}
Expand Down

0 comments on commit 8ba7652

Please sign in to comment.