Changed permissions for management users - #4794

This commit is contained in:
Tatiana Llorente 2019-10-11 11:47:38 +02:00
parent 7fc31d127d
commit 8c556d7d19
3 changed files with 31 additions and 6 deletions

View File

@ -18,7 +18,7 @@ check_login();
enterprise_hook('open_meta_frame');
if (! check_acl($config['id_user'], 0, 'PM')) {
if (! check_acl($config['id_user'], 0, 'UM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Profile Management'
@ -320,24 +320,29 @@ if ($id_profile || $new_profile) {
$table->data['IM'] = $row;
$table->data[] = '<hr>';
$disable_option = 'javascript: return false;';
if (check_acl($config['id_user'], 0, 'PM') || users_is_admin()) {
$disable_option = '';
}
// Users
$row = [];
$row['name'] = __('Manage users');
$row['input'] = html_print_checkbox('user_management', 1, $user_management, true);
$row['input'] = html_print_checkbox('user_management', 1, $user_management, true, false, $disable_option);
$table->data['UM'] = $row;
$table->data[] = '<hr>';
// DB
$row = [];
$row['name'] = __('Manage database');
$row['input'] = html_print_checkbox('db_management', 1, $db_management, true);
$row['input'] = html_print_checkbox('db_management', 1, $db_management, true, false, $disable_option);
$table->data['DM'] = $row;
$table->data[] = '<hr>';
// Pandora
$row = [];
$row['name'] = __('%s management', get_product_name());
$row['input'] = html_print_checkbox('pandora_management', 1, $pandora_management, true);
$row['input'] = html_print_checkbox('pandora_management', 1, $pandora_management, true, false, $disable_option);
$table->data['PM'] = $row;
$table->data[] = '<hr>';
@ -359,3 +364,18 @@ if ($id_profile || $new_profile) {
}
enterprise_hook('close_meta_frame');
?>
<script type="text/javascript" language="javascript">
$(document).ready (function () {
var disable_option = '<?php echo $disable_option; ?>';
if (disable_option != '') {
var ids = ['#checkbox-db_management', '#checkbox-user_management', '#checkbox-pandora_management'];
ids.forEach(id => {
$(id).css({'cursor':'not-allowed', 'opacity':'0.5'});
});
}
});
</script>

View File

@ -362,7 +362,10 @@ foreach ($profiles as $profile) {
$data['PM'] = ($profile['pandora_management'] ? $img : '');
$table->cellclass[]['operations'] = 'action_buttons';
$data['operations'] = '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_profile&id='.$profile['id_perfil'].'&pure='.$pure.'">'.html_print_image('images/config.png', true, ['title' => __('Edit')]).'</a>';
$data['operations'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/users/profile_list&delete_profile=1&id='.$profile['id_perfil'].'&pure='.$pure.'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true).'</a>';
if (check_acl($config['id_user'], 0, 'PM') || users_is_admin()) {
$data['operations'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/users/profile_list&delete_profile=1&id='.$profile['id_perfil'].'&pure='.$pure.'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true).'</a>';
}
array_push($table->data, $data);
}

View File

@ -420,7 +420,9 @@ else {
$u = get_user_info($key);
$g = users_get_groups($key, 'AR', $u['is_admin']);
$result = array_intersect($g, $own_groups);
if (!$usr['is_admin'] && !empty($result)) {
// Show users without profile too.
if (!$usr['is_admin'] && !empty($result) || (!$usr['is_admin'] && db_get_all_rows_field_filter('tusuario_perfil', 'id_usuario', $usr['id_user']) === false)) {
$info[$key] = $usr;
}