# -- # 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::ITSMServiceMenu::Link; use strict; use warnings; our @ObjectDependencies = ( 'Kernel::Config', 'Kernel::Output::HTML::Layout', 'Kernel::System::Group', 'Kernel::System::LinkObject', '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{Service} ) { $Kernel::OM->Get('Kernel::System::Log')->Log( Priority => 'error', Message => 'Need Service!', ); return; } # get groups my $GroupsRw = $Kernel::OM->Get('Kernel::Config')->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} && @{$GroupsRw} ) { # set access $Access = 0; # 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; # check if services can be linked with other objects my %PossibleObjects = $Kernel::OM->Get('Kernel::System::LinkObject')->PossibleObjectsList( Object => 'Service', UserID => $Self->{UserID}, ); # don't show link menu item if there are no linkable objects return if !%PossibleObjects; $LayoutObject->Block( Name => 'MenuItem', Data => { %Param, %{ $Param{Service} }, %{ $Param{Config} }, }, ); $Param{Counter}++; return $Param{Counter}; } 1;