init III
This commit is contained in:
123
Perl OTRS/Kernel/Output/HTML/TicketMenu/Generic.pm
Normal file
123
Perl OTRS/Kernel/Output/HTML/TicketMenu/Generic.pm
Normal file
@@ -0,0 +1,123 @@
|
||||
# --
|
||||
# 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::TicketMenu::Generic;
|
||||
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::System::Log',
|
||||
'Kernel::Config',
|
||||
'Kernel::System::Ticket',
|
||||
'Kernel::System::Group',
|
||||
);
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# get log object
|
||||
my $LogObject = $Kernel::OM->Get('Kernel::System::Log');
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{Ticket} ) {
|
||||
$LogObject->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need Ticket!'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# get config object
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# check if frontend module registered, if not, do not show action
|
||||
if ( $Param{Config}->{Action} ) {
|
||||
my $Module = $ConfigObject->Get('Frontend::Module')->{ $Param{Config}->{Action} };
|
||||
return if !$Module;
|
||||
|
||||
# get ticket object
|
||||
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
|
||||
|
||||
# check permission
|
||||
my $Config = $ConfigObject->Get("Ticket::Frontend::$Param{Config}->{Action}");
|
||||
|
||||
if ( $Config->{Permission} ) {
|
||||
my $AccessOk = $TicketObject->TicketPermission(
|
||||
Type => $Config->{Permission},
|
||||
TicketID => $Param{Ticket}->{TicketID},
|
||||
UserID => $Self->{UserID},
|
||||
LogNo => 1,
|
||||
);
|
||||
return if !$AccessOk;
|
||||
}
|
||||
if ( $Config->{RequiredLock} ) {
|
||||
if (
|
||||
$TicketObject->TicketLockGet( TicketID => $Param{Ticket}->{TicketID} )
|
||||
)
|
||||
{
|
||||
my $AccessOk = $TicketObject->OwnerCheck(
|
||||
TicketID => $Param{Ticket}->{TicketID},
|
||||
OwnerID => $Self->{UserID},
|
||||
);
|
||||
return if !$AccessOk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# group check
|
||||
if ( $Param{Config}->{Group} ) {
|
||||
|
||||
my @Items = split /;/, $Param{Config}->{Group};
|
||||
|
||||
my $AccessOk;
|
||||
ITEM:
|
||||
for my $Item (@Items) {
|
||||
|
||||
my ( $Permission, $Name ) = $Item =~ m{^([^:]+):(.*)$};
|
||||
|
||||
if ( !$Permission || !$Name ) {
|
||||
$LogObject->Log(
|
||||
Priority => 'error',
|
||||
Message => "Invalid config for Key Group: '$Item'! "
|
||||
. "Need something like '\$Permission:\$Group;'",
|
||||
);
|
||||
}
|
||||
|
||||
my %Groups = $Kernel::OM->Get('Kernel::System::Group')->PermissionUserGet(
|
||||
UserID => $Self->{UserID},
|
||||
Type => $Permission,
|
||||
);
|
||||
|
||||
next ITEM if !%Groups;
|
||||
|
||||
my %GroupsReverse = reverse %Groups;
|
||||
|
||||
next ITEM if !$GroupsReverse{$Name};
|
||||
|
||||
$AccessOk = 1;
|
||||
|
||||
last ITEM;
|
||||
}
|
||||
|
||||
return if !$AccessOk;
|
||||
}
|
||||
|
||||
# check acl
|
||||
if ( $Param{Config}->{Action} ) {
|
||||
my %ACLLookup = reverse( %{ $Param{ACL} || {} } );
|
||||
return if ( !$ACLLookup{ $Param{Config}->{Action} } );
|
||||
}
|
||||
|
||||
# return item
|
||||
return { %{ $Param{Config} }, %{ $Param{Ticket} }, %Param };
|
||||
}
|
||||
|
||||
1;
|
||||
127
Perl OTRS/Kernel/Output/HTML/TicketMenu/ITSMChange.pm
Normal file
127
Perl OTRS/Kernel/Output/HTML/TicketMenu/ITSMChange.pm
Normal file
@@ -0,0 +1,127 @@
|
||||
# --
|
||||
# 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::TicketMenu::ITSMChange;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::System::Group',
|
||||
'Kernel::System::ITSMChange',
|
||||
'Kernel::System::Log',
|
||||
);
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
# allocate new hash for object
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
# get UserID param
|
||||
$Self->{UserID} = $Param{UserID} || die "Got no UserID!";
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{Ticket} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need Ticket!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# get config object
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# if an action parameter was given
|
||||
if ( $Param{Config}->{Action} ) {
|
||||
|
||||
# check if frontend module is registered, if not, do not show action
|
||||
my $Module = $ConfigObject->Get('Frontend::Module')->{ $Param{Config}->{Action} };
|
||||
return if !$Module;
|
||||
|
||||
# check if current user has the permission for the given action
|
||||
if ( $Module->{GroupRo} && ref $Module->{GroupRo} eq 'ARRAY' && @{ $Module->{GroupRo} } ) {
|
||||
|
||||
my $Access;
|
||||
|
||||
GROUP:
|
||||
for my $Group ( @{ $Module->{GroupRo} } ) {
|
||||
|
||||
# get group object
|
||||
my $GroupObject = $Kernel::OM->Get('Kernel::System::Group');
|
||||
|
||||
# lookup the group id
|
||||
my $GroupID = $GroupObject->GroupLookup(
|
||||
Group => $Group,
|
||||
);
|
||||
|
||||
# do not grant access, when the group is not found
|
||||
next GROUP if !$GroupID;
|
||||
|
||||
# get user groups, where the user has the 'ro' privilege
|
||||
my %Groups = $GroupObject->GroupMemberList(
|
||||
UserID => $Self->{UserID},
|
||||
Type => 'ro',
|
||||
Result => 'HASH',
|
||||
);
|
||||
|
||||
# remember that the user has access
|
||||
if ( $Groups{$GroupID} ) {
|
||||
$Access = 1;
|
||||
}
|
||||
}
|
||||
|
||||
# do not grant access if the agent doesn't have the 'ro' rights in the group
|
||||
return if !$Access;
|
||||
}
|
||||
}
|
||||
|
||||
# the link is shown only for the configured ticket types,
|
||||
# so the ticket needs to have a type.
|
||||
return if !$Param{Ticket}->{Type};
|
||||
|
||||
# get and check the list of relevant ticket types
|
||||
my $AddChangeLinkTicketTypes = $ConfigObject->Get('ITSMChange::AddChangeLinkTicketTypes');
|
||||
|
||||
return if !$AddChangeLinkTicketTypes;
|
||||
return if ref $AddChangeLinkTicketTypes ne 'ARRAY';
|
||||
return if !@{$AddChangeLinkTicketTypes};
|
||||
|
||||
# check whether the ticket's type is relevant
|
||||
my %IsRelevant = map { $_ => 1 } @{$AddChangeLinkTicketTypes};
|
||||
|
||||
return if !$IsRelevant{ $Param{Ticket}->{Type} };
|
||||
|
||||
# check permission
|
||||
my $FrontendConfig = $ConfigObject->Get("ITSMChange::Frontend::$Param{Config}->{Action}");
|
||||
|
||||
if ( $FrontendConfig && $FrontendConfig->{Permission} ) {
|
||||
|
||||
my $Access = $Kernel::OM->Get('Kernel::System::ITSMChange')->Permission(
|
||||
Type => $FrontendConfig->{Permission},
|
||||
Action => $Param{Config}->{Action},
|
||||
UserID => $Self->{UserID},
|
||||
LogNo => 1,
|
||||
);
|
||||
|
||||
return if !$Access;
|
||||
}
|
||||
|
||||
return { %{ $Param{Config} }, %{ $Param{Ticket} }, %Param, };
|
||||
}
|
||||
|
||||
1;
|
||||
139
Perl OTRS/Kernel/Output/HTML/TicketMenu/Lock.pm
Normal file
139
Perl OTRS/Kernel/Output/HTML/TicketMenu/Lock.pm
Normal file
@@ -0,0 +1,139 @@
|
||||
# --
|
||||
# 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::TicketMenu::Lock;
|
||||
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Kernel::Language qw(Translatable);
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::System::Log',
|
||||
'Kernel::Config',
|
||||
'Kernel::System::Ticket',
|
||||
'Kernel::System::Group',
|
||||
);
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# get log object
|
||||
my $LogObject = $Kernel::OM->Get('Kernel::System::Log');
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{Ticket} ) {
|
||||
$LogObject->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need Ticket!'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# check if frontend module registered, if not, do not show action
|
||||
if ( $Param{Config}->{Action} ) {
|
||||
my $Module = $Kernel::OM->Get('Kernel::Config')->Get('Frontend::Module')->{ $Param{Config}->{Action} };
|
||||
return if !$Module;
|
||||
}
|
||||
|
||||
# get ticket object
|
||||
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
|
||||
|
||||
# check lock permission
|
||||
my $AccessOk = $TicketObject->TicketPermission(
|
||||
Type => 'lock',
|
||||
TicketID => $Param{Ticket}->{TicketID},
|
||||
UserID => $Self->{UserID},
|
||||
LogNo => 1,
|
||||
);
|
||||
return if !$AccessOk;
|
||||
|
||||
# check permission
|
||||
if ( $TicketObject->TicketLockGet( TicketID => $Param{Ticket}->{TicketID} ) ) {
|
||||
my $AccessOk = $TicketObject->OwnerCheck(
|
||||
TicketID => $Param{Ticket}->{TicketID},
|
||||
OwnerID => $Self->{UserID},
|
||||
);
|
||||
return if !$AccessOk;
|
||||
}
|
||||
|
||||
# group check
|
||||
if ( $Param{Config}->{Group} ) {
|
||||
|
||||
my @Items = split /;/, $Param{Config}->{Group};
|
||||
|
||||
my $AccessOk;
|
||||
ITEM:
|
||||
for my $Item (@Items) {
|
||||
|
||||
my ( $Permission, $Name ) = split /:/, $Item;
|
||||
|
||||
if ( !$Permission || !$Name ) {
|
||||
$LogObject->Log(
|
||||
Priority => 'error',
|
||||
Message => "Invalid config for Key Group: '$Item'! "
|
||||
. "Need something like '\$Permission:\$Group;'",
|
||||
);
|
||||
}
|
||||
|
||||
my %Groups = $Kernel::OM->Get('Kernel::System::Group')->PermissionUserGet(
|
||||
UserID => $Self->{UserID},
|
||||
Type => $Permission,
|
||||
);
|
||||
|
||||
next ITEM if !%Groups;
|
||||
|
||||
my %GroupsReverse = reverse %Groups;
|
||||
|
||||
next ITEM if !$GroupsReverse{$Name};
|
||||
|
||||
$AccessOk = 1;
|
||||
|
||||
last ITEM;
|
||||
}
|
||||
|
||||
return if !$AccessOk;
|
||||
}
|
||||
|
||||
# check acl
|
||||
my %ACLLookup = reverse( %{ $Param{ACL} || {} } );
|
||||
return if ( !$ACLLookup{ $Param{Config}->{Action} } );
|
||||
|
||||
# if ticket is locked
|
||||
if ( $Param{Ticket}->{Lock} eq 'lock' ) {
|
||||
|
||||
# if it is locked for somebody else
|
||||
return if $Param{Ticket}->{OwnerID} ne $Self->{UserID};
|
||||
|
||||
# show unlock action
|
||||
return {
|
||||
%{ $Param{Config} },
|
||||
%{ $Param{Ticket} },
|
||||
%Param,
|
||||
Name => Translatable('Unlock'),
|
||||
Description => Translatable('Unlock to give it back to the queue'),
|
||||
Link =>
|
||||
'Action=AgentTicketLock;Subaction=Unlock;TicketID=[% Data.TicketID | uri %];[% Env("ChallengeTokenParam") | html %]',
|
||||
};
|
||||
}
|
||||
|
||||
# if ticket is unlocked
|
||||
return {
|
||||
%{ $Param{Config} },
|
||||
%{ $Param{Ticket} },
|
||||
%Param,
|
||||
Name => Translatable('Lock'),
|
||||
Description => Translatable('Lock it to work on it'),
|
||||
Link =>
|
||||
'Action=AgentTicketLock;Subaction=Lock;TicketID=[% Data.TicketID | uri %];[% Env("ChallengeTokenParam") | html %]',
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
138
Perl OTRS/Kernel/Output/HTML/TicketMenu/Move.pm
Normal file
138
Perl OTRS/Kernel/Output/HTML/TicketMenu/Move.pm
Normal file
@@ -0,0 +1,138 @@
|
||||
# --
|
||||
# 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::TicketMenu::Move;
|
||||
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::System::Log',
|
||||
'Kernel::Config',
|
||||
'Kernel::System::Ticket',
|
||||
'Kernel::System::Group',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
);
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# get log object
|
||||
my $LogObject = $Kernel::OM->Get('Kernel::System::Log');
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{Ticket} ) {
|
||||
$LogObject->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need Ticket!'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# get config object
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# check if frontend module registered, if not, do not show action
|
||||
if ( $Param{Config}->{Action} ) {
|
||||
my $Module = $ConfigObject->Get('Frontend::Module')->{ $Param{Config}->{Action} };
|
||||
return if !$Module;
|
||||
}
|
||||
|
||||
# get ticket object
|
||||
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
|
||||
|
||||
# check permission
|
||||
my $Config = $ConfigObject->Get("Ticket::Frontend::$Param{Config}->{Action}");
|
||||
if ($Config) {
|
||||
if ( $Config->{Permission} ) {
|
||||
my $AccessOk = $TicketObject->Permission(
|
||||
Type => $Config->{Permission},
|
||||
TicketID => $Param{Ticket}->{TicketID},
|
||||
UserID => $Self->{UserID},
|
||||
LogNo => 1,
|
||||
);
|
||||
return if !$AccessOk;
|
||||
}
|
||||
}
|
||||
|
||||
# group check
|
||||
if ( $Param{Config}->{Group} ) {
|
||||
|
||||
my @Items = split /;/, $Param{Config}->{Group};
|
||||
|
||||
my $AccessOk;
|
||||
ITEM:
|
||||
for my $Item (@Items) {
|
||||
|
||||
my ( $Permission, $Name ) = split /:/, $Item;
|
||||
|
||||
if ( !$Permission || !$Name ) {
|
||||
$LogObject->Log(
|
||||
Priority => 'error',
|
||||
Message => "Invalid config for Key Group: '$Item'! "
|
||||
. "Need something like '\$Permission:\$Group;'",
|
||||
);
|
||||
}
|
||||
|
||||
my %Groups = $Kernel::OM->Get('Kernel::System::Group')->PermissionUserGet(
|
||||
UserID => $Self->{UserID},
|
||||
Type => $Permission,
|
||||
);
|
||||
|
||||
next ITEM if !%Groups;
|
||||
|
||||
my %GroupsReverse = reverse %Groups;
|
||||
|
||||
next ITEM if !$GroupsReverse{$Name};
|
||||
|
||||
$AccessOk = 1;
|
||||
|
||||
last ITEM;
|
||||
}
|
||||
|
||||
return if !$AccessOk;
|
||||
}
|
||||
|
||||
# check acl
|
||||
my %ACLLookup = reverse( %{ $Param{ACL} || {} } );
|
||||
return if ( !$ACLLookup{ $Param{Config}->{Action} } );
|
||||
|
||||
$Param{Link} = 'Action=AgentTicketMove;TicketID=[% Data.TicketID | uri %];';
|
||||
|
||||
if ( $ConfigObject->Get('Ticket::Frontend::MoveType') =~ /^form$/i ) {
|
||||
$Param{Target} = '';
|
||||
$Param{Block} = 'DocumentMenuItemMoveForm';
|
||||
|
||||
# get layout object
|
||||
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
|
||||
|
||||
# get move queues
|
||||
my %MoveQueues = $TicketObject->MoveList(
|
||||
TicketID => $Param{Ticket}->{TicketID},
|
||||
UserID => $Self->{UserID},
|
||||
Action => $LayoutObject->{Action},
|
||||
Type => 'move_into',
|
||||
);
|
||||
$MoveQueues{0} = '- ' . $LayoutObject->{LanguageObject}->Translate('Move') . ' -';
|
||||
$Param{MoveQueuesStrg} = $LayoutObject->AgentQueueListOption(
|
||||
Name => 'DestQueueID',
|
||||
Data => \%MoveQueues,
|
||||
Class => 'Modernize',
|
||||
);
|
||||
}
|
||||
else {
|
||||
$Param{PopupType} = 'TicketAction';
|
||||
}
|
||||
|
||||
# return item
|
||||
return { %{ $Param{Config} }, %{ $Param{Ticket} }, %Param };
|
||||
}
|
||||
|
||||
1;
|
||||
144
Perl OTRS/Kernel/Output/HTML/TicketMenu/Process.pm
Normal file
144
Perl OTRS/Kernel/Output/HTML/TicketMenu/Process.pm
Normal file
@@ -0,0 +1,144 @@
|
||||
# --
|
||||
# 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::TicketMenu::Process;
|
||||
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Output::HTML::NavBar::AgentTicketProcess',
|
||||
'Kernel::System::Log',
|
||||
'Kernel::Config',
|
||||
'Kernel::System::Ticket',
|
||||
'Kernel::System::Group',
|
||||
);
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# get log object
|
||||
my $LogObject = $Kernel::OM->Get('Kernel::System::Log');
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{Ticket} ) {
|
||||
$LogObject->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need Ticket!'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# get config object
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# check if ticket is already enrolled into a process
|
||||
my $ProcessEntityID = $Param{Ticket}->{
|
||||
'DynamicField_'
|
||||
. $ConfigObject->Get('Process::DynamicFieldProcessManagementProcessID')
|
||||
} || '';
|
||||
return if $ProcessEntityID;
|
||||
|
||||
# check if frontend module registered, if not, do not show action
|
||||
if ( $Param{Config}->{Action} ) {
|
||||
my $Module = $ConfigObject->Get('Frontend::Module')->{ $Param{Config}->{Action} };
|
||||
return if !$Module;
|
||||
}
|
||||
|
||||
# check permission
|
||||
my $Config = $ConfigObject->Get("Ticket::Frontend::$Param{Config}->{Action}");
|
||||
if ($Config) {
|
||||
|
||||
# get ticket object
|
||||
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
|
||||
|
||||
if ( $Config->{Permission} ) {
|
||||
my $AccessOk = $TicketObject->TicketPermission(
|
||||
Type => $Config->{Permission},
|
||||
TicketID => $Param{Ticket}->{TicketID},
|
||||
UserID => $Self->{UserID},
|
||||
LogNo => 1,
|
||||
);
|
||||
return if !$AccessOk;
|
||||
}
|
||||
if ( $Config->{RequiredLock} ) {
|
||||
if (
|
||||
$TicketObject->TicketLockGet( TicketID => $Param{Ticket}->{TicketID} )
|
||||
)
|
||||
{
|
||||
my $AccessOk = $TicketObject->OwnerCheck(
|
||||
TicketID => $Param{Ticket}->{TicketID},
|
||||
OwnerID => $Self->{UserID},
|
||||
);
|
||||
return if !$AccessOk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# group check
|
||||
if ( $Param{Config}->{Group} ) {
|
||||
|
||||
my @Items = split /;/, $Param{Config}->{Group};
|
||||
|
||||
my $AccessOk;
|
||||
ITEM:
|
||||
for my $Item (@Items) {
|
||||
|
||||
my ( $Permission, $Name ) = split /:/, $Item;
|
||||
|
||||
if ( !$Permission || !$Name ) {
|
||||
$LogObject->Log(
|
||||
Priority => 'error',
|
||||
Message => "Invalid config for Key Group: '$Item'! "
|
||||
. "Need something like '\$Permission:\$Group;'",
|
||||
);
|
||||
}
|
||||
|
||||
my %Groups = $Kernel::OM->Get('Kernel::System::Group')->PermissionUserGet(
|
||||
UserID => $Self->{UserID},
|
||||
Type => $Permission,
|
||||
);
|
||||
|
||||
next ITEM if !%Groups;
|
||||
|
||||
my %GroupsReverse = reverse %Groups;
|
||||
|
||||
next ITEM if !$GroupsReverse{$Name};
|
||||
|
||||
$AccessOk = 1;
|
||||
|
||||
last ITEM;
|
||||
}
|
||||
|
||||
return if !$AccessOk;
|
||||
}
|
||||
|
||||
# check ACL
|
||||
if ( $Param{Config}->{Action} ) {
|
||||
my %ACLLookup = reverse( %{ $Param{ACL} || {} } );
|
||||
return if ( !$ACLLookup{ $Param{Config}->{Action} } );
|
||||
}
|
||||
|
||||
# use the nav bar module to check for process ACLs to prevent code duplication
|
||||
$Kernel::OM->ObjectParamAdd(
|
||||
'Kernel::Output::HTML::NavBar::AgentTicketProcess' => {
|
||||
UserID => $Self->{UserID},
|
||||
},
|
||||
);
|
||||
my $NavBarModule = $Kernel::OM->Get('Kernel::Output::HTML::NavBar::AgentTicketProcess');
|
||||
|
||||
# check process ACLs with the nav bar module (if returns something hide the menu item)
|
||||
return if $NavBarModule->Run();
|
||||
|
||||
# return item
|
||||
return { %{ $Param{Config} }, %{ $Param{Ticket} }, %Param };
|
||||
}
|
||||
|
||||
1;
|
||||
127
Perl OTRS/Kernel/Output/HTML/TicketMenu/Responsible.pm
Normal file
127
Perl OTRS/Kernel/Output/HTML/TicketMenu/Responsible.pm
Normal file
@@ -0,0 +1,127 @@
|
||||
# --
|
||||
# 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::TicketMenu::Responsible;
|
||||
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::System::Log',
|
||||
'Kernel::Config',
|
||||
'Kernel::System::Ticket',
|
||||
'Kernel::System::Group',
|
||||
);
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# get log object
|
||||
my $LogObject = $Kernel::OM->Get('Kernel::System::Log');
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{Ticket} ) {
|
||||
$LogObject->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need Ticket!'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# get config object
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# check if feature is enabled
|
||||
return if !$ConfigObject->Get('Ticket::Responsible');
|
||||
|
||||
# check if frontend module registered, if not, do not show action
|
||||
if ( $Param{Config}->{Action} ) {
|
||||
my $Module = $ConfigObject->Get('Frontend::Module')->{ $Param{Config}->{Action} };
|
||||
return if !$Module;
|
||||
}
|
||||
|
||||
# check permission
|
||||
my $Config = $ConfigObject->Get("Ticket::Frontend::$Param{Config}->{Action}");
|
||||
if ($Config) {
|
||||
|
||||
# get ticket object
|
||||
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
|
||||
|
||||
if ( $Config->{Permission} ) {
|
||||
|
||||
my $AccessOk = $TicketObject->TicketPermission(
|
||||
Type => $Config->{Permission},
|
||||
TicketID => $Param{Ticket}->{TicketID},
|
||||
UserID => $Self->{UserID},
|
||||
LogNo => 1,
|
||||
);
|
||||
return if !$AccessOk;
|
||||
}
|
||||
if ( $Config->{RequiredLock} ) {
|
||||
if (
|
||||
$TicketObject->TicketLockGet( TicketID => $Param{Ticket}->{TicketID} )
|
||||
)
|
||||
{
|
||||
my $AccessOk = $TicketObject->OwnerCheck(
|
||||
TicketID => $Param{Ticket}->{TicketID},
|
||||
OwnerID => $Self->{UserID},
|
||||
);
|
||||
return if !$AccessOk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# group check
|
||||
if ( $Param{Config}->{Group} ) {
|
||||
|
||||
my @Items = split /;/, $Param{Config}->{Group};
|
||||
|
||||
my $AccessOk;
|
||||
ITEM:
|
||||
for my $Item (@Items) {
|
||||
|
||||
my ( $Permission, $Name ) = split /:/, $Item;
|
||||
|
||||
if ( !$Permission || !$Name ) {
|
||||
$LogObject->Log(
|
||||
Priority => 'error',
|
||||
Message => "Invalid config for Key Group: '$Item'! "
|
||||
. "Need something like '\$Permission:\$Group;'",
|
||||
);
|
||||
}
|
||||
|
||||
my %Groups = $Kernel::OM->Get('Kernel::System::Group')->PermissionUserGet(
|
||||
UserID => $Self->{UserID},
|
||||
Type => $Permission,
|
||||
);
|
||||
|
||||
next ITEM if !%Groups;
|
||||
|
||||
my %GroupsReverse = reverse %Groups;
|
||||
|
||||
next ITEM if !$GroupsReverse{$Name};
|
||||
|
||||
$AccessOk = 1;
|
||||
|
||||
last ITEM;
|
||||
}
|
||||
|
||||
return if !$AccessOk;
|
||||
}
|
||||
|
||||
# check acl
|
||||
my %ACLLookup = reverse( %{ $Param{ACL} || {} } );
|
||||
return if ( !$ACLLookup{ $Param{Config}->{Action} } );
|
||||
|
||||
# return item
|
||||
return { %{ $Param{Config} }, %{ $Param{Ticket} }, %Param };
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -0,0 +1,31 @@
|
||||
# --
|
||||
# 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::TicketMenu::TeaserAttachmentView;
|
||||
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::System::OTRSBusiness',
|
||||
);
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
if ( $Kernel::OM->Get('Kernel::System::OTRSBusiness')->OTRSBusinessIsInstalled() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
# return item
|
||||
return { %{ $Param{Config} }, %{ $Param{Ticket} }, %Param };
|
||||
}
|
||||
|
||||
1;
|
||||
110
Perl OTRS/Kernel/Output/HTML/TicketMenu/TicketWatcher.pm
Normal file
110
Perl OTRS/Kernel/Output/HTML/TicketMenu/TicketWatcher.pm
Normal file
@@ -0,0 +1,110 @@
|
||||
# --
|
||||
# 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::TicketMenu::TicketWatcher;
|
||||
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Kernel::Language qw(Translatable);
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::System::Log',
|
||||
'Kernel::Config',
|
||||
'Kernel::System::Group',
|
||||
'Kernel::System::Ticket',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
);
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{Ticket} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need Ticket!'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# get config object
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# check if feature is active
|
||||
return if !$ConfigObject->Get('Ticket::Watcher');
|
||||
|
||||
# check if frontend module registered, if not, do not show action
|
||||
if ( $Param{Config}->{Action} ) {
|
||||
my $Module = $ConfigObject->Get('Frontend::Module')->{ $Param{Config}->{Action} };
|
||||
return if !$Module;
|
||||
}
|
||||
|
||||
# check acl
|
||||
my %ACLLookup = reverse( %{ $Param{ACL} || {} } );
|
||||
return if ( !$ACLLookup{ $Param{Config}->{Action} } );
|
||||
|
||||
# check access
|
||||
my @Groups;
|
||||
if ( $ConfigObject->Get('Ticket::WatcherGroup') ) {
|
||||
@Groups = @{ $ConfigObject->Get('Ticket::WatcherGroup') };
|
||||
}
|
||||
|
||||
my $Access = 1;
|
||||
if (@Groups) {
|
||||
$Access = 0;
|
||||
my $GroupObject = $Kernel::OM->Get('Kernel::System::Group');
|
||||
GROUP:
|
||||
for my $Group (@Groups) {
|
||||
|
||||
my $HasPermission = $GroupObject->PermissionCheck(
|
||||
UserID => $Self->{UserID},
|
||||
GroupName => $Group,
|
||||
Type => 'rw',
|
||||
);
|
||||
if ($HasPermission) {
|
||||
$Access = 1;
|
||||
last GROUP;
|
||||
}
|
||||
}
|
||||
}
|
||||
return if !$Access;
|
||||
|
||||
# check if ticket get's watched right now
|
||||
my %Watch = $Kernel::OM->Get('Kernel::System::Ticket')->TicketWatchGet(
|
||||
TicketID => $Param{Ticket}->{TicketID},
|
||||
);
|
||||
|
||||
# show subscribe action
|
||||
if ( $Watch{ $Self->{UserID} } ) {
|
||||
return {
|
||||
%{ $Param{Config} },
|
||||
%{ $Param{Ticket} },
|
||||
%Param,
|
||||
Name => Translatable('Unwatch'),
|
||||
Description => Translatable('Remove from list of watched tickets'),
|
||||
Link =>
|
||||
'Action=AgentTicketWatcher;Subaction=Unsubscribe;TicketID=[% Data.TicketID | uri %];[% Env("ChallengeTokenParam") | html %]',
|
||||
};
|
||||
}
|
||||
|
||||
# show unsubscribe action
|
||||
return {
|
||||
%{ $Param{Config} },
|
||||
%{ $Param{Ticket} },
|
||||
%Param,
|
||||
Name => Translatable('Watch'),
|
||||
Description => Translatable('Add to list of watched tickets'),
|
||||
Link =>
|
||||
'Action=AgentTicketWatcher;Subaction=Subscribe;TicketID=[% Data.TicketID | uri %];[% Env("ChallengeTokenParam") | html %]',
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
Reference in New Issue
Block a user