Fix unhandled extra-options in group selector inclusions
This commit is contained in:
parent
2b5eb00e6a
commit
a4b2e38ffc
|
@ -548,7 +548,24 @@ $table->data[0][1] .= '<b>'.__('Cascade protection').'</b>'.html_print_select(
|
|||
$table->data[0][1] .= ' '.__('Module').' '.html_print_select($modules, 'cascade_protection_module', $cascade_protection_module, '', '', 0, true);
|
||||
|
||||
$table->data[1][0] = __('Group');
|
||||
$table->data[1][1] = html_print_select_groups(false, 'AR', false, 'group', $group, '', __('No change'), -1, true, false, true, '', false, 'width: 150px;');
|
||||
$table->data[1][1] = '<div class="w290px inline">';
|
||||
$table->data[1][1] .= html_print_select_groups(
|
||||
false,
|
||||
'AR',
|
||||
false,
|
||||
'group',
|
||||
$group,
|
||||
'',
|
||||
__('No change'),
|
||||
-1,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'width: 150px;'
|
||||
);
|
||||
$table->data[1][1] .= '</div>';
|
||||
|
||||
$table->data[2][0] = __('Interval');
|
||||
|
||||
|
|
|
@ -514,6 +514,11 @@ function html_print_select_groups(
|
|||
}
|
||||
}
|
||||
|
||||
if (empty($nothing) === false) {
|
||||
$fields[$nothing_value] = $nothing;
|
||||
$include_groups[$nothing_value] = $nothing;
|
||||
}
|
||||
|
||||
if (is_array($delete_groups) === true) {
|
||||
$json_exclusions = json_encode($delete_groups);
|
||||
}
|
||||
|
|
|
@ -170,8 +170,8 @@ class Group extends Entity
|
|||
private static function prepareGroups(array $groups):array
|
||||
{
|
||||
$return = [];
|
||||
$groups = \groups_get_groups_tree_recursive($groups);
|
||||
foreach ($groups as $k => $v) {
|
||||
$tree_groups = \groups_get_groups_tree_recursive($groups);
|
||||
foreach ($tree_groups as $k => $v) {
|
||||
$return[] = [
|
||||
'id' => $k,
|
||||
'text' => \io_safe_output(
|
||||
|
@ -187,8 +187,29 @@ class Group extends Entity
|
|||
];
|
||||
}
|
||||
|
||||
return $return;
|
||||
$unassigned = [];
|
||||
$processed = array_keys($tree_groups);
|
||||
foreach ($groups as $k => $v) {
|
||||
if (in_array($k, $processed) === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$unassigned[] = [
|
||||
'id' => $k,
|
||||
'text' => \io_safe_output(
|
||||
\ui_print_truncate_text(
|
||||
$v,
|
||||
GENERIC_SIZE_TEXT,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
)
|
||||
),
|
||||
'level' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
return array_merge($unassigned, $return);
|
||||
}
|
||||
|
||||
|
||||
|
@ -291,18 +312,25 @@ class Group extends Entity
|
|||
]
|
||||
);
|
||||
|
||||
$exclusions = json_decode(\io_safe_output($exclusions));
|
||||
$exclusions = json_decode(\io_safe_output($exclusions), true);
|
||||
if (empty($exclusions) === false) {
|
||||
foreach ($exclusions as $ex) {
|
||||
unset($groups[$ex]);
|
||||
}
|
||||
}
|
||||
|
||||
$inclusions = json_decode(\io_safe_output($inclusions));
|
||||
$inclusions = json_decode(\io_safe_output($inclusions), true);
|
||||
if (empty($inclusions) === false) {
|
||||
foreach ($inclusions as $g) {
|
||||
if (empty($groups[$g]) === true) {
|
||||
$groups[$g] = \groups_get_name($g);
|
||||
foreach ($inclusions as $k => $g) {
|
||||
if (empty($groups[$k]) === true) {
|
||||
if (is_numeric($g) === true) {
|
||||
$groups[$k] = \groups_get_name($k);
|
||||
}
|
||||
|
||||
if (empty($groups[$k]) === true) {
|
||||
// Group does not exist, direct value assigned.
|
||||
$groups[$k] = $g;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue