From ede97bc17422a24cbbee1fdcb7ead841b2a83b8e Mon Sep 17 00:00:00 2001 From: juanmanuelr Date: Thu, 17 Feb 2011 18:11:56 +0000 Subject: [PATCH] 2011-02-17 Juan Manuel Ramon * include/functions_custom_graphs.php godmode/reporting/graph_builder.main.php godmode/reporting/graphs.php: Only administrator users can select and see group All in this views. Fix: #3183419, 3183421 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3908 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 ++++++++ .../godmode/reporting/graph_builder.main.php | 9 ++++++-- pandora_console/godmode/reporting/graphs.php | 8 ++++++- .../include/functions_custom_graphs.php | 21 ++++++++++++------- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index b678715e19..b817cd6d2d 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2011-02-17 Juan Manuel Ramon + + * include/functions_custom_graphs.php + godmode/reporting/graph_builder.main.php + godmode/reporting/graphs.php: Only administrator users can select and see + group All in this views. + + Fix: #3183419, 3183421 + 2011-02-17 Juan Manuel Ramon * operation/agentes/estado_agente.php diff --git a/pandora_console/godmode/reporting/graph_builder.main.php b/pandora_console/godmode/reporting/graph_builder.main.php index 4dd2cef3b0..a1f7f1e936 100644 --- a/pandora_console/godmode/reporting/graph_builder.main.php +++ b/pandora_console/godmode/reporting/graph_builder.main.php @@ -102,9 +102,14 @@ if ($edit_graph) { } echo ">"; -$group_select = get_user_groups ($config['id_user']); +$own_info = get_user_info ($config['id_user']); +if ($own_info['is_admin'] || give_acl ($config['id_user'], 0, "PM")) + $return_all_groups = true; +else + $return_all_groups = false; + echo "".__('Group')."" . - print_select_groups($config['id_user'], "AR", true, 'graph_id_group', $id_group, '', '', '', true) . + print_select_groups($config['id_user'], "AR", $return_all_groups, 'graph_id_group', $id_group, '', '', '', true) . ""; echo ""; echo "".__('Description').""; diff --git a/pandora_console/godmode/reporting/graphs.php b/pandora_console/godmode/reporting/graphs.php index c76c0cffea..3ce2c89889 100644 --- a/pandora_console/godmode/reporting/graphs.php +++ b/pandora_console/godmode/reporting/graphs.php @@ -56,7 +56,13 @@ if ($delete_graph) { } } -$graphs = get_user_custom_graphs (); +$own_info = get_user_info ($config['id_user']); +if ($own_info['is_admin'] || give_acl ($config['id_user'], 0, "PM")) + $return_all_group = true; +else + $return_all_group = false; + +$graphs = get_user_custom_graphs ($config['id_user'], false, $return_all_group, "IW"); if (! empty ($graphs)) { $table->width = '720px'; diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php index 57bc495bf9..73dc5c8ab9 100644 --- a/pandora_console/include/functions_custom_graphs.php +++ b/pandora_console/include/functions_custom_graphs.php @@ -34,31 +34,36 @@ if ($config['flash_charts']) { * @param $id_user User id to check. * @param $only_names Wheter to return only graphs names in an associative array * or all the values. + * @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. */ -function get_user_custom_graphs ($id_user = 0, $only_names = false) { +function get_user_custom_graphs ($id_user = 0, $only_names = false, $returnAllGroup = true, $privileges = 'IR') { global $config; if (!$id_user) { $id_user = $config['id_user']; } - $groups = get_user_groups ($id_user, "AR", false); - + $groups = get_user_groups ($id_user, $privileges, $returnAllGroup); + $all_graphs = get_db_all_rows_in_table ('tgraph', 'name'); if ($all_graphs === false) return array (); - + $graphs = array (); foreach ($all_graphs as $graph) { + if (!in_array($graph['id_group'], array_keys($groups))) + continue; + if ($graph["id_user"] != $id_user && $graph['private']) continue; - if ($graph["id_group"] > 0) - if (!isset($groups[$graph["id_group"]])){ - continue; - } + if ($graph["id_group"] > 0) + if (!isset($groups[$graph["id_group"]])){ + continue; + } if ($only_names) { $graphs[$graph['id_graph']] = $graph['name'];