MaintenanceManager.pm
2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# --
# 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;