This commit is contained in:
2024-10-14 00:08:40 +02:00
parent dbfba56f66
commit 1462d52e13
4572 changed files with 2658864 additions and 0 deletions

View File

@@ -0,0 +1,309 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::Output::HTML::ITSMConfigItem::LayoutCustomer;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::System::Log',
'Kernel::Output::HTML::Layout',
'Kernel::System::Web::Request',
'Kernel::System::CustomerUser',
);
=head1 NAME
Kernel::Output::HTML::ITSMConfigItem::LayoutCustomer - layout backend module
=head1 DESCRIPTION
All layout functions of customer objects
=head2 new()
create an object
$BackendObject = Kernel::Output::HTML::ITSMConfigItem::LayoutCustomer->new(
%Param,
);
=cut
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
return $Self;
}
=head2 OutputStringCreate()
create output string
my $Value = $BackendObject->OutputStringCreate(
Value => 11, # (optional)
);
=cut
sub OutputStringCreate {
my ( $Self, %Param ) = @_;
# transform ascii to html
$Param{Value} = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->Ascii2Html(
Text => $Param{Value} || '',
HTMLResultMode => 1,
);
return $Param{Value};
}
=head2 FormDataGet()
get form data as hash reference
my $FormDataRef = $BackendObject->FormDataGet(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub FormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my %FormData;
# get param object
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
# get selected customer user
$FormData{Value} = $ParamObject->GetParam( Param => $Param{Key} );
# check search button
if ( $ParamObject->GetParam( Param => $Param{Key} . '::ButtonSearch' ) ) {
$Param{Item}->{Form}->{ $Param{Key} }->{Search} = $ParamObject->GetParam( Param => $Param{Key} . '::Search' );
}
# check select button
elsif ( $ParamObject->GetParam( Param => $Param{Key} . '::ButtonSelect' ) ) {
$FormData{Value} = $ParamObject->GetParam( Param => $Param{Key} . '::Select' );
}
# check clear button
elsif ( $ParamObject->GetParam( Param => $Param{Key} . '::ButtonClear' ) ) {
$FormData{Value} = '';
}
else {
# reset value if search field is empty
if (
!$ParamObject->GetParam( Param => $Param{Key} . '::Search' )
&& defined $FormData{Value}
)
{
$FormData{Value} = '';
}
# check required option
if ( $Param{Item}->{Input}->{Required} && !$FormData{Value} ) {
$Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1;
$FormData{Invalid} = 1;
}
}
return \%FormData;
}
=head2 InputCreate()
create a input string
my $Value = $BackendObject->InputCreate(
Key => 'Item::1::Node::3',
Value => 11, # (optional)
Item => $ItemRef,
);
=cut
sub InputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my $Value = '';
if ( defined $Param{Value} ) {
$Value = $Param{Value};
}
elsif ( $Param{Item}->{Input}->{ValueDefault} ) {
$Value = $Param{Item}->{Input}->{ValueDefault};
}
my $Class = 'W50pc ITSMCustomerSearch';
my $Search = '';
my $Required = $Param{Required} || '';
my $Invalid = $Param{Invalid} || '';
my $ItemId = $Param{ItemId} || '';
if ($Required) {
$Class .= ' Validate_Required';
}
if ($Invalid) {
$Class .= ' ServerError';
}
# create customer string
if ($Value) {
# get customer data
my %CustomerSearchList = $Kernel::OM->Get('Kernel::System::CustomerUser')->CustomerSearch(
Search => $Value,
);
# transform ascii to html
$Search = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->Ascii2Html(
Text => $CustomerSearchList{$Value} || '',
HTMLResultMode => 1,
);
}
# create string
my $String = '<input type="hidden" name="'
. $Param{Key}
. '" value="'
. $Value
. '" id="'
. $ItemId . 'Selected'
. '"/>'
. '<input type="text" name="'
. $Param{Key}
. '::Search" class="'
. $Class
. '" id="'
. $ItemId
. '" value="'
. $Search . '"/>';
return $String;
}
=head2 SearchFormDataGet()
get search form data
my $Value = $BackendObject->SearchFormDataGet(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub SearchFormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{Key} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need Key!',
);
return;
}
# get form data
my $Value;
if ( $Param{Value} ) {
$Value = $Param{Value};
}
else {
$Value = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Param{Key} );
}
return $Value;
}
=head2 SearchInputCreate()
create a search input string
my $Value = $BackendObject->SearchInputCreate(
Key => 'Item::1::Node::3',
);
=cut
sub SearchInputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my $Key = $Param{Key};
# hash with values for the input field
my %FormData;
if ( $Param{Value} ) {
$FormData{Value} = $Param{Value};
}
# create input field
my $InputString = $Self->InputCreate(
%FormData,
Key => $Param{Key},
Item => $Param{Item},
ItemId => $Param{Key},
);
return $InputString;
}
1;
=head1 TERMS AND CONDITIONS
This software is part of the OTRS project (L<https://otrs.org/>).
This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (GPL). If you
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
=cut

View File

@@ -0,0 +1,260 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::Output::HTML::ITSMConfigItem::LayoutCustomerCompany;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::System::Log',
'Kernel::Output::HTML::Layout',
'Kernel::System::Web::Request',
'Kernel::System::CustomerCompany',
);
=head1 NAME
Kernel::Output::HTML::ITSMConfigItem::LayoutCustomerCompany - layout backend module
=head1 DESCRIPTION
All layout functions of customer company objects
=head2 new()
create an object
$BackendObject = Kernel::Output::HTML::ITSMConfigItem::LayoutCustomerCompany->new(
%Param,
);
=cut
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
return $Self;
}
=head2 OutputStringCreate()
create output string
my $Value = $BackendObject->OutputStringCreate(
Value => 11, # (optional)
);
=cut
sub OutputStringCreate {
my ( $Self, %Param ) = @_;
# transform ascii to html
$Param{Value} = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->Ascii2Html(
Text => $Param{Value} || '',
HTMLResultMode => 1,
);
return $Param{Value};
}
=head2 FormDataGet()
get form data as hash reference
my $FormDataRef = $BackendObject->FormDataGet(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub FormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my %FormData;
# get form data
$FormData{Value} = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Param{Key} );
# set invalid param
if ( $Param{Item}->{Input}->{Required} && !$FormData{Value} ) {
$FormData{Invalid} = 1;
$Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1;
}
return \%FormData;
}
=head2 InputCreate()
create a input string
my $Value = $BackendObject->InputCreate(
Key => 'Item::1::Node::3',
Value => 11, # (optional)
Item => $ItemRef,
);
=cut
sub InputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my $SelectedID = $Param{Value} || $Param{Item}->{Input}->{ValueDefault} || '';
my $CSSClass = 'Modernize';
my $Required = $Param{Required};
my $Invalid = $Param{Invalid};
my $ItemId = $Param{ItemId};
if ($Required) {
$CSSClass .= ' Validate_Required';
}
if ($Invalid) {
$CSSClass .= ' ServerError';
}
# get class list
my %CompanyList = $Kernel::OM->Get('Kernel::System::CustomerCompany')->CustomerCompanyList(
Limit => 0, # Display all Customer Companies
);
# generate string
my $String = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->BuildSelection(
Data => \%CompanyList,
Name => $Param{Key},
ID => $ItemId,
PossibleNone => 1,
Translation => 0,
SelectedID => $SelectedID,
Class => $CSSClass,
);
return $String;
}
=head2 SearchFormDataGet()
get search form data
my $Value = $BackendObject->SearchFormDataGet(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub SearchFormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{Key} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need Key!',
);
return;
}
# get form data
my @Values;
if ( $Param{Value} ) {
@Values = @{ $Param{Value} };
}
else {
@Values = $Kernel::OM->Get('Kernel::System::Web::Request')->GetArray( Param => $Param{Key} );
}
return \@Values;
}
=head2 SearchInputCreate()
create a search input string
my $Value = $BackendObject->SearchInputCreate(
Key => 'Item::1::Node::3',
);
=cut
sub SearchInputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my $Values = $Self->SearchFormDataGet(%Param);
# get company data
my %CompanyList = $Kernel::OM->Get('Kernel::System::CustomerCompany')->CustomerCompanyList(
Limit => 0,
);
# generate string
my $String = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->BuildSelection(
Data => \%CompanyList,
Name => $Param{Key},
Size => 5,
Multiple => 1,
Translation => 0,
SelectedID => $Values,
Class => 'Modernize',
);
return $String;
}
1;
=head1 TERMS AND CONDITIONS
This software is part of the OTRS project (L<https://otrs.org/>).
This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (GPL). If you
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
=cut

View File

@@ -0,0 +1,371 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::Output::HTML::ITSMConfigItem::LayoutDate;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::System::Log',
'Kernel::Output::HTML::Layout',
'Kernel::System::Web::Request',
'Kernel::System::DateTime',
);
=head1 NAME
Kernel::Output::HTML::ITSMConfigItem::LayoutDate - layout backend module
=head1 DESCRIPTION
All layout functions of date objects.
=cut
=head2 new()
create an object
$BackendObject = Kernel::Output::HTML::ITSMConfigItem::LayoutDate->new(
%Param,
);
=cut
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
return $Self;
}
=head2 OutputStringCreate()
create output string
my $Value = $BackendObject->OutputStringCreate(
Value => '2007-01-01', # (optional)
);
=cut
sub OutputStringCreate {
my ( $Self, %Param ) = @_;
return '' if !$Param{Value};
$Param{Value} = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->Output(
Template => '[% Data.Date | Localize("Date") %]',
Data => {
Date => $Param{Value} . ' 00:00:00',
},
);
$Param{Value} =~ s/00:00:00//;
return $Param{Value} || '';
}
=head2 FormDataGet()
get form data as hash reference
my $FormDataRef = $BackendObject->FormDataGet(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub FormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my %FormData;
# get param object
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
# get form data
my $Day = $ParamObject->GetParam( Param => $Param{Key} . '::Day' );
my $Month = $ParamObject->GetParam( Param => $Param{Key} . '::Month' );
my $Year = $ParamObject->GetParam( Param => $Param{Key} . '::Year' );
if ( $Day && $Month && $Year ) {
$FormData{Value} = sprintf '%02d-%02d-%02d', $Year, $Month, $Day;
}
# set invalid param
if ( $Param{Item}->{Input}->{Required} && !$FormData{Value} ) {
$FormData{Invalid} = 1;
$Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1;
}
# Sanity check of the assembled timestamp
if ( $FormData{Value} ) {
my $DateTimeObject = $Kernel::OM->Create(
'Kernel::System::DateTime',
ObjectParams => {
String => $FormData{Value} . ' 00:00:00',
},
);
if ( !$DateTimeObject ) {
$FormData{Invalid} = 1;
$Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1;
}
}
return \%FormData;
}
=head2 InputCreate()
create a input string
my $Value = $BackendObject->InputCreate(
Key => 'Item::1::Node::3',
Value => '2007-03-26', # (optional)
Item => $ItemRef,
);
=cut
sub InputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my $Invalid = $Param{Invalid};
my %Values;
my $Class;
if ( $Param{Value} || $Param{Item}->{Input}->{ValueDefault} ) {
my $Value = $Param{Value} || $Param{Item}->{Input}->{ValueDefault};
if ( $Value =~ /^(\d\d\d\d)-(\d\d|\d)-(\d\d|\d)$/i ) {
$Values{ $Param{Key} . '::Year' } = $1;
$Values{ $Param{Key} . '::Month' } = $2;
$Values{ $Param{Key} . '::Day' } = $3;
if ($Invalid) {
$Class = 'ServerError';
}
}
}
my $String = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->BuildDateSelection(
Prefix => $Param{Key} . '::',
Format => 'DateInputFormat',
YearPeriodPast => $Param{Item}->{Input}->{YearPeriodPast} || 10,
YearPeriodFuture => $Param{Item}->{Input}->{YearPeriodFuture} || 10,
%Values,
$Param{Key} . '::' . 'Class' => $Class,
Validate => 1,
OverrideTimeZone => $Param{OverrideTimeZone},
);
return $String;
}
=head2 SearchFormDataGet()
get search form data
my $Value = $BackendObject->SearchFormDataGet(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub SearchFormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
# get form data
my $Used;
my $StartDay;
my $StartMonth;
my $StartYear;
my $StopDay;
my $StopMonth;
my $StopYear;
# get param object
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
if ( $Param{Value} && ref $Param{Value} eq 'HASH' ) {
$Used = $Param{Value}->{ $Param{Key} };
$StartDay = $Param{Value}->{ $Param{Key} . '::TimeStart::Day' };
$StartMonth = $Param{Value}->{ $Param{Key} . '::TimeStart::Month' };
$StartYear = $Param{Value}->{ $Param{Key} . '::TimeStart::Year' };
$StopDay = $Param{Value}->{ $Param{Key} . '::TimeStop::Day' };
$StopMonth = $Param{Value}->{ $Param{Key} . '::TimeStop::Month' };
$StopYear = $Param{Value}->{ $Param{Key} . '::TimeStop::Year' };
}
else {
$Used = $ParamObject->GetParam( Param => $Param{Key} );
$StartDay = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStart::Day' );
$StartMonth = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStart::Month' );
$StartYear = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStart::Year' );
$StopDay = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStop::Day' );
$StopMonth = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStop::Month' );
$StopYear = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStop::Year' );
}
if (
$Used
&& $StartDay && $StartMonth && $StartYear
&& $StopDay && $StopMonth && $StopYear
)
{
my $StartDate = sprintf '%02d-%02d-%02d', $StartYear, $StartMonth, $StartDay;
my $StopDate = sprintf '%02d-%02d-%02d', $StopYear, $StopMonth, $StopDay;
return { '-between' => [ $StartDate, $StopDate ] };
}
return []; # no conditions by default
}
=head2 SearchInputCreate()
create a search input string
my $Value = $BackendObject->SearchInputCreate(
Key => 'Item::1::Node::3',
Item => $ItemRef,
Optional => 1, # (optional) default 0 (0|1)
);
=cut
sub SearchInputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
# just for convenience
my $Key = $Param{Key};
my $PrefixStart = $Key . '::TimeStart::';
my $PrefixStop = $Key . '::TimeStop::';
# get time related params
my %GetParam;
# get param object
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
if ( $Param{Value} ) {
%GetParam = %{ $Param{Value} };
}
else {
$GetParam{$Key} = $ParamObject->GetParam( Param => $Key );
for my $TimeType ( $PrefixStart, $PrefixStop ) {
for my $Part (qw( Year Month Day )) {
my $ParamKey = $TimeType . $Part;
my $ParamVal = $ParamObject->GetParam( Param => $ParamKey );
# remove white space on the start and end
if ($ParamVal) {
$ParamVal =~ s{ \A \s+ }{}xms;
$ParamVal =~ s{ \s+ \z }{}xms;
}
# store in %GetParam
$GetParam{$ParamKey} = $ParamVal;
}
}
}
# get layout object
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
# Build selection for the start and stop time.
# Note that searching is by date, while input is by time as well
my $TimeStartSelectionString = $LayoutObject->BuildDateSelection(
Prefix => $PrefixStart,
Format => 'DateInputFormat',
YearPeriodPast => 10,
YearPeriodFuture => 10,
%GetParam,
);
my $TimeStopSelectionString = $LayoutObject->BuildDateSelection(
Optional => 0,
Prefix => $PrefixStop,
Format => 'DateInputFormat',
YearPeriodPast => 10,
YearPeriodFuture => 10,
%GetParam,
);
my $Checkbox = qq{<input type="hidden" name="$Key" value="1"/>};
if ( $Param{Optional} ) {
$Checkbox = qq{<input type="checkbox" name="$Key" value="1"/>};
}
my $Between = $LayoutObject->{LanguageObject}->Translate('Between');
my $And = $LayoutObject->{LanguageObject}->Translate('and');
return "<div> $Checkbox $Between $TimeStartSelectionString </div>"
. "<span style=\"margin-left: 27px;\">$And</span> $TimeStopSelectionString";
}
1;
=head1 TERMS AND CONDITIONS
This software is part of the OTRS project (L<https://otrs.org/>).
This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (GPL). If you
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
=cut

View File

@@ -0,0 +1,393 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::Output::HTML::ITSMConfigItem::LayoutDateTime;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::System::Log',
'Kernel::Output::HTML::Layout',
'Kernel::System::Web::Request',
'Kernel::System::DateTime',
);
=head1 NAME
Kernel::Output::HTML::ITSMConfigItem::LayoutDateTime - layout backend module
=head1 DESCRIPTION
All layout functions of datetime objects.
=cut
=head2 new()
create an object
$BackendObject = Kernel::Output::HTML::ITSMConfigItem::LayoutDateTime->new(
%Param,
);
=cut
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
return $Self;
}
=head2 OutputStringCreate()
create output string
my $Value = $BackendObject->OutputStringCreate(
Value => '2007-01-01 12:00', # (optional)
);
=cut
sub OutputStringCreate {
my ( $Self, %Param ) = @_;
return '' if !$Param{Value};
$Param{Value} = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->Output(
Template => '[% Data.Date | Localize("TimeLong") %]',
Data => {
Date => $Param{Value} . ':00',
},
);
return $Param{Value} || '';
}
=head2 FormDataGet()
get form data as hash reference
my $FormDataRef = $BackendObject->FormDataGet(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub FormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my %FormData;
# get param object
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
# get form data
my $Day = $ParamObject->GetParam( Param => $Param{Key} . '::Day' );
my $Month = $ParamObject->GetParam( Param => $Param{Key} . '::Month' );
my $Year = $ParamObject->GetParam( Param => $Param{Key} . '::Year' );
my $Hour = $ParamObject->GetParam( Param => $Param{Key} . '::Hour' ) || 0;
my $Minute = $ParamObject->GetParam( Param => $Param{Key} . '::Minute' ) || 0;
if ( $Day && $Month && $Year ) {
$FormData{Value} = sprintf '%02d-%02d-%02d %02d:%02d', $Year, $Month, $Day, $Hour, $Minute;
}
# set invalid param
if ( $Param{Item}->{Input}->{Required} && !$FormData{Value} ) {
$FormData{Invalid} = 1;
$Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1;
}
# Sanity check of the assembled timestamp
if ( $FormData{Value} ) {
my $DateTimeObject = $Kernel::OM->Create(
'Kernel::System::DateTime',
ObjectParams => {
String => $FormData{Value} . ':00',
},
);
if ( !$DateTimeObject ) {
$FormData{Invalid} = 1;
$Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1;
}
}
return \%FormData;
}
=head2 InputCreate()
create a input string
my $Value = $BackendObject->InputCreate(
Key => 'Item::1::Node::3',
Value => '2007-03-26 12:00', # (optional)
Item => $ItemRef,
);
=cut
sub InputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my $Invalid = $Param{Invalid};
my %Values;
my $Class;
if ( $Param{Value} || $Param{Item}->{Input}->{ValueDefault} ) {
my $Value = $Param{Value} || $Param{Item}->{Input}->{ValueDefault};
if ( $Value =~ /^(\d\d\d\d)-(\d\d|\d)-(\d\d|\d) (\d\d|\d):(\d\d|\d)$/i ) {
$Values{ $Param{Key} . '::Year' } = $1;
$Values{ $Param{Key} . '::Month' } = $2;
$Values{ $Param{Key} . '::Day' } = $3;
$Values{ $Param{Key} . '::Hour' } = $4;
$Values{ $Param{Key} . '::Minute' } = $5;
if ($Invalid) {
$Class = 'ServerError';
}
}
}
my $String = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->BuildDateSelection(
Prefix => $Param{Key} . '::',
Format => 'DateInputFormatLong',
YearPeriodPast => $Param{Item}->{Input}->{YearPeriodPast} || 10,
YearPeriodFuture => $Param{Item}->{Input}->{YearPeriodFuture} || 10,
%Values,
$Param{Key} . '::' . 'Class' => $Class,
Validate => 1,
);
return $String;
}
=head2 SearchFormDataGet()
get search form data
my $Value = $BackendObject->SearchFormDataGet(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub SearchFormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my $Used;
my $StartMinute;
my $StartHour;
my $StartDay;
my $StartMonth;
my $StartYear;
my $StopMinute;
my $StopHour;
my $StopDay;
my $StopMonth;
my $StopYear;
# get param object
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
# get form data
if ( $Param{Value} && ref $Param{Value} eq 'HASH' ) {
$Used = $Param{Value}->{ $Param{Key} };
$StartMinute = $Param{Value}->{ $Param{Key} . '::TimeStart::Minute' };
$StartHour = $Param{Value}->{ $Param{Key} . '::TimeStart::Hour' };
$StartDay = $Param{Value}->{ $Param{Key} . '::TimeStart::Day' };
$StartMonth = $Param{Value}->{ $Param{Key} . '::TimeStart::Month' };
$StartYear = $Param{Value}->{ $Param{Key} . '::TimeStart::Year' };
$StopMinute = $Param{Value}->{ $Param{Key} . '::TimeStop::Minute' };
$StopHour = $Param{Value}->{ $Param{Key} . '::TimeStop::Hour' };
$StopDay = $Param{Value}->{ $Param{Key} . '::TimeStop::Day' };
$StopMonth = $Param{Value}->{ $Param{Key} . '::TimeStop::Month' };
$StopYear = $Param{Value}->{ $Param{Key} . '::TimeStop::Year' };
}
else {
$Used = $ParamObject->GetParam( Param => $Param{Key} );
$StartMinute = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStart::Minute' ) || 00;
$StartHour = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStart::Hour' )
|| 00;
$StartDay = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStart::Day' );
$StartMonth = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStart::Month' );
$StartYear = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStart::Year' );
$StopMinute = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStop::Minute' )
|| 59;
$StopHour = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStop::Hour' )
|| 23;
$StopDay = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStop::Day' );
$StopMonth = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStop::Month' );
$StopYear = $ParamObject->GetParam( Param => $Param{Key} . '::TimeStop::Year' );
}
if (
$Used
&& $StartMinute && $StartHour && $StartDay && $StartMonth && $StartYear
&& $StopMinute && $StopHour && $StopDay && $StopMonth && $StopYear
)
{
# add hour, minutes and seconds,
# so that that the first and the last day is selected as well
my $StartDate = sprintf '%02d-%02d-%02d %02d:%02d:00'
, $StartYear, $StartMonth, $StartDay, $StartHour, $StartMinute;
my $StopDate = sprintf '%02d-%02d-%02d %02d:%02d:59'
, $StopYear, $StopMonth, $StopDay, $StopHour, $StopMinute;
return { '-between' => [ $StartDate, $StopDate ] };
}
return []; # no conditions by default
}
=head2 SearchInputCreate()
create a search input string
my $Value = $BackendObject->SearchInputCreate(
Key => 'Item::1::Node::3',
Item => $ItemRef,
Optional => 1, # (optional) default 0 (0|1)
);
=cut
sub SearchInputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
# just for convenience
my $Key = $Param{Key};
my $PrefixStart = $Key . '::TimeStart::';
my $PrefixStop = $Key . '::TimeStop::';
# get time related params
my %GetParam;
# get param object
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
if ( $Param{Value} ) {
%GetParam = %{ $Param{Value} };
}
else {
$GetParam{$Key} = $ParamObject->GetParam( Param => $Key );
for my $TimeType ( $PrefixStart, $PrefixStop ) {
for my $Part (qw( Year Month Day )) {
my $ParamKey = $TimeType . $Part;
my $ParamVal = $ParamObject->GetParam( Param => $ParamKey );
# remove white space on the start and end
if ($ParamVal) {
$ParamVal =~ s{ \A \s+ }{}xms;
$ParamVal =~ s{ \s+ \z }{}xms;
}
# store in %GetParam
$GetParam{$ParamKey} = $ParamVal;
}
}
}
# get layout object
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
# Build selection for the start and stop time.
my $TimeStartSelectionString = $LayoutObject->BuildDateSelection(
Prefix => $PrefixStart,
Format => 'DateInputFormatLong',
YearPeriodPast => 10,
YearPeriodFuture => 10,
%GetParam,
);
my $TimeStopSelectionString = $LayoutObject->BuildDateSelection(
Optional => 0,
Prefix => $PrefixStop,
Format => 'DateInputFormatLong',
YearPeriodPast => 10,
YearPeriodFuture => 10,
%GetParam,
);
my $Checkbox = qq{<input type="hidden" name="$Key" value="1"/>};
if ( $Param{Optional} ) {
$Checkbox = qq{<input type="checkbox" name="$Key" value="1"/>};
}
my $Between = $LayoutObject->{LanguageObject}->Translate('Between');
my $And = $LayoutObject->{LanguageObject}->Translate('and');
return "<div> $Checkbox $Between $TimeStartSelectionString </div>"
. "<span style=\"margin-left: 27px;\"> $And </span> $TimeStopSelectionString";
}
1;
=head1 TERMS AND CONDITIONS
This software is part of the OTRS project (L<https://otrs.org/>).
This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (GPL). If you
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
=cut

View File

@@ -0,0 +1,246 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::Output::HTML::ITSMConfigItem::LayoutDummy;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::System::Log',
'Kernel::Output::HTML::Layout',
'Kernel::System::Web::Request',
'Kernel::Config',
);
=head1 NAME
Kernel::Output::HTML::ITSMConfigItem::LayoutDummy - layout backend module
=head1 DESCRIPTION
All layout functions of dummy objects
=head2 new()
create an object
$BackendObject = Kernel::Output::HTML::ITSMConfigItem::LayoutDummy->new(
%Param,
);
=cut
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
return $Self;
}
=head2 OutputStringCreate()
create output string
my $Value = $BackendObject->OutputStringCreate();
=cut
sub OutputStringCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{Item} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need Item!',
);
return;
}
if ( !defined $Param{Value} ) {
$Param{Value} = '';
}
# get layout object
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
# translate
if ( $Param{Item}->{Input}->{Translation} ) {
$Param{Value} = $LayoutObject->{LanguageObject}->Translate( $Param{Value} );
}
my $LinkFeature = 1;
# do not transform links in print view
if ( $Param{Print} ) {
$LinkFeature = 0;
}
# transform ascii to html
$Param{Value} = $LayoutObject->Ascii2Html(
Text => $Param{Value},
HTMLResultMode => 1,
LinkFeature => $LinkFeature,
);
return $Param{Value};
}
=head2 FormDataGet()
get form data as hash reference
my $FormDataRef = $BackendObject->FormDataGet();
=cut
sub FormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my %FormData;
# get form data
$FormData{Value} = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Param{Key} );
# set invalid param
if ( $Param{Item}->{Input}->{Required} && !$FormData{Value} ) {
$FormData{Invalid} = 1;
$Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1;
}
return \%FormData;
}
=head2 InputCreate()
create a input string
my $Value = $BackendObject->InputCreate();
=cut
sub InputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my $Value = $Param{Value};
if ( !defined $Param{Value} ) {
$Value = $Param{Item}->{Input}->{ValueDefault} || '';
}
my $Class = '';
my $Size = 'W50pc';
my $Required = $Param{Required};
my $Invalid = $Param{Invalid};
my $ItemId = $Param{ItemId};
if ($Required) {
$Class .= ' Validate_Required';
}
if ($Invalid) {
$Class .= ' ServerError';
}
$Class .= ' ' . $Size;
my $String = "<span style=\"display: inline-block; height: 1.3em;\">";
$String
.= "<input style=\"display:none;\" type=\"text\" name=\"$Param{Key}\" class=\"$Class\" ";
if ($ItemId) {
$String .= "id=\"$ItemId\" ";
}
if ($Value) {
# get layout object
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
# translate
if ( $Param{Item}->{Input}->{Translation} ) {
$Value = $LayoutObject->{LanguageObject}->Translate($Value);
}
# transform ascii to html
$Value = $LayoutObject->Ascii2Html(
Text => $Value,
HTMLResultMode => 1,
);
}
$String .= "value=\"$Value\" ";
# add maximum length
if ( $Param{Item}->{Input}->{MaxLength} ) {
$String .= "maxlength=\"$Param{Item}->{Input}->{MaxLength}\" ";
}
$String .= '/> </span>';
return $String;
}
=head2 SearchFormDataGet()
get search form data
my $Value = $BackendObject->SearchFormDataGet();
=cut
sub SearchFormDataGet {
return [];
}
=head2 SearchInputCreate()
create a search input string
my $Value = $BackendObject->SearchInputCreate();
=cut
sub SearchInputCreate {
return '&nbsp;';
}
1;
=head1 TERMS AND CONDITIONS
This software is part of the OTRS project (L<https://otrs.org/>).
This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (GPL). If you
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
=cut

View File

@@ -0,0 +1,296 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::Output::HTML::ITSMConfigItem::LayoutGeneralCatalog;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::System::GeneralCatalog',
'Kernel::System::Log',
'Kernel::Output::HTML::Layout',
'Kernel::System::Web::Request'
);
=head1 NAME
Kernel::Output::HTML::ITSMConfigItem::LayoutGeneralCatalog - layout backend module
=head1 DESCRIPTION
All layout functions of general catalog objects
=head2 new()
create an object
$BackendObject = Kernel::Output::HTML::ITSMConfigItem::LayoutGeneralCatalog->new(
%Param,
);
=cut
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
return $Self;
}
=head2 OutputStringCreate()
create output string
my $Value = $BackendObject->OutputStringCreate(
Value => 11, # (optional)
Item => $ItemRef,
);
=cut
sub OutputStringCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{Item} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need Item!',
);
return;
}
$Param{Value} //= '';
# translate
if ( $Param{Item}->{Input}->{Translation} ) {
$Param{Value} = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->{LanguageObject}->Translate( $Param{Value} );
}
return $Param{Value};
}
=head2 FormDataGet()
get form data as hash reference
my $FormDataRef = $BackendObject->FormDataGet(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub FormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my %FormData;
# get form data
$FormData{Value} = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Param{Key} );
# set invalid param
if ( $Param{Item}->{Input}->{Required} && !$FormData{Value} ) {
$FormData{Invalid} = 1;
$Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1;
}
return \%FormData;
}
=head2 InputCreate()
create a input string
my $Value = $BackendObject->InputCreate(
Key => 'Item::1::Node::3',
Value => 11, # (optional)
Item => $ItemRef,
);
=cut
sub InputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my $CSSClass = 'Modernize';
my $Required = $Param{Required};
my $Invalid = $Param{Invalid};
my $ItemId = $Param{ItemId};
if ($Required) {
$CSSClass .= ' Validate_Required';
}
if ($Invalid) {
$CSSClass .= ' ServerError';
}
# translation on or off
my $Translation = 0;
if ( $Param{Item}->{Input}->{Translation} ) {
$Translation = 1;
}
# get class list
my $ClassList = $Kernel::OM->Get('Kernel::System::GeneralCatalog')->ItemList(
Class => $Param{Item}->{Input}->{Class} || '',
);
# reverse the class list
my %ReverseClassList = reverse %{$ClassList};
my $SelectedID;
# get the current value
if ( defined $Param{Value} ) {
$SelectedID = $Param{Value};
}
# get the default id by default value
else {
$SelectedID = $ReverseClassList{ $Param{Item}->{Input}->{ValueDefault} || '' } || '';
}
# generate string
my $String = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->BuildSelection(
Data => $ClassList,
Name => $Param{Key},
ID => $ItemId,
PossibleNone => 1,
Translation => $Translation,
SelectedID => $SelectedID,
Class => $CSSClass,
);
return $String;
}
=head2 SearchFormDataGet()
get search form data
my $Value = $BackendObject->SearchFormDataGet(
Key => 'Item::1::Node::3',
);
=cut
sub SearchFormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{Key} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need Key!',
);
return;
}
# get form data
my @Values;
if ( $Param{Value} ) {
@Values = @{ $Param{Value} };
}
else {
@Values = $Kernel::OM->Get('Kernel::System::Web::Request')->GetArray( Param => $Param{Key} );
}
return \@Values;
}
=head2 SearchInputCreate()
create a search input string
my $Value = $BackendObject->SearchInputCreate(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub SearchInputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my $Values = $Self->SearchFormDataGet(%Param);
# translation on or off
my $Translation = 0;
if ( $Param{Item}->{Input}->{Translation} ) {
$Translation = 1;
}
# get class list
my $ClassList = $Kernel::OM->Get('Kernel::System::GeneralCatalog')->ItemList(
Class => $Param{Item}->{Input}->{Class} || '',
);
# generate string
my $String = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->BuildSelection(
Data => $ClassList,
Name => $Param{Key},
Size => 5,
Multiple => 1,
Translation => $Translation,
SelectedID => $Values,
Class => 'Modernize',
);
return $String;
}
1;
=head1 TERMS AND CONDITIONS
This software is part of the OTRS project (L<https://otrs.org/>).
This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (GPL). If you
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
=cut

View File

@@ -0,0 +1,277 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::Output::HTML::ITSMConfigItem::LayoutInteger;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::System::Log',
'Kernel::Output::HTML::Layout',
'Kernel::System::Web::Request'
);
=head1 NAME
Kernel::Output::HTML::ITSMConfigItem::LayoutInteger - layout backend module
=head1 DESCRIPTION
All layout functions of integer objects
=head2 new()
create an object
$BackendObject = Kernel::Output::HTML::ITSMConfigItem::LayoutInteger->new(
%Param,
);
=cut
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
return $Self;
}
=head2 OutputStringCreate()
create output string
my $Value = $BackendObject->OutputStringCreate(
Value => 11, # (optional)
);
=cut
sub OutputStringCreate {
my ( $Self, %Param ) = @_;
if ( !defined $Param{Value} ) {
$Param{Value} = '';
}
return $Param{Value};
}
=head2 FormDataGet()
get form data as hash reference
my $FormDataRef = $BackendObject->FormDataGet(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub FormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my %FormData;
# get form data
$FormData{Value} = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Param{Key} );
# set invalid param
if ( $Param{Item}->{Input}->{Required} && !$FormData{Value} ) {
$FormData{Invalid} = 1;
$Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1;
}
return \%FormData;
}
=head2 InputCreate()
create a input string
my $Value = $BackendObject->InputCreate(
Key => 'Item::1::Node::3',
Value => 11, # (optional)
Item => $ItemRef,
);
=cut
sub InputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
# set min, max and default
my $ValueMin = $Param{Item}->{Input}->{ValueMin} // 1;
my $ValueMax = $Param{Item}->{Input}->{ValueMax} // 1;
if ( $ValueMin > $ValueMax ) {
$ValueMin = $ValueMax;
}
if (
$Param{Item}->{Input}->{ValueDefault}
&& (
$Param{Item}->{Input}->{ValueDefault} < $ValueMin
|| $Param{Item}->{Input}->{ValueDefault} > $ValueMax
)
)
{
$Param{Item}->{Input}->{ValueDefault} = '';
}
# create data array
my $IntegerList = [];
for my $Counter ( $ValueMin .. $ValueMax ) {
push @{$IntegerList}, $Counter;
}
# generate string
my $String = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->BuildSelection(
Data => $IntegerList,
Name => $Param{Key},
PossibleNone => 1,
Translation => 0,
SelectedID => $Param{Value} || $Param{Item}->{Input}->{ValueDefault} || '',
Class => 'Modernize',
);
return $String;
}
=head2 SearchFormDataGet()
get search form data
my $Value = $BackendObject->SearchFormDataGet(
Key => 'Item::1::Node::3',
);
=cut
sub SearchFormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{Key} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need Key!'
);
return;
}
# get form data
my @Values;
if ( $Param{Value} ) {
@Values = @{ $Param{Value} };
}
else {
@Values = $Kernel::OM->Get('Kernel::System::Web::Request')->GetArray( Param => $Param{Key} );
}
return \@Values;
}
=head2 SearchInputCreate()
create a search input string
my $Value = $BackendObject->SearchInputCreate(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub SearchInputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
# set min, max
my $ValueMin = $Param{Item}->{Input}->{ValueMin} // 1;
my $ValueMax = $Param{Item}->{Input}->{ValueMax} // 1;
if ( $ValueMin > $ValueMax ) {
$ValueMin = $ValueMax;
}
# set preselected value, either from previous selection or the default
my $Values = $Self->SearchFormDataGet(%Param);
# check whether the preselected value is within the valid range
my @FilteredValues;
VALUE:
for my $Value ( @{$Values} ) {
next VALUE if !defined $Value;
next VALUE if !$Value;
next VALUE if $Value < $ValueMin;
next VALUE if $Value > $ValueMax;
push @FilteredValues, $Value;
}
# create data array
my @IntegerList = ( $ValueMin .. $ValueMax );
# generate string
my $String = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->BuildSelection(
Data => \@IntegerList,
Name => $Param{Key},
Size => 5,
Translation => 0,
SelectedID => \@FilteredValues,
Multiple => 1,
Class => 'Modernize',
);
return $String;
}
1;
=head1 TERMS AND CONDITIONS
This software is part of the OTRS project (L<https://otrs.org/>).
This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (GPL). If you
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
=cut

View File

@@ -0,0 +1,312 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::Output::HTML::ITSMConfigItem::LayoutText;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::System::Log',
'Kernel::Output::HTML::Layout',
'Kernel::Config',
'Kernel::System::Web::Request'
);
=head1 NAME
Kernel::Output::HTML::ITSMConfigItem::LayoutText - layout backend module
=head1 DESCRIPTION
All layout functions of text objects
=head2 new()
create an object
$BackendObject = Kernel::Output::HTML::ITSMConfigItem::LayoutText->new(
%Param,
);
=cut
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
return $Self;
}
=head2 OutputStringCreate()
create output string
my $Value = $BackendObject->OutputStringCreate(
Value => 11, # (optional)
Item => $ItemRef,
);
=cut
sub OutputStringCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{Item} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need Item!',
);
return;
}
if ( !defined $Param{Value} ) {
$Param{Value} = '';
}
# get layout object
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
# translate
if ( $Param{Item}->{Input}->{Translation} ) {
$Param{Value} = $LayoutObject->{LanguageObject}->Translate( $Param{Value} );
}
my $LinkFeature = 1;
# do not transform links in print view
if ( $Param{Print} ) {
$LinkFeature = 0;
}
# transform ascii to html
$Param{Value} = $LayoutObject->Ascii2Html(
Text => $Param{Value},
HTMLResultMode => 1,
LinkFeature => $LinkFeature,
);
return $Param{Value};
}
=head2 FormDataGet()
get form data as hash reference
my $FormDataRef = $BackendObject->FormDataGet(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub FormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my %FormData;
# get form data
$FormData{Value} = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Param{Key} );
# set invalid param
if ( $Param{Item}->{Input}->{Required} && !defined $FormData{Value} ) {
$FormData{Invalid} = 1;
$Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1;
}
# value was entered in the form, a regex is defined and the value does not match the regex
if (
$FormData{Value}
&& $Param{Item}->{Input}->{RegEx}
&& $FormData{Value} !~ m{ $Param{Item}->{Input}->{RegEx} }xms
)
{
$FormData{Invalid} = 1;
$Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1;
$Param{Item}->{Form}->{ $Param{Key} }->{RegExErrorMessage} = $Param{Item}->{Input}->{RegExErrorMessage};
}
return \%FormData;
}
=head2 InputCreate()
create a input string
my $Value = $BackendObject->InputCreate(
Key => 'Item::1::Node::3',
Value => 11, # (optional)
Item => $ItemRef,
);
=cut
sub InputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my $Value = $Param{Value};
if ( !defined $Param{Value} ) {
$Value = $Param{Item}->{Input}->{ValueDefault} || '';
}
my $Class = '';
my $Size = 'W50pc';
my $Required = $Param{Required};
my $Invalid = $Param{Invalid};
my $ItemId = $Param{ItemId};
if ($Required) {
$Class .= ' Validate_Required';
}
if ($Invalid) {
$Class .= ' ServerError';
}
$Class .= ' ' . $Size;
my $String = "<input type=\"text\" name=\"$Param{Key}\" class=\"$Class\" ";
if ($ItemId) {
$String .= "id=\"$ItemId\" ";
}
if ($Value) {
# get layout object
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
# translate
if ( $Param{Item}->{Input}->{Translation} ) {
$Value = $LayoutObject->{LanguageObject}->Translate($Value);
}
# transform ascii to html
$Value = $LayoutObject->Ascii2Html(
Text => $Value,
HTMLResultMode => 1,
);
}
$String .= "value=\"$Value\" ";
# add maximum length
if ( $Param{Item}->{Input}->{MaxLength} ) {
$String .= "maxlength=\"$Param{Item}->{Input}->{MaxLength}\" ";
}
$String .= '/> ';
return $String;
}
=head2 SearchFormDataGet()
get search form data
my $Value = $BackendObject->SearchFormDataGet(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub SearchFormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{Key} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need Key!',
);
return;
}
# get form data
my $Value;
if ( $Param{Value} ) {
$Value = $Param{Value};
}
else {
$Value = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Param{Key} );
}
return $Value;
}
=head2 SearchInputCreate()
create a search input string
my $Value = $BackendObject->SearchInputCreate(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub SearchInputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my $Value = $Self->SearchFormDataGet(%Param);
if ( !defined $Value ) {
$Value = '';
}
my $String = qq{<input type="text" name="$Param{Key}" value="$Value" class="W50pc" >};
return $String;
}
1;
=head1 TERMS AND CONDITIONS
This software is part of the OTRS project (L<https://otrs.org/>).
This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (GPL). If you
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
=cut

View File

@@ -0,0 +1,290 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::Output::HTML::ITSMConfigItem::LayoutTextArea;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::System::Log',
'Kernel::Output::HTML::Layout',
'Kernel::Config',
'Kernel::System::Web::Request'
);
=head1 NAME
Kernel::Output::HTML::ITSMConfigItem::LayoutTextArea - layout backend module
=head1 DESCRIPTION
All layout functions of textarea objects
=head2 new()
create an object
$BackendObject = Kernel::Output::HTML::ITSMConfigItem::LayoutTextArea->new(
%Param,
);
=cut
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
return $Self;
}
=head2 OutputStringCreate()
create output string
my $Value = $BackendObject->OutputStringCreate(
Value => 11, # (optional)
Item => $ItemRef,
);
=cut
sub OutputStringCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{Item} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need Item!',
);
return;
}
if ( !defined $Param{Value} ) {
$Param{Value} = '';
}
# get layout object
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
# translate
if ( $Param{Item}->{Input}->{Translation} ) {
$Param{Value} = $LayoutObject->{LanguageObject}->Translate( $Param{Value} );
}
my $LinkFeature = 1;
my $HTMLResultMode = 1;
# do not transform links in print view
if ( $Param{Print} ) {
$LinkFeature = 0;
$HTMLResultMode = 0;
}
# transform ascii to html
$Param{Value} = $LayoutObject->Ascii2Html(
Text => $Param{Value},
HTMLResultMode => $HTMLResultMode,
LinkFeature => $LinkFeature,
);
return $Param{Value};
}
=head2 FormDataGet()
get form data as hash reference
my $FormDataRef = $BackendObject->FormDataGet(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub FormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my %FormData;
# get form data
$FormData{Value} = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Param{Key} );
# set invalid param
if ( $Param{Item}->{Input}->{Required} && !defined $FormData{Value} ) {
$FormData{Invalid} = 1;
$Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1;
}
# value was entered in the form, a regex is defined and the value does not match the regex
if (
$FormData{Value}
&& $Param{Item}->{Input}->{RegEx}
&& $FormData{Value} !~ m{ $Param{Item}->{Input}->{RegEx} }xms
)
{
$FormData{Invalid} = 1;
$Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1;
$Param{Item}->{Form}->{ $Param{Key} }->{RegExErrorMessage} = $Param{Item}->{Input}->{RegExErrorMessage};
}
return \%FormData;
}
=head2 InputCreate()
create a input string
my $Value = $BackendObject->InputCreate(
Key => 'Item::1::Node::3',
Value => 11, # (optional)
Item => $ItemRef,
);
=cut
sub InputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my $Cols = $Param{Item}->{Input}->{Cols} || 58;
my $Rows = $Param{Item}->{Input}->{Rows} || 10;
my $Value = $Param{Value};
if ( !defined $Param{Value} ) {
$Value = $Param{Item}->{Input}->{ValueDefault} || '';
}
my $Class = 'W50pc';
my $Required = $Param{Required};
my $Invalid = $Param{Invalid};
my $ItemId = $Param{ItemId};
if ($Required) {
$Class .= ' Validate_Required';
}
if ($Invalid) {
$Class .= ' ServerError';
}
# translate
if ( $Param{Item}->{Input}->{Translation} ) {
$Value = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->{LanguageObject}->Translate($Value);
}
my $String
= "<textarea name=\"$Param{Key}\" id=\"$ItemId\" cols=\"$Cols\" rows=\"$Rows\" class=\"$Class\">$Value</textarea>";
return $String;
}
=head2 SearchFormDataGet()
get search form data
my $Value = $BackendObject->SearchFormDataGet(
Key => 'Item::1::Node::3',
);
=cut
sub SearchFormDataGet {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{Key} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need Key!',
);
return;
}
# get form data
my $Value;
if ( $Param{Value} ) {
$Value = $Param{Value};
}
else {
$Value = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Param{Key} );
}
return $Value;
}
=head2 SearchInputCreate()
create a search input string
my $Value = $BackendObject->SearchInputCreate(
Key => 'Item::1::Node::3',
Item => $ItemRef,
);
=cut
sub SearchInputCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Argument (qw(Key Item)) {
if ( !$Param{$Argument} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Argument!",
);
return;
}
}
my $Value = $Self->SearchFormDataGet(%Param);
if ( !defined $Value ) {
$Value = '';
}
my $String = qq{<input type="text" name="$Param{Key}" value="$Value" class="W50pc">};
return $String;
}
1;
=head1 TERMS AND CONDITIONS
This software is part of the OTRS project (L<https://otrs.org/>).
This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (GPL). If you
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
=cut

View File

@@ -0,0 +1,145 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::Output::HTML::ITSMConfigItem::MenuGeneric;
use strict;
use warnings;
use parent('Kernel::Output::HTML::Base');
our @ObjectDependencies = (
'Kernel::Config',
'Kernel::Language',
'Kernel::Output::HTML::Layout',
'Kernel::System::Log',
'Kernel::System::Group',
);
sub Run {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{ConfigItem} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need ConfigItem!',
);
return;
}
# grant access by default
my $Access = 1;
# get action
my $Action = $Param{Config}->{Action};
if ( $Action eq 'AgentLinkObject' ) {
# The Link-link is a special case, as it is not specific to ITSMConfigItem.
# As a workaround we hardcode that AgentLinkObject is treated like AgentITSMConfigItemEdit
$Action = 'AgentITSMConfigItemEdit';
}
# get config object
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
# get groups
my $GroupsRo = $ConfigObject->Get('Frontend::Module')->{$Action}->{GroupRo} || [];
my $GroupsRw = $ConfigObject->Get('Frontend::Module')->{$Action}->{Group} || [];
# get layout object
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
# check permission
if ( $Action && ( @{$GroupsRo} || @{$GroupsRw} ) ) {
# deny access by default, when there are groups to check
$Access = 0;
# check read only groups
ROGROUP:
for my $RoGroup ( @{$GroupsRo} ) {
next ROGROUP if !$Kernel::OM->Get('Kernel::System::Group')->PermissionCheck(
UserID => $Self->{UserID},
GroupName => $RoGroup,
Type => 'ro',
);
# set access
$Access = 1;
last ROGROUP;
}
# check read write groups
RWGROUP:
for my $RwGroup ( @{$GroupsRw} ) {
next RWGROUP if !$Kernel::OM->Get('Kernel::System::Group')->PermissionCheck(
UserID => $Self->{UserID},
GroupName => $RwGroup,
Type => 'rw',
);
# set access
$Access = 1;
last RWGROUP;
}
}
return $Param{Counter} if !$Access;
# output menu block
$LayoutObject->Block( Name => 'Menu' );
# output menu item
$LayoutObject->Block(
Name => 'MenuItem',
Data => {
%Param,
%{ $Param{ConfigItem} },
%{ $Param{Config} },
},
);
# check if a dialog has to be shown
if ( $Param{Config}->{DialogTitle} ) {
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
my $LanguageObject = $Kernel::OM->Get('Kernel::Language');
# Replace the template toolkit expressions with the final value.
my %JSData = (
%Param,
%{ $Param{ConfigItem} },
%{ $Param{Config} },
);
delete $JSData{Config};
delete $JSData{ConfigItem};
$JSData{ElementSelector} =~ s/\[%\s*Data\.MenuID\s*\|\s*html\s*%\]/$JSData{MenuID}/i;
$JSData{DialogContentQueryString} =~ s/\[%\s*Data\.ConfigItemID\s*\|\s*html\s*%\]/$JSData{ConfigItemID}/i;
$JSData{ConfirmedActionQueryString} =~ s/\[%\s*Data\.ConfigItemID\s*\|\s*html\s*%\]/$JSData{ConfigItemID}/i;
$JSData{DialogTitle} =~ s/\[%\s*Translate\("(.*)"\)\s*\|\s*html\s*%\]/$LanguageObject->Translate($1)/ei;
$JSData{DialogTitle} =~ s/\[%\s*Config\("(.*)"\)\s*%\]/$ConfigObject->Get($1)/ei;
$JSData{DialogTitle} =~ s/\[%\s*Data.Number\s*\|\s*html\s*%\]/$JSData{Number}/ei;
$JSData{MenuID} = 'Menu' . $JSData{MenuID};
$LayoutObject->AddJSData(
Key => 'ITSMShowConfirmDialog.' . $Param{MenuID},
Value => \%JSData,
);
}
$Param{Counter}++;
return $Param{Counter};
}
1;

