Skip to content

Commit

Permalink
Improved ACL checks in ticket overview modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
jepf committed Jan 14, 2025
1 parent 829a336 commit ce785c4
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 189 deletions.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The following persons contributed to Znuny:
* Henrik Vetter <[email protected]>
* IB Development Team <[email protected]>
* Igor Djuric <[email protected]>
* Ivo Oliveira <[email protected]>
* Jan Steinweg <[email protected]>
* JannisKleinrensing <[email protected]>
* Jaroslav Balaz <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 7.1.4 2024-??-??
- 2024-12-23 Improved ACL checks in ticket overview modules.
- 2024-12-10 System configuration option SendmailEncodingForce is now a selection instead of a text field.
- 2024-12-10 Fixed "From" and "To" not being expandable for an article in ticket zoom. Thanks to Oliver Freyermuth (@olifre) for reporting. [#605](https://github.com/znuny/Znuny/issues/605)
- 2024-12-09 Fixed multiple notifications being sent for empty process tickets (event NotificationNewTicket).
Expand Down
101 changes: 16 additions & 85 deletions Kernel/Output/HTML/TicketOverview/Medium.pm
Original file line number Diff line number Diff line change
Expand Up @@ -479,19 +479,7 @@ sub _Show {
sort keys %Actions;
}

my $ACL = $TicketObject->TicketAcl(
Data => \%PossibleActions,
Action => $Self->{Action},
TicketID => $Article{TicketID},
ReturnType => 'Action',
ReturnSubType => '-',
UserID => $Self->{UserID},
);

my %AclAction = %PossibleActions;
if ($ACL) {
%AclAction = $TicketObject->TicketAclActionData();
}

# get main object
my $MainObject = $Kernel::OM->Get('Kernel::System::Main');
Expand All @@ -500,6 +488,22 @@ sub _Show {
my @ActionItems;
if ( ref $ConfigObject->Get('Ticket::Frontend::PreMenuModule') eq 'HASH' ) {
my %Menus = %{ $ConfigObject->Get('Ticket::Frontend::PreMenuModule') };

if (%Menus) {
my $ACL = $TicketObject->TicketAcl(
Data => \%PossibleActions,
Action => $Self->{Action},
TicketID => $Article{TicketID},
ReturnType => 'Action',
ReturnSubType => '-',
UserID => $Self->{UserID},
);

if ($ACL) {
%AclAction = $TicketObject->TicketAclActionData();
}
}

MENU:
for my $Menu ( sort keys %Menus ) {

Expand Down Expand Up @@ -676,78 +680,6 @@ sub _Show {
}
}

# create output
$LayoutObject->Block(
Name => 'AgentAnswer',
Data => {
%Param,
%Article,
%AclAction,
},
);

if (
$ConfigObject->Get('Frontend::Module')->{AgentTicketCompose}
&& ( !defined $AclAction{AgentTicketCompose} || $AclAction{AgentTicketCompose} )
)
{
my $Access = 1;
my $Config = $ConfigObject->Get("Ticket::Frontend::AgentTicketCompose");
if ( $Config->{Permission} ) {
my $Ok = $TicketObject->TicketPermission(
Type => $Config->{Permission},
TicketID => $Param{TicketID},
UserID => $Self->{UserID},
LogNo => 1,
);
if ( !$Ok ) {
$Access = 0;
}
if ($Access) {
$LayoutObject->Block(
Name => 'AgentAnswerCompose',
Data => {
%Param,
%Article,
%AclAction,
},
);
}
}
}
if (
$ConfigObject->Get('Frontend::Module')->{AgentTicketPhoneOutbound}
&& (
!defined $AclAction{AgentTicketPhoneOutbound}
|| $AclAction{AgentTicketPhoneOutbound}
)
)
{
my $Access = 1;
my $Config = $ConfigObject->Get("Ticket::Frontend::AgentTicketPhoneOutbound");
if ( $Config->{Permission} ) {
my $OK = $TicketObject->TicketPermission(
Type => $Config->{Permission},
TicketID => $Param{TicketID},
UserID => $Self->{UserID},
LogNo => 1,
);
if ( !$OK ) {
$Access = 0;
}
}
if ($Access) {
$LayoutObject->Block(
Name => 'AgentAnswerPhoneOutbound',
Data => {
%Param,
%Article,
%AclAction,
},
);
}
}

# ticket type
if ( $ConfigObject->Get('Ticket::Type') ) {
$LayoutObject->Block(
Expand Down Expand Up @@ -1064,7 +996,6 @@ sub _Show {
Data => {
%Param,
%Article,
%AclAction,
},
);

Expand Down
110 changes: 17 additions & 93 deletions Kernel/Output/HTML/TicketOverview/Preview.pm
Original file line number Diff line number Diff line change
Expand Up @@ -513,19 +513,7 @@ sub _Show {
sort keys %Actions;
}

my $ACL = $TicketObject->TicketAcl(
Data => \%PossibleActions,
Action => $Self->{Action},
TicketID => $Article{TicketID},
ReturnType => 'Action',
ReturnSubType => '-',
UserID => $Self->{UserID},
);

my %AclAction = %PossibleActions;
if ($ACL) {
%AclAction = $TicketObject->TicketAclActionData();
}

# get main object
my $MainObject = $Kernel::OM->Get('Kernel::System::Main');
Expand All @@ -534,6 +522,22 @@ sub _Show {
my @ActionItems;
if ( ref $ConfigObject->Get('Ticket::Frontend::PreMenuModule') eq 'HASH' ) {
my %Menus = %{ $ConfigObject->Get('Ticket::Frontend::PreMenuModule') };

if (%Menus) {
my $ACL = $TicketObject->TicketAcl(
Data => \%PossibleActions,
Action => $Self->{Action},
TicketID => $Article{TicketID},
ReturnType => 'Action',
ReturnSubType => '-',
UserID => $Self->{UserID},
);

if ($ACL) {
%AclAction = $TicketObject->TicketAclActionData();
}
}

MENU:
for my $Menu ( sort keys %Menus ) {

Expand Down Expand Up @@ -769,77 +773,6 @@ sub _Show {
}
}

# create output
$LayoutObject->Block(
Name => 'AgentAnswer',
Data => {
%Param,
%Article,
%AclAction,
},
);
if (
$ConfigObject->Get('Frontend::Module')->{AgentTicketCompose}
&& ( !defined $AclAction{AgentTicketCompose} || $AclAction{AgentTicketCompose} )
)
{
my $Access = 1;
my $Config = $ConfigObject->Get('Ticket::Frontend::AgentTicketCompose');
if ( $Config->{Permission} ) {
my $Ok = $TicketObject->Permission(
Type => $Config->{Permission},
TicketID => $Param{TicketID},
UserID => $Self->{UserID},
LogNo => 1,
);
if ( !$Ok ) {
$Access = 0;
}
if ($Access) {
$LayoutObject->Block(
Name => 'AgentAnswerCompose',
Data => {
%Param,
%Article,
%AclAction,
},
);
}
}
}
if (
$ConfigObject->Get('Frontend::Module')->{AgentTicketPhoneOutbound}
&& (
!defined $AclAction{AgentTicketPhoneOutbound}
|| $AclAction{AgentTicketPhoneOutbound}
)
)
{
my $Access = 1;
my $Config = $ConfigObject->Get('Ticket::Frontend::AgentTicketPhoneOutbound');
if ( $Config->{Permission} ) {
my $OK = $TicketObject->Permission(
Type => $Config->{Permission},
TicketID => $Param{TicketID},
UserID => $Self->{UserID},
LogNo => 1,
);
if ( !$OK ) {
$Access = 0;
}
}
if ($Access) {
$LayoutObject->Block(
Name => 'AgentAnswerPhoneOutbound',
Data => {
%Param,
%Article,
%AclAction,
},
);
}
}

# ticket type
if ( $ConfigObject->Get('Ticket::Type') ) {
$LayoutObject->Block(
Expand Down Expand Up @@ -1191,7 +1124,6 @@ sub _Show {
Data => {
%Param,
%Article,
%AclAction,
},
);
}
Expand Down Expand Up @@ -1259,14 +1191,7 @@ sub _Show {
);

# check if compose link should be shown
if (
$ConfigObject->Get('Frontend::Module')->{AgentTicketCompose}
&& (
!defined $AclAction{AgentTicketCompose}
|| $AclAction{AgentTicketCompose}
)
)
{
if ( $ConfigObject->Get('Frontend::Module')->{AgentTicketCompose} ) {
my $Access = 1;
my $Config = $ConfigObject->Get('Ticket::Frontend::AgentTicketCompose');
if ( $Config->{Permission} ) {
Expand Down Expand Up @@ -1319,7 +1244,6 @@ sub _Show {
Data => {
%Param,
%Article,
%AclAction,
},
);
return \$Output;
Expand Down
26 changes: 15 additions & 11 deletions Kernel/Output/HTML/TicketOverview/Small.pm
Original file line number Diff line number Diff line change
Expand Up @@ -542,23 +542,27 @@ sub Run {
sort keys %Actions;
}

my $ACL = $TicketObject->TicketAcl(
Data => \%PossibleActions,
Action => $Self->{Action},
TicketID => $Article{TicketID},
ReturnType => 'Action',
ReturnSubType => '-',
UserID => $Self->{UserID},
);
my %AclAction = %PossibleActions;
if ($ACL) {
%AclAction = $TicketObject->TicketAclActionData();
}

# run ticket pre menu modules
my @ActionItems;
if ( ref $ConfigObject->Get('Ticket::Frontend::PreMenuModule') eq 'HASH' ) {
my %Menus = %{ $ConfigObject->Get('Ticket::Frontend::PreMenuModule') };

if (%Menus) {
my $ACL = $TicketObject->TicketAcl(
Data => \%PossibleActions,
Action => $Self->{Action},
TicketID => $Article{TicketID},
ReturnType => 'Action',
ReturnSubType => '-',
UserID => $Self->{UserID},
);
if ($ACL) {
%AclAction = $TicketObject->TicketAclActionData();
}
}

my @Items;
MENU:
for my $Menu ( sort keys %Menus ) {
Expand Down

0 comments on commit ce785c4

Please sign in to comment.