init III
This commit is contained in:
@@ -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::System::Ticket::Acl::CloseParentAfterClosedChilds;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::System::LinkObject',
|
||||
'Kernel::System::Log',
|
||||
'Kernel::System::Ticket',
|
||||
);
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
# allocate new hash for object
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
for (qw(Config Acl)) {
|
||||
if ( !$Param{$_} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => "Need $_!"
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
# check if child tickets are not closed
|
||||
return 1 if !$Param{TicketID} || !$Param{UserID};
|
||||
|
||||
# link tickets
|
||||
my $Links = $Kernel::OM->Get('Kernel::System::LinkObject')->LinkList(
|
||||
Object => 'Ticket',
|
||||
Key => $Param{TicketID},
|
||||
State => 'Valid',
|
||||
Type => 'ParentChild',
|
||||
UserID => $Param{UserID},
|
||||
);
|
||||
|
||||
return 1 if !$Links;
|
||||
return 1 if ref $Links ne 'HASH';
|
||||
return 1 if !$Links->{Ticket};
|
||||
return 1 if ref $Links->{Ticket} ne 'HASH';
|
||||
return 1 if !$Links->{Ticket}->{ParentChild};
|
||||
return 1 if ref $Links->{Ticket}->{ParentChild} ne 'HASH';
|
||||
return 1 if !$Links->{Ticket}->{ParentChild}->{Target};
|
||||
return 1 if ref $Links->{Ticket}->{ParentChild}->{Target} ne 'HASH';
|
||||
|
||||
my $OpenSubTickets = 0;
|
||||
TICKETID:
|
||||
for my $TicketID ( sort keys %{ $Links->{Ticket}->{ParentChild}->{Target} } ) {
|
||||
|
||||
# get ticket
|
||||
my %Ticket = $Kernel::OM->Get('Kernel::System::Ticket')->TicketGet(
|
||||
TicketID => $TicketID,
|
||||
DynamicFields => 0,
|
||||
);
|
||||
|
||||
if ( $Ticket{StateType} !~ m{ \A (close|merge|remove) }xms ) {
|
||||
$OpenSubTickets = 1;
|
||||
last TICKETID;
|
||||
}
|
||||
}
|
||||
|
||||
# generate acl
|
||||
if ($OpenSubTickets) {
|
||||
|
||||
$Param{Acl}->{CloseParentAfterClosedChilds} = {
|
||||
|
||||
# match properties
|
||||
Properties => {
|
||||
|
||||
# current ticket match properties
|
||||
Ticket => {
|
||||
TicketID => [ $Param{TicketID} ],
|
||||
},
|
||||
},
|
||||
|
||||
# return possible options (black list)
|
||||
PossibleNot => {
|
||||
|
||||
# possible ticket options (black list)
|
||||
Ticket => {
|
||||
State => $Param{Config}->{State},
|
||||
},
|
||||
Action => ['AgentTicketClose'],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
||||
116
Perl OTRS/Kernel/System/Ticket/Acl/RestrictTicketTypes.pm
Normal file
116
Perl OTRS/Kernel/System/Ticket/Acl/RestrictTicketTypes.pm
Normal file
@@ -0,0 +1,116 @@
|
||||
# --
|
||||
# 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::System::Ticket::Acl::RestrictTicketTypes;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::System::Group',
|
||||
'Kernel::System::Log',
|
||||
'Kernel::System::Ticket',
|
||||
);
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
# allocate new hash for object
|
||||
my $Self = {%Param};
|
||||
bless( $Self, $Type );
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
for my $Argument (qw(Config Acl)) {
|
||||
if ( !$Param{$Argument} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => "Need $Argument!",
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
# check if user id is given
|
||||
return 1 if !$Param{UserID};
|
||||
|
||||
# get and check the list of relevant ticket types
|
||||
my $AddChangeLinkTicketTypes = $Kernel::OM->Get('Kernel::Config')->Get('ITSMChange::AddChangeLinkTicketTypes');
|
||||
|
||||
return 1 if !$AddChangeLinkTicketTypes;
|
||||
return 1 if ref $AddChangeLinkTicketTypes ne 'ARRAY';
|
||||
return 1 if !@{$AddChangeLinkTicketTypes};
|
||||
|
||||
# create a lookup hash for the relevant ticket types
|
||||
my %IsRelevant = map { $_ => 1 } @{$AddChangeLinkTicketTypes};
|
||||
|
||||
# if ticket id was given
|
||||
if ( $Param{TicketID} ) {
|
||||
|
||||
# get ticket data
|
||||
my %Ticket = $Kernel::OM->Get('Kernel::System::Ticket')->TicketGet(
|
||||
TicketID => $Param{TicketID},
|
||||
);
|
||||
|
||||
# check if ticket exists
|
||||
return 1 if !%Ticket;
|
||||
|
||||
# don't remove relevant types from type list
|
||||
# if the ticket type is already one of these types
|
||||
return 1 if $IsRelevant{ $Ticket{Type} };
|
||||
}
|
||||
|
||||
# get user groups, where the user has the rw privilege
|
||||
my %Groups = $Kernel::OM->Get('Kernel::System::Group')->GroupMemberList(
|
||||
UserID => $Param{UserID},
|
||||
Type => 'rw',
|
||||
Result => 'HASH',
|
||||
Cached => 1,
|
||||
);
|
||||
|
||||
# get and check the list of groups who are allowed to use the AddChangeLinkTicketTypes
|
||||
my $RestrictTicketTypesGroups = $Kernel::OM->Get('Kernel::Config')->Get('ITSMChange::RestrictTicketTypes::Groups');
|
||||
|
||||
return 1 if !$RestrictTicketTypesGroups;
|
||||
return 1 if ref $RestrictTicketTypesGroups ne 'ARRAY';
|
||||
return 1 if !@{$RestrictTicketTypesGroups};
|
||||
|
||||
# check if the user is in one of these groups
|
||||
for my $Group ( @{$RestrictTicketTypesGroups} ) {
|
||||
|
||||
# get the group id
|
||||
my $GroupID = $Kernel::OM->Get('Kernel::System::Group')->GroupLookup(
|
||||
Group => $Group,
|
||||
);
|
||||
|
||||
# do not remove the ticket type 'RfC' if user is in one of the groups
|
||||
return 1 if $Groups{$GroupID};
|
||||
}
|
||||
|
||||
# generate acl
|
||||
$Param{Acl}->{RestrictTicketTypes} = {
|
||||
|
||||
# remove ticket types listed in sysconfig option 'ITSMChange::AddChangeLinkTicketTypes'
|
||||
# from type dropdown list in all frontend modules
|
||||
PossibleNot => {
|
||||
Ticket => {
|
||||
Type => $AddChangeLinkTicketTypes,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
||||
Reference in New Issue
Block a user