From 021675d82561bcf1cd71851bc9fa0fc449b7cd28 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Fri, 26 Mar 2021 11:28:34 +0100 Subject: [PATCH] fixed minor error --- .../include/functions_custom_graphs.php | 2 +- .../lib/Dashboard/Widgets/custom_graph.php | 23 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php index e50d15fbb2..17f52de0f1 100644 --- a/pandora_console/include/functions_custom_graphs.php +++ b/pandora_console/include/functions_custom_graphs.php @@ -113,7 +113,7 @@ function custom_graphs_create( * @param $returnAllGroup Wheter to return graphs of group All or not. * @param $privileges Privileges to check in user group * - * @return Custom graphs of a an user. Empty array if none. + * @return array graphs of a an user. Empty array if none. */ function custom_graphs_get_user($id_user=0, $only_names=false, $returnAllGroup=true, $privileges='RR') { diff --git a/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php b/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php index e883dd0ec2..0913cf212b 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php +++ b/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php @@ -245,17 +245,26 @@ class CustomGraphWidget extends Widget $return_all_group = false; - if (users_can_manage_group_all('RM')) { + if (users_can_manage_group_all('RM') === true) { $return_all_group = true; } // Custom graph. $fields = \custom_graphs_get_user(0, false, $return_all_group); - // If currently selected graph is not included in fields array (it belongs to a group over which user has no permissions), then add it to fields array. - // This is aimed to avoid overriding this value when a user with narrower permissions edits widget configuration. - if ($values['id_graph'] !== null && !array_key_exists($values['id_graph'], $fields)) { - $selected_graph = db_get_row('tgraph', 'id_graph', $values['id_graph']); + // If currently selected graph is not included in fields array + // (it belongs to a group over which user has no permissions), + // then add it to fields array. + // This is aimed to avoid overriding this value when a user + // with narrower permissions edits widget configuration. + if ($values['id_graph'] !== null + && array_key_exists($values['id_graph'], $fields) === false + ) { + $selected_graph = db_get_row( + 'tgraph', + 'id_graph', + $values['id_graph'] + ); $fields[$values['id_graph']] = $selected_graph; } @@ -366,7 +375,8 @@ class CustomGraphWidget extends Widget ); $hackLegendHight = (30 * count($sources)); - if ($hackLegendHight > ($size['height'] - 10 - $hackLegendHight)) { + $operation = ($size['height'] - 10 - $hackLegendHight); + if ($hackLegendHight < $operation) { $height = ($size['height'] - $hackLegendHight); } else { $height = ($size['height'] - 10); @@ -406,7 +416,6 @@ class CustomGraphWidget extends Widget 'height' => $height, 'only_image' => false, 'homeurl' => $config['homeurl'], - 'percentil' => $percentil, 'backgroundColor' => 'transparent', 'menu' => false, 'show_legend' => $this->values['showLegend'],