I enabled Customer Group relation and now I would like to filter the queue selection list on "New Phone Ticket" also depending on the permissions of the selected customer and not only of the agent user to create a new ticket in a queue.
To this end I edited the definition of _GetTos subroutine in /opt/otrs/Kernel/Modules/AgentTicketPhone.pm with this lines:
Code: Select all
sub _GetTos {
my ( $Self, %Param ) = @_;
# get config object
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
# check own selection
my %NewTos;
if ( $ConfigObject->Get('Ticket::Frontend::NewQueueOwnSelection') ) {
%NewTos = %{ $ConfigObject->Get('Ticket::Frontend::NewQueueOwnSelection') };
}
else {
# SelectionType Queue or SystemAddress?
my %Tos;
if ( $ConfigObject->Get('Ticket::Frontend::NewQueueSelectionType') eq 'Queue' ) {
%Tos = $Kernel::OM->Get('Kernel::System::Ticket')->MoveList(
%Param,
Type => 'create',
Action => $Self->{Action},
QueueID => $Self->{QueueID},
UserID => $Self->{UserID},
);
}
else {
%Tos = $Kernel::OM->Get('Kernel::System::DB')->GetTableData(
Table => 'system_address',
What => 'queue_id, id',
Valid => 1,
Clamp => 1,
);
}
# get create permission queues
my %UserGroups = $Kernel::OM->Get('Kernel::System::Group')->PermissionUserGet(
UserID => $Self->{UserID},
Type => 'create',
);
## FIRST EDIT BY ME... ADDED THE FOLLOWING
my $CustomerID = $Param{CustomerUserID};
my %CustomerGroups = {};
%CustomerGroups = $Kernel::OM->Get('Kernel::System::CustomerGroup')->GroupMemberList(
UserID => $CustomerID,
Type => 'rw',
Result => 'HASH',
);
## ...TILL HERE
# build selection string
QUEUEID:
for my $QueueID ( sort keys %Tos ) {
my %QueueData = $Kernel::OM->Get('Kernel::System::Queue')->QueueGet( ID => $QueueID );
# permission check, can we create new tickets in queue
next QUEUEID if !$UserGroups{ $QueueData{GroupID} };
## ADDED THE FOLLOWING PERMISSION CHECK
next QUEUEID if !$CustomerGroups{ $QueueData{GroupID} };
## END OF EDITING BY ME
my $String = $ConfigObject->Get('Ticket::Frontend::NewQueueSelectionString')
|| '<Realname> <<Email>> - Queue: <Queue>';
$String =~ s/<Queue>/$QueueData{Name}/g;
$String =~ s/<QueueComment>/$QueueData{Comment}/g;
if ( $ConfigObject->Get('Ticket::Frontend::NewQueueSelectionType') ne 'Queue' )
{
my %SystemAddressData = $Kernel::OM->Get('Kernel::System::SystemAddress')->SystemAddressGet(
ID => $Tos{$QueueID},
);
$String =~ s/<Realname>/$SystemAddressData{Realname}/g;
$String =~ s/<Email>/$SystemAddressData{Name}/g;
}
$NewTos{$QueueID} = $String;
}
}
# add empty selection
$NewTos{''} = '-';
return \%NewTos;
}
Thank you
Giulio
EDIT: I could notice that it seems to work correctly for customer users defined in the internal OTRS database, while for customer users loaded from ActiveDirectory, the queue selection list results in that "Loading..." label