diff --git a/graph.php b/graph.php
index a96997c9b..c6386e35b 100644
--- a/graph.php
+++ b/graph.php
@@ -44,6 +44,7 @@ get_filter_request_var('view_type', FILTER_VALIDATE_REGEXP, array('options' => a
api_plugin_hook_function('graph');
include_once('./lib/html_tree.php');
+
top_graph_header();
if (!isset_request_var('rra_id')) {
@@ -51,9 +52,9 @@ if (!isset_request_var('rra_id')) {
}
if (get_request_var('rra_id') == 'all') {
- $sql_where = ' WHERE id IS NOT NULL';
+ $sql_where = ' AND dspr.id IS NOT NULL';
}else{
- $sql_where = ' WHERE id=' . get_request_var('rra_id');
+ $sql_where = ' AND dspr.id=' . get_request_var('rra_id');
}
/* make sure the graph requested exists (sanity) */
@@ -74,7 +75,7 @@ if (get_request_var('action') != 'properties') {
print "
";
}
-$rras = get_associated_rras(get_request_var('local_graph_id'));
+$rras = get_associated_rras(get_request_var('local_graph_id'), $sql_where);
switch (get_request_var('action')) {
case 'view':
diff --git a/lib/functions.php b/lib/functions.php
index 0dec1ea69..b9f733602 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -2712,8 +2712,8 @@ function resolve_navigation_variables($text) {
/* get_associated_rras - returns a list of all RRAs referenced by a particular graph
@arg $local_graph_id - (int) the ID of the graph to retrieve a list of RRAs for
@returns - (array) an array containing the name and id of each RRA found */
-function get_associated_rras($local_graph_id) {
- return db_fetch_assoc_prepared('SELECT DISTINCT ' . SQL_NO_CACHE . '
+function get_associated_rras($local_graph_id, $sql_where = '') {
+ return db_fetch_assoc_prepared('SELECT DISTINCT ' . SQL_NO_CACHE . "
dspr.id, dspr.steps, dspr.rows, dspr.name, dtd.rrd_step
FROM graph_templates_item AS gti
LEFT JOIN data_template_rrd AS dtr
@@ -2725,7 +2725,7 @@ function get_associated_rras($local_graph_id) {
LEFT JOIN data_source_profiles_rra AS dspr
ON dsp.id=dspr.data_source_profile_id
AND dtd.local_data_id != 0
- WHERE gti.local_graph_id = ?', array($local_graph_id));
+ WHERE gti.local_graph_id = ? $sql_where", array($local_graph_id));
}
/* get_browser_query_string - returns the full url, including args requested by the browser