# -- # Kernel/Modules/MaintenanceManager.pm - frontend module for manager maintenances # # Copyright (C) 2014-2018 - SeTIC - UFSC - http://setic.ufsc.br/ # Version 2015-08-01 - Adjustments for OTRS 4 # Version 2018-01-05 - Adjustments for OTRS 6 # # -- # This software comes with ABSOLUTELY NO WARRANTY. For details, see # the enclosed file COPYING for license information (AGPL). If you # did not receive this file, see http://www.gnu.org/licenses/agpl.txt. # -- package Kernel::Modules::MaintenanceManager; use strict; use warnings; our @ObjectDependencies = ( "Kernel::Output::HTML::MaintenanceAdvisor", "Kernel::System::Maintenance", "Kernel::Output::HTML::Layout", "Kernel::System::Web::Request" # OLD ParamObject ); sub new { my ( $Type, %Param ) = @_; # allocate new hash for object my $Self = {%Param}; bless( $Self, $Type ); return $Self; } sub Run { my ( $Self, %Param ) = @_; my %Data = (); my $Subaction = $Kernel::OM->Get("Kernel::System::Web::Request")->GetParam( Param => "Subaction" ) || "List"; my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout"); my $MaintenanceObject = $Kernel::OM->Get("Kernel::System::Maintenance"); my $LanguageObject = $Kernel::OM->Get("Kernel::Language"); if ($Subaction eq "EndMaintenance") { $MaintenanceObject->EndMaintenance(ID => $Kernel::OM->Get("Kernel::System::Web::Request")->GetParam( Param => "ID" )); } elsif ($Subaction eq "CancelMaintenance") { $MaintenanceObject->CancelMaintenance(ID => $Kernel::OM->Get("Kernel::System::Web::Request")->GetParam( Param => "ID" )); } elsif ($Subaction eq "Status") { return $LayoutObject->Attachment( ContentType => 'text; charset=' . $LayoutObject->{Charset}, Content => $Kernel::OM->Get("Kernel::Output::HTML::MaintenanceAdvisor")->GetStatus(), Type => 'inline', NoCache => 1, ); } elsif ($Subaction eq "StatusID") { my ($totalMaintenances, $lastMaintenance) = $MaintenanceObject->GetStatusID(); return $LayoutObject->Attachment( ContentType => 'application/json; charset=' . $LayoutObject->{Charset}, Content => "[$totalMaintenances, $lastMaintenance]", Type => 'inline', NoCache => 1, ); } # build output my $type = $Kernel::OM->Get("Kernel::System::Web::Request")->GetParam( Param => "Type" ) || "current"; $Data{Type} = $type; my @maintenances = $MaintenanceObject->ListMaintenances(Type => $type); for my $maintenance ( @maintenances ) { $LayoutObject->Block( Name => 'Maintenance', Data => $maintenance, ); } my $Output = $LayoutObject->Header( Title => $LanguageObject->Translate("Maintenances") ); $Output .= $LayoutObject->NavigationBar(); $Output .= $LayoutObject->Output( Data => \%Data, TemplateFile => 'Maintenances', ); $Output .= $LayoutObject->Footer(); return $Output; } 1;