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

* 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).

        * operation/events/events.php: Description wasn't being added to the
        audit log when deleting multiple items. Fixed

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1071 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
guruevi 2008-09-02 17:54:32 +00:00
parent e05f2e04bf
commit d49ff57c61
3 changed files with 43 additions and 46 deletions

View File

@ -1,3 +1,12 @@
2008-09-02 Evi Vanoost <vanooste@rcbi.rochester.edu>
* 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).
* operation/events/events.php: Description wasn't being added to the
audit log when deleting multiple items. Fixed
2008-09-02 Esteban Sanchez <estebans@artica.es> 2008-09-02 Esteban Sanchez <estebans@artica.es>
* include/functions.php: Style correction. * include/functions.php: Style correction.

View File

@ -120,15 +120,16 @@ if (isset ($_POST["deletebt"])){
while ($count <= $config["block_size"]) { while ($count <= $config["block_size"]) {
if (isset ($_POST["eventid".$count])) { if (isset ($_POST["eventid".$count])) {
$event_id = get_parameter_post ("eventid".$count); $event_id = get_parameter_post ("eventid".$count);
$descr = return_event_description ($event_id); //Get description before it gets deleted
// Look for event_id following parameters: id_group. // Look for event_id following parameters: id_group.
$id_group = gime_idgroup_from_idevent ($event_id); $id_group = gime_idgroup_from_idevent ($event_id);
if (give_acl ($config['id_user'], $id_group, "IM")) { if (give_acl ($config['id_user'], $id_group, "IM")) {
process_sql ("DELETE FROM tevento WHERE id_evento = ".$event_id); process_sql ("DELETE FROM tevento WHERE id_evento = ".$event_id);
audit_db ($config['id_user'], $REMOTE_ADDR, audit_db ($config['id_user'], $REMOTE_ADDR,
"Event deleted","Deleted event: ".return_event_description ($event_id)); "Event deleted","Deleted event: ".$descr);
} else { } else {
audit_db ($config['id_user'], $REMOTE_ADDR, audit_db ($config['id_user'], $REMOTE_ADDR,
"ACL Violation","Trying to delete event ".return_event_description ($event_id)); "ACL Violation","Trying to delete event: ".$descr);
} }
} }
$count++; $count++;

View File

@ -1374,54 +1374,40 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) {
function grafico_eventos_grupo ($width = 300, $height = 200, $url = "") { function grafico_eventos_grupo ($width = 300, $height = 200, $url = "") {
global $config; global $config;
$url = str_replace ( "\\" , "", $url); $url = rawurldecode ($url); //It was urlencoded, so we urldecode it
$data = array(); $data = array();
$legend = array(); $legend = array();
$sql1="SELECT * FROM tagente";
$result=mysql_query($sql1); //This will give the distinct id_agente, give the id_grupo that goes
while ($row=mysql_fetch_array($result)){ //with it and then the number of times it occured. GROUP BY statement
if (give_acl($config["id_user"], $row["id_grupo"], "AR") == 1) { //is required if both DISTINCT() and COUNT() are in the statement
$sql1="SELECT COUNT(id_evento) FROM tevento WHERE 1=1 $url AND id_agente = ".$row["id_agente"]; $sql = "SELECT DISTINCT(id_agente) AS id_agente, id_grupo, COUNT(id_agente) AS count FROM tevento WHERE 1=1 ".$url." GROUP BY id_agente";
if ($result2=mysql_query($sql1)) $result = get_db_all_rows_sql ($sql);
$row2=mysql_fetch_array($result2); if ($result === false)
if ($row2[0] > 0) { $result = array();
$data[] = $row2[0];
$legend[] = substr($row["nombre"],0,15)." ( $row2[0] )";
}
}
}
// System events
$sql1="SELECT COUNT(id_evento) FROM tevento WHERE 1=1 $url AND id_agente = 0";
if ($result2 = mysql_query($sql1))
$row2=mysql_fetch_array($result2);
if ($row2[0] > 0){
$data[] = $row2[0];
$legend[] = "SYSTEM"." ( $row2[0] )";
}
// Sort array by bubble method (yes, I study more methods in university, but if you want more speed, please, submit a patch :) foreach ($result as $row) {
// or much better, pay me to do a special version for you, highly optimized :-)))) if (give_acl ($config["id_user"], $row["id_grupo"], "AR") == 1) {
for ($i=0;$i < sizeof($data);$i++){ $data[] = $row["count"];
for ($j=$i; $j <sizeof($data); $j++) if ($row["id_agente"] == 0) {
if ($data[$j] > $data[$i]) { //System event
$temp = $data[$i]; $legend[] = "SYSTEM (".$row["count"].")";
$temp_label = $legend[$i]; } else {
$data[$i] = $data[$j]; //Other events
$legend[$i] = $legend[$j]; $legend[] = substr (dame_nombre_agente ($row["id_agente"]), 0, 15)." (".$row["count"].")";
$data[$j] = $temp;
$legend[$j] = $temp_label;
} }
}
$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); 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);
} }
@ -2083,6 +2069,7 @@ $stacked = get_parameter ("stacked", 0);
$date = get_parameter ("date"); $date = get_parameter ("date");
$graphic_type = (string) get_parameter ('tipo'); $graphic_type = (string) get_parameter ('tipo');
$mode = get_parameter ("mode", 1); $mode = get_parameter ("mode", 1);
$url = get_parameter ('url','');
if ($graphic_type) { if ($graphic_type) {
switch ($graphic_type) { switch ($graphic_type) {
@ -2122,7 +2109,7 @@ if ($graphic_type) {
graph_event_module ($width, $height, $id_agent); graph_event_module ($width, $height, $id_agent);
case "group_events": case "group_events":
grafico_eventos_grupo($width, $height); grafico_eventos_grupo($width, $height, $url);
break; break;
case "user_events": case "user_events":