Merge branch 'ent-6952-bug-group-creation-user-admin-no-all' into 'develop'

Ent 6952 bug group creation user admin no all

See merge request artica/pandorafms!3844
This commit is contained in:
Daniel Rodriguez 2021-04-07 08:11:35 +00:00
commit decea8ab95
4 changed files with 24 additions and 13 deletions

View File

@ -149,12 +149,12 @@ if ($id_group) {
$table->data[2][1] .= html_print_select_groups( $table->data[2][1] .= html_print_select_groups(
false, false,
'AR', 'AR',
true, false,
'id_parent', 'id_parent',
$id_parent, $id_parent,
'', '',
'', __('None'),
'', -1,
true, true,
false, false,
true, true,
@ -174,7 +174,9 @@ if ($id_group) {
'name' => 'id_parent', 'name' => 'id_parent',
'selected' => $id_parent, 'selected' => $id_parent,
'return' => true, 'return' => true,
'returnAllGroup' => true, 'returnAllGroup' => false,
'nothing' => __('None'),
'nothing_value' => -1,
] ]
); );
$table->data[2][1] .= '</div>'; $table->data[2][1] .= '</div>';
@ -182,7 +184,7 @@ if ($id_group) {
if ($acl_parent) { if ($acl_parent) {
$table->data[2][1] .= ' <span id="parent_preview">'; $table->data[2][1] .= ' <span id="parent_preview">';
$table->data[2][1] .= html_print_image('images/groups_small/'.groups_get_icon($id_parent).'.png', true); $table->data[2][1] .= html_print_image('images/groups_small/'.( $id_parent != 0 ? groups_get_icon($id_parent) : 'without_group').'.png', true);
$table->data[2][1] .= '</span>'; $table->data[2][1] .= '</span>';
} }

View File

@ -59,11 +59,11 @@ if (is_ajax() === true) {
if ($get_group_json === true) { if ($get_group_json === true) {
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
if ($id_group === 0) { if ($id_group === 0 || $id_group === -1) {
$group = [ $group = [
'id_grupo' => 0, 'id_grupo' => 0,
'nombre' => 'All', 'nombre' => 'None',
'icon' => 'world', 'icon' => '',
'parent' => 0, 'parent' => 0,
'disabled' => 0, 'disabled' => 0,
'custom_id' => null, 'custom_id' => null,
@ -472,7 +472,7 @@ if ($update_group) {
$values = [ $values = [
'nombre' => $name, 'nombre' => $name,
'icon' => empty($icon) ? '' : substr($icon, 0, -4), 'icon' => empty($icon) ? '' : substr($icon, 0, -4),
'parent' => $id_parent, 'parent' => $id_parent == -1 ? 0 : $id_parent,
'disabled' => !$alerts_enabled, 'disabled' => !$alerts_enabled,
'custom_id' => $custom_id, 'custom_id' => $custom_id,
'id_skin' => $skin, 'id_skin' => $skin,
@ -719,7 +719,7 @@ if ($tab == 'tree') {
if (users_can_manage_group_all('AR') === false) { if (users_can_manage_group_all('AR') === false) {
$user_groups_acl = users_get_groups(false, 'AR'); $user_groups_acl = users_get_groups(false, 'AR');
$groups_acl = implode(',', $user_groups_ACL); $groups_acl = implode('","', $user_groups_acl);
if (empty($groups_acl) === true) { if (empty($groups_acl) === true) {
return ui_print_info_message( return ui_print_info_message(
[ [
@ -729,7 +729,7 @@ if ($tab == 'tree') {
); );
} }
$acl = 'AND t.id_grupo IN ('.$groups_acl.')'; $acl = 'AND t.nombre IN ("'.$groups_acl.'")';
} }
$form = "<form method='post' action=''>"; $form = "<form method='post' action=''>";
@ -908,7 +908,7 @@ if ($tab == 'tree') {
} }
} }
if (check_acl($config['id_user'], 0, 'PM') === true) { if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/groups/configure_group">'; echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/groups/configure_group">';
echo '<div class="action-buttons w100p">'; echo '<div class="action-buttons w100p">';
html_print_submit_button(__('Create group'), 'crt', false, 'class="sub next"'); html_print_submit_button(__('Create group'), 'crt', false, 'class="sub next"');

View File

@ -1494,7 +1494,7 @@ class DiscoveryTaskList extends HTML
if (is_array($data['modules'])) { if (is_array($data['modules'])) {
// Alphabetically sort. // Alphabetically sort.
ksort($data['modules'], SORT_STRING | SORT_FLAG_CASE); ksort($data['modules'], (SORT_STRING | SORT_FLAG_CASE));
$simple_data = array_merge( $simple_data = array_merge(
$simple_data, $simple_data,

View File

@ -139,6 +139,15 @@ class TreeGroupEdition extends TreeGroup
} }
); );
// Filter groups that user has permission.
$groups = array_filter(
$groups,
function ($group) {
global $config;
return check_acl($config['id_user'], $group['id'], 'AR');
}
);
usort($groups, ['Tree', 'cmpSortNames']); usort($groups, ['Tree', 'cmpSortNames']);
return $groups; return $groups;
} }