Skip to content

Commit

Permalink
Fixed button to edit customer user in widget of customer information …
Browse files Browse the repository at this point in the history
…center.
  • Loading branch information
NiklasSchmitt authored and jepf committed Mar 26, 2024
1 parent 5a748da commit fb82aac
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 7.0.16 2024-??-??
- 2024-03-22 Fixed dynamic field smart tag support for snippets. [#537](https://github.com/znuny/Znuny/issues/537)
- 2024-03-19 Fixed button to edit customer user in widget of customer information center. [#543](https://github.com/znuny/Znuny/issues/543)
- 2024-03-13 Fixed usage of sysconfig setting `Ticket::Frontend::Overview::PreviewArticleSenderTypes`. [#542](https://github.com/znuny/Znuny/issues/542)
- 2024-03-11 Split Blink feature from VisualAlarms feature.
- 2024-03-05 Hide ticket zoom widgets when no data is available to show.
Expand Down
56 changes: 37 additions & 19 deletions Kernel/Output/HTML/Dashboard/CustomerUserList.pm
Original file line number Diff line number Diff line change
Expand Up @@ -127,31 +127,20 @@ sub Header {
# Show add new customer button if:
# - The agent has permission to use the module
# - There are writable customer backends
my $AddAccess;

TYPE:
for my $Permission (qw(ro rw)) {
$AddAccess = $LayoutObject->Permission(
Action => 'AdminCustomerUser',
Type => $Permission,
);
last TYPE if $AddAccess;
}
my $HasAdminCustomerUserPermission = $Self->_HasAdminCustomerUserPermission();

# Get writable data sources.
my %CustomerSource = $CustomerUserObject->CustomerSourceList(
my %CustomerSources = $CustomerUserObject->CustomerSourceList(
ReadOnly => 0,
);

if ( $AddAccess && scalar keys %CustomerSource ) {
if ( $HasAdminCustomerUserPermission && %CustomerSources ) {
$LayoutObject->Block(
Name => 'ContentLargeCustomerUserAdd',
Data => {
CustomerID => $Self->{CustomerID},
},
);

$Self->{EditCustomerPermission} = 1;
}

my $Header = $LayoutObject->Output(
Expand Down Expand Up @@ -194,10 +183,13 @@ sub Run {
# get layout object
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');

my $HasAdminCustomerUserPermission = $Self->_HasAdminCustomerUserPermission();

$LayoutObject->Block(
Name => 'ContentCustomerUserList',
Data => {
%Param,
HasAdminCustomerUserPermission => $HasAdminCustomerUserPermission,
},
);

Expand Down Expand Up @@ -291,9 +283,9 @@ sub Run {
Name => 'ContentLargeCustomerUserListRow',
Data => {
%Param,
EditCustomerPermission => $Self->{EditCustomerPermission},
CustomerKey => $CustomerKey,
CustomerListEntry => $CustomerIDs->{$CustomerKey},
HasAdminCustomerUserPermission => $HasAdminCustomerUserPermission,
CustomerKey => $CustomerKey,
CustomerListEntry => $CustomerIDs->{$CustomerKey},
},
);

Expand Down Expand Up @@ -364,6 +356,16 @@ sub Run {
);
}

if ($HasAdminCustomerUserPermission)
{
$LayoutObject->Block(
Name => 'OverviewResultEditCustomer',
Data => {
%Param,
},
);
}

if ( $ConfigObject->Get('SwitchToCustomer') && $Self->{SwitchToCustomerPermission} )
{
$LayoutObject->Block(
Expand Down Expand Up @@ -409,13 +411,29 @@ sub Run {
TemplateFile => 'AgentDashboardCustomerUserList',
Data => {
%{ $Self->{Config} },
EditCustomerPermission => $Self->{EditCustomerPermission},
Name => $Self->{Name},
HasAdminCustomerUserPermission => $HasAdminCustomerUserPermission,
Name => $Self->{Name},
},
AJAX => $Param{AJAX},
);

return $Content;
}

sub _HasAdminCustomerUserPermission {
my ( $Self, %Param ) = @_;

my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');

for my $PermissionType (qw(ro rw)) {
my $HasPermission = $LayoutObject->Permission(
Action => 'AdminCustomerUser',
Type => 'rw',
);
return 1 if $HasPermission;
}

return;
}

1;
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
[% RenderBlockStart("OverviewResultNewAgentTicketEmail") %]
<th>[% Translate("Email ticket") | html %]</th>
[% RenderBlockEnd("OverviewResultNewAgentTicketEmail") %]
[% IF Data.EditCustomerPermission %]
[% IF Data.HasAdminCustomerUserPermission %]
<th class="Center">[% Translate("Edit") | html %]</th>
[% END %]
[% END %]
[% RenderBlockStart("OverviewResultSwitchToCustomer") %]
<th>[% Translate("Login as") | html %]</th>
[% RenderBlockEnd("OverviewResultSwitchToCustomer") %]
Expand Down Expand Up @@ -92,7 +92,7 @@
</a>
</td>
[% RenderBlockEnd("ContentLargeCustomerUserListNewAgentTicketEmail") %]
[% IF Data.EditCustomerPermission %]
[% IF Data.HasAdminCustomerUserPermission %]
<td class="Center">
<a class="table-icon-hover-md" href="[% Env("Baselink") %]Action=AdminCustomerUser;Subaction=Change;ID=[% Data.CustomerKey | uri %];Nav=Agent" title="Edit customer user">
<i class="fa fa-pencil-square-o"></i>
Expand Down

0 comments on commit fb82aac

Please sign in to comment.