Fixed misplaced function in functions_reporting_html.php

This commit is contained in:
mdtrooper 2015-06-11 21:23:11 +02:00
parent 0be8792b01
commit 19f74c8e78
2 changed files with 51 additions and 49 deletions

View File

@ -7805,4 +7805,54 @@ function reporting_get_stats_servers($tiny = true) {
return $output;
}
/**
* Get all the template graphs a user can see.
*
* @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 template graphs of a an user. Empty array if none.
*/
function reporting_template_graphs_get_user ($id_user = 0, $only_names = false, $returnAllGroup = true, $privileges = 'RR') {
global $config;
if (!$id_user) {
$id_user = $config['id_user'];
}
$groups = users_get_groups ($id_user, $privileges, $returnAllGroup);
$all_templates = db_get_all_rows_in_table ('tgraph_template', 'name');
if ($all_templates === false)
return array ();
$templates = array ();
foreach ($all_templates as $template) {
if (!in_array($template['id_group'], array_keys($groups)))
continue;
if ($template["id_user"] != $id_user && $template['private'])
continue;
if ($template["id_group"] > 0)
if (!isset($groups[$template["id_group"]])) {
continue;
}
if ($only_names) {
$templates[$template['id_graph_template']] = $template['name'];
}
else {
$templates[$template['id_graph_template']] = $template;
$templatesCount = db_get_value_sql("SELECT COUNT(id_gs_template) FROM tgraph_source_template WHERE id_template = " . $template['id_graph_template']);
$templates[$template['id_graph_template']]['graphs_template_count'] = $templatesCount;
}
}
return $templates;
}
?>

View File

@ -2500,55 +2500,7 @@ function reporting_header_content($mini, $content, $report, &$table,
/**
* Get all the template graphs a user can see.
*
* @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 template graphs of a an user. Empty array if none.
*/
function reporting_template_graphs_get_user ($id_user = 0, $only_names = false, $returnAllGroup = true, $privileges = 'RR') {
global $config;
if (!$id_user) {
$id_user = $config['id_user'];
}
$groups = users_get_groups ($id_user, $privileges, $returnAllGroup);
$all_templates = db_get_all_rows_in_table ('tgraph_template', 'name');
if ($all_templates === false)
return array ();
$templates = array ();
foreach ($all_templates as $template) {
if (!in_array($template['id_group'], array_keys($groups)))
continue;
if ($template["id_user"] != $id_user && $template['private'])
continue;
if ($template["id_group"] > 0)
if (!isset($groups[$template["id_group"]])) {
continue;
}
if ($only_names) {
$templates[$template['id_graph_template']] = $template['name'];
}
else {
$templates[$template['id_graph_template']] = $template;
$templatesCount = db_get_value_sql("SELECT COUNT(id_gs_template) FROM tgraph_source_template WHERE id_template = " . $template['id_graph_template']);
$templates[$template['id_graph_template']]['graphs_template_count'] = $templatesCount;
}
}
return $templates;
}