From 222da4ee403e7054d73b08ed5bf637e465b2e59a Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 4 Dec 2018 09:36:48 +0100 Subject: [PATCH] group filter custom field view --- pandora_console/include/ajax/custom_fields.php | 3 ++- pandora_console/include/functions_custom_fields.php | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/ajax/custom_fields.php b/pandora_console/include/ajax/custom_fields.php index d24dd88b40..8500166413 100644 --- a/pandora_console/include/ajax/custom_fields.php +++ b/pandora_console/include/ajax/custom_fields.php @@ -460,6 +460,7 @@ if($build_table_save_filter){ $table->class = 'databox'; $array_filters = get_filters_custom_fields_view(0, true); + $table->data[0][0] = __('Filter name'); $table->data[0][1] = html_print_select( $array_filters, 'id_name', @@ -491,7 +492,7 @@ if($append_tab_filter){ $table->data[0][2] = __('Group'); $table->data[0][3] = html_print_select_groups( - $config['id_user'], 'AR', true, 'group_search', + $config['id_user'], 'AR', true, 'group_search_cr', 0, '', '', '0', true, false, false, '', false, '', false, false, 'id_grupo', false diff --git a/pandora_console/include/functions_custom_fields.php b/pandora_console/include/functions_custom_fields.php index e22956adf1..dcc038b620 100644 --- a/pandora_console/include/functions_custom_fields.php +++ b/pandora_console/include/functions_custom_fields.php @@ -506,8 +506,16 @@ function agent_counters_custom_fields($filters){ } function get_filters_custom_fields_view($id = 0, $for_select = false, $name = ""){ + //filter group and check ACL groups + $groups_and = ""; + if (!users_can_manage_group_all()) { + $user_groups = array_keys(users_get_groups(false, "AR", false)); + $id_groups = implode(", ", $user_groups); + $groups_and = " AND (group_search IN ($id_groups)) "; + } + if($for_select){ - $query = "SELECT id, `name` FROM tagent_custom_fields_filter"; + $query = "SELECT id, `name` FROM tagent_custom_fields_filter WHERE 1=1" . $groups_and; $rs = db_get_all_rows_sql($query); if(isset($rs) && is_array($rs)){ foreach ($rs as $key => $value) { @@ -519,7 +527,7 @@ function get_filters_custom_fields_view($id = 0, $for_select = false, $name = "" } } else{ - $query = "SELECT * FROM tagent_custom_fields_filter WHERE 1=1"; + $query = "SELECT * FROM tagent_custom_fields_filter WHERE 1=1" . $groups_and; if($id){ $query .= " AND id = " . $id;