# -- # 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::ITSMSLAMenu::Generic; use strict; use warnings; our @ObjectDependencies = ( 'Kernel::Config', 'Kernel::Output::HTML::Layout', 'Kernel::System::Group', 'Kernel::System::Log', ); sub new { my ( $Type, %Param ) = @_; # allocate new hash for object my $Self = {}; bless( $Self, $Type ); # check UserID param $Self->{UserID} = $Param{UserID} || die "Got no UserID!"; return $Self; } sub Run { my ( $Self, %Param ) = @_; # check needed stuff if ( !$Param{SLA} ) { $Kernel::OM->Get('Kernel::System::Log')->Log( Priority => 'error', Message => 'Need SLA!', ); return; } # get config object my $ConfigObject = $Kernel::OM->Get('Kernel::Config'); # get groups my $GroupsRo = $ConfigObject->Get('Frontend::Module')->{ $Param{Config}->{Action} }->{GroupRo} || []; my $GroupsRw = $ConfigObject->Get('Frontend::Module')->{ $Param{Config}->{Action} }->{Group} || []; # set access my $Access = 1; # get layout object my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout'); # check permission if ( $Param{Config}->{Action} && ( @{$GroupsRo} || @{$GroupsRw} ) ) { # set access $Access = 0; # find 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; } # find 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 item $LayoutObject->Block( Name => 'MenuItem', Data => { %Param, %{ $Param{SLA} }, %{ $Param{Config} }, }, ); $Param{Counter}++; return $Param{Counter}; } 1;