View File

@@ -0,0 +1,526 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::Output::HTML::ITSMConfigItem::OverviewSmall;
use strict;
use warnings;
use Kernel::Language qw(Translatable);
our @ObjectDependencies = (
'Kernel::Config',
'Kernel::Output::HTML::Layout',
'Kernel::System::GeneralCatalog',
'Kernel::System::Group',
'Kernel::System::HTMLUtils',
'Kernel::System::ITSMConfigItem',
'Kernel::System::Log',
'Kernel::System::Main',
);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {%Param};
bless( $Self, $Type );
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
# get log object
my $LogObject = $Kernel::OM->Get('Kernel::System::Log');
# check needed stuff
for my $Needed (qw(PageShown StartHit)) {
if ( !$Param{$Needed} ) {
$LogObject->Log(
Priority => 'error',
Message => "Need $Needed!",
);
return;
}
}
# need ConfigItemIDs
if ( !$Param{ConfigItemIDs} ) {
$LogObject->Log(
Priority => 'error',
Message => 'Need the ConfigItemIDs!',
);
return;
}
# define incident signals, needed for services
my %InciSignals = (
Translatable('operational') => 'greenled',
Translatable('warning') => 'yellowled',
Translatable('incident') => 'redled',
);
# to store the color for the deployment states
my %DeplSignals;
# get general catalog object
my $GeneralCatalogObject = $Kernel::OM->Get('Kernel::System::GeneralCatalog');
# get list of deployment states
my $DeploymentStatesList = $GeneralCatalogObject->ItemList(
Class => 'ITSM::ConfigItem::DeploymentState',
);
# set deployment style colors
my $StyleClasses = '';
ITEMID:
for my $ItemID ( sort keys %{$DeploymentStatesList} ) {
# get deployment state preferences
my %Preferences = $GeneralCatalogObject->GeneralCatalogPreferencesGet(
ItemID => $ItemID,
);
# check if a color is defined in preferences
next ITEMID if !$Preferences{Color};
# get deployment state
my $DeplState = $DeploymentStatesList->{$ItemID};
# remove any non ascii word characters
$DeplState =~ s{ [^a-zA-Z0-9] }{_}msxg;
# store the original deployment state as key
# and the ss safe coverted deployment state as value
$DeplSignals{ $DeploymentStatesList->{$ItemID} } = $DeplState;
# covert to lower case
my $DeplStateColor = lc $Preferences{Color};
# add to style classes string
$StyleClasses .= "
.Flag span.$DeplState {
background-color: #$DeplStateColor;
}
";
}
# wrap into style tags
if ($StyleClasses) {
$StyleClasses = "<style>$StyleClasses</style>";
}
# store either ConfigItem IDs Locally
my @ConfigItemIDs = @{ $Param{ConfigItemIDs} };
# get needed objects
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
# check if bulk feature is enabled
my $BulkFeature = 0;
if ( $ConfigObject->Get('ITSMConfigItem::Frontend::BulkFeature') ) {
my @Groups;
if ( $ConfigObject->Get('ITSMConfigItem::Frontend::BulkFeatureGroup') ) {
@Groups = @{ $ConfigObject->Get('ITSMConfigItem::Frontend::BulkFeatureGroup') };
}
if ( !@Groups ) {
$BulkFeature = 1;
}
else {
GROUP:
for my $Group (@Groups) {
next GROUP if !$Kernel::OM->Get('Kernel::System::Group')->PermissionCheck(
UserID => $Self->{UserID},
GroupName => $Group,
Type => 'rw',
);
$BulkFeature = 1;
last GROUP;
}
}
}
# get config item pre menu modules
my @ActionItems;
if ( ref $ConfigObject->Get('ITSMConfigItem::Frontend::PreMenuModule') eq 'HASH' ) {
my %Menus = %{ $ConfigObject->Get('ITSMConfigItem::Frontend::PreMenuModule') };
MENU:
for my $MenuKey ( sort keys %Menus ) {
# load module
if ( $Kernel::OM->Get('Kernel::System::Main')->Require( $Menus{$MenuKey}->{Module} ) ) {
my $Object = $Menus{$MenuKey}->{Module}->new(
%{$Self},
);
# check if the menu is available
next MENU if ref $Menus{$MenuKey} ne 'HASH';
# set classes
if ( $Menus{$MenuKey}->{Target} ) {
if ( $Menus{$MenuKey}->{Target} eq 'PopUp' ) {
$Menus{$MenuKey}->{MenuClass} = 'AsPopup';
$Menus{$MenuKey}->{PopupType} = 'ITSMConfigItemAction';
}
else {
$Menus{$MenuKey}->{MenuClass} = '';
$Menus{$MenuKey}->{PopupType} = '';
}
}
# grant access by default
my $Access = 1;
my $Action = $Menus{$MenuKey}->{Action};
# can not execute the module due to a ConfigItem is required, then just check the
# permissions as in the MenuModuleGeneric
my $GroupsRo = $ConfigObject->Get('Frontend::Module')->{$Action}->{GroupRo} || [];
my $GroupsRw = $ConfigObject->Get('Frontend::Module')->{$Action}->{Group} || [];
# check permission
if ( $Action && ( @{$GroupsRo} || @{$GroupsRw} ) ) {
# deny access by default, when there are groups to check
$Access = 0;
# check read only groups
ROGROUP:
for my $RoGroup ( @{$GroupsRo} ) {
next ROGROUP if !$Kernel::OM->Get('Kernel::System::Group')->PermissionCheck(
UserID => $Self->{UserID},
GroupName => $RoGroup,
Type => 'ro',
);
# set access
$Access = 1;
last ROGROUP;
}
# check read write groups
RWGROUP:
for my $RwGroup ( @{$GroupsRw} ) {
next RWGROUP if !$Kernel::OM->Get('Kernel::System::Group')->PermissionCheck(
UserID => $Self->{UserID},
GroupName => $RwGroup,
Type => 'rw',
);
# set access
$Access = 1;
last RWGROUP;
}
}
# return if there is no access to the module
next MENU if !$Access;
# translate Name and Description
my $Description = $LayoutObject->{LanguageObject}->Translate( $Menus{$MenuKey}->{Description} );
my $Name = $LayoutObject->{LanguageObject}->Translate( $Menus{$MenuKey}->{Description} );
# generarte a web safe link
my $Link = $LayoutObject->{Baselink} . $Menus{$MenuKey}->{Link};
# sanity check
if ( !defined $Menus{$MenuKey}->{MenuClass} ) {
$Menus{$MenuKey}->{MenuClass} = '';
}
# generate HTML for the menu item
my $MenuHTML = << "END";
<li>
<a href="$Link" class="$Menus{$MenuKey}->{MenuClass}" title="$Description">$Name</a>
</li>
END
$MenuHTML =~ s/\n+//g;
$MenuHTML =~ s/\s+/ /g;
$MenuHTML =~ s/<\!--.+?-->//g;
$Menus{$MenuKey}->{ID} = $Menus{$MenuKey}->{Name};
$Menus{$MenuKey}->{ID} =~ s/(\s|&|;)//ig;
push @ActionItems, {
HTML => $MenuHTML,
ID => $Menus{$MenuKey}->{ID},
Link => $Link,
Target => $Menus{$MenuKey}->{Target},
PopupType => $Menus{$MenuKey}->{PopupType},
Description => $Description,
};
}
}
}
# check ShowColumns parameter
my @ShowColumns;
my @XMLShowColumns;
if ( $Param{ShowColumns} && ref $Param{ShowColumns} eq 'ARRAY' ) {
@ShowColumns = @{ $Param{ShowColumns} };
}
# get config item object
my $ConfigItemObject = $Kernel::OM->Get('Kernel::System::ITSMConfigItem');
# build column header blocks
if (@ShowColumns) {
# show the bulk action button checkboxes if feature is enabled
if ($BulkFeature) {
push @ShowColumns, 'BulkAction';
}
for my $Column (@ShowColumns) {
# create needed veriables
my $CSS = 'OverviewHeader';
my $OrderBy;
# remove ID if necesary
if ( $Param{SortBy} ) {
$Param{SortBy} = ( $Param{SortBy} eq 'InciStateID' )
? 'CurInciState'
: ( $Param{SortBy} eq 'DeplStateID' ) ? 'CurDeplState'
: ( $Param{SortBy} eq 'ClassID' ) ? 'Class'
: ( $Param{SortBy} eq 'ChangeTime' ) ? 'LastChanged'
: $Param{SortBy};
}
# set the correct Set CSS class and order by link
if ( $Param{SortBy} && ( $Param{SortBy} eq $Column ) ) {
if ( $Param{OrderBy} && ( $Param{OrderBy} eq 'Up' ) ) {
$OrderBy = 'Down';
$CSS .= ' SortDescendingLarge';
}
else {
$OrderBy = 'Up';
$CSS .= ' SortAscendingLarge';
}
}
else {
$OrderBy = 'Up';
}
$LayoutObject->Block(
Name => 'Record' . $Column . 'Header',
Data => {
%Param,
CSS => $CSS,
OrderBy => $OrderBy,
},
);
}
# get the XML column headers only if the filter is not set to 'all'
# and if there are CIs to show
if ( $Param{Filter} && $Param{Filter} ne 'All' && @ConfigItemIDs ) {
# get the version data of the first config item, including all the XML data
# to get the column header names
my $ConfigItem = $ConfigItemObject->VersionGet(
ConfigItemID => $ConfigItemIDs[0],
XMLDataGet => 1,
);
# convert the XML data into a hash
my $ExtendedVersionData = $LayoutObject->XMLData2Hash(
XMLDefinition => $ConfigItem->{XMLDefinition},
XMLData => $ConfigItem->{XMLData}->[1]->{Version}->[1],
Attributes => \@ShowColumns,
Print => 1,
);
# get the xml columns (they contain ::)
@XMLShowColumns = grep {/::/} @ShowColumns;
COLUMN:
for my $Column (@XMLShowColumns) {
# check if column exists in CI-Data
next COLUMN if !$ExtendedVersionData->{$Column}->{Name};
# show the xml attribute header
$LayoutObject->Block(
Name => 'RecordXMLAttributeHeader',
Data => {
%Param,
XMLAttributeHeader => $ExtendedVersionData->{$Column}->{Name},
},
);
}
}
}
my $Output = '';
my $Counter = 0;
# show config items if there are some
if (@ConfigItemIDs) {
# to store all data
my %Data;
CONFIGITEMID:
for my $ConfigItemID (@ConfigItemIDs) {
$Counter++;
if (
$Counter >= $Param{StartHit}
&& $Counter < ( $Param{PageShown} + $Param{StartHit} )
)
{
# check for access rights
my $HasAccess = $ConfigItemObject->Permission(
Scope => 'Item',
ItemID => $ConfigItemID,
UserID => $Self->{UserID},
Type => $Self->{Config}->{Permission},
);
next CONFIGITEMID if !$HasAccess;
# get config item data
my $ConfigItem = $ConfigItemObject->VersionGet(
ConfigItemID => $ConfigItemID,
XMLDataGet => 1,
);
next CONFIGITEMID if !$ConfigItem;
# convert the XML data into a hash
my $ExtendedVersionData = $LayoutObject->XMLData2Hash(
XMLDefinition => $ConfigItem->{XMLDefinition},
XMLData => $ConfigItem->{XMLData}->[1]->{Version}->[1],
Attributes => \@ShowColumns,
Print => 1,
);
# store config item data,
%Data = %{$ConfigItem};
# Get config item data for 'CreateTime' and 'ChangeTime'.
my $ConfigItemData = $ConfigItemObject->ConfigItemGet(
ConfigItemID => $ConfigItemID,
);
$Data{CreateTime} = $ConfigItemData->{CreateTime};
$Data{ChangeTime} = $ConfigItemData->{ChangeTime};
# build record block
$LayoutObject->Block(
Name => 'Record',
Data => {
%Param,
%Data,
},
);
# build column record blocks
if (@ShowColumns) {
COLUMN:
for my $Column (@ShowColumns) {
$LayoutObject->Block(
Name => 'Record' . $Column,
Data => {
%Param,
%Data,
CurInciSignal => $InciSignals{ $Data{CurInciStateType} },
CurDeplSignal => $DeplSignals{ $Data{CurDeplState} },
},
);
}
COLUMN:
for my $Column (@XMLShowColumns) {
# check if column exists in CI-Data
next COLUMN if !$ExtendedVersionData->{$Column}->{Name};
# Convert to ascii text in case the value contains html.
my $Value = $Kernel::OM->Get('Kernel::System::HTMLUtils')
->ToAscii( String => $ExtendedVersionData->{$Column}->{Value} // '' ) // '';
# convert all whitespace and newlines to single spaces
$Value =~ s{ \s+ }{ }gxms;
# show the xml attribute data
$LayoutObject->Block(
Name => 'RecordXMLAttribute',
Data => {
%Param,
XMLAttributeData => $Value,
},
);
}
}
# make a deep copy of the action items to avoid changing the definition
my $ClonedActionItems = Storable::dclone( \@ActionItems );
# substitute TT variables
for my $ActionItem ( @{$ClonedActionItems} ) {
$ActionItem->{HTML} =~ s{ \Q[% Data.ConfigItemID | html %]\E }{$ConfigItemID}xmsg;
$ActionItem->{HTML} =~ s{ \Q[% Data.VersionID | html %]\E }{$ConfigItem->{VersionID}}xmsg;
$ActionItem->{Link} =~ s{ \Q[% Data.ConfigItemID | html %]\E }{$ConfigItemID}xmsg;
$ActionItem->{Link} =~ s{ \Q[% Data.VersionID | html %]\E }{$ConfigItem->{VersionID}}xmsg;
}
#my $JSON = $LayoutObject->JSONEncode(
# Data => $ClonedActionItems,
#);
#$LayoutObject->Block(
# Name => 'DocumentReadyActionRowAdd',
# Data => {
# ConfigItemID => $ConfigItemID,
# Data => $JSON,
# },
#);
$LayoutObject->AddJSData(
Key => 'ITSMConfigItemActionRow.' . $ConfigItemID,
Value => $ClonedActionItems,
);
}
}
}
# if there are no config items to show, a no data found message is displayed in the table
else {
$LayoutObject->Block(
Name => 'NoDataFoundMsg',
Data => {
TotalColumns => scalar @ShowColumns,
},
);
}
# use template
$Output .= $LayoutObject->Output(
TemplateFile => 'AgentITSMConfigItemOverviewSmall',
Data => {
%Param,
Type => $Self->{ViewType},
ColumnCount => scalar @ShowColumns,
StyleClasses => $StyleClasses,
},
);
return $Output;
}
1;