From c02d40b946274bb22d336a1e401918d8b82cb1e3 Mon Sep 17 00:00:00 2001
From: ramonn <noreply@pandorafms.org>
Date: Wed, 1 Jul 2009 16:14:51 +0000
Subject: [PATCH] 2009-07-01  Ramon Novoa  <rnovoa@artica.es>

	* include/functions_custom_graphs.php, include/fgraph.php,
          include/functions_fsgraph.php: Small fixes, mostly path related.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1785 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_console/ChangeLog                           |  5 +++++
 pandora_console/include/fgraph.php                  |  5 ++++-
 pandora_console/include/functions_custom_graphs.php |  1 +
 pandora_console/include/functions_fsgraph.php       | 12 +++++++-----
 4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index b35a3a253e..59e7a925c6 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-01  Ramon Novoa  <rnovoa@artica.es>
+
+	* include/functions_custom_graphs.php, include/fgraph.php,
+	  include/functions_fsgraph.php: Small fixes, mostly path related.
+
 2009-06-01  Jorge Gonzalez  <jorgegonz@artica.es>
 
 	* include/languages/es.po, include/languages/es.mo: Updated Spanish
diff --git a/pandora_console/include/fgraph.php b/pandora_console/include/fgraph.php
index 382fab2733..4af2a96705 100644
--- a/pandora_console/include/fgraph.php
+++ b/pandora_console/include/fgraph.php
@@ -327,7 +327,7 @@ function grafico_modulo_sparse ($id_agente_modulo, $period, $show_event,
 	
 	if ($all_data === false) {
 		if (! $graphic_type) {
-			return fs_error_image ('../images');
+			return fs_error_image ();
 		}
 		graphic_error ();
 	}
@@ -800,6 +800,9 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) {
 			GROUP BY id_agentmodule LIMIT %d', $id_agent, $max_items);
 	$events = get_db_all_rows_sql ($sql);
 	if ($events === false) {
+		if (! $graphic_type) {
+			return fs_error_image ();
+		}
 		graphic_error ();
 		return;
 	}
diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php
index 22681d8780..2173044b6f 100644
--- a/pandora_console/include/functions_custom_graphs.php
+++ b/pandora_console/include/functions_custom_graphs.php
@@ -14,6 +14,7 @@
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
 
+global $config;
 if ($config['flash_charts']) {
 	require_once ('include/fgraph.php');
 }
diff --git a/pandora_console/include/functions_fsgraph.php b/pandora_console/include/functions_fsgraph.php
index 229441b52b..9c8f8d04ed 100644
--- a/pandora_console/include/functions_fsgraph.php
+++ b/pandora_console/include/functions_fsgraph.php
@@ -25,7 +25,7 @@ function get_chart_code ($chart, $width, $height, $swf) {
     $output .= '<script type="text/javascript">
     			<!--
         			$(document).ready(function pie_' . $chart_id . ' () {
-        				var myChart = new FusionCharts("' . $swf . '", "' . $chart_id . '", "' . $width. '", "' . $height. '", "0", "1");
+        				var myChart = new FusionCharts("' . $config['homeurl'] . $swf . '", "' . $chart_id . '", "' . $width. '", "' . $height. '", "0", "1");
         				myChart.setDataXML("' . addslashes($chart->getXML ()) . '");
 						myChart.addParam("WMode", "Transparent");
         				myChart.render("' . $div_id . '");
@@ -174,11 +174,11 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti
 	$div_id = 'chart_div_' . $random_number;
 	$chart_id = 'chart_' . $random_number;
     $output = '<div id="' . $div_id. '" style="z-index:1;"></div>'; 
-	$output .= '<script language="JavaScript" src="../../include/FusionCharts/FusionCharts.js"></script>';
+	$output .= '<script language="JavaScript" src="' . $config['homeurl'] . '/include/FusionCharts/FusionCharts.js"></script>';
     $output .= '<script type="text/javascript">
     			<!--
         			function pie_' . $chart_id . ' () {
-        				var myChart = new FusionCharts("../../include/FusionCharts/FCF_MSArea2D.swf", "' . $chart_id . '", "' . $width. '", "' . $height. '", "0", "1");
+        				var myChart = new FusionCharts("' . $config['homeurl'] . '/include/FusionCharts/FCF_MSArea2D.swf", "' . $chart_id . '", "' . $width. '", "' . $height. '", "0", "1");
         				myChart.setDataXML("' . addslashes($chart->getXML ()) . '");
 						myChart.addParam("WMode", "Transparent");
         				myChart.render("' . $div_id . '");
@@ -281,8 +281,10 @@ function clean_flash_string ($string) {
 }
 
 // Prints an error image
-function fs_error_image ($image_dir = 'images') {
-	return '<img border="0" src="' . $image_dir . '/image_problem.png" />';
+function fs_error_image () {
+	global $config;
+
+	return '<img border="0" src="' . $config['homeurl'] . '/images/image_problem.png" />';
 }
 
 ?>