Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added DisableLocalUserDataManagement parameter to disable local agent data management #403

Open
wants to merge 3 commits into
base: rel-6_5-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Kernel/Config/Defaults.pm
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,10 @@ sub LoadDefaults {
# Utilize extended nested group search? (may impact performance)
# $Self->{'AuthSyncModule::LDAP::NestedGroupSearch'} = 1;

# DisableLocalUserDataManagement
# Set to 1 do disable local user data management (if synchronized from LDAP only for example).
# $Self->{'DisableLocalUserDataManagement'} = 1;

# AuthSyncModule::LDAP::UserSyncGroupsDefinition
# (If "LDAP" was selected for AuthModule and you want to sync LDAP
# groups to otrs groups, define the following.)
Expand Down
6 changes: 5 additions & 1 deletion Kernel/Modules/AdminRoleUser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,11 @@ sub _Overview {

$LayoutObject->Block(
Name => 'Overview',
Data => {},
Data => {

# Hide agent add option if local user data management is disabled.
DisableLocalUserDataManagement => $Kernel::OM->Get('Kernel::Config')->Get('DisableLocalUserDataManagement'),
},
);

# get user list
Expand Down
20 changes: 19 additions & 1 deletion Kernel/Modules/AdminUser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ sub Run {
$Errors{'UserLoginInvalid'} = 'ServerError';
}

# Don't allow local agent data changes if local user data management is disabled.
if ( $Kernel::OM->Get('Kernel::Config')->Get('DisableLocalUserDataManagement') ) {
$Note = $Kernel::OM->Get('Kernel::Language')->Translate('Local agent data management is disabled.');
}

# if no errors occurred
if ( !%Errors )
{
Expand Down Expand Up @@ -334,6 +339,11 @@ sub Run {
$Errors{'UserLoginInvalid'} = 'ServerError';
}

# Don't allow local agent data changes if local user data management is disabled.
if ( $Kernel::OM->Get('Kernel::Config')->Get('DisableLocalUserDataManagement') ) {
$Note = $Kernel::OM->Get('Kernel::Language')->Translate('Local agent data management is disabled.');
}

# if no errors occurred
if ( !%Errors )
{
Expand Down Expand Up @@ -458,11 +468,15 @@ sub _Edit {
my %ValidList = $Kernel::OM->Get('Kernel::System::Valid')->ValidList();
my %ValidListReverse = reverse %ValidList;

# Put all user data in read-only mode if local user data management is disabled.
$Param{DisableLocalUserDataManagement} = $Kernel::OM->Get('Kernel::Config')->Get('DisableLocalUserDataManagement');

$Param{ValidOption} = $LayoutObject->BuildSelection(
Data => \%ValidList,
Name => 'ValidID',
SelectedID => $Param{ValidID} || $ValidListReverse{valid},
Class => 'Modernize',
Disabled => $Param{DisableLocalUserDataManagement} ? 1 : 0,
);

$LayoutObject->Block(
Expand Down Expand Up @@ -532,7 +546,11 @@ sub _Overview {
Name => 'ActionSearch',
Data => \%Param,
);
$LayoutObject->Block( Name => 'ActionAdd' );

# Put all user data in read-only mode if local user data management is disabled.
if ( !$Kernel::OM->Get('Kernel::Config')->Get('DisableLocalUserDataManagement') ) {
$LayoutObject->Block( Name => 'ActionAdd' );
}

# get user object
my $UserObject = $Kernel::OM->Get('Kernel::System::User');
Expand Down
5 changes: 5 additions & 0 deletions Kernel/Modules/AdminUserGroup.pm
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@ sub _Overview {
);
$LayoutObject->Block(
Name => 'NewActions',
Data => {

# Hide agent add option if local user data management is disabled.
DisableLocalUserDataManagement => $Kernel::OM->Get('Kernel::Config')->Get('DisableLocalUserDataManagement'),
},
);

$LayoutObject->Block(
Expand Down
2 changes: 2 additions & 0 deletions Kernel/Output/HTML/Templates/Standard/AdminRoleUser.tt
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
</div>
<div class="Content">
<ul class="ActionList">
[% IF !Data.DisableLocalUserDataManagement %]
<li>
<a href="[% Env("Baselink") %]Action=AdminUser;Subaction=Add" class="CallForAction Fullsize Center"><span><i class="fa fa-plus-square"></i>[% Translate("Add Agent") | html %]</span></a>
</li>
[% END %]
<li>
<a href="[% Env("Baselink") %]Action=AdminRole;Subaction=Add" class="CallForAction Fullsize Center"><span><i class="fa fa-plus-square"></i>[% Translate("Add Role") | html %]</span></a>
</li>
Expand Down
29 changes: 22 additions & 7 deletions Kernel/Output/HTML/Templates/Standard/AdminUser.tt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@
]
%]

[% IF Data.DisableLocalUserDataManagement %]
[% BreadcrumbPath.push({ Name => Translate("Agent Data"),}) %]
[% ELSE %]
[% SWITCH Data.Action %]
[% CASE 'Add' %]
[% BreadcrumbPath.push({ Name => Translate("Add Agent"),}) %]
[% CASE 'Change' %]
[% USE EditTitle = String(Translate("Edit Agent")) %]
[% BreadcrumbPath.push({ Name => EditTitle.append( ': ', Data.UserLogin ) }) %]
[% END %]
[% END %]

[% INCLUDE "Breadcrumb.tt" Path = BreadcrumbPath %]

Expand Down Expand Up @@ -63,11 +67,14 @@
</li>
[% RenderBlockEnd("ActionSearch") %]
[% RenderBlockStart("ActionAdd") %]
[% IF !Data.DisableLocalUserDataManagement %]

<li>
<a class="CallForAction Fullsize Center" href="[% Env("Baselink") %]Action=[% Env("Action") %];Subaction=Add">
<span><i class="fa fa-plus-square"></i> [% Translate("Add Agent") | html %]</span>
</a>
</li>
[% END %]
[% RenderBlockEnd("ActionAdd") %]
</ul>
</div>
Expand Down Expand Up @@ -183,11 +190,15 @@

[% RenderBlockStart("OverviewUpdate") %]
<div class="Header">
[% IF Data.DisableLocalUserDataManagement %]
<h2>[% Translate("Agent Data") | html %]</h2>
[% ELSE %]
[% IF Data.Action == "Add" %]
<h2>[% Translate("Add Agent") | html %]</h2>
[% ELSE %]
<h2>[% Translate("Edit Agent") | html %]</h2>
[% END %]
[% END %]
</div>

<div class="Content">
Expand All @@ -203,29 +214,29 @@

<label for="UserTitle">[% Translate("Title or salutation") | html %]:</label>
<div class="Field">
<input type="text" name="UserTitle" id="UserTitle" value="[% Data.UserTitle | html %]" class="W50pc" maxlength="50"/>
<input type="text" name="UserTitle" id="UserTitle" value="[% Data.UserTitle | html %]" class="W50pc" maxlength="50"[% IF Data.DisableLocalUserDataManagement %] readonly="readonly"[% END %]/>
</div>
<div class="Clear"></div>

<label class="Mandatory" for="UserFirstname"><span class="Marker">*</span> [% Translate("Firstname") | html %]:</label>
<div class="Field">
<input type="text" name="UserFirstname" id="UserFirstname" value="[% Data.UserFirstname | html %]" class="W50pc Validate_Required [% Data.UserFirstnameInvalid | html %]" maxlength="100"/>
<input type="text" name="UserFirstname" id="UserFirstname" value="[% Data.UserFirstname | html %]" class="W50pc Validate_Required [% Data.UserFirstnameInvalid | html %]" maxlength="100"[% IF Data.DisableLocalUserDataManagement %] readonly="readonly"[% END %]/>
<div id="UserFirstnameError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="UserFirstnameServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
</div>
<div class="Clear"></div>

<label class="Mandatory" for="UserLastname"><span class="Marker">*</span> [% Translate("Lastname") | html %]:</label>
<div class="Field">
<input type="text" name="UserLastname" id="UserLastname" value="[% Data.UserLastname | html %]" class="W50pc Validate_Required [% Data.UserLastnameInvalid | html %]" maxlength="100"/>
<input type="text" name="UserLastname" id="UserLastname" value="[% Data.UserLastname | html %]" class="W50pc Validate_Required [% Data.UserLastnameInvalid | html %]" maxlength="100"[% IF Data.DisableLocalUserDataManagement %] readonly="readonly"[% END %]/>
<div id="UserLastnameError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="UserLastnameServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
</div>
<div class="Clear"></div>

<label class="Mandatory" for="UserLogin"><span class="Marker">*</span> [% Translate("Username") | html %]:</label>
<div class="Field">
<input type="text" name="UserLogin" id="UserLogin" value="[% Data.UserLogin | html %]" class="W50pc Validate_Required [% Data.UserLoginInvalid | html %]" maxlength="200" autocomplete="off" />
<input type="text" name="UserLogin" id="UserLogin" value="[% Data.UserLogin | html %]" class="W50pc Validate_Required [% Data.UserLoginInvalid | html %]" maxlength="200" autocomplete="off"[% IF Data.DisableLocalUserDataManagement %] readonly="readonly"[% END %]/>
<div id="UserLoginError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="UserLoginServerError" class="TooltipErrorMessage">
[% RenderBlockStart("UserLoginServerError") %]
Expand All @@ -242,7 +253,7 @@
[% Translate("Password") | html %]:
</label>
<div class="Field">
<input type="password" name="UserPw" id="UserPw" value="" class="W50pc [% Data.UserPwInvalid | html %] " maxlength="100" autocomplete="new-password" />
<input type="password" name="UserPw" id="UserPw" value="" class="W50pc [% Data.UserPwInvalid | html %] " maxlength="100" autocomplete="new-password" [% IF Data.DisableLocalUserDataManagement %] readonly="readonly"[% END %]/>
[% RenderBlockStart("ShowPasswordHint") %]
<p class="FieldExplanation">
[% Translate("Will be auto-generated if left empty.") | html %]
Expand All @@ -253,7 +264,7 @@

<label class="Mandatory" for="UserEmail"><span class="Marker">*</span> [% Translate("Email") | html %]:</label>
<div class="Field">
<input type="[% Env("EmailFieldType") | html %]" name="UserEmail" id="UserEmail" value="[% Data.UserEmail | html %]" class="W50pc Validate_Email Validate_Required [% Data.UserEmailInvalid | html %]" maxlength="250"/>
<input type="[% Env("EmailFieldType") | html %]" name="UserEmail" id="UserEmail" value="[% Data.UserEmail | html %]" class="W50pc Validate_Email Validate_Required [% Data.UserEmailInvalid | html %]" maxlength="250"[% IF Data.DisableLocalUserDataManagement %] readonly="readonly"[% END %]/>
<div id="UserEmailError" class="TooltipErrorMessage"><p>[% Translate("This field is required and needs to be a valid email address.") | html %]</p></div>
[% RenderBlockStart("UserEmailServerErrorMsg") %]
<div id="UserEmailServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
Expand All @@ -275,7 +286,7 @@

<label for="UserMobile">[% Translate("Mobile") | html %]:</label>
<div class="Field">
<input type="text" name="UserMobile" id="UserMobile" value="[% Data.UserMobile | html %]" class="W50pc" maxlength="50"/>
<input type="text" name="UserMobile" id="UserMobile" value="[% Data.UserMobile | html %]" class="W50pc" maxlength="50"[% IF Data.DisableLocalUserDataManagement %] readonly="readonly"[% END %]/>
</div>
<div class="Clear"></div>

Expand All @@ -286,6 +297,7 @@
<div class="Clear"></div>

<div class="Field SpacingTop">
[% IF !Data.DisableLocalUserDataManagement %]
[% IF Data.Action == 'Change' %]
<button class="CallForAction Primary" id="SubmitAndContinue" type="button" value="[% Translate("Save") | html %]"><span>[% Translate("Save") | html %]</span></button>
[% Translate("or") | html %]
Expand All @@ -295,6 +307,9 @@
[% END %]
[% Translate("or") | html %]
<a href="[% Env("Baselink") %]Action=[% Env("Action") %]">[% Translate("Cancel") | html %]</a>
[% ELSE %]
<a href="[% Env("Baselink") %]Action=[% Env("Action") %]">[% Translate("Close") | html %]</a>
[% END %]
</div>
<div class="Clear"></div>
</fieldset>
Expand Down
2 changes: 2 additions & 0 deletions Kernel/Output/HTML/Templates/Standard/AdminUserGroup.tt
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
</li>
[% RenderBlockEnd("ActionOverview") %]
[% RenderBlockStart("NewActions") %]
[% IF !Data.DisableLocalUserDataManagement %]
<li>
<a href="[% Env("Baselink") %]Action=AdminUser;Subaction=Add" class="CallForAction Fullsize Center"><span><i class="fa fa-plus-square"></i>[% Translate("Add Agent") | html %]</span></a>
</li>
[% END %]
<li>
<a href="[% Env("Baselink") %]Action=AdminGroup;Subaction=Add" class="CallForAction Fullsize Center"><span><i class="fa fa-plus-square"></i>[% Translate("Add Group") | html %]</span></a>
</li>
Expand Down