Skip to content

Commit

Permalink
User - hide the profile in edit form if it is disabled with user_stat…
Browse files Browse the repository at this point in the history
…us_show_option for admin sessions - refs BT#19598
  • Loading branch information
cfasanando committed Jan 3, 2023
1 parent fcf64ae commit adb7ab5
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions main/admin/user_edit.php
Expand Up @@ -250,16 +250,38 @@ function confirmation(name) {
// Status
$status = UserManager::getUserStatusList();

$form->addElement(
'select',
'status',
get_lang('Profile'),
$status,
[
'id' => 'status_select',
'onchange' => 'javascript: display_drh_list();',
]
);
$hideSelectProfile = false;
// to hide the status list if it is not enabled with user_status_show_option for admin sessions.
if (api_is_session_admin()) {
if (true === api_get_configuration_value('user_status_show_options_enabled')) {
$userStatusConfig = api_get_configuration_value('user_status_show_option');
if (!empty($userStatusConfig)) {
$statusConfigHidden = [];
foreach ($userStatusConfig as $role => $enabled) {
$constStatus = constant($role);
if (!$enabled) {
$statusConfigHidden[] = $constStatus;
}
}
$hideSelectProfile = in_array($user_data['status'], $statusConfigHidden);
}
}
}

if (!$hideSelectProfile) {
$form->addElement(
'select',
'status',
get_lang('Profile'),
$status,
[
'id' => 'status_select',
'onchange' => 'javascript: display_drh_list();',
]
);
} else {
$form->addElement('hidden', 'status', $user_data['status']);
}

$display = isset($user_data['status']) && ($user_data['status'] == STUDENT || (isset($_POST['status']) && $_POST['status'] == STUDENT)) ? 'block' : 'none';

Expand Down

0 comments on commit adb7ab5

Please sign in to comment.