2008-09-02 Evi Vanoost <vanooste@rcbi.rochester.edu>

* reporting/fgraph.php: Updated graph_event_module and minor fix in switch

        * include/functions_reporting.php: Minor fix for uninitialized array()

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1072 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
guruevi 2008-09-02 20:11:46 +00:00
parent 79d2010ae2
commit b209513cb6
3 changed files with 39 additions and 48 deletions

View File

@ -3,10 +3,13 @@
* reporting/fgraph.php: SQL passed wasn't being processed, so the graph
was off for grafico_eventos_group. Updated that and the whole
function. Simplified, it runs very fast now (practically no delay).
Updated graph_event_module as well.
* operation/events/events.php: Description wasn't being added to the
audit log when deleting multiple items. Fixed
* include/functions_reporting.php: Minor fix for uninitialized array
2008-09-02 Esteban Sanchez <estebans@artica.es>
* include/functions.php: Style correction.

View File

@ -563,6 +563,8 @@ function get_agent_modules_reporting_table ($id_agent, $period = 0, $date = 0) {
$table->data = array ();
$n_a_string = __('N/A').'(*)';
$modules = get_modules_in_agent ($id_agent);
if ($modules === false)
$modules = array();
$data = array ();
foreach ($modules as $module) {

View File

@ -1320,54 +1320,39 @@ function grafico_eventos_total ($filter = "") {
}
function graph_event_module ($width = 300, $height = 200, $id_agent) {
// Need ACL check
$data = array();
$legend = array();
$sql1="SELECT * FROM tagente_modulo WHERE id_agente = $id_agent AND disabled = 0";
$result=mysql_query($sql1);
while ($row=mysql_fetch_array($result)){
$sql1="SELECT COUNT(*) FROM tevento WHERE id_agentmodule = ".$row["id_agente_modulo"];
if ($result2=mysql_query($sql1))
$row2=mysql_fetch_array($result2);
if ($row2[0] > 0) {
$data[] = $row2[0];
$legend[] = substr($row["nombre"],0,15)." ( $row2[0] )";
}
}
global $config;
$sql1="SELECT COUNT(*) FROM tevento WHERE id_agentmodule = 0 AND id_agente = $id_agent";
if ($result2=mysql_query($sql1))
$row2=mysql_fetch_array($result2);
if ($row2[0] > 0) {
$data[] = $row2[0];
$legend[] = __('System')." ( $row2[0] )";
}
$data = array();
$legend = array();
$sql = "SELECT DISTINCT(id_agentmodule) AS id_agentmodule, id_grupo, COUNT(id_agentmodule) AS count FROM tevento WHERE id_agente = ".$id_agent." GROUP BY id_agentmodule";
$result = get_db_all_rows_sql ($sql);
if ($result === false)
$result = array();
// Sort array by bubble method (yes, I study more methods in university, but if you want more speed, please, submit a patch :)
// or much better, pay me to do a special version for you, highly optimized :-))))
for ($i = 0; $i < sizeof ($data); $i++) {
for ($j = $i; $j <sizeof ($data); $j++)
if ($data[$j] > $data[$i]) {
$temp = $data[$i];
$temp_label = $legend[$i];
$data[$i] = $data[$j];
$legend[$i] = $legend[$j];
$data[$j] = $temp;
$legend[$j] = $temp_label;
}
}
foreach ($result as $row) {
if (give_acl ($config["id_user"], $row["id_grupo"], "AR") == 1) {
$data[] = $row["count"];
if ($row["id_agentmodule"] == 0) {
//System event
$legend[] = "SYSTEM (".$row["count"].")";
} else {
//Other events
$legend[] = substr (dame_nombre_modulo_agentemodulo ($row["id_agentmodule"]), 0, 15)." (".$row["count"].")";
}
}
}
array_multisort ($legend, $data);
$max_items = 6; //Maximum items on the piegraph
while (count($data) > $max_items) {
//Pops an element off the array until the array is small enough
array_pop ($data);
}
generic_pie_graph ($width, $height, $data, $legend);
$max_items = 6;
// Take only the first x items
if (sizeof($data) >= $max_items) {
for ($i = 0; $i < $max_items; $i++) {
$legend2[] = $legend[$i];
$data2[] = $data[$i];
}
generic_pie_graph ($width, $height, $data2, $legend2);
} else
generic_pie_graph ($width, $height, $data, $legend);
}
@ -2107,7 +2092,8 @@ if ($graphic_type) {
break;
case "event_module":
graph_event_module ($width, $height, $id_agent);
break;
case "group_events":
grafico_eventos_grupo($width, $height, $url);
@ -2137,15 +2123,15 @@ if ($graphic_type) {
break;
case "agentaccess":
graphic_agentaccess ($_GET["id"], $_GET["periodo"], $width, $height);
graphic_agentaccess ($id, get_parameter ("periodo"), $width, $height);
break;
case "agentmodules":
graphic_agentmodules($_GET["id"], $width, $height);
graphic_agentmodules($id, $width, $height);
break;
case "progress":
$percent = $_GET["percent"];
$percent = get_parameter_get ("percent");
progress_bar ($percent,$width,$height, $mode);
break;