From 993bad314d81f97db207cc502325667b28fd31c7 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 11 Jan 2017 13:26:50 +0100 Subject: [PATCH 1/8] fixed errors in events reports #135 --- .../reporting_builder.item_editor.php | 128 ++-- .../godmode/reporting/reporting_builder.php | 70 +- pandora_console/include/functions_events.php | 662 +++++++++++------- pandora_console/include/functions_graph.php | 2 +- .../include/functions_reporting.php | 482 +++---------- .../include/functions_reporting_html.php | 121 ++-- pandora_console/index.php | 2 +- 7 files changed, 714 insertions(+), 753 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 91c16e0a27..cdb9961af9 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -95,17 +95,15 @@ $percentil = false; $time_compare_overlapped = false; //Added for events items -$filter_event_validated = false; -$filter_event_no_validated = false; -$filter_event_critical = false; -$filter_event_warning = false; - -$filter_event_type = false; - +$show_summary_group = false; +$filter_event_severity = false; +$filter_event_type = false; +$filter_event_status = false; $event_graph_by_agent = false; $event_graph_by_user_validator = false; $event_graph_by_criticity = false; $event_graph_validated_vs_unvalidated = false; + $netflow_filter = 0; $max_values = 0; $resolution = 0; @@ -401,33 +399,17 @@ switch ($action) { $group = $item['id_group']; break; case 'event_report_agent': - $description = $item['description']; - $idAgent = $item['id_agent']; - $period = $item['period']; - - //Added for events items - $filter_event_no_validated = $style['filter_event_no_validated']; - $filter_event_validated = $style['filter_event_validated']; - $filter_event_critical = $style['filter_event_critical']; - $filter_event_warning = $style['filter_event_warning']; - $filter_event_type = json_decode($style['filter_event_type'], true); - - $event_graph_by_agent = $style['event_graph_by_agent']; - $event_graph_by_user_validator = $style['event_graph_by_user_validator']; - $event_graph_by_criticity = $style['event_graph_by_criticity']; - $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; - break; case 'event_report_group': $description = $item['description']; $period = $item['period']; $group = $item['id_group']; + $idAgent = $item['id_agent']; //Added for events items - $filter_event_no_validated = $style['filter_event_no_validated']; - $filter_event_validated = $style['filter_event_validated']; - $filter_event_critical = $style['filter_event_critical']; - $filter_event_warning = $style['filter_event_warning']; - $filter_event_type = json_decode($style['filter_event_type'], true); + $show_summary_group = $style['show_summary_group']; + $filter_event_severity = json_decode($style['filter_event_severity'], true); + $filter_event_status = json_decode($style['filter_event_status'], true); + $filter_event_type = json_decode($style['filter_event_type'], true); $event_graph_by_agent = $style['event_graph_by_agent']; $event_graph_by_user_validator = $style['event_graph_by_user_validator']; @@ -1338,22 +1320,28 @@ You can of course remove the warnings, that's why we include the source and do n ?> - - + + + - + + + + + + + + @@ -1362,11 +1350,22 @@ You can of course remove the warnings, that's why we include the source and do n html_print_select ($event_types_select, 'filter_event_type[]', $filter_event_type, '', __('All'), 'all', false, true, false, '', false, false, false, false, false, ''); - ?> + + + + + + + @@ -2479,7 +2478,6 @@ function chooseType() { $("#row_date").hide(); $("#row_agent_multi").hide(); $("#row_module_multi").hide(); - $("#row_event_filter").hide(); $("#row_event_graphs").hide(); $("#row_event_graph_by_agent").hide(); $("#row_event_graph_by_user").hide(); @@ -2494,7 +2492,10 @@ function chooseType() { $("#agents_row").hide(); $("#select_agent_modules").hide(); $("#modules_row").hide(); + $("#row_show_summary_group").hide(); + $("#row_event_severity").hide(); $("#row_event_type").hide(); + $("#row_event_status").hide(); // SLA list default state $("#sla_list").hide(); @@ -2510,24 +2511,6 @@ function chooseType() { $('#agent_autocomplete_events').show(); switch (type) { - case 'event_report_group': - $("#row_description").show(); - $("#row_period").show(); - $("#row_servers").show(); - $("#row_group").show(); - $("#row_show_in_two_columns").show(); - $("#row_event_filter").show(); - $("#row_event_graphs").show(); - - $("#row_event_graph_by_agent").show(); - $("#row_event_graph_by_user").show(); - $("#row_event_graph_by_criticity").show(); - $("#row_event_graph_by_validated").show(); - $("#row_event_type").show(); - - $("#row_filter_search").show(); - break; - case 'simple_graph': $("#row_time_compare_overlapped").show(); $("#row_only_avg").show(); @@ -2782,12 +2765,36 @@ function chooseType() { $("#row_show_in_two_columns").show(); break; + case 'event_report_group': + $("#row_description").show(); + $("#row_period").show(); + $("#row_servers").show(); + $("#row_group").show(); + $("#row_show_in_two_columns").show(); + $("#row_event_severity").show(); + $("#row_event_status").show(); + $("#row_show_summary_group").show(); + + $("#row_event_graphs").show(); + + $("#row_event_graph_by_agent").show(); + $("#row_event_graph_by_user").show(); + $("#row_event_graph_by_criticity").show(); + $("#row_event_graph_by_validated").show(); + $("#row_event_type").show(); + + $("#row_filter_search").show(); + break; + + case 'event_report_agent': $("#row_description").show(); $("#row_agent").show(); $("#row_period").show(); $("#row_show_in_two_columns").show(); - $("#row_event_filter").show(); + $("#row_event_severity").show(); + $("#row_event_status").show(); + $("#row_show_summary_group").show(); $("#row_event_graphs").show(); $("#row_event_graph_by_user").show(); @@ -2797,6 +2804,7 @@ function chooseType() { $('#agent_autocomplete').hide(); $('#agent_autocomplete_events').show(); + $("#row_filter_search").show(); break; case 'event_report_module': diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 32b39fe279..349484b772 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1065,15 +1065,14 @@ switch ($action) { $resultOperationDB = false; break; } - $filter_event_validated = get_parameter('filter_event_validated', 0); - $filter_event_no_validated = get_parameter('filter_event_no_validated', 0); - $filter_event_critical = get_parameter('filter_event_critical', 0); - $filter_event_warning = get_parameter('filter_event_warning', 0); - $filter_event_type = get_parameter('filter_event_type', ''); - - $event_graph_by_agent = get_parameter('event_graph_by_agent', 0); - $event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0); - $event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0); + $show_summary_group = get_parameter('show_summary_group', 0); + $filter_event_severity = get_parameter('filter_event_severity', 0); + $filter_event_type = get_parameter('filter_event_type', ''); + $filter_event_status = get_parameter('filter_event_status', 0); + + $event_graph_by_agent = get_parameter('event_graph_by_agent', 0); + $event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0); + $event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0); $event_graph_validated_vs_unvalidated = get_parameter('event_graph_validated_vs_unvalidated', 0); $event_filter_search = get_parameter('filter_search', ''); @@ -1136,11 +1135,11 @@ switch ($action) { case 'event_report_agent': case 'event_report_group': //Added for events items - $style['filter_event_no_validated'] = $filter_event_no_validated; - $style['filter_event_validated'] = $filter_event_validated; - $style['filter_event_critical'] = $filter_event_critical; - $style['filter_event_warning'] = $filter_event_warning; - $style['filter_event_type'] = json_encode($filter_event_type); + $style['show_summary_group'] = $show_summary_group; + $style['filter_event_severity'] = json_encode($filter_event_severity); + $style['filter_event_type'] = json_encode($filter_event_type); + $style['filter_event_status'] = json_encode($filter_event_status); + $style['event_graph_by_agent'] = $event_graph_by_agent; $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; $style['event_graph_by_criticity'] = $event_graph_by_criticity; @@ -1148,10 +1147,8 @@ switch ($action) { switch ($values['type']) { case 'event_report_group': - $style['event_filter_search'] = - $event_filter_search; - break; case 'event_report_agent': + $style['event_filter_search'] = $event_filter_search; if ($label != '') $style['label'] = $label; else @@ -1449,38 +1446,35 @@ switch ($action) { switch ($values['type']) { case 'event_report_agent': - case 'event_report_group': - $filter_event_no_validated = get_parameter('filter_event_no_validated', 0); - $filter_event_validated = get_parameter('filter_event_validated', 0); - $filter_event_critical = get_parameter('filter_event_critical', 0); - $filter_event_warning = get_parameter('filter_event_warning', 0); + case 'event_report_group': + $show_summary_group = get_parameter('show_summary_group', 0); + $filter_event_severity = get_parameter('filter_event_severity', ''); + $filter_event_type = get_parameter('filter_event_type', ''); + $filter_event_status = get_parameter('filter_event_status', ''); - $event_graph_by_agent = get_parameter('event_graph_by_agent', 0); - $event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0); - $event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0); + $event_graph_by_agent = get_parameter('event_graph_by_agent', 0); + $event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0); + $event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0); $event_graph_validated_vs_unvalidated = get_parameter('event_graph_validated_vs_unvalidated', 0); - $filter_event_type = get_parameter('filter_event_type', ''); $event_filter_search = get_parameter('filter_search', ''); //Added for events items - $style['filter_event_no_validated'] = $filter_event_no_validated; - $style['filter_event_validated'] = $filter_event_validated; - $style['filter_event_critical'] = $filter_event_critical; - $style['filter_event_warning'] = $filter_event_warning; - $style['filter_event_type'] = json_encode($filter_event_type); - - $style['event_graph_by_agent'] = $event_graph_by_agent; - $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; - $style['event_graph_by_criticity'] = $event_graph_by_criticity; + $style['show_summary_group'] = $show_summary_group; + $style['filter_event_severity'] = json_encode($filter_event_severity); + $style['filter_event_type'] = json_encode($filter_event_type); + $style['filter_event_status'] = json_encode($filter_event_status); + + $style['event_graph_by_agent'] = $event_graph_by_agent; + $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; + $style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; + switch ($values['type']) { case 'event_report_group': - $style['event_filter_search'] = - $event_filter_search; - break; case 'event_report_agent': + $style['event_filter_search'] = $event_filter_search; if ($label != '') $style['label'] = $label; else diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 9aec882fd2..a4ce09480b 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -109,6 +109,20 @@ function events_get_event ($id, $fields = false) { return $event; } +function events_get_events_no_grouped($sql_post, $offset = 0, + $pagination = 1, $meta = false, $history = false, $total = false, + $history_db = false, $order = "ASC") { + + global $config; + + $table = events_get_events_table($meta, $history); + + $sql = "SELECT * FROM $table te WHERE 1=1 " . $sql_post; + + $events = db_get_all_rows_sql ($sql, $history_db); + + return $events; +} function events_get_events_grouped($sql_post, $offset = 0, $pagination = 1, $meta = false, $history = false, $total = false, @@ -124,7 +138,7 @@ function events_get_events_grouped($sql_post, $offset = 0, else { $groupby_extra = ''; } - + switch ($config["dbtype"]) { case "mysql": db_process_sql ('SET group_concat_max_len = 9999999'); @@ -136,19 +150,19 @@ function events_get_events_grouped($sql_post, $offset = 0, } else { $sql = "SELECT *, MAX(id_evento) AS id_evento, - GROUP_CONCAT(DISTINCT user_comment SEPARATOR '
') AS user_comment, - GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids, - COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep, - MIN(utimestamp) AS timestamp_rep_min, - (SELECT owner_user FROM $table WHERE id_evento = MAX(te.id_evento)) owner_user, - (SELECT id_usuario FROM $table WHERE id_evento = MAX(te.id_evento)) id_usuario, - (SELECT id_agente FROM $table WHERE id_evento = MAX(te.id_evento)) id_agente, - (SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity, - (SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp - FROM $table te - WHERE 1=1 " . $sql_post . " - GROUP BY estado, evento, id_agentmodule" . $groupby_extra . " - ORDER BY timestamp_rep " . $order . " LIMIT " . $offset . "," . $pagination; + GROUP_CONCAT(DISTINCT user_comment SEPARATOR '
') AS user_comment, + GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids, + COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep, + MIN(utimestamp) AS timestamp_rep_min, + (SELECT owner_user FROM $table WHERE id_evento = MAX(te.id_evento)) owner_user, + (SELECT id_usuario FROM $table WHERE id_evento = MAX(te.id_evento)) id_usuario, + (SELECT id_agente FROM $table WHERE id_evento = MAX(te.id_evento)) id_agente, + (SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity, + (SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp + FROM $table te + WHERE 1=1 " . $sql_post . " + GROUP BY estado, evento, id_agentmodule" . $groupby_extra . " + ORDER BY timestamp_rep " . $order . " LIMIT " . $offset . "," . $pagination; } break; case "postgresql": @@ -210,7 +224,6 @@ function events_get_events_grouped($sql_post, $offset = 0, } break; } - //Extract the events by filter (or not) from db $events = db_get_all_rows_sql ($sql, $history_db); @@ -1173,89 +1186,6 @@ function events_print_type_description ($type, $return = false) { echo $output; } -/** - * Get all the events happened in a group during a period of time. - * - * The returned events will be in the time interval ($date - $period, $date] - * - * @param mixed $id_group Group id to get events for. - * @param int $period Period of time in seconds to get events. - * @param int $date Beginning date to get events. - * - * @return array An array with all the events happened. - */ -function events_get_group_events ($id_group, $period, $date, - $filter_event_validated = false, $filter_event_critical = false, - $filter_event_warning = false, $filter_event_no_validated = false, - $filter_event_search = false, $meta = false, $history = false, - $filter_event_type = false) { - - global $config; - - $id_group = groups_safe_acl ($config["id_user"], $id_group, "ER"); - - if (empty ($id_group)) { - //An empty array means the user doesn't have access - return false; - } - - $datelimit = $date - $period; - - $sql_where = ' AND 1 = 1 '; - $criticities = array(); - if ($filter_event_critical) { - $criticities[] = 4; - } - if ($filter_event_warning) { - $criticities[] = 3; - } - if (!empty($criticities)) { - $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')'; - } - if ($filter_event_validated) { - $sql_where .= ' AND estado = 1 '; - } - if ($filter_event_no_validated) { - $sql_where .= ' AND estado = 0 '; - } - - if (!empty($filter_event_search)) { - $sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_search) . '%"'. - ' OR id_evento LIKE "%' . io_safe_input($filter_event_search) . '%")'; - } - - if (!empty($filter_event_type) && $filter_event_type[0] != 'all') { - $sql_where .= ' AND ('; - $type = array(); - foreach ($filter_event_type as $event_type) { - if ($event_type != "") { - // If normal, warning, could be several (going_up_warning, going_down_warning... too complex - // for the user so for him is presented only "warning, critical and normal" - if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") { - $type[] = " event_type LIKE '%$event_type%' "; - } - else if ($event_type == "not_normal") { - $type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') "; - } - else if ($event_type != "all") { - $type[] = " event_type = '" . $event_type."'"; - } - } - } - - $sql_where .= implode(' OR ', $type) . ')'; - } - - $sql_where .= sprintf(' - AND id_grupo IN (%s) - AND utimestamp > %d - AND utimestamp <= %d ', - implode (",", $id_group), $datelimit, $date); - - return events_get_events_grouped($sql_where, 0, 1000, $meta, - false, false, $history); -} - /** * Get all the events happened in a group during a period of time. * @@ -1328,46 +1258,72 @@ function events_get_group_events_steps ($begin, &$result, $id_group, $period, $d * * @return array An array with all the events happened. */ -function events_get_agent ($id_agent, $period, $date = 0, - $filter_event_validated = false, $filter_event_critical = false, - $filter_event_warning = false, $filter_event_no_validated = false, - $history = false, $filter_event_type = false) { - +function events_get_agent ($id_agent, $period, $date = 0, + $history = false, $show_summary_group = false, $filter_event_severity = false, + $filter_event_type = false, $filter_event_status = false, $filter_event_filter_search=false, + $id_group = false, $events_group = false) { + global $config; + if (!is_numeric ($date)) { $date = strtotime ($date); } if (empty ($date)) { $date = get_system_time (); } + + if($events_group){ + $id_group = groups_safe_acl ($config["id_user"], $id_group, "ER"); - $datelimit = $date - $period; - - $sql_where = ''; - - $criticities = array(); - if ($filter_event_critical) { - $criticities[] = 4; - } - if ($filter_event_warning) { - $criticities[] = 3; - } - if (!empty($criticities)) { - $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')'; - } - - if ( $filter_event_validated && $filter_event_no_validated ) { - $sql_where .= " AND (estado = 1 OR estado = 0)"; - } - else { - if ($filter_event_validated) { - $sql_where .= ' AND estado = 1 '; - } else { - if ($filter_event_no_validated) { - $sql_where .= ' AND estado = 0 '; - } + if (empty ($id_group)) { + //An empty array means the user doesn't have access + return false; } } + $datelimit = $date - $period; + + $sql_where = ''; + $severity_all = 0; + if (!empty($filter_event_severity)) { + foreach ($filter_event_severity as $key => $value) { + switch ($value) { + case 'all': + $severity_all = 1; + break; + case 34: + $filter_event_severity[$key] = '3, 4'; + break; + case 20: + $filter_event_severity[$key] = '0, 1, 3, 4, 5, 6'; + break; + case 21: + $filter_event_severity[$key] = '4, 2'; + break; + default: + break; + } + } + if(!$severity_all){ + $sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')'; + } + } + + $status_all = 0; + if(!empty($filter_event_status)){ + foreach ($filter_event_status as $key => $value) { + switch ($value) { + case -1: + $status_all = 1; + break; + default: + break; + } + } + if(!$status_all){ + $sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')'; + } + } + if (!empty($filter_event_type) && $filter_event_type[0] != 'all') { $sql_where .= ' AND ('; $type = array(); @@ -1386,15 +1342,31 @@ function events_get_agent ($id_agent, $period, $date = 0, } } } - $sql_where .= implode(' OR ', $type) . ')'; } + + if (!empty($filter_event_filter_search)) { + $sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'. + ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")'; + } - $sql_where .= sprintf(' AND id_agente = %d AND utimestamp > %d + if(!$events_group){ + $sql_where .= sprintf(' AND id_agente = %d AND utimestamp > %d AND utimestamp <= %d ', $id_agent, $datelimit, $date); + } + else{ + $sql_where .= sprintf(' AND id_grupo IN (%s) AND utimestamp > %d + AND utimestamp <= %d ', implode (",", $id_group), $datelimit, $date); + } - return events_get_events_grouped($sql_where, 0, 1000, + if($show_summary_group){ + return events_get_events_grouped($sql_where, 0, 1000, is_metaconsole(), false, false, $history); + } + else{ + return events_get_events_no_grouped($sql_where, 0, 1000, + is_metaconsole(), false, false, $history); + } } /** @@ -1408,7 +1380,7 @@ function events_get_agent ($id_agent, $period, $date = 0, * * @return array An array with all the events happened. */ -function events_get_module ($id_agent_module, $period, $date = 0, $history = false) { +function events_get_module ($id_agent_module, $period, $date = 0, $history = false, $show_summary_group = false) { global $config; if (!is_numeric ($date)) { @@ -1549,13 +1521,22 @@ function events_get_severity_types ($severity_id) { * * @return array Status description array. */ -function events_get_all_status () { +function events_get_all_status ($report = false) { $fields = array (); - $fields[-1] = __('All event'); - $fields[0] = __('Only new'); - $fields[1] = __('Only validated'); - $fields[2] = __('Only in process'); - $fields[3] = __('Only not validated'); + if(!$report){ + $fields[-1] = __('All event'); + $fields[0] = __('Only new'); + $fields[1] = __('Only validated'); + $fields[2] = __('Only in process'); + $fields[3] = __('Only not validated'); + } + else{ + $fields[-1] = __('All event'); + $fields[0] = __('New'); + $fields[1] = __('Validated'); + $fields[2] = __('In process'); + $fields[3] = __('Not Validated'); + } return $fields; } @@ -2643,12 +2624,20 @@ function events_clean_tags ($tags) { * @return array An array with all the events happened. */ function events_get_count_events_by_agent ($id_group, $period, $date, - $filter_event_validated = false, $filter_event_critical = false, - $filter_event_warning = false, $filter_event_no_validated = false, - $filter_event_search = false) { + $filter_event_severity = false, $filter_event_type = false, + $filter_event_status = false, $filter_event_filter_search = false) { global $config; - + + //date + if (!is_numeric ($date)) { + $date = strtotime ($date); + } + if (empty ($date)) { + $date = get_system_time (); + } + + //group $id_group = groups_safe_acl ($config["id_user"], $id_group, "AR"); if (empty ($id_group)) { @@ -2658,30 +2647,74 @@ function events_get_count_events_by_agent ($id_group, $period, $date, $datelimit = $date - $period; - $sql_where = ' AND 1 = 1 '; - $criticities = array(); - if ($filter_event_critical) { - $criticities[] = 4; + $sql_where = ''; + $severity_all = 0; + if (!empty($filter_event_severity)) { + foreach ($filter_event_severity as $key => $value) { + switch ($value) { + case 'all': + $severity_all = 1; + break; + case 34: + $filter_event_severity[$key] = '3, 4'; + break; + case 20: + $filter_event_severity[$key] = '0, 1, 3, 4, 5, 6'; + break; + case 21: + $filter_event_severity[$key] = '4, 2'; + break; + default: + break; + } + } + if(!$severity_all){ + $sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')'; + } } - if ($filter_event_warning) { - $criticities[] = 3; - } - if (!empty($criticities)) { - $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')'; + + $status_all = 0; + if(!empty($filter_event_status)){ + foreach ($filter_event_status as $key => $value) { + switch ($value) { + case -1: + $status_all = 1; + break; + default: + break; + } + } + if(!$status_all){ + $sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')'; + } } - if ($filter_event_validated) { - $sql_where .= ' AND estado = 1 '; + if (!empty($filter_event_type) && $filter_event_type[0] != 'all') { + $sql_where .= ' AND ('; + $type = array(); + foreach ($filter_event_type as $event_type) { + if ($event_type != "") { + // If normal, warning, could be several (going_up_warning, going_down_warning... too complex + // for the user so for him is presented only "warning, critical and normal" + if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") { + $type[] = " event_type LIKE '%$event_type%' "; + } + else if ($event_type == "not_normal") { + $type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') "; + } + else if ($event_type != "all") { + $type[] = " event_type = '" . $event_type."'"; + } + } + } + $sql_where .= implode(' OR ', $type) . ')'; } - if ($filter_event_no_validated) { - $sql_where .= ' AND estado = 0 '; + + if (!empty($filter_event_filter_search)) { + $sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'. + ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")'; } - - if (!empty($filter_event_search)) { - $sql_where .= ' AND (evento LIKE "%%'. io_safe_input($filter_event_search) . '%%"'. - ' OR id_evento LIKE "%%' . io_safe_input($filter_event_search) . '%%")'; - } - + $sql = sprintf ('SELECT id_agente, (SELECT t2.nombre FROM tagente t2 @@ -2689,9 +2722,9 @@ function events_get_count_events_by_agent ($id_group, $period, $date, COUNT(*) AS count FROM tevento t3 WHERE utimestamp > %d AND utimestamp <= %d - AND id_grupo IN (%s) ' . $sql_where . ' + AND id_grupo IN (%s) %s GROUP BY id_agente', - $datelimit, $date, implode (",", $id_group)); + $datelimit, $date, implode (",", $id_group), $sql_where); $rows = db_get_all_rows_sql ($sql); @@ -2722,12 +2755,11 @@ function events_get_count_events_by_agent ($id_group, $period, $date, * @return array An array with all the events happened. */ function events_get_count_events_validated_by_user ($filter, $period, $date, - $filter_event_validated = false, $filter_event_critical = false, - $filter_event_warning = false, $filter_event_no_validated = false, - $filter_event_search = false) { + $filter_event_severity = false, $filter_event_type = false, + $filter_event_status = false, $filter_event_filter_search = false) { global $config; - + //group $sql_filter = ' AND 1=1 '; if (isset($filter['id_group'])) { $id_group = groups_safe_acl ($config["id_user"], $filter['id_group'], "AR"); @@ -2745,30 +2777,82 @@ function events_get_count_events_validated_by_user ($filter, $period, $date, sprintf(' AND id_agente = %d ', $filter['id_agent']); } + //date + if (!is_numeric ($date)) { + $date = strtotime ($date); + } + if (empty ($date)) { + $date = get_system_time (); + } + $datelimit = $date - $period; - $sql_where = ' AND 1 = 1 '; - $criticities = array(); - if ($filter_event_critical) { - $criticities[] = 4; + $sql_where = ''; + $severity_all = 0; + if (!empty($filter_event_severity)) { + foreach ($filter_event_severity as $key => $value) { + switch ($value) { + case 'all': + $severity_all = 1; + break; + case 34: + $filter_event_severity[$key] = '3, 4'; + break; + case 20: + $filter_event_severity[$key] = '0, 1, 3, 4, 5, 6'; + break; + case 21: + $filter_event_severity[$key] = '4, 2'; + break; + default: + break; + } + } + if(!$severity_all){ + $sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')'; + } } - if ($filter_event_warning) { - $criticities[] = 3; - } - if (!empty($criticities)) { - $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')'; + + $status_all = 0; + if(!empty($filter_event_status)){ + foreach ($filter_event_status as $key => $value) { + switch ($value) { + case -1: + $status_all = 1; + break; + default: + break; + } + } + if(!$status_all){ + $sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')'; + } } - if ($filter_event_validated) { - $sql_where .= ' AND estado = 1 '; + if (!empty($filter_event_type) && $filter_event_type[0] != 'all') { + $sql_where .= ' AND ('; + $type = array(); + foreach ($filter_event_type as $event_type) { + if ($event_type != "") { + // If normal, warning, could be several (going_up_warning, going_down_warning... too complex + // for the user so for him is presented only "warning, critical and normal" + if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") { + $type[] = " event_type LIKE '%$event_type%' "; + } + else if ($event_type == "not_normal") { + $type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') "; + } + else if ($event_type != "all") { + $type[] = " event_type = '" . $event_type."'"; + } + } + } + $sql_where .= implode(' OR ', $type) . ')'; } - if ($filter_event_no_validated) { - $sql_where .= ' AND estado = 0 '; - } - - if (!empty($filter_event_search)) { - $sql_where .= ' AND (evento LIKE "%%'. io_safe_input($filter_event_search) . '%%"'. - ' OR id_evento LIKE "%%' . io_safe_input($filter_event_search) . '%%")'; + + if (!empty($filter_event_filter_search)) { + $sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'. + ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")'; } $sql = sprintf ('SELECT id_usuario, @@ -2778,10 +2862,10 @@ function events_get_count_events_validated_by_user ($filter, $period, $date, COUNT(*) AS count FROM tevento t3 WHERE utimestamp > %d AND utimestamp <= %d - %s ' . $sql_where . ' + %s %s GROUP BY id_usuario', - $datelimit, $date, $sql_filter); - + $datelimit, $date, $sql_filter, $sql_where); + $rows = db_get_all_rows_sql ($sql); if ($rows == false) @@ -2811,9 +2895,8 @@ function events_get_count_events_validated_by_user ($filter, $period, $date, * @return array An array with all the events happened. */ function events_get_count_events_by_criticity ($filter, $period, $date, - $filter_event_validated = false, $filter_event_critical = false, - $filter_event_warning = false, $filter_event_no_validated = false, - $filter_event_search = false) { + $filter_event_severity = false, $filter_event_type = false, + $filter_event_status = false, $filter_event_filter_search = false) { global $config; @@ -2833,40 +2916,91 @@ function events_get_count_events_by_criticity ($filter, $period, $date, $sql_filter .= sprintf(' AND id_agente = %d ', $filter['id_agent']); } + + if (!is_numeric ($date)) { + $date = strtotime ($date); + } + if (empty ($date)) { + $date = get_system_time (); + } $datelimit = $date - $period; - $sql_where = ' AND 1 = 1 '; - $criticities = array(); - if ($filter_event_critical) { - $criticities[] = 4; + $sql_where = ''; + $severity_all = 0; + if (!empty($filter_event_severity)) { + foreach ($filter_event_severity as $key => $value) { + switch ($value) { + case 'all': + $severity_all = 1; + break; + case 34: + $filter_event_severity[$key] = '3, 4'; + break; + case 20: + $filter_event_severity[$key] = '0, 1, 3, 4, 5, 6'; + break; + case 21: + $filter_event_severity[$key] = '4, 2'; + break; + default: + break; + } + } + if(!$severity_all){ + $sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')'; + } } - if ($filter_event_warning) { - $criticities[] = 3; - } - if (!empty($criticities)) { - $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')'; + + $status_all = 0; + if(!empty($filter_event_status)){ + foreach ($filter_event_status as $key => $value) { + switch ($value) { + case -1: + $status_all = 1; + break; + default: + break; + } + } + if(!$status_all){ + $sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')'; + } } - if ($filter_event_validated) { - $sql_where .= ' AND estado = 1 '; + if (!empty($filter_event_type) && $filter_event_type[0] != 'all') { + $sql_where .= ' AND ('; + $type = array(); + foreach ($filter_event_type as $event_type) { + if ($event_type != "") { + // If normal, warning, could be several (going_up_warning, going_down_warning... too complex + // for the user so for him is presented only "warning, critical and normal" + if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") { + $type[] = " event_type LIKE '%$event_type%' "; + } + else if ($event_type == "not_normal") { + $type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') "; + } + else if ($event_type != "all") { + $type[] = " event_type = '" . $event_type."'"; + } + } + } + $sql_where .= implode(' OR ', $type) . ')'; } - if ($filter_event_no_validated) { - $sql_where .= ' AND estado = 0 '; + + if (!empty($filter_event_filter_search)) { + $sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'. + ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")'; } - - if (!empty($filter_event_search)) { - $sql_where .= ' AND (evento LIKE "%%'. io_safe_input($filter_event_search) . '%%"'. - ' OR id_evento LIKE "%%' . io_safe_input($filter_event_search) . '%%")'; - } - + $sql = sprintf ('SELECT criticity, COUNT(*) AS count FROM tevento WHERE utimestamp > %d AND utimestamp <= %d - %s ' . $sql_where . ' + %s %s GROUP BY criticity', - $datelimit, $date, $sql_filter); + $datelimit, $date, $sql_filter, $sql_where); $rows = db_get_all_rows_sql ($sql); @@ -2893,12 +3027,12 @@ function events_get_count_events_by_criticity ($filter, $period, $date, * @return array An array with all the events happened. */ function events_get_count_events_validated ($filter, $period = null, $date = null, - $filter_event_validated = false, $filter_event_critical = false, - $filter_event_warning = false, $filter_event_no_validated = false, - $filter_event_search = false) { + $filter_event_severity = false, $filter_event_type = false, + $filter_event_status = false, $filter_event_filter_search = false) { global $config; + //group $sql_filter = " 1=1 "; if (isset($filter['id_group'])) { $id_group = groups_safe_acl ($config["id_user"], $filter['id_group'], "AR"); @@ -2916,6 +3050,14 @@ function events_get_count_events_validated ($filter, $period = null, $date = nul sprintf(" AND id_agente = %d ", $filter['id_agent']); } + //date + if (!is_numeric ($date)) { + $date = strtotime ($date); + } + if (empty ($date)) { + $date = get_system_time (); + } + $date_filter = ''; if (!empty($date) && !empty($period)) { $datelimit = $date - $period; @@ -2934,31 +3076,75 @@ function events_get_count_events_validated ($filter, $period = null, $date = nul $date_filter .= sprintf (" AND utimestamp <= %d ", $date); } - $sql_where = " AND 1=1 "; - $criticities = array(); - if ($filter_event_critical) { - $criticities[] = 4; - } - if ($filter_event_warning) { - $criticities[] = 3; - } - if (!empty($criticities)) { - $sql_where .= " AND criticity IN (" . implode(",", $criticities) . ")"; - } - - if ($filter_event_validated) { - $sql_where .= " AND estado = 1 "; - } - if ($filter_event_no_validated) { - $sql_where .= " AND estado = 0 "; - } - - if (!empty($filter_event_search)) { - $sql_where .= " AND (evento LIKE '%%" . io_safe_input($filter_event_search) . "%%'" . - " OR id_evento LIKE '%%" . io_safe_input($filter_event_search) . "%%')"; + $sql_where = ''; + $severity_all = 0; + if (!empty($filter_event_severity)) { + foreach ($filter_event_severity as $key => $value) { + switch ($value) { + case 'all': + $severity_all = 1; + break; + case 34: + $filter_event_severity[$key] = '3, 4'; + break; + case 20: + $filter_event_severity[$key] = '0, 1, 3, 4, 5, 6'; + break; + case 21: + $filter_event_severity[$key] = '4, 2'; + break; + default: + break; + } + } + if(!$severity_all){ + $sql_where .= ' AND criticity IN (' . implode(', ', $filter_event_severity) . ')'; + } } - $sql = sprintf ("SELECT estado, COUNT(*) AS count FROM tevento WHERE %s " . $sql_where . " GROUP BY estado", $sql_filter); + $status_all = 0; + if(!empty($filter_event_status)){ + foreach ($filter_event_status as $key => $value) { + switch ($value) { + case -1: + $status_all = 1; + break; + default: + break; + } + } + if(!$status_all){ + $sql_where .= ' AND estado IN (' . implode(', ', $filter_event_status) . ')'; + } + } + + if (!empty($filter_event_type) && $filter_event_type[0] != 'all') { + $sql_where .= ' AND ('; + $type = array(); + foreach ($filter_event_type as $event_type) { + if ($event_type != "") { + // If normal, warning, could be several (going_up_warning, going_down_warning... too complex + // for the user so for him is presented only "warning, critical and normal" + if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") { + $type[] = " event_type LIKE '%$event_type%' "; + } + else if ($event_type == "not_normal") { + $type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') "; + } + else if ($event_type != "all") { + $type[] = " event_type = '" . $event_type."'"; + } + } + } + $sql_where .= implode(' OR ', $type) . ')'; + } + + if (!empty($filter_event_filter_search)) { + $sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'. + ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")'; + } + + $sql = sprintf ("SELECT estado, COUNT(*) AS count FROM tevento WHERE %s %s GROUP BY estado", $sql_filter, $sql_where); $rows = db_get_all_rows_sql ($sql); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 6014f63cb6..3d2410219d 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2926,7 +2926,7 @@ function graph_events_validated($width = 300, $height = 200, $url = "", $meta = global $config; global $graphic_type; - $data_graph = reporting_get_count_events_validated( + $data_graph = events_get_count_events_validated( array('id_group' => array_keys(users_get_groups()))); $colors = array(); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 2e78622ead..2a55275a3e 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -405,15 +405,6 @@ function reporting_make_reporting_data($report = null, $id_report, $report, $content); break; - case 'agent_detailed_event': - case 'event_report_agent': - $report['contents'][] = reporting_event_report_agent( - $report, - $content, - $type, - $force_width_chart, - $force_height_chart); - break; case 'group_report': $report['contents'][] = reporting_group_report( $report, @@ -444,6 +435,15 @@ function reporting_make_reporting_data($report = null, $id_report, $content, $type); break; + case 'agent_detailed_event': + case 'event_report_agent': + $report['contents'][] = reporting_event_report_agent( + $report, + $content, + $type, + $force_width_chart, + $force_height_chart); + break; case 'event_report_module': $report['contents'][] = reporting_event_report_module( $report, @@ -1287,26 +1287,25 @@ function reporting_event_report_group($report, $content, $return["date"] = reporting_get_date_text($report, $content); $event_filter = $content['style']; - - $filter_event_no_validated = $event_filter['filter_event_no_validated']; - $filter_event_validated = $event_filter['filter_event_validated']; - $filter_event_critical = $event_filter['filter_event_critical']; - $filter_event_warning = $event_filter['filter_event_warning']; + $return['show_summary_group'] = $event_filter['show_summary_group']; + //filter + $show_summary_group = $event_filter['show_summary_group']; + $filter_event_severity = json_decode($event_filter['filter_event_severity'],true); + $filter_event_type = json_decode($event_filter['filter_event_type'],true); + $filter_event_status = json_decode($event_filter['filter_event_status'],true); $filter_event_filter_search = $event_filter['event_filter_search']; - $filter_event_type = json_decode($event_filter['filter_event_type'],true); - $event_graph_by_agent = $event_filter['event_graph_by_agent']; - $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator']; - $event_graph_by_criticity = $event_filter['event_graph_by_criticity']; + //graphs + $event_graph_by_agent = $event_filter['event_graph_by_agent']; + $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator']; + $event_graph_by_criticity = $event_filter['event_graph_by_criticity']; $event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated']; - - $data = reporting_get_group_detailed_event( - $content['id_group'], $content['period'], $report["datetime"], - true, true, $filter_event_validated, $filter_event_critical, - $filter_event_warning, $filter_event_no_validated, - $filter_event_filter_search, 'hash', $history, $filter_event_type); - + $data = events_get_agent (false, $content['period'], $report["datetime"], + $history, $show_summary_group, $filter_event_severity, + $filter_event_type, $filter_event_status, $filter_event_filter_search, + $content['id_group'], true); + if (empty($data)) { $return['failed'] = __('No events'); } @@ -1314,8 +1313,6 @@ function reporting_event_report_group($report, $content, $return['data'] = array_reverse($data); } - - reporting_set_conf_charts($width, $height, $only_image, $type, $content, $ttl); @@ -1327,22 +1324,16 @@ function reporting_event_report_group($report, $content, $height = $force_height_chart; } - - $return['chart']['by_agent'] = null; $return['chart']['by_user_validator'] = null; $return['chart']['by_criticity'] = null; $return['chart']['validated_vs_unvalidated'] = null; if ($event_graph_by_agent) { - $data_graph = reporting_get_count_events_by_agent( - $content['id_group'], $content['period'], - $report["datetime"], - $filter_event_validated, - $filter_event_critical, - $filter_event_warning, - $filter_event_no_validated, - $filter_event_filter_search); + $data_graph = events_get_count_events_by_agent( + $content['id_group'], $content['period'], $report["datetime"], + $filter_event_severity, $filter_event_type, + $filter_event_status, $filter_event_filter_search); $return['chart']['by_agent']= pie3d_graph( false, @@ -1358,15 +1349,10 @@ function reporting_event_report_group($report, $content, } if ($event_graph_by_user_validator) { - $data_graph = - reporting_get_count_events_validated_by_user( - array('id_group' => $content['id_group']), $content['period'], - $report["datetime"], - $filter_event_validated, - $filter_event_critical, - $filter_event_warning, - $filter_event_no_validated, - $filter_event_filter_search); + $data_graph = events_get_count_events_validated_by_user( + array('id_group' => $content['id_group']), $content['period'], + $report["datetime"],$filter_event_severity, $filter_event_type, + $filter_event_status, $filter_event_filter_search); $return['chart']['by_user_validator'] = pie3d_graph( false, @@ -1382,14 +1368,10 @@ function reporting_event_report_group($report, $content, } if ($event_graph_by_criticity) { - $data_graph = reporting_get_count_events_by_criticity( + $data_graph = events_get_count_events_by_criticity( array('id_group' => $content['id_group']), $content['period'], - $report["datetime"], - $filter_event_validated, - $filter_event_critical, - $filter_event_warning, - $filter_event_no_validated, - $filter_event_filter_search); + $report["datetime"],$filter_event_severity, $filter_event_type, + $filter_event_status, $filter_event_filter_search); $colors = get_criticity_pie_colors($data_graph); @@ -1409,15 +1391,10 @@ function reporting_event_report_group($report, $content, } if ($event_graph_validated_vs_unvalidated) { - $data_graph = - reporting_get_count_events_validated( - array('id_group' => $content['id_group']), $content['period'], - $report["datetime"], - $filter_event_validated, - $filter_event_critical, - $filter_event_warning, - $filter_event_no_validated, - $filter_event_filter_search); + $data_graph = events_get_count_events_validated( + array('id_group' => $content['id_group']), $content['period'], + $report["datetime"],$filter_event_severity, $filter_event_type, + $filter_event_status, $filter_event_filter_search); $return['chart']['validated_vs_unvalidated'] = pie3d_graph( false, @@ -1442,8 +1419,9 @@ function reporting_event_report_group($report, $content, } function reporting_event_report_module($report, $content) { - global $config; + global $config; + $return['type'] = 'event_report_module'; if (empty($content['name'])) { @@ -2176,38 +2154,39 @@ function reporting_event_report_agent($report, $content, if ($config['history_event_enabled']) $history = true; - $return['title'] = $content['name']; - $return['subtitle'] = agents_get_name($content['id_agent']); - $return["description"] = $content["description"]; - $return["date"] = reporting_get_date_text($report, $content); - $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; + $return['title'] = $content['name']; + $return['subtitle'] = agents_get_name($content['id_agent']); + $return["description"] = $content["description"]; + $return["date"] = reporting_get_date_text($report, $content); + $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; + $return['show_summary_group'] = $content['style']['show_summary_group']; $style = $content['style']; - - $filter_event_no_validated = $style['filter_event_no_validated']; - $filter_event_validated = $style['filter_event_validated']; - $filter_event_critical = $style['filter_event_critical']; - $filter_event_warning = $style['filter_event_warning']; - $filter_event_type = json_decode($style['filter_event_type'], true); - - $event_graph_by_user_validator = $style['event_graph_by_user_validator']; - $event_graph_by_criticity = $style['event_graph_by_criticity']; + + //filter + $show_summary_group = $style['show_summary_group']; + $filter_event_severity = json_decode($style['filter_event_severity'], true); + $filter_event_type = json_decode($style['filter_event_type'], true); + $filter_event_status = json_decode($style['filter_event_status'], true); + $filter_event_filter_search = $style['event_filter_search']; + + //graph + $event_graph_by_user_validator = $style['event_graph_by_user_validator']; + $event_graph_by_criticity = $style['event_graph_by_criticity']; $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; - + $return['data'] = reporting_get_agents_detailed_event( $content['id_agent'], $content['period'], $report["datetime"], true, - $filter_event_validated, - $filter_event_critical, - $filter_event_warning, - $filter_event_no_validated, true, $history, - $filter_event_type); - - + $show_summary_group, + $filter_event_severity, + $filter_event_type, + $filter_event_status, + $filter_event_filter_search); reporting_set_conf_charts($width, $height, $only_image, $type, $content, $ttl); @@ -2220,26 +2199,19 @@ function reporting_event_report_agent($report, $content, $height = $force_height_chart; } - - $return["chart"]["by_user_validator"] = null; $return["chart"]["by_criticity"] = null; $return["chart"]["validated_vs_unvalidated"] = null; if ($event_graph_by_user_validator) { - $data_chart = - reporting_get_count_events_validated_by_user( - array('id_agent' => $content['id_agent']), - $content['period'], - $report["datetime"], - $filter_event_validated, - $filter_event_critical, - $filter_event_warning, - $filter_event_no_validated); + $data_graph = events_get_count_events_validated_by_user( + array('id_agent' => $content['id_agent']), $content['period'], + $report["datetime"],$filter_event_severity, $filter_event_type, + $filter_event_status, $filter_event_filter_search); $return["chart"]["by_user_validator"] = pie3d_graph( false, - $data_chart, + $data_graph, 500, 150, __("other"), @@ -2251,13 +2223,10 @@ function reporting_event_report_agent($report, $content, } if ($event_graph_by_criticity) { - $data_graph = reporting_get_count_events_by_criticity( + $data_graph = events_get_count_events_by_criticity( array('id_agent' => $content['id_agent']), $content['period'], - $report["datetime"], - $filter_event_validated, - $filter_event_critical, - $filter_event_warning, - $filter_event_no_validated); + $report["datetime"],$filter_event_severity, $filter_event_type, + $filter_event_status, $filter_event_filter_search); $colors = get_criticity_pie_colors($data_graph); @@ -2277,13 +2246,10 @@ function reporting_event_report_agent($report, $content, } if ($event_graph_validated_vs_unvalidated) { - $data_graph = reporting_get_count_events_validated( + $data_graph = events_get_count_events_validated( array('id_agent' => $content['id_agent']), $content['period'], - $report["datetime"], - $filter_event_validated, - $filter_event_critical, - $filter_event_warning, - $filter_event_no_validated); + $report["datetime"],$filter_event_severity, $filter_event_type, + $filter_event_status, $filter_event_filter_search); $return["chart"]["validated_vs_unvalidated"] = pie3d_graph( false, @@ -6036,221 +6002,6 @@ function reporting_set_conf_charts(&$width, &$height, &$only_image, $type, //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -/** - * Gets a detailed reporting of groups's events. - * - * @param unknown_type $id_group Id of the group. - * @param unknown_type $period Time period of the report. - * @param unknown_type $date Date of the report. - * @param unknown_type $return Whether to return or not. - * @param unknown_type $html Whether to return HTML code or not. - * - * @return string Report of groups's events - */ -function reporting_get_count_events_validated ($filter, $period = 0, - $date = 0, - $filter_event_validated = false, $filter_event_critical = false, - $filter_event_warning = false, $filter_event_no_validated = false, - $filter_event_search = false) { - - if (!is_numeric ($date)) { - $date = strtotime ($date); - } - if (empty ($date)) { - $date = get_system_time (); - } - - return events_get_count_events_validated($filter, $period, $date, - $filter_event_validated, $filter_event_critical, - $filter_event_warning, $filter_event_no_validated, - $filter_event_search); -} - -/** - * Gets a detailed reporting of groups's events. - * - * @param unknown_type $id_group Id of the group. - * @param unknown_type $period Time period of the report. - * @param unknown_type $date Date of the report. - * @param unknown_type $return Whether to return or not. - * @param unknown_type $html Whether to return HTML code or not. - * - * @return string Report of groups's events - */ -function reporting_get_count_events_by_criticity ($filter, $period = 0, - $date = 0, - $filter_event_validated = false, $filter_event_critical = false, - $filter_event_warning = false, $filter_event_no_validated = false, - $filter_event_search = false) { - - if (!is_numeric ($date)) { - $date = strtotime ($date); - } - if (empty ($date)) { - $date = get_system_time (); - } - - return events_get_count_events_by_criticity($filter, $period, $date, - $filter_event_validated, $filter_event_critical, - $filter_event_warning, $filter_event_no_validated, - $filter_event_search); -} - -/** - * Gets a detailed reporting of groups's events. - * - * @param unknown_type $filter. - * @param unknown_type $period Time period of the report. - * @param unknown_type $date Date of the report. - * @param unknown_type $return Whether to return or not. - * @param unknown_type $html Whether to return HTML code or not. - * - * @return string Report of groups's events - */ -function reporting_get_count_events_validated_by_user ($filter, $period = 0, - $date = 0, - $filter_event_validated = false, $filter_event_critical = false, - $filter_event_warning = false, $filter_event_no_validated = false, - $filter_event_search = false) { - - if (!is_numeric ($date)) { - $date = strtotime ($date); - } - if (empty ($date)) { - $date = get_system_time (); - } - - return events_get_count_events_validated_by_user($filter, $period, $date, - $filter_event_validated, $filter_event_critical, - $filter_event_warning, $filter_event_no_validated, $filter_event_search); -} - -/** - * Gets a detailed reporting of groups's events. - * - * @param unknown_type $id_group Id of the group. - * @param unknown_type $period Time period of the report. - * @param unknown_type $date Date of the report. - * @param unknown_type $return Whether to return or not. - * @param unknown_type $html Whether to return HTML code or not. - * - * @return string Report of groups's events - */ -function reporting_get_group_detailed_event ($id_group, $period = 0, - $date = 0, $return = false, $html = true, - $filter_event_validated = false, $filter_event_critical = false, - $filter_event_warning = false, $filter_event_no_validated = false, - $filter_event_filter_search = null, $return_type = false, - $history = false, $filter_event_type = false) { - - global $config; - - if (!is_numeric ($date)) { - $date = strtotime ($date); - } - if (empty ($date)) { - $date = get_system_time (); - } - - $table = new stdClass(); - $table->width = '99%'; - - $table->align = array(); - $table->align[0] = 'center'; - $table->align[2] = 'center'; - - $table->data = array (); - - $table->head = array (); - $table->head[0] = __('Status'); - $table->head[1] = __('Name'); - $table->head[2] = __('Type'); - $table->head[3] = __('Agent'); - $table->head[4] = __('Severity'); - $table->head[5] = __('Val. by'); - $table->head[6] = __('Timestamp'); - - $events = events_get_group_events($id_group, $period, $date, - $filter_event_validated, $filter_event_critical, - $filter_event_warning, $filter_event_no_validated, - $filter_event_filter_search, false, $history, $filter_event_type); - - if ($return_type === 'hash') { - return $events; - } - - if ($events) { - $note = ''; - if (count($events) >= 1000) { - $note .= '* ' . __('Maximum of events shown') . ' (1000)
'; - } - foreach ($events as $k => $event) { - //First pass along the class of this row - $table->cellclass[$k][1] = $table->cellclass[$k][3] = - $table->cellclass[$k][4] = $table->cellclass[$k][5] = - $table->cellclass[$k][6] = - get_priority_class ($event["criticity"]); - - $data = array (); - - // Colored box - switch ($event['estado']) { - case 0: - $img_st = "images/star.png"; - $title_st = __('New event'); - break; - case 1: - $img_st = "images/tick.png"; - $title_st = __('Event validated'); - break; - case 2: - $img_st = "images/hourglass.png"; - $title_st = __('Event in process'); - break; - } - $data[] = html_print_image ($img_st, true, - array ("class" => "image_status", - "width" => 16, - "title" => $title_st, - "id" => 'status_img_' . $event["id_evento"])); - - $data[] = ui_print_truncate_text( - io_safe_output($event['evento']), - 140, false, true); - - //$data[1] = $event['event_type']; - $data[] = events_print_type_img ($event["event_type"], true); - - if (!empty($event['id_agente'])) - $data[] = agents_get_name($event['id_agente']); - else - $data[] = __('Pandora System'); - $data[] = get_priority_name ($event['criticity']); - if (empty($event['id_usuario']) && $event['estado'] == EVENT_VALIDATE) { - $data[] = '' . __('System') . ''; - } - else { - $user_name = db_get_value ('fullname', 'tusuario', 'id_user', $event['id_usuario']); - $data[] = io_safe_output($user_name); - } - $data[] = '' . - date($config['date_format'], $event['timestamp_rep']) . - ''; - array_push ($table->data, $data); - } - - if ($html) { - return html_print_table ($table, $return) . $note; - } - else { - return $table; - } - } - else { - return false; - } -} - /** * Get a detailed report of summarized events per agent * @@ -6286,7 +6037,7 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, $events = array (); foreach ($id_modules as $id_module) { - $event = events_get_module ($id_module, (int) $period, (int) $date, $history); + $event = events_get_module ($id_module, (int) $period, (int) $date, $history, $show_summary_group); if (!empty ($event)) { array_push ($events, $event); } @@ -6367,10 +6118,10 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, * @return A table object (XHTML) */ function reporting_get_agents_detailed_event ($id_agents, $period = 0, - $date = 0, $return = false, $filter_event_validated = false, - $filter_event_critical = false, $filter_event_warning = false, - $filter_event_no_validated = false, $only_data = false, - $history = false, $filter_event_type = false) { + $date = 0, $return = false, $only_data = false, $history = false, + $show_summary_group = false, $filter_event_severity = false, + $filter_event_type = false, $filter_event_status = false, + $filter_event_filter_search = false) { global $config; @@ -6392,12 +6143,10 @@ function reporting_get_agents_detailed_event ($id_agents, $period = 0, $events = array (); foreach ($id_agents as $id_agent) { - $event = events_get_agent ($id_agent, - (int)$period, - (int)$date, - $filter_event_validated, $filter_event_critical, - $filter_event_warning, $filter_event_no_validated, - $history, $filter_event_type); + $event = events_get_agent ($id_agent, (int)$period, (int)$date, + $history, $show_summary_group, $filter_event_severity, + $filter_event_type, $filter_event_status, + $filter_event_filter_search, false, false); if (empty($event)) { $event = array(); @@ -6406,17 +6155,28 @@ function reporting_get_agents_detailed_event ($id_agents, $period = 0, if ($only_data) { $nevents = count($event); for($i=$nevents-1; $i >= 0; $i--) { - $e = $event[$i]; - //foreach ($event as $e) { - $return_data[] = array( - 'status' => $e['estado'], - 'count' => $e['event_rep'], - 'name' => $e['evento'], - 'type' => $e["event_type"], - 'criticity' => $e["criticity"], - 'validated_by' => $e['id_usuario'], - 'timestamp' => $e['timestamp_rep'] - ); + $e = $event[$i]; + if($show_summary_group){ + $return_data[] = array( + 'status' => $e['estado'], + 'count' => $e['event_rep'], + 'name' => $e['evento'], + 'type' => $e["event_type"], + 'criticity' => $e["criticity"], + 'validated_by' => $e['id_usuario'], + 'timestamp' => $e['timestamp_rep'] + ); + } + else{ + $return_data[] = array( + 'status' => $e['estado'], + 'name' => $e['evento'], + 'type' => $e["event_type"], + 'criticity' => $e["criticity"], + 'validated_by' => $e['id_usuario'], + 'timestamp' => $e['timestamp'] + ); + } } } else { @@ -8610,36 +8370,6 @@ function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_dat return $downtime_dates; } -/** - * Gets a detailed reporting of groups's events. - * - * @param unknown_type $id_group Id of the group. - * @param unknown_type $period Time period of the report. - * @param unknown_type $date Date of the report. - * @param unknown_type $return Whether to return or not. - * @param unknown_type $html Whether to return HTML code or not. - * - * @return string Report of groups's events - */ -function reporting_get_count_events_by_agent ($id_group, $period = 0, - $date = 0, - $filter_event_validated = false, $filter_event_critical = false, - $filter_event_warning = false, $filter_event_no_validated = false, - $filter_event_filter_search = null) { - - if (!is_numeric ($date)) { - $date = strtotime ($date); - } - if (empty ($date)) { - $date = get_system_time (); - } - - return events_get_count_events_by_agent($id_group, $period, $date, - $filter_event_validated, $filter_event_critical, - $filter_event_warning, $filter_event_no_validated, - $filter_event_filter_search); -} - /** * Get the maximum value of an agent module in a period of time. * diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index c9aacc65e8..5a1a6c2386 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -250,10 +250,6 @@ function reporting_html_print_report($report, $mini = false) { case 'database_serialized': reporting_html_database_serialized($table, $item); break; - case 'agent_detailed_event': - case 'event_report_agent': - reporting_html_event_report_agent($table, $item); - break; case 'group_report': reporting_html_group_report($table, $item); break; @@ -269,6 +265,10 @@ function reporting_html_print_report($report, $mini = false) { case 'inventory_changes': reporting_html_inventory_changes($table, $item); break; + case 'agent_detailed_event': + case 'event_report_agent': + reporting_html_event_report_agent($table, $item); + break; case 'event_report_module': reporting_html_event_report_module($table, $item); break; @@ -752,7 +752,6 @@ function reporting_html_top_n($table, $item) { function reporting_html_event_report_group($table, $item) { global $config; - if (!empty($item['failed'])) { $table->colspan['events']['cell'] = 3; $table->data['events']['cell'] = $item['failed']; @@ -763,26 +762,49 @@ function reporting_html_event_report_group($table, $item) { $table1->align = array(); $table1->align[0] = 'center'; - $table1->align[2] = 'center'; - + if($item['show_summary_group']){ + $table1->align[3] = 'center'; + } + else{ + $table1->align[2] = 'center'; + } $table1->data = array (); $table1->head = array (); - $table1->head[0] = __('Status'); - $table1->head[1] = __('Name'); - $table1->head[2] = __('Type'); - $table1->head[3] = __('Agent'); - $table1->head[4] = __('Severity'); - $table1->head[5] = __('Val. by'); - $table1->head[6] = __('Timestamp'); - + if($item['show_summary_group']){ + $table1->head[0] = __('Status'); + $table1->head[1] = __('Count'); + $table1->head[2] = __('Name'); + $table1->head[3] = __('Type'); + $table1->head[4] = __('Agent'); + $table1->head[5] = __('Severity'); + $table1->head[6] = __('Val. by'); + $table1->head[7] = __('Timestamp'); + } + else{ + $table1->head[0] = __('Status'); + $table1->head[1] = __('Name'); + $table1->head[2] = __('Type'); + $table1->head[3] = __('Agent'); + $table1->head[4] = __('Severity'); + $table1->head[5] = __('Val. by'); + $table1->head[6] = __('Timestamp'); + } + foreach ($item['data'] as $k => $event) { //First pass along the class of this row - $table1->cellclass[$k][1] = $table1->cellclass[$k][3] = - $table1->cellclass[$k][4] = $table1->cellclass[$k][5] = - $table1->cellclass[$k][6] = - get_priority_class ($event["criticity"]); - + if($item['show_summary_group']){ + $table1->cellclass[$k][1] = $table1->cellclass[$k][2] = + $table1->cellclass[$k][4] = $table1->cellclass[$k][5] = + $table1->cellclass[$k][6] = $table1->cellclass[$k][7] = + get_priority_class ($event["criticity"]); + } + else{ + $table1->cellclass[$k][1] = $table1->cellclass[$k][3] = + $table1->cellclass[$k][4] = $table1->cellclass[$k][5] = + $table1->cellclass[$k][6] = + get_priority_class ($event["criticity"]); + } $data = array (); // Colored box @@ -805,6 +827,10 @@ function reporting_html_event_report_group($table, $item) { "width" => 16, "title" => $title_st, "id" => 'status_img_' . $event["id_evento"])); + + if($item['show_summary_group']){ + $data[] = $event['event_rep']; + } $data[] = ui_print_truncate_text( io_safe_output($event['evento']), @@ -825,17 +851,20 @@ function reporting_html_event_report_group($table, $item) { $user_name = db_get_value ('fullname', 'tusuario', 'id_user', $event['id_usuario']); $data[] = io_safe_output($user_name); } - $data[] = '' . - date($config['date_format'], $event['timestamp_rep']) . - ''; + + if($item['show_summary_group']){ + $data[] = '' . date($config['date_format'], $event['timestamp_rep']) . ''; + } + else{ + $data[] = '' . date($config['date_format'], strtotime($event['timestamp'])) . ''; + } + array_push ($table1->data, $data); } $table->colspan['events']['cell'] = 3; $table->data['events']['cell'] = html_print_table($table1, true); - - if (!empty($item['chart']['by_agent'])) { $table1 = new stdClass(); $table1->width = '99%'; @@ -1368,10 +1397,8 @@ function reporting_html_group_report($table, $item) { function reporting_html_event_report_agent($table, $item) { global $config; - $table1 = new stdClass(); $table1->width = '99%'; - $table1->align = array(); $table1->align[0] = 'center'; $table1->align[1] = 'center'; @@ -1381,7 +1408,9 @@ function reporting_html_event_report_agent($table, $item) { $table1->head = array (); $table1->head[0] = __('Status'); - $table1->head[1] = __('Count'); + if($item['show_summary_group']){ + $table1->head[1] = __('Count'); + } $table1->head[2] = __('Name'); $table1->head[3] = __('Type'); $table1->head[4] = __('Severity'); @@ -1389,13 +1418,21 @@ function reporting_html_event_report_agent($table, $item) { $table1->head[6] = __('Timestamp'); foreach ($item['data'] as $i => $event) { - $table1->cellclass[$i][1] = - $table1->cellclass[$i][2] = - $table1->cellclass[$i][4] = - $table1->cellclass[$i][5] = - $table1->cellclass[$i][6] = - get_priority_class ($event["criticity"]); - + if($item['show_summary_group']){ + $table1->cellclass[$i][1] = + $table1->cellclass[$i][2] = + $table1->cellclass[$i][4] = + $table1->cellclass[$i][5] = + $table1->cellclass[$i][6] = + get_priority_class ($event["criticity"]); + } + else{ + $table1->cellclass[$i][1] = + $table1->cellclass[$i][3] = + $table1->cellclass[$i][4] = + $table1->cellclass[$i][5] = + get_priority_class ($event["criticity"]); + } $data = array (); // Colored box switch ($event['status']) { @@ -1417,8 +1454,10 @@ function reporting_html_event_report_agent($table, $item) { "width" => 16, "title" => $title_st)); - $data[] = $event['count']; - + if($item['show_summary_group']){ + $data[] = $event['count']; + } + $data[] = ui_print_truncate_text( io_safe_output($event['name']), 140, false, true); @@ -1433,8 +1472,12 @@ function reporting_html_event_report_agent($table, $item) { $user_name = db_get_value ('fullname', 'tusuario', 'id_user', $event['validated_by']); $data[] = io_safe_output($user_name); } - $data[] = '' . - date($config['date_format'], $event['timestamp']) . ''; + if($item['show_summary_group']){ + $data[] = '' . date($config['date_format'], $event['timestamp']) . ''; + } + else{ + $data[] = '' . date($config['date_format'], strtotime($event['timestamp'])) . ''; + } array_push ($table1->data, $data); } diff --git a/pandora_console/index.php b/pandora_console/index.php index c546c4ac3a..2593da0e42 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -689,7 +689,7 @@ else { $main_sec = get_parameter('extension_in_menu'); else if ($sec == 'gextensions') -+ $main_sec = get_parameter('extension_in_menu'); + $main_sec = get_parameter('extension_in_menu'); else $main_sec = $sec; $sec = $sec2; From 99aa41b32a20f53a571051f1a8e10d5f539e0a02 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 13 Jan 2017 14:09:56 +0100 Subject: [PATCH 2/8] fixed reports events --- pandora_console/general/shortcut_bar.php | 3 +- .../reporting_builder.item_editor.php | 107 ++++++--- .../godmode/reporting/reporting_builder.php | 6 +- .../visual_console_builder.editor.php | 2 +- pandora_console/include/functions_events.php | 76 +++---- .../include/functions_reporting.php | 215 +++++++++++------- .../include/functions_reporting_html.php | 182 ++++++++++----- .../include/functions_visual_map.php | 2 +- pandora_console/include/styles/pandora.css | 6 + 9 files changed, 372 insertions(+), 227 deletions(-) diff --git a/pandora_console/general/shortcut_bar.php b/pandora_console/general/shortcut_bar.php index 5be87f3e70..f37915b110 100644 --- a/pandora_console/general/shortcut_bar.php +++ b/pandora_console/general/shortcut_bar.php @@ -102,7 +102,8 @@ function sc_get_critical_events () { $own_groups = array_keys(users_get_groups($config['id_user'], "IR", false)); // Get events in the last 8 hours - $shortcut_events_update = events_get_group_events($own_groups, 28800, time()); + $shortcut_events_update = events_get_agent (false, 28800, time(), false, false, false, false, + false, false, $own_groups, true); if ($shortcut_events_update == false) $shortcut_events_update = array(); diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index cdb9961af9..2aa6c11774 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -400,11 +400,13 @@ switch ($action) { break; case 'event_report_agent': case 'event_report_group': + case 'event_report_module': $description = $item['description']; $period = $item['period']; $group = $item['id_group']; $idAgent = $item['id_agent']; - + $idAgentModule = $item['id_agent_module']; + //Added for events items $show_summary_group = $style['show_summary_group']; $filter_event_severity = json_decode($style['filter_event_severity'], true); @@ -418,14 +420,6 @@ switch ($action) { $filter_search = $style['event_filter_search']; break; - case 'event_report_module': - $description = $item['description']; - $idAgentModule = $item['id_agent_module']; - $idAgent = db_get_value_filter('id_agente', - 'tagente_modulo', - array('id_agente_modulo' => $idAgentModule)); - $period = $item['period']; - break; case 'general': $description = $item['description']; $group_by_agent = $item['group_by_agent']; @@ -981,10 +975,12 @@ You can of course remove the warnings, that's why we include the source and do n if ((empty($agents)) || $agents == -1) $agents = array(); $agents_select = array(); - foreach ($id_agents as $id) { - foreach ($agents as $key => $a) { - if ($key == (int)$id) { - $agents_select[$key] = $key; + if (is_array($id_agents) || is_object($id_agents)){ + foreach ($id_agents as $id) { + foreach ($agents as $key => $a) { + if ($key == (int)$id) { + $agents_select[$key] = $key; + } } } } @@ -1336,8 +1332,8 @@ You can of course remove the warnings, that's why we include the source and do n @@ -1346,10 +1342,10 @@ You can of course remove the warnings, that's why we include the source and do n @@ -1358,10 +1354,10 @@ You can of course remove the warnings, that's why we include the source and do n @@ -1427,9 +1423,7 @@ You can of course remove the warnings, that's why we include the source and do n ?> - - - + @@ -1983,7 +1977,7 @@ $(document).ready (function () { switch (data) { case 'boolean': case 'sparse': - $("#row_percentil").show(); + //$("#row_percentil").show(); break; default: $("#row_percentil").hide(); @@ -1993,6 +1987,47 @@ $(document).ready (function () { }); }); + + + $("#submit-create_item").click(function () { + var type = $('#type').val(); + switch (type){ + case 'alert_report_module': case 'alert_report_agent': case 'alert_report_group': + case 'event_report_agent': case 'event_report_module': case 'event_report_group': + case 'simple_graph': case 'simple_baseline_graph': case 'TTRT': case 'TTO': + case 'MTBF': case 'MTTR': case 'prediction_date': case 'projection_graph': + case 'avg_value': case 'max_value': case 'min_value': case 'monitor_report': + case 'database_serialized': case 'sumatory': case 'historical_data': + case 'agent_configuration': + if ($("#hidden-id_agent").val() == 0) { + alert( ); + return false; + } + break; + default: + break; + } + }); + + $("#submit-edit_item").click(function () { + var type = $('#type').val(); + switch (type){ + case 'alert_report_module': case 'alert_report_agent': case 'alert_report_group': + case 'event_report_agent': case 'event_report_module': case 'event_report_group': + case 'simple_graph': case 'simple_baseline_graph': case 'TTRT': case 'TTO': + case 'MTBF': case 'MTTR': case 'prediction_date': case 'projection_graph': + case 'avg_value': case 'max_value': case 'min_value': case 'monitor_report': + case 'database_serialized': case 'sumatory': case 'historical_data': + case 'agent_configuration': + if ($("#hidden-id_agent").val() == 0) { + alert( ); + return false; + } + break; + default: + break; + } + }); }); @@ -2770,13 +2805,10 @@ function chooseType() { $("#row_period").show(); $("#row_servers").show(); $("#row_group").show(); - $("#row_show_in_two_columns").show(); $("#row_event_severity").show(); $("#row_event_status").show(); $("#row_show_summary_group").show(); - $("#row_event_graphs").show(); - $("#row_event_graph_by_agent").show(); $("#row_event_graph_by_user").show(); $("#row_event_graph_by_criticity").show(); @@ -2791,16 +2823,17 @@ function chooseType() { $("#row_description").show(); $("#row_agent").show(); $("#row_period").show(); - $("#row_show_in_two_columns").show(); $("#row_event_severity").show(); $("#row_event_status").show(); $("#row_show_summary_group").show(); $("#row_event_graphs").show(); + $("#row_event_type").show(); + $("#row_event_graph_by_user").show(); $("#row_event_graph_by_criticity").show(); $("#row_event_graph_by_validated").show(); - $("#row_event_type").show(); + $('#agent_autocomplete').hide(); $('#agent_autocomplete_events').show(); @@ -2812,15 +2845,19 @@ function chooseType() { $("#row_agent").show(); $("#row_module").show(); $("#row_period").show(); - $("#row_show_in_two_columns").show(); - - $("#row_event_graph_by_agent").show(); + $("#row_event_severity").show(); + $("#row_event_status").show(); + $("#row_show_summary_group").show(); + $("#row_event_graphs").show(); + $("#row_event_type").show(); + $("#row_event_graph_by_user").show(); $("#row_event_graph_by_criticity").show(); $("#row_event_graph_by_validated").show(); $('#agent_autocomplete').hide(); $('#agent_autocomplete_events').show(); + $("#row_filter_search").show(); break; case 'general': diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 349484b772..d63128770d 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1134,6 +1134,7 @@ switch ($action) { switch ($values['type']) { case 'event_report_agent': case 'event_report_group': + case 'event_report_module': //Added for events items $style['show_summary_group'] = $show_summary_group; $style['filter_event_severity'] = json_encode($filter_event_severity); @@ -1167,7 +1168,6 @@ switch ($action) { $style['label'] = ''; break; case 'agent_configuration': - case 'event_report_module': case 'alert_report_agent': case 'alert_report_module': case 'historical_data': @@ -1446,7 +1446,8 @@ switch ($action) { switch ($values['type']) { case 'event_report_agent': - case 'event_report_group': + case 'event_report_group': + case 'event_report_module': $show_summary_group = get_parameter('show_summary_group', 0); $filter_event_severity = get_parameter('filter_event_severity', ''); $filter_event_type = get_parameter('filter_event_type', ''); @@ -1494,7 +1495,6 @@ switch ($action) { $style['label'] = ''; break; case 'agent_configuration': - case 'event_report_module': case 'alert_report_agent': case 'alert_report_module': case 'historical_data': diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.php b/pandora_console/godmode/reporting/visual_console_builder.editor.php index 2468cef5cf..1f86475a36 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.php +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.php @@ -75,7 +75,7 @@ if (!defined('METACONSOLE')) { echo '
'; } else { - echo '
'; + echo '
'; } echo '
'; diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index a4ce09480b..ae089f2fa0 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1261,7 +1261,7 @@ function events_get_group_events_steps ($begin, &$result, $id_group, $period, $d function events_get_agent ($id_agent, $period, $date = 0, $history = false, $show_summary_group = false, $filter_event_severity = false, $filter_event_type = false, $filter_event_status = false, $filter_event_filter_search=false, - $id_group = false, $events_group = false) { + $id_group = false, $events_group = false, $id_agent_module = false, $events_module = false) { global $config; if (!is_numeric ($date)) { @@ -1350,15 +1350,19 @@ function events_get_agent ($id_agent, $period, $date = 0, ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")'; } - if(!$events_group){ - $sql_where .= sprintf(' AND id_agente = %d AND utimestamp > %d - AND utimestamp <= %d ', $id_agent, $datelimit, $date); - } - else{ + if($events_group){ $sql_where .= sprintf(' AND id_grupo IN (%s) AND utimestamp > %d AND utimestamp <= %d ', implode (",", $id_group), $datelimit, $date); } - + elseif($events_module){ + $sql_where .= sprintf(' AND id_agentmodule = %d AND utimestamp > %d + AND utimestamp <= %d ', $id_agent_module, $datelimit, $date); + } + else{ + $sql_where .= sprintf(' AND id_agente = %d AND utimestamp > %d + AND utimestamp <= %d ', $id_agent, $datelimit, $date); + } + if($show_summary_group){ return events_get_events_grouped($sql_where, 0, 1000, is_metaconsole(), false, false, $history); @@ -1369,43 +1373,6 @@ function events_get_agent ($id_agent, $period, $date = 0, } } -/** - * Get all the events happened in an Agent during a period of time. - * - * The returned events will be in the time interval ($date - $period, $date] - * - * @param int $id_agent_module Module id to get events. - * @param int $period Period of time in seconds to get events. - * @param int $date Beginning date to get events. - * - * @return array An array with all the events happened. - */ -function events_get_module ($id_agent_module, $period, $date = 0, $history = false, $show_summary_group = false) { - global $config; - - if (!is_numeric ($date)) { - $date = strtotime ($date); - } - if (empty ($date)) { - $date = get_system_time (); - } - - $datelimit = $date - $period; - - $sql_where = sprintf(' AND id_agentmodule = %d AND utimestamp > %d - AND utimestamp <= %d ', $id_agent_module, $datelimit, $date); - - return events_get_events_grouped($sql_where, 0, 1000, false, - false, false, $history); - - $sql = sprintf ('SELECT evento, event_type, criticity, count(*) as count_rep, max(timestamp) AS time2 - FROM tevento - WHERE id_agentmodule = %d AND utimestamp > %d AND utimestamp <= %d - GROUP BY id_agentmodule, evento ORDER BY time2 DESC', $id_agent_module, $datelimit, $date); - - return db_get_all_rows_sql ($sql); -} - /** * Decode a numeric type into type description. * @@ -2757,7 +2724,6 @@ function events_get_count_events_by_agent ($id_group, $period, $date, function events_get_count_events_validated_by_user ($filter, $period, $date, $filter_event_severity = false, $filter_event_type = false, $filter_event_status = false, $filter_event_filter_search = false) { - global $config; //group $sql_filter = ' AND 1=1 '; @@ -2772,11 +2738,17 @@ function events_get_count_events_validated_by_user ($filter, $period, $date, $sql_filter .= sprintf(' AND id_grupo IN (%s) ', implode (",", $id_group)); } + if (!empty($filter['id_agent'])) { $sql_filter .= sprintf(' AND id_agente = %d ', $filter['id_agent']); } + if(!empty($filter['id_agentmodule'])){ + $sql_filter .= + sprintf(' AND id_agentmodule = %d ', $filter['id_agentmodule']); + } + //date if (!is_numeric ($date)) { $date = strtotime ($date); @@ -2865,7 +2837,6 @@ function events_get_count_events_validated_by_user ($filter, $period, $date, %s %s GROUP BY id_usuario', $datelimit, $date, $sql_filter, $sql_where); - $rows = db_get_all_rows_sql ($sql); if ($rows == false) @@ -2879,7 +2850,6 @@ function events_get_count_events_validated_by_user ($filter, $period, $date, } $return[$user_name] = $row['count']; } - return $return; } @@ -2912,11 +2882,17 @@ function events_get_count_events_by_criticity ($filter, $period, $date, $sql_filter .= sprintf(' AND id_grupo IN (%s) ', implode (",", $id_group)); } + if (!empty($filter['id_agent'])) { $sql_filter .= sprintf(' AND id_agente = %d ', $filter['id_agent']); } + if(!empty($filter['id_agentmodule'])){ + $sql_filter .= + sprintf(' AND id_agentmodule = %d ', $filter['id_agentmodule']); + } + if (!is_numeric ($date)) { $date = strtotime ($date); } @@ -3045,10 +3021,16 @@ function events_get_count_events_validated ($filter, $period = null, $date = nul $sql_filter .= sprintf(" AND id_grupo IN (%s) ", implode (",", $id_group)); } + //agent if (!empty($filter['id_agent'])) { $sql_filter .= sprintf(" AND id_agente = %d ", $filter['id_agent']); } + //module + if(!empty($filter['id_agentmodule'])){ + $sql_filter .= + sprintf(' AND id_agentmodule = %d ', $filter['id_agentmodule']); + } //date if (!is_numeric ($date)) { diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 2a55275a3e..b31a5ee9e7 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -447,7 +447,10 @@ function reporting_make_reporting_data($report = null, $id_report, case 'event_report_module': $report['contents'][] = reporting_event_report_module( $report, - $content); + $content, + $type, + $force_width_chart, + $force_height_chart); break; case 'event_report_group': $report['contents'][] = reporting_event_report_group( @@ -1413,15 +1416,25 @@ function reporting_event_report_group($report, $content, metaconsole_restore_db(); } - $return['total_events'] = count($return['data']); + //total_events + if(isset($return['data'])){ + $return['total_events'] = count($return['data']); + } + else{ + $return['total_events'] = 0; + } return reporting_check_structure_content($return); } -function reporting_event_report_module($report, $content) { +function reporting_event_report_module($report, $content, + $type = 'dinamic', $force_width_chart = null, + $force_height_chart = null) { global $config; + $ttl = 1; + $return['type'] = 'event_report_module'; if (empty($content['name'])) { @@ -1445,23 +1458,39 @@ function reporting_event_report_module($report, $content) { $return["date"] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; - $data = reporting_get_module_detailed_event( - $content['id_agent_module'], $content['period'], - $report["datetime"], true, false, true); + $event_filter = $content['style']; + $return['show_summary_group'] = $event_filter['show_summary_group']; + //filter + $show_summary_group = $event_filter['show_summary_group']; + $filter_event_severity = json_decode($event_filter['filter_event_severity'],true); + $filter_event_type = json_decode($event_filter['filter_event_type'],true); + $filter_event_status = json_decode($event_filter['filter_event_status'],true); + $filter_event_filter_search = $event_filter['event_filter_search']; + //graphs + $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator']; + $event_graph_by_criticity = $event_filter['event_graph_by_criticity']; + $event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated']; + + //data events + $data = reporting_get_module_detailed_event ( + $content['id_agent_module'], $content['period'], $report["datetime"], + $show_summary_group, $filter_event_severity, $filter_event_type, + $filter_event_status, $filter_event_filter_search, $force_width_chart, + $event_graph_by_user_validator, $event_graph_by_criticity, + $event_graph_validated_vs_unvalidated, $ttl); + if (empty($data)) { $return['failed'] = __('No events'); } else { $return['data'] = array_reverse($data); - } - + } + if ($config['metaconsole']) { metaconsole_restore_db(); } - $return['total_events'] = count($return['data']); - return reporting_check_structure_content($return); } @@ -2268,8 +2297,14 @@ function reporting_event_report_agent($report, $content, metaconsole_restore_db(); } - $return['total_events'] = count($return['data']); - + //total_events + if(isset($return['data'])){ + $return['total_events'] = count($return['data']); + } + else{ + $return['total_events'] = 0; + } + return reporting_check_structure_content($return); } @@ -5987,13 +6022,6 @@ function reporting_set_conf_charts(&$width, &$height, &$only_image, $type, } } - - - - - - - //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// @@ -6017,7 +6045,11 @@ function reporting_set_conf_charts(&$width, &$height, &$only_image, $type, * @return mixed A table object (XHTML) or object table is false the html. */ function reporting_get_module_detailed_event ($id_modules, $period = 0, - $date = 0, $return = false, $html = true, $only_data = false) { + $date = 0, $show_summary_group = false, $filter_event_severity = false, + $filter_event_type = false, $filter_event_status = false, + $filter_event_filter_search = false, $force_width_chart = false, + $event_graph_by_user_validator = false, $event_graph_by_criticity = false, + $event_graph_validated_vs_unvalidated = false, $ttl = 1) { global $config; @@ -6037,72 +6069,93 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, $events = array (); foreach ($id_modules as $id_module) { - $event = events_get_module ($id_module, (int) $period, (int) $date, $history, $show_summary_group); + $event['data'] = events_get_agent (false, (int) $period, (int) $date, + $history, $show_summary_group, $filter_event_severity, + $filter_event_type, $filter_event_status, $filter_event_filter_search, + false, false, $id_module, true); + + //total_events + if(isset($event['data'])){ + $event['total_events'] = count($event['data']); + } + else{ + $event['total_events'] = 0; + } + + //graphs + if (!empty($force_width_chart)) { + $width = $force_width_chart; + } + + if (!empty($force_height_chart)) { + $height = $force_height_chart; + } + + if ($event_graph_by_user_validator) { + $data_graph = events_get_count_events_validated_by_user( + array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity, + $filter_event_type, $filter_event_status, $filter_event_filter_search); + + $event['chart']['by_user_validator'] = pie3d_graph( + false, + $data_graph, + 500, + 150, + __("other"), + ui_get_full_url(false, false, false, false), + ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", + $config['fontpath'], + $config['font_size'], + $ttl); + } + + if ($event_graph_by_criticity) { + $data_graph = events_get_count_events_by_criticity( + array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity, + $filter_event_type, $filter_event_status, $filter_event_filter_search); + + $colors = get_criticity_pie_colors($data_graph); + + $event['chart']['by_criticity'] = pie3d_graph( + false, + $data_graph, + 500, + 150, + __("other"), + ui_get_full_url(false, false, false, false), + ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", + $config['fontpath'], + $config['font_size'], + $ttl, + false, + $colors); + } + + if ($event_graph_validated_vs_unvalidated) { + $data_graph = events_get_count_events_validated( + array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity, + $filter_event_type, $filter_event_status, $filter_event_filter_search); + + $event['chart']['validated_vs_unvalidated'] = pie3d_graph( + false, + $data_graph, + 500, + 150, + __("other"), + ui_get_full_url(false, false, false, false), + ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", + $config['fontpath'], + $config['font_size'], + $ttl); + } + if (!empty ($event)) { array_push ($events, $event); } } - - if ($only_data) { - return $event; - } - - if ($events) { - $note = ''; - if (count($events) >= 1000) { - $note .= '* ' . __('Maximum of events shown') . ' (1000)
'; - } - foreach ($events as $eventRow) { - foreach ($eventRow as $k => $event) { - //$k = count($table->data); - $table->cellclass[$k][1] = $table->cellclass[$k][2] = - $table->cellclass[$k][3] = $table->cellclass[$k][4] = - $table->cellclass[$k][5] = get_priority_class ($event["criticity"]); - - $data = array (); - - // Colored box - switch ($event['estado']) { - case 0: - $img_st = "images/star.png"; - $title_st = __('New event'); - break; - case 1: - $img_st = "images/tick.png"; - $title_st = __('Event validated'); - break; - case 2: - $img_st = "images/hourglass.png"; - $title_st = __('Event in process'); - break; - } - $data[0] = html_print_image ($img_st, true, - array ("class" => "image_status", - "width" => 16, - "title" => $title_st, - "id" => 'status_img_' . $event["id_evento"])); - - $data[1] = io_safe_output($event['evento']); - $data[2] = $event['event_type']; - $data[3] = get_priority_name ($event['criticity']); - $data[4] = $event['event_rep']; - $data[5] = date($config['date_format'], $event['timestamp_rep']); - array_push ($table->data, $data); - } - } - - if ($html) { - return html_print_table ($table, $return) . $note; - } - else { - return $table; - } - } - else { - return false; - } -} + return $events; +} /** * Get a detailed report of summarized events per agent diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 5a1a6c2386..e72c5b557e 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -130,17 +130,13 @@ function reporting_html_print_report($report, $mini = false) { $table->data['description_row']['description'] = $item['description']; - if($item['type']=='event_report_agent' || $item['type']=='event_report_module' || $item['type']=='event_report_group'){ - + if($item['type']=='event_report_agent' || $item['type']=='event_report_group'){ if($item['description'] != '' && $item['description'] != null){ $table->data['description_row']['description'] .= " - "; } - $table->data['description_row']['description'] .= "Total events: ".$item["total_events"]; - - } $table->colspan['description_row']['description'] = 3; @@ -916,69 +912,139 @@ function reporting_html_event_report_group($table, $item) { } function reporting_html_event_report_module($table, $item) { - global $config; - + $show_summary_group = $item['show_summary_group']; if (!empty($item['failed'])) { $table->colspan['events']['cell'] = 3; $table->data['events']['cell'] = $item['failed']; } else { - $table1 = new stdClass(); - $table1->width = '99%'; - $table1->data = array (); - $table1->head = array (); - $table1->head[0] = __('Status'); - $table1->head[1] = __('Event name'); - $table1->head[2] = __('Event type'); - $table1->head[3] = __('Severity'); - $table1->head[4] = __('Count'); - $table1->head[5] = __('Timestamp'); - $table1->style[0] = 'text-align: center;'; - $table1->style[4] = 'text-align: center;'; - - - foreach ($item['data'] as $i => $event) { - $data = array(); - - $table1->cellclass[$i][1] = - $table1->cellclass[$i][2] = - $table1->cellclass[$i][3] = - $table1->cellclass[$i][4] = - $table1->cellclass[$i][5] = get_priority_class($event["criticity"]); - - // Colored box - switch ($event['estado']) { - case 0: - $img_st = "images/star.png"; - $title_st = __('New event'); - break; - case 1: - $img_st = "images/tick.png"; - $title_st = __('Event validated'); - break; - case 2: - $img_st = "images/hourglass.png"; - $title_st = __('Event in process'); - break; + foreach ($item['data'] as $item) { + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->data = array (); + $table1->head = array (); + if($show_summary_group){ + $table1->head[0] = __('Status'); + $table1->head[1] = __('Event name'); + $table1->head[2] = __('Event type'); + $table1->head[3] = __('Severity'); + $table1->head[4] = __('Count'); + $table1->head[5] = __('Timestamp'); + $table1->style[0] = 'text-align: center;'; + } + else{ + $table1->head[0] = __('Status'); + $table1->head[1] = __('Event name'); + $table1->head[2] = __('Event type'); + $table1->head[3] = __('Severity'); + $table1->head[4] = __('Timestamp'); + $table1->style[0] = 'text-align: center;'; + } + $table->data['tatal_events']['cell'] = "Total events: ".$item["total_events"]; + if (is_array($item['data']) || is_object($item['data'])){ + $item_data = array_reverse($item['data']); } - $data[0] = html_print_image ($img_st, true, - array ("class" => "image_status", - "width" => 16, - "title" => $title_st, - "id" => 'status_img_' . $event["id_evento"])); - $data[1] = io_safe_output($event['evento']); - $data[2] = $event['event_type']; - $data[3] = get_priority_name ($event['criticity']); - $data[4] = $event['event_rep']; - $data[5] = date($config['date_format'], $event['timestamp_rep']); + if (is_array($item_data) || is_object($item_data)){ + foreach ($item_data as $i => $event) { + $data = array(); + if($show_summary_group){ + $table1->cellclass[$i][1] = $table1->cellclass[$i][2] = + $table1->cellclass[$i][3] = $table1->cellclass[$i][4] = + $table1->cellclass[$i][5] = get_priority_class($event["criticity"]); + } + else{ + $table1->cellclass[$i][1] = $table1->cellclass[$i][2] = + $table1->cellclass[$i][3] = + $table1->cellclass[$i][4] = get_priority_class($event["criticity"]); + } + // Colored box + switch ($event['estado']) { + case 0: + $img_st = "images/star.png"; + $title_st = __('New event'); + break; + case 1: + $img_st = "images/tick.png"; + $title_st = __('Event validated'); + break; + case 2: + $img_st = "images/hourglass.png"; + $title_st = __('Event in process'); + break; + } + + $data[0] = html_print_image ($img_st, true, + array ("class" => "image_status", + "width" => 16, + "title" => $title_st, + "id" => 'status_img_' . $event["id_evento"])); + $data[1] = io_safe_output($event['evento']); + $data[2] = $event['event_type']; + $data[3] = get_priority_name ($event['criticity']); + if($show_summary_group){ + $data[4] = $event['event_rep']; + $data[5] = date($config['date_format'], $event['timestamp_rep']); + } + else{ + $data[4] = date($config['date_format'], strtotime($event['timestamp'])); + } + $table1->data[] = $data; + } + } + + $table->colspan['events']['cell'] = 3; + $table->data['events']['cell'] = html_print_table($table1, true); + + if (!empty($item['chart']['by_agent'])) { + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->head = array (); + $table1->head[0] = __('Events by agent'); + $table1->data[0][0] = $item['chart']['by_agent']; + + $table->colspan['chart_by_agent']['cell'] = 3; + $table->cellstyle['chart_by_agent']['cell'] = 'text-align: center;'; + $table->data['chart_by_agent']['cell'] = html_print_table($table1, true); + } - $table1->data[] = $data; + if (!empty($item['chart']['by_user_validator'])) { + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->head = array (); + $table1->head[0] = __('Events by user validator'); + $table1->data[0][0] = $item['chart']['by_user_validator']; + + $table->colspan['chart_by_user_validator']['cell'] = 3; + $table->cellstyle['chart_by_user_validator']['cell'] = 'text-align: center;'; + $table->data['chart_by_user_validator']['cell'] = html_print_table($table1, true); + } + + if (!empty($item['chart']['by_criticity'])) { + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->head = array (); + $table1->head[0] = __('Events by Severity'); + $table1->data[0][0] = $item['chart']['by_criticity']; + + $table->colspan['chart_by_criticity']['cell'] = 3; + $table->cellstyle['chart_by_criticity']['cell'] = 'text-align: center;'; + $table->data['chart_by_criticity']['cell'] = html_print_table($table1, true); + } + + if (!empty($item['chart']['validated_vs_unvalidated'])) { + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->head = array (); + $table1->head[0] = __('Events validated vs unvalidated'); + $table1->data[0][0] = $item['chart']['validated_vs_unvalidated']; + + $table->colspan['chart_validated_vs_unvalidated']['cell'] = 3; + $table->cellstyle['chart_validated_vs_unvalidated']['cell'] = 'text-align: center;'; + $table->data['chart_validated_vs_unvalidated']['cell'] = html_print_table($table1, true); + } } - - $table->colspan['events']['cell'] = 3; - $table->data['events']['cell'] = html_print_table($table1, true); } } diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index b27154c6c6..90c5c86089 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -2137,7 +2137,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, } if (defined('METACONSOLE')) { - echo "
"; + echo "
"; } echo '
Date: Wed, 18 Jan 2017 10:37:08 +0100 Subject: [PATCH 3/8] fixed pdf reports events --- pandora_console/include/functions_events.php | 10 +- .../include/functions_reporting.php | 12 +- .../include/functions_reporting_html.php | 201 ++++++++++++++---- 3 files changed, 169 insertions(+), 54 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index ae089f2fa0..7480fb48a2 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1287,7 +1287,7 @@ function events_get_agent ($id_agent, $period, $date = 0, if (!empty($filter_event_severity)) { foreach ($filter_event_severity as $key => $value) { switch ($value) { - case 'all': + case -1: $severity_all = 1; break; case 34: @@ -2619,7 +2619,7 @@ function events_get_count_events_by_agent ($id_group, $period, $date, if (!empty($filter_event_severity)) { foreach ($filter_event_severity as $key => $value) { switch ($value) { - case 'all': + case -1: $severity_all = 1; break; case 34: @@ -2764,7 +2764,7 @@ function events_get_count_events_validated_by_user ($filter, $period, $date, if (!empty($filter_event_severity)) { foreach ($filter_event_severity as $key => $value) { switch ($value) { - case 'all': + case -1: $severity_all = 1; break; case 34: @@ -2907,7 +2907,7 @@ function events_get_count_events_by_criticity ($filter, $period, $date, if (!empty($filter_event_severity)) { foreach ($filter_event_severity as $key => $value) { switch ($value) { - case 'all': + case -1: $severity_all = 1; break; case 34: @@ -3063,7 +3063,7 @@ function events_get_count_events_validated ($filter, $period = null, $date = nul if (!empty($filter_event_severity)) { foreach ($filter_event_severity as $key => $value) { switch ($value) { - case 'all': + case -1: $severity_all = 1; break; case 34: diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index b31a5ee9e7..e706184fdf 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -450,7 +450,8 @@ function reporting_make_reporting_data($report = null, $id_report, $content, $type, $force_width_chart, - $force_height_chart); + $force_height_chart, + $pdf); break; case 'event_report_group': $report['contents'][] = reporting_event_report_group( @@ -1429,11 +1430,16 @@ function reporting_event_report_group($report, $content, function reporting_event_report_module($report, $content, $type = 'dinamic', $force_width_chart = null, - $force_height_chart = null) { + $force_height_chart = null, $pdf=0) { global $config; - $ttl = 1; + if($pdf){ + $ttl = 2; + } + else{ + $ttl = 1; + } $return['type'] = 'event_report_module'; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index e72c5b557e..a81eb7099d 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -746,7 +746,7 @@ function reporting_html_top_n($table, $item) { } } -function reporting_html_event_report_group($table, $item) { +function reporting_html_event_report_group($table, $item, $pdf = 0) { global $config; if (!empty($item['failed'])) { $table->colspan['events']['cell'] = 3; @@ -858,9 +858,16 @@ function reporting_html_event_report_group($table, $item) { array_push ($table1->data, $data); } - $table->colspan['events']['cell'] = 3; - $table->data['events']['cell'] = html_print_table($table1, true); - + if($pdf){ + $table1->class = 'table-beauty'; + $pdf_export = html_print_table($table1, true); + $pdf_export .= '
'; + } + else{ + $table->colspan['events']['cell'] = 3; + $table->data['events']['cell'] = html_print_table($table1, true); + } + if (!empty($item['chart']['by_agent'])) { $table1 = new stdClass(); $table1->width = '99%'; @@ -868,9 +875,16 @@ function reporting_html_event_report_group($table, $item) { $table1->head[0] = __('Events by agent'); $table1->data[0][0] = $item['chart']['by_agent']; - $table->colspan['chart_by_agent']['cell'] = 3; - $table->cellstyle['chart_by_agent']['cell'] = 'text-align: center;'; - $table->data['chart_by_agent']['cell'] = html_print_table($table1, true); + if($pdf){ + $table1->class = 'table-beauty'; + $pdf_export .= html_print_table($table1, true); + $pdf_export .= '
'; + } + else{ + $table->colspan['chart_by_agent']['cell'] = 3; + $table->cellstyle['chart_by_agent']['cell'] = 'text-align: center;'; + $table->data['chart_by_agent']['cell'] = html_print_table($table1, true); + } } if (!empty($item['chart']['by_user_validator'])) { @@ -880,9 +894,16 @@ function reporting_html_event_report_group($table, $item) { $table1->head[0] = __('Events by user validator'); $table1->data[0][0] = $item['chart']['by_user_validator']; - $table->colspan['chart_by_user_validator']['cell'] = 3; - $table->cellstyle['chart_by_user_validator']['cell'] = 'text-align: center;'; - $table->data['chart_by_user_validator']['cell'] = html_print_table($table1, true); + if($pdf){ + $table1->class = 'table-beauty'; + $pdf_export .= html_print_table($table1, true); + $pdf_export .= '
'; + } + else{ + $table->colspan['chart_by_user_validator']['cell'] = 3; + $table->cellstyle['chart_by_user_validator']['cell'] = 'text-align: center;'; + $table->data['chart_by_user_validator']['cell'] = html_print_table($table1, true); + } } if (!empty($item['chart']['by_criticity'])) { @@ -892,9 +913,16 @@ function reporting_html_event_report_group($table, $item) { $table1->head[0] = __('Events by Severity'); $table1->data[0][0] = $item['chart']['by_criticity']; - $table->colspan['chart_by_criticity']['cell'] = 3; - $table->cellstyle['chart_by_criticity']['cell'] = 'text-align: center;'; - $table->data['chart_by_criticity']['cell'] = html_print_table($table1, true); + if($pdf){ + $table1->class = 'table-beauty'; + $pdf_export .= html_print_table($table1, true); + $pdf_export .= '
'; + } + else{ + $table->colspan['chart_by_criticity']['cell'] = 3; + $table->cellstyle['chart_by_criticity']['cell'] = 'text-align: center;'; + $table->data['chart_by_criticity']['cell'] = html_print_table($table1, true); + } } if (!empty($item['chart']['validated_vs_unvalidated'])) { @@ -904,14 +932,25 @@ function reporting_html_event_report_group($table, $item) { $table1->head[0] = __('Events validated vs unvalidated'); $table1->data[0][0] = $item['chart']['validated_vs_unvalidated']; - $table->colspan['chart_validated_vs_unvalidated']['cell'] = 3; - $table->cellstyle['chart_validated_vs_unvalidated']['cell'] = 'text-align: center;'; - $table->data['chart_validated_vs_unvalidated']['cell'] = html_print_table($table1, true); + if($pdf){ + $table1->class = 'table-beauty'; + $pdf_export .= html_print_table($table1, true); + $pdf_export .= '
'; + } + else{ + $table->colspan['chart_validated_vs_unvalidated']['cell'] = 3; + $table->cellstyle['chart_validated_vs_unvalidated']['cell'] = 'text-align: center;'; + $table->data['chart_validated_vs_unvalidated']['cell'] = html_print_table($table1, true); + } + } + + if($pdf){ + return $pdf_export; } } } -function reporting_html_event_report_module($table, $item) { +function reporting_html_event_report_module($table, $item, $pdf = 0) { global $config; $show_summary_group = $item['show_summary_group']; if (!empty($item['failed'])) { @@ -993,10 +1032,16 @@ function reporting_html_event_report_module($table, $item) { $table1->data[] = $data; } } - - $table->colspan['events']['cell'] = 3; - $table->data['events']['cell'] = html_print_table($table1, true); - + if($pdf){ + $table1->class = 'table-beauty'; + $pdf_export = html_print_table($table1, true); + $pdf_export .= '
'; + } + else{ + $table->colspan['events']['cell'] = 3; + $table->data['events']['cell'] = html_print_table($table1, true); + } + if (!empty($item['chart']['by_agent'])) { $table1 = new stdClass(); $table1->width = '99%'; @@ -1004,9 +1049,16 @@ function reporting_html_event_report_module($table, $item) { $table1->head[0] = __('Events by agent'); $table1->data[0][0] = $item['chart']['by_agent']; - $table->colspan['chart_by_agent']['cell'] = 3; - $table->cellstyle['chart_by_agent']['cell'] = 'text-align: center;'; - $table->data['chart_by_agent']['cell'] = html_print_table($table1, true); + if($pdf){ + $table1->class = 'table-beauty'; + $pdf_export .= html_print_table($table1, true); + $pdf_export .= '
'; + } + else{ + $table->colspan['chart_by_agent']['cell'] = 3; + $table->cellstyle['chart_by_agent']['cell'] = 'text-align: center;'; + $table->data['chart_by_agent']['cell'] = html_print_table($table1, true); + } } if (!empty($item['chart']['by_user_validator'])) { @@ -1016,9 +1068,16 @@ function reporting_html_event_report_module($table, $item) { $table1->head[0] = __('Events by user validator'); $table1->data[0][0] = $item['chart']['by_user_validator']; - $table->colspan['chart_by_user_validator']['cell'] = 3; - $table->cellstyle['chart_by_user_validator']['cell'] = 'text-align: center;'; - $table->data['chart_by_user_validator']['cell'] = html_print_table($table1, true); + if($pdf){ + $table1->class = 'table-beauty'; + $pdf_export .= html_print_table($table1, true); + $pdf_export .= '
'; + } + else{ + $table->colspan['chart_by_user_validator']['cell'] = 3; + $table->cellstyle['chart_by_user_validator']['cell'] = 'text-align: center;'; + $table->data['chart_by_user_validator']['cell'] = html_print_table($table1, true); + } } if (!empty($item['chart']['by_criticity'])) { @@ -1028,9 +1087,16 @@ function reporting_html_event_report_module($table, $item) { $table1->head[0] = __('Events by Severity'); $table1->data[0][0] = $item['chart']['by_criticity']; - $table->colspan['chart_by_criticity']['cell'] = 3; - $table->cellstyle['chart_by_criticity']['cell'] = 'text-align: center;'; - $table->data['chart_by_criticity']['cell'] = html_print_table($table1, true); + if($pdf){ + $table1->class = 'table-beauty'; + $pdf_export .= html_print_table($table1, true); + $pdf_export .= '
'; + } + else{ + $table->colspan['chart_by_criticity']['cell'] = 3; + $table->cellstyle['chart_by_criticity']['cell'] = 'text-align: center;'; + $table->data['chart_by_criticity']['cell'] = html_print_table($table1, true); + } } if (!empty($item['chart']['validated_vs_unvalidated'])) { @@ -1040,9 +1106,20 @@ function reporting_html_event_report_module($table, $item) { $table1->head[0] = __('Events validated vs unvalidated'); $table1->data[0][0] = $item['chart']['validated_vs_unvalidated']; - $table->colspan['chart_validated_vs_unvalidated']['cell'] = 3; - $table->cellstyle['chart_validated_vs_unvalidated']['cell'] = 'text-align: center;'; - $table->data['chart_validated_vs_unvalidated']['cell'] = html_print_table($table1, true); + if($pdf){ + $table1->class = 'table-beauty'; + $pdf_export .= html_print_table($table1, true); + $pdf_export .= '
'; + } + else{ + $table->colspan['chart_validated_vs_unvalidated']['cell'] = 3; + $table->cellstyle['chart_validated_vs_unvalidated']['cell'] = 'text-align: center;'; + $table->data['chart_validated_vs_unvalidated']['cell'] = html_print_table($table1, true); + } + } + + if($pdf){ + return $pdf_export; } } } @@ -1461,7 +1538,7 @@ function reporting_html_group_report($table, $item) { "; } -function reporting_html_event_report_agent($table, $item) { +function reporting_html_event_report_agent($table, $item, $pdf = 0) { global $config; $table1 = new stdClass(); $table1->width = '99%'; @@ -1547,9 +1624,16 @@ function reporting_html_event_report_agent($table, $item) { array_push ($table1->data, $data); } - $table->colspan['event_list']['cell'] = 3; - $table->cellstyle['event_list']['cell'] = 'text-align: center;'; - $table->data['event_list']['cell'] = html_print_table($table1, true); + if($pdf){ + $table1->class = 'table-beauty'; + $pdf_export = html_print_table($table1, true); + $pdf_export .= '
'; + } + else{ + $table->colspan['event_list']['cell'] = 3; + $table->cellstyle['event_list']['cell'] = 'text-align: center;'; + $table->data['event_list']['cell'] = html_print_table($table1, true); + } if (!empty($item['chart']['by_user_validator'])) { $table1 = new stdClass(); @@ -1558,9 +1642,16 @@ function reporting_html_event_report_agent($table, $item) { $table1->head[0] = __('Events validated by user'); $table1->data[0][0] = $item['chart']['by_user_validator']; - $table->colspan['chart_by_user_validator']['cell'] = 3; - $table->cellstyle['chart_by_user_validator']['cell'] = 'text-align: center;'; - $table->data['chart_by_user_validator']['cell'] = html_print_table($table1, true); + if($pdf){ + $table1->class = 'table-beauty'; + $pdf_export .= html_print_table($table1, true); + $pdf_export .= '
'; + } + else{ + $table->colspan['chart_by_user_validator']['cell'] = 3; + $table->cellstyle['chart_by_user_validator']['cell'] = 'text-align: center;'; + $table->data['chart_by_user_validator']['cell'] = html_print_table($table1, true); + } } if (!empty($item['chart']['by_criticity'])) { @@ -1570,9 +1661,16 @@ function reporting_html_event_report_agent($table, $item) { $table1->head[0] = __('Events by severity'); $table1->data[0][0] = $item['chart']['by_criticity']; - $table->colspan['chart_by_criticity']['cell'] = 3; - $table->cellstyle['chart_by_criticity']['cell'] = 'text-align: center;'; - $table->data['chart_by_criticity']['cell'] = html_print_table($table1, true); + if($pdf){ + $table1->class = 'table-beauty'; + $pdf_export .= html_print_table($table1, true); + $pdf_export .= '
'; + } + else{ + $table->colspan['chart_by_criticity']['cell'] = 3; + $table->cellstyle['chart_by_criticity']['cell'] = 'text-align: center;'; + $table->data['chart_by_criticity']['cell'] = html_print_table($table1, true); + } } if (!empty($item['chart']['validated_vs_unvalidated'])) { @@ -1582,9 +1680,20 @@ function reporting_html_event_report_agent($table, $item) { $table1->head[0] = __('Amount events validated'); $table1->data[0][0] = $item['chart']['validated_vs_unvalidated']; - $table->colspan['chart_validated_vs_unvalidated']['cell'] = 3; - $table->cellstyle['chart_validated_vs_unvalidated']['cell'] = 'text-align: center;'; - $table->data['chart_validated_vs_unvalidated']['cell'] = html_print_table($table1, true); + if($pdf){ + $table1->class = 'table-beauty'; + $pdf_export .= html_print_table($table1, true); + $pdf_export .= '
'; + } + else{ + $table->colspan['chart_validated_vs_unvalidated']['cell'] = 3; + $table->cellstyle['chart_validated_vs_unvalidated']['cell'] = 'text-align: center;'; + $table->data['chart_validated_vs_unvalidated']['cell'] = html_print_table($table1, true); + } + } + + if($pdf){ + return $pdf_export; } } From 3f7109c347d60a632add2dcadb4f769f84f62a26 Mon Sep 17 00:00:00 2001 From: enriquecd Date: Wed, 18 Jan 2017 15:39:04 +0100 Subject: [PATCH 4/8] Improve visual console 2 - #15 --- .../visual_console_builder.editor.js | 4 +- .../themes/advanced/editor_template.js | 1509 ++++++++++++++++- 2 files changed, 1510 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index d40e20d9c0..fbac43f3cb 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -1265,7 +1265,7 @@ function hiddenFields(item) { $("#percentile_item_row_4." + item).css('display', ''); $("#period_row").css('display', 'none'); - $("#period_row." + item).css('display', ''); + $("#period_row." + item).css('display', 'none'); $("#size_row").css('display', 'none'); $("#size_row." + item).css('display', ''); @@ -1335,7 +1335,7 @@ function cleanFields(item) { $("input[name=top]").val(0); $("input[name=agent]").val(''); $("select[name=module]").val(''); - $("input[name=process_value]").val(''); + $("select[name=process_value]").val(0); $("select[name=background_image]").val(''); $("input[name=width_percentile]").val(''); $("input[name=max_percentile]").val(''); diff --git a/pandora_console/include/javascript/tiny_mce/themes/advanced/editor_template.js b/pandora_console/include/javascript/tiny_mce/themes/advanced/editor_template.js index 4b8d563757..7bf23855ab 100644 --- a/pandora_console/include/javascript/tiny_mce/themes/advanced/editor_template.js +++ b/pandora_console/include/javascript/tiny_mce/themes/advanced/editor_template.js @@ -1 +1,1508 @@ -(function(h){var i=h.DOM,g=h.dom.Event,c=h.extend,f=h.each,a=h.util.Cookie,e,d=h.explode;function b(p,m){var k,l,o=p.dom,j="",n,r;previewStyles=p.settings.preview_styles;if(previewStyles===false){return""}if(!previewStyles){previewStyles="font-family font-size font-weight text-decoration text-transform color background-color"}function q(s){return s.replace(/%(\w+)/g,"")}k=m.block||m.inline||"span";l=o.create(k);f(m.styles,function(t,s){t=q(t);if(t){o.setStyle(l,s,t)}});f(m.attributes,function(t,s){t=q(t);if(t){o.setAttrib(l,s,t)}});f(m.classes,function(s){s=q(s);if(!o.hasClass(l,s)){o.addClass(l,s)}});o.setStyles(l,{position:"absolute",left:-65535});p.getBody().appendChild(l);n=o.getStyle(p.getBody(),"fontSize",true);n=/px$/.test(n)?parseInt(n,10):0;f(previewStyles.split(" "),function(s){var t=o.getStyle(l,s,true);if(s=="background-color"&&/transparent|rgba\s*\([^)]+,\s*0\)/.test(t)){t=o.getStyle(p.getBody(),s,true);if(o.toHex(t).toLowerCase()=="#ffffff"){return}}if(s=="font-size"){if(/em|%$/.test(t)){if(n===0){return}t=parseFloat(t,10)/(/%$/.test(t)?100:1);t=(t*n)+"px"}}j+=s+":"+t+";"});o.remove(l);return j}h.ThemeManager.requireLangPack("advanced");h.create("tinymce.themes.AdvancedTheme",{sizes:[8,10,12,14,18,24,36],controls:{bold:["bold_desc","Bold"],italic:["italic_desc","Italic"],underline:["underline_desc","Underline"],strikethrough:["striketrough_desc","Strikethrough"],justifyleft:["justifyleft_desc","JustifyLeft"],justifycenter:["justifycenter_desc","JustifyCenter"],justifyright:["justifyright_desc","JustifyRight"],justifyfull:["justifyfull_desc","JustifyFull"],bullist:["bullist_desc","InsertUnorderedList"],numlist:["numlist_desc","InsertOrderedList"],outdent:["outdent_desc","Outdent"],indent:["indent_desc","Indent"],cut:["cut_desc","Cut"],copy:["copy_desc","Copy"],paste:["paste_desc","Paste"],undo:["undo_desc","Undo"],redo:["redo_desc","Redo"],link:["link_desc","mceLink"],unlink:["unlink_desc","unlink"],image:["image_desc","mceImage"],cleanup:["cleanup_desc","mceCleanup"],help:["help_desc","mceHelp"],code:["code_desc","mceCodeEditor"],hr:["hr_desc","InsertHorizontalRule"],removeformat:["removeformat_desc","RemoveFormat"],sub:["sub_desc","subscript"],sup:["sup_desc","superscript"],forecolor:["forecolor_desc","ForeColor"],forecolorpicker:["forecolor_desc","mceForeColor"],backcolor:["backcolor_desc","HiliteColor"],backcolorpicker:["backcolor_desc","mceBackColor"],charmap:["charmap_desc","mceCharMap"],visualaid:["visualaid_desc","mceToggleVisualAid"],anchor:["anchor_desc","mceInsertAnchor"],newdocument:["newdocument_desc","mceNewDocument"],blockquote:["blockquote_desc","mceBlockQuote"]},stateControls:["bold","italic","underline","strikethrough","bullist","numlist","justifyleft","justifycenter","justifyright","justifyfull","sub","sup","blockquote"],init:function(k,l){var m=this,n,j,p;m.editor=k;m.url=l;m.onResolveName=new h.util.Dispatcher(this);n=k.settings;k.forcedHighContrastMode=k.settings.detect_highcontrast&&m._isHighContrast();k.settings.skin=k.forcedHighContrastMode?"highcontrast":k.settings.skin;if(!n.theme_advanced_buttons1){n=c({theme_advanced_buttons1:"bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",theme_advanced_buttons3:"hr,removeformat,visualaid,|,sub,sup,|,charmap"},n)}m.settings=n=c({theme_advanced_path:true,theme_advanced_toolbar_location:"top",theme_advanced_blockformats:"p,address,pre,h1,h2,h3,h4,h5,h6",theme_advanced_toolbar_align:"left",theme_advanced_statusbar_location:"bottom",theme_advanced_fonts:"Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats",theme_advanced_more_colors:1,theme_advanced_row_height:23,theme_advanced_resize_horizontal:1,theme_advanced_resizing_use_cookie:1,theme_advanced_font_sizes:"1,2,3,4,5,6,7",theme_advanced_font_selector:"span",theme_advanced_show_current_color:0,readonly:k.settings.readonly},n);if(!n.font_size_style_values){n.font_size_style_values="8pt,10pt,12pt,14pt,18pt,24pt,36pt"}if(h.is(n.theme_advanced_font_sizes,"string")){n.font_size_style_values=h.explode(n.font_size_style_values);n.font_size_classes=h.explode(n.font_size_classes||"");p={};k.settings.theme_advanced_font_sizes=n.theme_advanced_font_sizes;f(k.getParam("theme_advanced_font_sizes","","hash"),function(r,q){var o;if(q==r&&r>=1&&r<=7){q=r+" ("+m.sizes[r-1]+"pt)";o=n.font_size_classes[r-1];r=n.font_size_style_values[r-1]||(m.sizes[r-1]+"pt")}if(/^\s*\./.test(r)){o=r.replace(/\./g,"")}p[q]=o?{"class":o}:{fontSize:r}});n.theme_advanced_font_sizes=p}if((j=n.theme_advanced_path_location)&&j!="none"){n.theme_advanced_statusbar_location=n.theme_advanced_path_location}if(n.theme_advanced_statusbar_location=="none"){n.theme_advanced_statusbar_location=0}if(k.settings.content_css!==false){k.contentCSS.push(k.baseURI.toAbsolute(l+"/skins/"+k.settings.skin+"/content.css"))}k.onInit.add(function(){if(!k.settings.readonly){k.onNodeChange.add(m._nodeChanged,m);k.onKeyUp.add(m._updateUndoStatus,m);k.onMouseUp.add(m._updateUndoStatus,m);k.dom.bind(k.dom.getRoot(),"dragend",function(){m._updateUndoStatus(k)})}});k.onSetProgressState.add(function(r,o,s){var t,u=r.id,q;if(o){m.progressTimer=setTimeout(function(){t=r.getContainer();t=t.insertBefore(i.create("DIV",{style:"position:relative"}),t.firstChild);q=i.get(r.id+"_tbl");i.add(t,"div",{id:u+"_blocker","class":"mceBlocker",style:{width:q.clientWidth+2,height:q.clientHeight+2}});i.add(t,"div",{id:u+"_progress","class":"mceProgress",style:{left:q.clientWidth/2,top:q.clientHeight/2}})},s||0)}else{i.remove(u+"_blocker");i.remove(u+"_progress");clearTimeout(m.progressTimer)}});i.loadCSS(n.editor_css?k.documentBaseURI.toAbsolute(n.editor_css):l+"/skins/"+k.settings.skin+"/ui.css");if(n.skin_variant){i.loadCSS(l+"/skins/"+k.settings.skin+"/ui_"+n.skin_variant+".css")}},_isHighContrast:function(){var j,k=i.add(i.getRoot(),"div",{style:"background-color: rgb(171,239,86);"});j=(i.getStyle(k,"background-color",true)+"").toLowerCase().replace(/ /g,"");i.remove(k);return j!="rgb(171,239,86)"&&j!="#abef56"},createControl:function(m,j){var k,l;if(l=j.createControl(m)){return l}switch(m){case"styleselect":return this._createStyleSelect();case"formatselect":return this._createBlockFormats();case"fontselect":return this._createFontSelect();case"fontsizeselect":return this._createFontSizeSelect();case"forecolor":return this._createForeColorMenu();case"backcolor":return this._createBackColorMenu()}if((k=this.controls[m])){return j.createButton(m,{title:"advanced."+k[0],cmd:k[1],ui:k[2],value:k[3]})}},execCommand:function(l,k,m){var j=this["_"+l];if(j){j.call(this,k,m);return true}return false},_importClasses:function(l){var j=this.editor,k=j.controlManager.get("styleselect");if(k.getLength()==0){f(j.dom.getClasses(),function(q,m){var p="style_"+m,n;n={inline:"span",attributes:{"class":q["class"]},selector:"*"};j.formatter.register(p,n);k.add(q["class"],p,{style:function(){return b(j,n)}})})}},_createStyleSelect:function(o){var l=this,j=l.editor,k=j.controlManager,m;m=k.createListBox("styleselect",{title:"advanced.style_select",onselect:function(q){var r,n=[],p;f(m.items,function(s){n.push(s.value)});j.focus();j.undoManager.add();r=j.formatter.matchAll(n);h.each(r,function(s){if(!q||s==q){if(s){j.formatter.remove(s)}p=true}});if(!p){j.formatter.apply(q)}j.undoManager.add();j.nodeChanged();return false}});j.onPreInit.add(function(){var p=0,n=j.getParam("style_formats");if(n){f(n,function(q){var r,s=0;f(q,function(){s++});if(s>1){r=q.name=q.name||"style_"+(p++);j.formatter.register(r,q);m.add(q.title,r,{style:function(){return b(j,q)}})}else{m.add(q.title)}})}else{f(j.getParam("theme_advanced_styles","","hash"),function(t,s){var r,q;if(t){r="style_"+(p++);q={inline:"span",classes:t,selector:"*"};j.formatter.register(r,q);m.add(l.editor.translate(s),r,{style:function(){return b(j,q)}})}})}});if(m.getLength()==0){m.onPostRender.add(function(p,q){if(!m.NativeListBox){g.add(q.id+"_text","focus",l._importClasses,l);g.add(q.id+"_text","mousedown",l._importClasses,l);g.add(q.id+"_open","focus",l._importClasses,l);g.add(q.id+"_open","mousedown",l._importClasses,l)}else{g.add(q.id,"focus",l._importClasses,l)}})}return m},_createFontSelect:function(){var l,k=this,j=k.editor;l=j.controlManager.createListBox("fontselect",{title:"advanced.fontdefault",onselect:function(m){var n=l.items[l.selectedIndex];if(!m&&n){j.execCommand("FontName",false,n.value);return}j.execCommand("FontName",false,m);l.select(function(o){return m==o});if(n&&n.value==m){l.select(null)}return false}});if(l){f(j.getParam("theme_advanced_fonts",k.settings.theme_advanced_fonts,"hash"),function(n,m){l.add(j.translate(m),n,{style:n.indexOf("dings")==-1?"font-family:"+n:""})})}return l},_createFontSizeSelect:function(){var m=this,k=m.editor,n,l=0,j=[];n=k.controlManager.createListBox("fontsizeselect",{title:"advanced.font_size",onselect:function(o){var p=n.items[n.selectedIndex];if(!o&&p){p=p.value;if(p["class"]){k.formatter.toggle("fontsize_class",{value:p["class"]});k.undoManager.add();k.nodeChanged()}else{k.execCommand("FontSize",false,p.fontSize)}return}if(o["class"]){k.focus();k.undoManager.add();k.formatter.toggle("fontsize_class",{value:o["class"]});k.undoManager.add();k.nodeChanged()}else{k.execCommand("FontSize",false,o.fontSize)}n.select(function(q){return o==q});if(p&&(p.value.fontSize==o.fontSize||p.value["class"]&&p.value["class"]==o["class"])){n.select(null)}return false}});if(n){f(m.settings.theme_advanced_font_sizes,function(p,o){var q=p.fontSize;if(q>=1&&q<=7){q=m.sizes[parseInt(q)-1]+"pt"}n.add(o,p,{style:"font-size:"+q,"class":"mceFontSize"+(l++)+(" "+(p["class"]||""))})})}return n},_createBlockFormats:function(){var l,j={p:"advanced.paragraph",address:"advanced.address",pre:"advanced.pre",h1:"advanced.h1",h2:"advanced.h2",h3:"advanced.h3",h4:"advanced.h4",h5:"advanced.h5",h6:"advanced.h6",div:"advanced.div",blockquote:"advanced.blockquote",code:"advanced.code",dt:"advanced.dt",dd:"advanced.dd",samp:"advanced.samp"},k=this;l=k.editor.controlManager.createListBox("formatselect",{title:"advanced.block",onselect:function(m){k.editor.execCommand("FormatBlock",false,m);return false}});if(l){f(k.editor.getParam("theme_advanced_blockformats",k.settings.theme_advanced_blockformats,"hash"),function(n,m){l.add(k.editor.translate(m!=n?m:j[n]),n,{"class":"mce_formatPreview mce_"+n,style:function(){return b(k.editor,{block:n})}})})}return l},_createForeColorMenu:function(){var n,k=this,l=k.settings,m={},j;if(l.theme_advanced_more_colors){m.more_colors_func=function(){k._mceColorPicker(0,{color:n.value,func:function(o){n.setColor(o)}})}}if(j=l.theme_advanced_text_colors){m.colors=j}if(l.theme_advanced_default_foreground_color){m.default_color=l.theme_advanced_default_foreground_color}m.title="advanced.forecolor_desc";m.cmd="ForeColor";m.scope=this;n=k.editor.controlManager.createColorSplitButton("forecolor",m);return n},_createBackColorMenu:function(){var n,k=this,l=k.settings,m={},j;if(l.theme_advanced_more_colors){m.more_colors_func=function(){k._mceColorPicker(0,{color:n.value,func:function(o){n.setColor(o)}})}}if(j=l.theme_advanced_background_colors){m.colors=j}if(l.theme_advanced_default_background_color){m.default_color=l.theme_advanced_default_background_color}m.title="advanced.backcolor_desc";m.cmd="HiliteColor";m.scope=this;n=k.editor.controlManager.createColorSplitButton("backcolor",m);return n},renderUI:function(l){var q,m,r,w=this,u=w.editor,x=w.settings,v,k,j;if(u.settings){u.settings.aria_label=x.aria_label+u.getLang("advanced.help_shortcut")}q=k=i.create("span",{role:"application","aria-labelledby":u.id+"_voice",id:u.id+"_parent","class":"mceEditor "+u.settings.skin+"Skin"+(x.skin_variant?" "+u.settings.skin+"Skin"+w._ufirst(x.skin_variant):"")+(u.settings.directionality=="rtl"?" mceRtl":"")});i.add(q,"span",{"class":"mceVoiceLabel",style:"display:none;",id:u.id+"_voice"},x.aria_label);if(!i.boxModel){q=i.add(q,"div",{"class":"mceOldBoxModel"})}q=v=i.add(q,"table",{role:"presentation",id:u.id+"_tbl","class":"mceLayout",cellSpacing:0,cellPadding:0});q=r=i.add(q,"tbody");switch((x.theme_advanced_layout_manager||"").toLowerCase()){case"rowlayout":m=w._rowLayout(x,r,l);break;case"customlayout":m=u.execCallback("theme_advanced_custom_layout",x,r,l,k);break;default:m=w._simpleLayout(x,r,l,k)}q=l.targetNode;j=v.rows;i.addClass(j[0],"mceFirst");i.addClass(j[j.length-1],"mceLast");f(i.select("tr",r),function(o){i.addClass(o.firstChild,"mceFirst");i.addClass(o.childNodes[o.childNodes.length-1],"mceLast")});if(i.get(x.theme_advanced_toolbar_container)){i.get(x.theme_advanced_toolbar_container).appendChild(k)}else{i.insertAfter(k,q)}g.add(u.id+"_path_row","click",function(n){n=n.target;if(n.nodeName=="A"){w._sel(n.className.replace(/^.*mcePath_([0-9]+).*$/,"$1"));return false}});if(!u.getParam("accessibility_focus")){g.add(i.add(k,"a",{href:"#"},""),"focus",function(){tinyMCE.get(u.id).focus()})}if(x.theme_advanced_toolbar_location=="external"){l.deltaHeight=0}w.deltaHeight=l.deltaHeight;l.targetNode=null;u.onKeyDown.add(function(p,n){var s=121,o=122;if(n.altKey){if(n.keyCode===s){if(h.isWebKit){window.focus()}w.toolbarGroup.focus();return g.cancel(n)}else{if(n.keyCode===o){i.get(p.id+"_path_row").focus();return g.cancel(n)}}}});u.addShortcut("alt+0","","mceShortcuts",w);return{iframeContainer:m,editorContainer:u.id+"_parent",sizeContainer:v,deltaHeight:l.deltaHeight}},getInfo:function(){return{longname:"Advanced theme",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",version:h.majorVersion+"."+h.minorVersion}},resizeBy:function(j,k){var l=i.get(this.editor.id+"_ifr");this.resizeTo(l.clientWidth+j,l.clientHeight+k)},resizeTo:function(j,n,l){var k=this.editor,m=this.settings,o=i.get(k.id+"_tbl"),p=i.get(k.id+"_ifr");j=Math.max(m.theme_advanced_resizing_min_width||100,j);n=Math.max(m.theme_advanced_resizing_min_height||100,n);j=Math.min(m.theme_advanced_resizing_max_width||65535,j);n=Math.min(m.theme_advanced_resizing_max_height||65535,n);i.setStyle(o,"height","");i.setStyle(p,"height",n);if(m.theme_advanced_resize_horizontal){i.setStyle(o,"width","");i.setStyle(p,"width",j);if(j"));i.setHTML(l,r.join(""))},_addStatusBar:function(p,k){var l,w=this,q=w.editor,x=w.settings,j,u,v,m;l=i.add(p,"tr");l=m=i.add(l,"td",{"class":"mceStatusbar"});l=i.add(l,"div",{id:q.id+"_path_row",role:"group","aria-labelledby":q.id+"_path_voice"});if(x.theme_advanced_path){i.add(l,"span",{id:q.id+"_path_voice"},q.translate("advanced.path"));i.add(l,"span",{},": ")}else{i.add(l,"span",{}," ")}if(x.theme_advanced_resizing){i.add(m,"a",{id:q.id+"_resize",href:"javascript:;",onclick:"return false;","class":"mceResize",tabIndex:"-1"});if(x.theme_advanced_resizing_use_cookie){q.onPostRender.add(function(){var n=a.getHash("TinyMCE_"+q.id+"_size"),r=i.get(q.id+"_tbl");if(!n){return}w.resizeTo(n.cw,n.ch)})}q.onPostRender.add(function(){g.add(q.id+"_resize","click",function(n){n.preventDefault()});g.add(q.id+"_resize","mousedown",function(E){var t,r,s,o,D,A,B,G,n,F,y;function z(H){H.preventDefault();n=B+(H.screenX-D);F=G+(H.screenY-A);w.resizeTo(n,F)}function C(H){g.remove(i.doc,"mousemove",t);g.remove(q.getDoc(),"mousemove",r);g.remove(i.doc,"mouseup",s);g.remove(q.getDoc(),"mouseup",o);n=B+(H.screenX-D);F=G+(H.screenY-A);w.resizeTo(n,F,true);q.nodeChanged()}E.preventDefault();D=E.screenX;A=E.screenY;y=i.get(w.editor.id+"_ifr");B=n=y.clientWidth;G=F=y.clientHeight;t=g.add(i.doc,"mousemove",z);r=g.add(q.getDoc(),"mousemove",z);s=g.add(i.doc,"mouseup",C);o=g.add(q.getDoc(),"mouseup",C)})})}k.deltaHeight-=21;l=p=null},_updateUndoStatus:function(k){var j=k.controlManager,l=k.undoManager;j.setDisabled("undo",!l.hasUndo()&&!l.typing);j.setDisabled("redo",!l.hasRedo())},_nodeChanged:function(o,u,E,r,F){var z=this,D,G=0,y,H,A=z.settings,x,l,w,C,m,k,j;h.each(z.stateControls,function(n){u.setActive(n,o.queryCommandState(z.controls[n][1]))});function q(p){var s,n=F.parents,t=p;if(typeof(p)=="string"){t=function(v){return v.nodeName==p}}for(s=0;s0){H.mark(p)}})}if(H=u.get("formatselect")){D=q(o.dom.isBlock);if(D){H.select(D.nodeName.toLowerCase())}}q(function(p){if(p.nodeName==="SPAN"){if(!x&&p.className){x=p.className}}if(o.dom.is(p,A.theme_advanced_font_selector)){if(!l&&p.style.fontSize){l=p.style.fontSize}if(!w&&p.style.fontFamily){w=p.style.fontFamily.replace(/[\"\']+/g,"").replace(/^([^,]+).*/,"$1").toLowerCase()}if(!C&&p.style.color){C=p.style.color}if(!m&&p.style.backgroundColor){m=p.style.backgroundColor}}return false});if(H=u.get("fontselect")){H.select(function(n){return n.replace(/^([^,]+).*/,"$1").toLowerCase()==w})}if(H=u.get("fontsizeselect")){if(A.theme_advanced_runtime_fontsize&&!l&&!x){l=o.dom.getStyle(E,"fontSize",true)}H.select(function(n){if(n.fontSize&&n.fontSize===l){return true}if(n["class"]&&n["class"]===x){return true}})}if(A.theme_advanced_show_current_color){function B(p,n){if(H=u.get(p)){if(!n){n=H.settings.default_color}if(n!==H.value){H.displayColor(n)}}}B("forecolor",C);B("backcolor",m)}if(A.theme_advanced_show_current_color){function B(p,n){if(H=u.get(p)){if(!n){n=H.settings.default_color}if(n!==H.value){H.displayColor(n)}}}B("forecolor",C);B("backcolor",m)}if(A.theme_advanced_path&&A.theme_advanced_statusbar_location){D=i.get(o.id+"_path")||i.add(o.id+"_path_row","span",{id:o.id+"_path"});if(z.statusKeyboardNavigation){z.statusKeyboardNavigation.destroy();z.statusKeyboardNavigation=null}i.setHTML(D,"");q(function(I){var p=I.nodeName.toLowerCase(),s,v,t="";if(I.nodeType!=1||p==="br"||I.getAttribute("data-mce-bogus")||i.hasClass(I,"mceItemHidden")||i.hasClass(I,"mceItemRemoved")){return}if(h.isIE&&I.scopeName!=="HTML"&&I.scopeName){p=I.scopeName+":"+p}p=p.replace(/mce\:/g,"");switch(p){case"b":p="strong";break;case"i":p="em";break;case"img":if(y=i.getAttrib(I,"src")){t+="src: "+y+" "}break;case"a":if(y=i.getAttrib(I,"name")){t+="name: "+y+" ";p+="#"+y}if(y=i.getAttrib(I,"href")){t+="href: "+y+" "}break;case"font":if(y=i.getAttrib(I,"face")){t+="font: "+y+" "}if(y=i.getAttrib(I,"size")){t+="size: "+y+" "}if(y=i.getAttrib(I,"color")){t+="color: "+y+" "}break;case"span":if(y=i.getAttrib(I,"style")){t+="style: "+y+" "}break}if(y=i.getAttrib(I,"id")){t+="id: "+y+" "}if(y=I.className){y=y.replace(/\b\s*(webkit|mce|Apple-)\w+\s*\b/g,"");if(y){t+="class: "+y+" ";if(o.dom.isBlock(I)||p=="img"||p=="span"){p+="."+y}}}p=p.replace(/(html:)/g,"");p={name:p,node:I,title:t};z.onResolveName.dispatch(z,p);t=p.title;p=p.name;v=i.create("a",{href:"javascript:;",role:"button",onmousedown:"return false;",title:t,"class":"mcePath_"+(G++)},p);if(D.hasChildNodes()){D.insertBefore(i.create("span",{"aria-hidden":"true"},"\u00a0\u00bb "),D.firstChild);D.insertBefore(v,D.firstChild)}else{D.appendChild(v)}},o.getBody());if(i.select("a",D).length>0){z.statusKeyboardNavigation=new h.ui.KeyboardNavigation({root:o.id+"_path_row",items:i.select("a",D),excludeFromTabOrder:true,onCancel:function(){o.focus()}},i)}}},_sel:function(j){this.editor.execCommand("mceSelectNodeDepth",false,j)},_mceInsertAnchor:function(l,k){var j=this.editor;j.windowManager.open({url:this.url+"/anchor.htm",width:320+parseInt(j.getLang("advanced.anchor_delta_width",0)),height:90+parseInt(j.getLang("advanced.anchor_delta_height",0)),inline:true},{theme_url:this.url})},_mceCharMap:function(){var j=this.editor;j.windowManager.open({url:this.url+"/charmap.htm",width:550+parseInt(j.getLang("advanced.charmap_delta_width",0)),height:265+parseInt(j.getLang("advanced.charmap_delta_height",0)),inline:true},{theme_url:this.url})},_mceHelp:function(){var j=this.editor;j.windowManager.open({url:this.url+"/about.htm",width:480,height:380,inline:true},{theme_url:this.url})},_mceShortcuts:function(){var j=this.editor;j.windowManager.open({url:this.url+"/shortcuts.htm",width:480,height:380,inline:true},{theme_url:this.url})},_mceColorPicker:function(l,k){var j=this.editor;k=k||{};j.windowManager.open({url:this.url+"/color_picker.htm",width:375+parseInt(j.getLang("advanced.colorpicker_delta_width",0)),height:250+parseInt(j.getLang("advanced.colorpicker_delta_height",0)),close_previous:false,inline:true},{input_color:k.color,func:k.func,theme_url:this.url})},_mceCodeEditor:function(k,l){var j=this.editor;j.windowManager.open({url:this.url+"/source_editor.htm",width:parseInt(j.getParam("theme_advanced_source_editor_width",720)),height:parseInt(j.getParam("theme_advanced_source_editor_height",580)),inline:true,resizable:true,maximizable:true},{theme_url:this.url})},_mceImage:function(k,l){var j=this.editor;if(j.dom.getAttrib(j.selection.getNode(),"class","").indexOf("mceItem")!=-1){return}j.windowManager.open({url:this.url+"/image.htm",width:355+parseInt(j.getLang("advanced.image_delta_width",0)),height:275+parseInt(j.getLang("advanced.image_delta_height",0)),inline:true},{theme_url:this.url})},_mceLink:function(k,l){var j=this.editor;j.windowManager.open({url:this.url+"/link.htm",width:310+parseInt(j.getLang("advanced.link_delta_width",0)),height:200+parseInt(j.getLang("advanced.link_delta_height",0)),inline:true},{theme_url:this.url})},_mceNewDocument:function(){var j=this.editor;j.windowManager.confirm("advanced.newdocument",function(k){if(k){j.execCommand("mceSetContent",false,"")}})},_mceForeColor:function(){var j=this;this._mceColorPicker(0,{color:j.fgColor,func:function(k){j.fgColor=k;j.editor.execCommand("ForeColor",false,k)}})},_mceBackColor:function(){var j=this;this._mceColorPicker(0,{color:j.bgColor,func:function(k){j.bgColor=k;j.editor.execCommand("HiliteColor",false,k)}})},_ufirst:function(j){return j.substring(0,1).toUpperCase()+j.substring(1)}});h.ThemeManager.add("advanced",h.themes.AdvancedTheme)}(tinymce)); \ No newline at end of file +/** + * editor_template_src.js + * + * Copyright 2009, Moxiecode Systems AB + * Released under LGPL License. + * + * License: http://tinymce.moxiecode.com/license + * Contributing: http://tinymce.moxiecode.com/contributing + */ + +(function(tinymce) { + var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, each = tinymce.each, Cookie = tinymce.util.Cookie, lastExtID, explode = tinymce.explode; + + // Generates a preview for a format + function getPreviewCss(ed, fmt) { + var name, previewElm, dom = ed.dom, previewCss = '', parentFontSize, previewStylesName; + + previewStyles = ed.settings.preview_styles; + + // No preview forced + if (previewStyles === false) + return ''; + + // Default preview + if (!previewStyles) + previewStyles = 'font-family font-size font-weight text-decoration text-transform color background-color'; + + // Removes any variables since these can't be previewed + function removeVars(val) { + return val.replace(/%(\w+)/g, ''); + }; + + // Create block/inline element to use for preview + name = fmt.block || fmt.inline || 'span'; + previewElm = dom.create(name); + + // Add format styles to preview element + each(fmt.styles, function(value, name) { + value = removeVars(value); + + if (value) + dom.setStyle(previewElm, name, value); + }); + + // Add attributes to preview element + each(fmt.attributes, function(value, name) { + value = removeVars(value); + + if (value) + dom.setAttrib(previewElm, name, value); + }); + + // Add classes to preview element + each(fmt.classes, function(value) { + value = removeVars(value); + + if (!dom.hasClass(previewElm, value)) + dom.addClass(previewElm, value); + }); + + // Add the previewElm outside the visual area + dom.setStyles(previewElm, {position: 'absolute', left: -0xFFFF}); + ed.getBody().appendChild(previewElm); + + // Get parent container font size so we can compute px values out of em/% for older IE:s + parentFontSize = dom.getStyle(ed.getBody(), 'fontSize', true); + parentFontSize = /px$/.test(parentFontSize) ? parseInt(parentFontSize, 10) : 0; + + each(previewStyles.split(' '), function(name) { + var value = dom.getStyle(previewElm, name, true); + + // If background is transparent then check if the body has a background color we can use + if (name == 'background-color' && /transparent|rgba\s*\([^)]+,\s*0\)/.test(value)) { + value = dom.getStyle(ed.getBody(), name, true); + + // Ignore white since it's the default color, not the nicest fix + if (dom.toHex(value).toLowerCase() == '#ffffff') { + return; + } + } + + // Old IE won't calculate the font size so we need to do that manually + if (name == 'font-size') { + if (/em|%$/.test(value)) { + if (parentFontSize === 0) { + return; + } + + // Convert font size from em/% to px + value = parseFloat(value, 10) / (/%$/.test(value) ? 100 : 1); + value = (value * parentFontSize) + 'px'; + } + } + + previewCss += name + ':' + value + ';'; + }); + + dom.remove(previewElm); + + return previewCss; + }; + + // Tell it to load theme specific language pack(s) + tinymce.ThemeManager.requireLangPack('advanced'); + + tinymce.create('tinymce.themes.AdvancedTheme', { + sizes : [8, 10, 12, 14, 18, 24, 36], + + // Control name lookup, format: title, command + controls : { + bold : ['bold_desc', 'Bold'], + italic : ['italic_desc', 'Italic'], + underline : ['underline_desc', 'Underline'], + strikethrough : ['striketrough_desc', 'Strikethrough'], + justifyleft : ['justifyleft_desc', 'JustifyLeft'], + justifycenter : ['justifycenter_desc', 'JustifyCenter'], + justifyright : ['justifyright_desc', 'JustifyRight'], + justifyfull : ['justifyfull_desc', 'JustifyFull'], + bullist : ['bullist_desc', 'InsertUnorderedList'], + numlist : ['numlist_desc', 'InsertOrderedList'], + outdent : ['outdent_desc', 'Outdent'], + indent : ['indent_desc', 'Indent'], + cut : ['cut_desc', 'Cut'], + copy : ['copy_desc', 'Copy'], + paste : ['paste_desc', 'Paste'], + undo : ['undo_desc', 'Undo'], + redo : ['redo_desc', 'Redo'], + link : ['link_desc', 'mceLink'], + unlink : ['unlink_desc', 'unlink'], + image : ['image_desc', 'mceImage'], + cleanup : ['cleanup_desc', 'mceCleanup'], + help : ['help_desc', 'mceHelp'], + code : ['code_desc', 'mceCodeEditor'], + hr : ['hr_desc', 'InsertHorizontalRule'], + removeformat : ['removeformat_desc', 'RemoveFormat'], + sub : ['sub_desc', 'subscript'], + sup : ['sup_desc', 'superscript'], + forecolor : ['forecolor_desc', 'ForeColor'], + forecolorpicker : ['forecolor_desc', 'mceForeColor'], + backcolor : ['backcolor_desc', 'HiliteColor'], + backcolorpicker : ['backcolor_desc', 'mceBackColor'], + charmap : ['charmap_desc', 'mceCharMap'], + visualaid : ['visualaid_desc', 'mceToggleVisualAid'], + anchor : ['anchor_desc', 'mceInsertAnchor'], + newdocument : ['newdocument_desc', 'mceNewDocument'], + blockquote : ['blockquote_desc', 'mceBlockQuote'] + }, + + stateControls : ['bold', 'italic', 'underline', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'sub', 'sup', 'blockquote'], + + init : function(ed, url) { + var t = this, s, v, o; + + t.editor = ed; + t.url = url; + t.onResolveName = new tinymce.util.Dispatcher(this); + s = ed.settings; + + ed.forcedHighContrastMode = ed.settings.detect_highcontrast && t._isHighContrast(); + ed.settings.skin = ed.forcedHighContrastMode ? 'highcontrast' : ed.settings.skin; + + // Setup default buttons + if (!s.theme_advanced_buttons1) { + s = extend({ + theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect", + theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code", + theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap" + }, s); + } + + // Default settings + t.settings = s = extend({ + theme_advanced_path : true, + theme_advanced_toolbar_location : 'top', + theme_advanced_blockformats : "p,address,pre,h1,h2,h3,h4,h5,h6", + theme_advanced_toolbar_align : "left", + theme_advanced_statusbar_location : "bottom", + //theme_advanced_fonts : "Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats", + theme_advanced_fonts : "Roboto=roboto;Lato=lato;Open sans=opensans;League gothic=leaguegothic", + theme_advanced_more_colors : 1, + theme_advanced_row_height : 23, + theme_advanced_resize_horizontal : 1, + theme_advanced_resizing_use_cookie : 1, + theme_advanced_font_sizes : "1,2,3,4,5,6,7", + theme_advanced_font_selector : "span", + theme_advanced_show_current_color: 0, + readonly : ed.settings.readonly + }, s); + + // Setup default font_size_style_values + if (!s.font_size_style_values) + s.font_size_style_values = "8pt,10pt,12pt,14pt,18pt,24pt,36pt"; + + if (tinymce.is(s.theme_advanced_font_sizes, 'string')) { + s.font_size_style_values = tinymce.explode(s.font_size_style_values); + s.font_size_classes = tinymce.explode(s.font_size_classes || ''); + + // Parse string value + o = {}; + ed.settings.theme_advanced_font_sizes = s.theme_advanced_font_sizes; + each(ed.getParam('theme_advanced_font_sizes', '', 'hash'), function(v, k) { + var cl; + + if (k == v && v >= 1 && v <= 7) { + k = v + ' (' + t.sizes[v - 1] + 'pt)'; + cl = s.font_size_classes[v - 1]; + v = s.font_size_style_values[v - 1] || (t.sizes[v - 1] + 'pt'); + } + + if (/^\s*\./.test(v)) + cl = v.replace(/\./g, ''); + + o[k] = cl ? {'class' : cl} : {fontSize : v}; + }); + + s.theme_advanced_font_sizes = o; + } + + if ((v = s.theme_advanced_path_location) && v != 'none') + s.theme_advanced_statusbar_location = s.theme_advanced_path_location; + + if (s.theme_advanced_statusbar_location == 'none') + s.theme_advanced_statusbar_location = 0; + + if (ed.settings.content_css !== false) + ed.contentCSS.push(ed.baseURI.toAbsolute(url + "/skins/" + ed.settings.skin + "/content.css")); + + // Init editor + ed.onInit.add(function() { + if (!ed.settings.readonly) { + ed.onNodeChange.add(t._nodeChanged, t); + ed.onKeyUp.add(t._updateUndoStatus, t); + ed.onMouseUp.add(t._updateUndoStatus, t); + ed.dom.bind(ed.dom.getRoot(), 'dragend', function() { + t._updateUndoStatus(ed); + }); + } + }); + + ed.onSetProgressState.add(function(ed, b, ti) { + var co, id = ed.id, tb; + + if (b) { + t.progressTimer = setTimeout(function() { + co = ed.getContainer(); + co = co.insertBefore(DOM.create('DIV', {style : 'position:relative'}), co.firstChild); + tb = DOM.get(ed.id + '_tbl'); + + DOM.add(co, 'div', {id : id + '_blocker', 'class' : 'mceBlocker', style : {width : tb.clientWidth + 2, height : tb.clientHeight + 2}}); + DOM.add(co, 'div', {id : id + '_progress', 'class' : 'mceProgress', style : {left : tb.clientWidth / 2, top : tb.clientHeight / 2}}); + }, ti || 0); + } else { + DOM.remove(id + '_blocker'); + DOM.remove(id + '_progress'); + clearTimeout(t.progressTimer); + } + }); + + DOM.loadCSS(s.editor_css ? ed.documentBaseURI.toAbsolute(s.editor_css) : url + "/skins/" + ed.settings.skin + "/ui.css"); + + if (s.skin_variant) + DOM.loadCSS(url + "/skins/" + ed.settings.skin + "/ui_" + s.skin_variant + ".css"); + }, + + _isHighContrast : function() { + var actualColor, div = DOM.add(DOM.getRoot(), 'div', {'style': 'background-color: rgb(171,239,86);'}); + + actualColor = (DOM.getStyle(div, 'background-color', true) + '').toLowerCase().replace(/ /g, ''); + DOM.remove(div); + + return actualColor != 'rgb(171,239,86)' && actualColor != '#abef56'; + }, + + createControl : function(n, cf) { + var cd, c; + + if (c = cf.createControl(n)) + return c; + + switch (n) { + case "styleselect": + return this._createStyleSelect(); + + case "formatselect": + return this._createBlockFormats(); + + case "fontselect": + return this._createFontSelect(); + + case "fontsizeselect": + return this._createFontSizeSelect(); + + case "forecolor": + return this._createForeColorMenu(); + + case "backcolor": + return this._createBackColorMenu(); + } + + if ((cd = this.controls[n])) + return cf.createButton(n, {title : "advanced." + cd[0], cmd : cd[1], ui : cd[2], value : cd[3]}); + }, + + execCommand : function(cmd, ui, val) { + var f = this['_' + cmd]; + + if (f) { + f.call(this, ui, val); + return true; + } + + return false; + }, + + _importClasses : function(e) { + var ed = this.editor, ctrl = ed.controlManager.get('styleselect'); + + if (ctrl.getLength() == 0) { + each(ed.dom.getClasses(), function(o, idx) { + var name = 'style_' + idx, fmt; + + fmt = { + inline : 'span', + attributes : {'class' : o['class']}, + selector : '*' + }; + + ed.formatter.register(name, fmt); + + ctrl.add(o['class'], name, { + style: function() { + return getPreviewCss(ed, fmt); + } + }); + }); + } + }, + + _createStyleSelect : function(n) { + var t = this, ed = t.editor, ctrlMan = ed.controlManager, ctrl; + + // Setup style select box + ctrl = ctrlMan.createListBox('styleselect', { + title : 'advanced.style_select', + onselect : function(name) { + var matches, formatNames = [], removedFormat; + + each(ctrl.items, function(item) { + formatNames.push(item.value); + }); + + ed.focus(); + ed.undoManager.add(); + + // Toggle off the current format(s) + matches = ed.formatter.matchAll(formatNames); + tinymce.each(matches, function(match) { + if (!name || match == name) { + if (match) + ed.formatter.remove(match); + + removedFormat = true; + } + }); + + if (!removedFormat) + ed.formatter.apply(name); + + ed.undoManager.add(); + ed.nodeChanged(); + + return false; // No auto select + } + }); + + // Handle specified format + ed.onPreInit.add(function() { + var counter = 0, formats = ed.getParam('style_formats'); + + if (formats) { + each(formats, function(fmt) { + var name, keys = 0; + + each(fmt, function() {keys++;}); + + if (keys > 1) { + name = fmt.name = fmt.name || 'style_' + (counter++); + ed.formatter.register(name, fmt); + ctrl.add(fmt.title, name, { + style: function() { + return getPreviewCss(ed, fmt); + } + }); + } else + ctrl.add(fmt.title); + }); + } else { + each(ed.getParam('theme_advanced_styles', '', 'hash'), function(val, key) { + var name, fmt; + + if (val) { + name = 'style_' + (counter++); + fmt = { + inline : 'span', + classes : val, + selector : '*' + }; + + ed.formatter.register(name, fmt); + ctrl.add(t.editor.translate(key), name, { + style: function() { + return getPreviewCss(ed, fmt); + } + }); + } + }); + } + }); + + // Auto import classes if the ctrl box is empty + if (ctrl.getLength() == 0) { + ctrl.onPostRender.add(function(ed, n) { + if (!ctrl.NativeListBox) { + Event.add(n.id + '_text', 'focus', t._importClasses, t); + Event.add(n.id + '_text', 'mousedown', t._importClasses, t); + Event.add(n.id + '_open', 'focus', t._importClasses, t); + Event.add(n.id + '_open', 'mousedown', t._importClasses, t); + } else + Event.add(n.id, 'focus', t._importClasses, t); + }); + } + + return ctrl; + }, + + _createFontSelect : function() { + var c, t = this, ed = t.editor; + + c = ed.controlManager.createListBox('fontselect', { + title : 'advanced.fontdefault', + onselect : function(v) { + var cur = c.items[c.selectedIndex]; + + if (!v && cur) { + ed.execCommand('FontName', false, cur.value); + return; + } + + ed.execCommand('FontName', false, v); + + // Fake selection, execCommand will fire a nodeChange and update the selection + c.select(function(sv) { + return v == sv; + }); + + if (cur && cur.value == v) { + c.select(null); + } + + return false; // No auto select + } + }); + + if (c) { + each(ed.getParam('theme_advanced_fonts', t.settings.theme_advanced_fonts, 'hash'), function(v, k) { + c.add(ed.translate(k), v, {style : v.indexOf('dings') == -1 ? 'font-family:' + v : ''}); + }); + } + + return c; + }, + + _createFontSizeSelect : function() { + var t = this, ed = t.editor, c, i = 0, cl = []; + + c = ed.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', onselect : function(v) { + var cur = c.items[c.selectedIndex]; + + if (!v && cur) { + cur = cur.value; + + if (cur['class']) { + ed.formatter.toggle('fontsize_class', {value : cur['class']}); + ed.undoManager.add(); + ed.nodeChanged(); + } else { + ed.execCommand('FontSize', false, cur.fontSize); + } + + return; + } + + if (v['class']) { + ed.focus(); + ed.undoManager.add(); + ed.formatter.toggle('fontsize_class', {value : v['class']}); + ed.undoManager.add(); + ed.nodeChanged(); + } else + ed.execCommand('FontSize', false, v.fontSize); + + // Fake selection, execCommand will fire a nodeChange and update the selection + c.select(function(sv) { + return v == sv; + }); + + if (cur && (cur.value.fontSize == v.fontSize || cur.value['class'] && cur.value['class'] == v['class'])) { + c.select(null); + } + + return false; // No auto select + }}); + + if (c) { + each(t.settings.theme_advanced_font_sizes, function(v, k) { + var fz = v.fontSize; + + if (fz >= 1 && fz <= 7) + fz = t.sizes[parseInt(fz) - 1] + 'pt'; + + c.add(k, v, {'style' : 'font-size:' + fz, 'class' : 'mceFontSize' + (i++) + (' ' + (v['class'] || ''))}); + }); + } + + return c; + }, + + _createBlockFormats : function() { + var c, fmts = { + p : 'advanced.paragraph', + address : 'advanced.address', + pre : 'advanced.pre', + h1 : 'advanced.h1', + h2 : 'advanced.h2', + h3 : 'advanced.h3', + h4 : 'advanced.h4', + h5 : 'advanced.h5', + h6 : 'advanced.h6', + div : 'advanced.div', + blockquote : 'advanced.blockquote', + code : 'advanced.code', + dt : 'advanced.dt', + dd : 'advanced.dd', + samp : 'advanced.samp' + }, t = this; + + c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', onselect : function(v) { + t.editor.execCommand('FormatBlock', false, v); + return false; + }}); + + if (c) { + each(t.editor.getParam('theme_advanced_blockformats', t.settings.theme_advanced_blockformats, 'hash'), function(v, k) { + c.add(t.editor.translate(k != v ? k : fmts[v]), v, {'class' : 'mce_formatPreview mce_' + v, style: function() { + return getPreviewCss(t.editor, {block: v}); + }}); + }); + } + + return c; + }, + + _createForeColorMenu : function() { + var c, t = this, s = t.settings, o = {}, v; + + if (s.theme_advanced_more_colors) { + o.more_colors_func = function() { + t._mceColorPicker(0, { + color : c.value, + func : function(co) { + c.setColor(co); + } + }); + }; + } + + if (v = s.theme_advanced_text_colors) + o.colors = v; + + if (s.theme_advanced_default_foreground_color) + o.default_color = s.theme_advanced_default_foreground_color; + + o.title = 'advanced.forecolor_desc'; + o.cmd = 'ForeColor'; + o.scope = this; + + c = t.editor.controlManager.createColorSplitButton('forecolor', o); + + return c; + }, + + _createBackColorMenu : function() { + var c, t = this, s = t.settings, o = {}, v; + + if (s.theme_advanced_more_colors) { + o.more_colors_func = function() { + t._mceColorPicker(0, { + color : c.value, + func : function(co) { + c.setColor(co); + } + }); + }; + } + + if (v = s.theme_advanced_background_colors) + o.colors = v; + + if (s.theme_advanced_default_background_color) + o.default_color = s.theme_advanced_default_background_color; + + o.title = 'advanced.backcolor_desc'; + o.cmd = 'HiliteColor'; + o.scope = this; + + c = t.editor.controlManager.createColorSplitButton('backcolor', o); + + return c; + }, + + renderUI : function(o) { + var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl; + + if (ed.settings) { + ed.settings.aria_label = s.aria_label + ed.getLang('advanced.help_shortcut'); + } + + // TODO: ACC Should have an aria-describedby attribute which is user-configurable to describe what this field is actually for. + // Maybe actually inherit it from the original textara? + n = p = DOM.create('span', {role : 'application', 'aria-labelledby' : ed.id + '_voice', id : ed.id + '_parent', 'class' : 'mceEditor ' + ed.settings.skin + 'Skin' + (s.skin_variant ? ' ' + ed.settings.skin + 'Skin' + t._ufirst(s.skin_variant) : '') + (ed.settings.directionality == "rtl" ? ' mceRtl' : '')}); + DOM.add(n, 'span', {'class': 'mceVoiceLabel', 'style': 'display:none;', id: ed.id + '_voice'}, s.aria_label); + + if (!DOM.boxModel) + n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'}); + + n = sc = DOM.add(n, 'table', {role : "presentation", id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0}); + n = tb = DOM.add(n, 'tbody'); + + switch ((s.theme_advanced_layout_manager || '').toLowerCase()) { + case "rowlayout": + ic = t._rowLayout(s, tb, o); + break; + + case "customlayout": + ic = ed.execCallback("theme_advanced_custom_layout", s, tb, o, p); + break; + + default: + ic = t._simpleLayout(s, tb, o, p); + } + + n = o.targetNode; + + // Add classes to first and last TRs + nl = sc.rows; + DOM.addClass(nl[0], 'mceFirst'); + DOM.addClass(nl[nl.length - 1], 'mceLast'); + + // Add classes to first and last TDs + each(DOM.select('tr', tb), function(n) { + DOM.addClass(n.firstChild, 'mceFirst'); + DOM.addClass(n.childNodes[n.childNodes.length - 1], 'mceLast'); + }); + + if (DOM.get(s.theme_advanced_toolbar_container)) + DOM.get(s.theme_advanced_toolbar_container).appendChild(p); + else + DOM.insertAfter(p, n); + + Event.add(ed.id + '_path_row', 'click', function(e) { + e = e.target; + + if (e.nodeName == 'A') { + t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/, '$1')); + return false; + } + }); +/* + if (DOM.get(ed.id + '_path_row')) { + Event.add(ed.id + '_tbl', 'mouseover', function(e) { + var re; + + e = e.target; + + if (e.nodeName == 'SPAN' && DOM.hasClass(e.parentNode, 'mceButton')) { + re = DOM.get(ed.id + '_path_row'); + t.lastPath = re.innerHTML; + DOM.setHTML(re, e.parentNode.title); + } + }); + + Event.add(ed.id + '_tbl', 'mouseout', function(e) { + if (t.lastPath) { + DOM.setHTML(ed.id + '_path_row', t.lastPath); + t.lastPath = 0; + } + }); + } +*/ + + if (!ed.getParam('accessibility_focus')) + Event.add(DOM.add(p, 'a', {href : '#'}, ''), 'focus', function() {tinyMCE.get(ed.id).focus();}); + + if (s.theme_advanced_toolbar_location == 'external') + o.deltaHeight = 0; + + t.deltaHeight = o.deltaHeight; + o.targetNode = null; + + ed.onKeyDown.add(function(ed, evt) { + var DOM_VK_F10 = 121, DOM_VK_F11 = 122; + + if (evt.altKey) { + if (evt.keyCode === DOM_VK_F10) { + // Make sure focus is given to toolbar in Safari. + // We can't do this in IE as it prevents giving focus to toolbar when editor is in a frame + if (tinymce.isWebKit) { + window.focus(); + } + t.toolbarGroup.focus(); + return Event.cancel(evt); + } else if (evt.keyCode === DOM_VK_F11) { + DOM.get(ed.id + '_path_row').focus(); + return Event.cancel(evt); + } + } + }); + + // alt+0 is the UK recommended shortcut for accessing the list of access controls. + ed.addShortcut('alt+0', '', 'mceShortcuts', t); + + return { + iframeContainer : ic, + editorContainer : ed.id + '_parent', + sizeContainer : sc, + deltaHeight : o.deltaHeight + }; + }, + + getInfo : function() { + return { + longname : 'Advanced theme', + author : 'Moxiecode Systems AB', + authorurl : 'http://tinymce.moxiecode.com', + version : tinymce.majorVersion + "." + tinymce.minorVersion + } + }, + + resizeBy : function(dw, dh) { + var e = DOM.get(this.editor.id + '_ifr'); + + this.resizeTo(e.clientWidth + dw, e.clientHeight + dh); + }, + + resizeTo : function(w, h, store) { + var ed = this.editor, s = this.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr'); + + // Boundery fix box + w = Math.max(s.theme_advanced_resizing_min_width || 100, w); + h = Math.max(s.theme_advanced_resizing_min_height || 100, h); + w = Math.min(s.theme_advanced_resizing_max_width || 0xFFFF, w); + h = Math.min(s.theme_advanced_resizing_max_height || 0xFFFF, h); + + // Resize iframe and container + DOM.setStyle(e, 'height', ''); + DOM.setStyle(ifr, 'height', h); + + if (s.theme_advanced_resize_horizontal) { + DOM.setStyle(e, 'width', ''); + DOM.setStyle(ifr, 'width', w); + + // Make sure that the size is never smaller than the over all ui + if (w < e.clientWidth) { + w = e.clientWidth; + DOM.setStyle(ifr, 'width', e.clientWidth); + } + } + + // Store away the size + if (store && s.theme_advanced_resizing_use_cookie) { + Cookie.setHash("TinyMCE_" + ed.id + "_size", { + cw : w, + ch : h + }); + } + }, + + destroy : function() { + var id = this.editor.id; + + Event.clear(id + '_resize'); + Event.clear(id + '_path_row'); + Event.clear(id + '_external_close'); + }, + + // Internal functions + + _simpleLayout : function(s, tb, o, p) { + var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c; + + if (s.readonly) { + n = DOM.add(tb, 'tr'); + n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); + return ic; + } + + // Create toolbar container at top + if (lo == 'top') + t._addToolbars(tb, o); + + // Create external toolbar + if (lo == 'external') { + n = c = DOM.create('div', {style : 'position:relative'}); + n = DOM.add(n, 'div', {id : ed.id + '_external', 'class' : 'mceExternalToolbar'}); + DOM.add(n, 'a', {id : ed.id + '_external_close', href : 'javascript:;', 'class' : 'mceExternalClose'}); + n = DOM.add(n, 'table', {id : ed.id + '_tblext', cellSpacing : 0, cellPadding : 0}); + etb = DOM.add(n, 'tbody'); + + if (p.firstChild.className == 'mceOldBoxModel') + p.firstChild.appendChild(c); + else + p.insertBefore(c, p.firstChild); + + t._addToolbars(etb, o); + + ed.onMouseUp.add(function() { + var e = DOM.get(ed.id + '_external'); + DOM.show(e); + + DOM.hide(lastExtID); + + var f = Event.add(ed.id + '_external_close', 'click', function() { + DOM.hide(ed.id + '_external'); + Event.remove(ed.id + '_external_close', 'click', f); + return false; + }); + + DOM.show(e); + DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1); + + // Fixes IE rendering bug + DOM.hide(e); + DOM.show(e); + e.style.filter = ''; + + lastExtID = ed.id + '_external'; + + e = null; + }); + } + + if (sl == 'top') + t._addStatusBar(tb, o); + + // Create iframe container + if (!s.theme_advanced_toolbar_container) { + n = DOM.add(tb, 'tr'); + n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); + } + + // Create toolbar container at bottom + if (lo == 'bottom') + t._addToolbars(tb, o); + + if (sl == 'bottom') + t._addStatusBar(tb, o); + + return ic; + }, + + _rowLayout : function(s, tb, o) { + var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to, a; + + dc = s.theme_advanced_containers_default_class || ''; + da = s.theme_advanced_containers_default_align || 'center'; + + each(explode(s.theme_advanced_containers || ''), function(c, i) { + var v = s['theme_advanced_container_' + c] || ''; + + switch (c.toLowerCase()) { + case 'mceeditor': + n = DOM.add(tb, 'tr'); + n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'}); + break; + + case 'mceelementpath': + t._addStatusBar(tb, o); + break; + + default: + a = (s['theme_advanced_container_' + c + '_align'] || da).toLowerCase(); + a = 'mce' + t._ufirst(a); + + n = DOM.add(DOM.add(tb, 'tr'), 'td', { + 'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + a || da + }); + + to = cf.createToolbar("toolbar" + i); + t._addControls(v, to); + DOM.setHTML(n, to.renderHTML()); + o.deltaHeight -= s.theme_advanced_row_height; + } + }); + + return ic; + }, + + _addControls : function(v, tb) { + var t = this, s = t.settings, di, cf = t.editor.controlManager; + + if (s.theme_advanced_disable && !t._disabled) { + di = {}; + + each(explode(s.theme_advanced_disable), function(v) { + di[v] = 1; + }); + + t._disabled = di; + } else + di = t._disabled; + + each(explode(v), function(n) { + var c; + + if (di && di[n]) + return; + + // Compatiblity with 2.x + if (n == 'tablecontrols') { + each(["table","|","row_props","cell_props","|","row_before","row_after","delete_row","|","col_before","col_after","delete_col","|","split_cells","merge_cells"], function(n) { + n = t.createControl(n, cf); + + if (n) + tb.add(n); + }); + + return; + } + + c = t.createControl(n, cf); + + if (c) + tb.add(c); + }); + }, + + _addToolbars : function(c, o) { + var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a, toolbarGroup, toolbarsExist = false; + + toolbarGroup = cf.createToolbarGroup('toolbargroup', { + 'name': ed.getLang('advanced.toolbar'), + 'tab_focus_toolbar':ed.getParam('theme_advanced_tab_focus_toolbar') + }); + + t.toolbarGroup = toolbarGroup; + + a = s.theme_advanced_toolbar_align.toLowerCase(); + a = 'mce' + t._ufirst(a); + + n = DOM.add(DOM.add(c, 'tr', {role: 'presentation'}), 'td', {'class' : 'mceToolbar ' + a, "role":"toolbar"}); + + // Create toolbar and add the controls + for (i=1; (v = s['theme_advanced_buttons' + i]); i++) { + toolbarsExist = true; + tb = cf.createToolbar("toolbar" + i, {'class' : 'mceToolbarRow' + i}); + + if (s['theme_advanced_buttons' + i + '_add']) + v += ',' + s['theme_advanced_buttons' + i + '_add']; + + if (s['theme_advanced_buttons' + i + '_add_before']) + v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v; + + t._addControls(v, tb); + toolbarGroup.add(tb); + + o.deltaHeight -= s.theme_advanced_row_height; + } + // Handle case when there are no toolbar buttons and ensure editor height is adjusted accordingly + if (!toolbarsExist) + o.deltaHeight -= s.theme_advanced_row_height; + h.push(toolbarGroup.renderHTML()); + h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '')); + DOM.setHTML(n, h.join('')); + }, + + _addStatusBar : function(tb, o) { + var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td; + + n = DOM.add(tb, 'tr'); + n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'}); + n = DOM.add(n, 'div', {id : ed.id + '_path_row', 'role': 'group', 'aria-labelledby': ed.id + '_path_voice'}); + if (s.theme_advanced_path) { + DOM.add(n, 'span', {id: ed.id + '_path_voice'}, ed.translate('advanced.path')); + DOM.add(n, 'span', {}, ': '); + } else { + DOM.add(n, 'span', {}, ' '); + } + + + if (s.theme_advanced_resizing) { + DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize', tabIndex:"-1"}); + + if (s.theme_advanced_resizing_use_cookie) { + ed.onPostRender.add(function() { + var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl'); + + if (!o) + return; + + t.resizeTo(o.cw, o.ch); + }); + } + + ed.onPostRender.add(function() { + Event.add(ed.id + '_resize', 'click', function(e) { + e.preventDefault(); + }); + + Event.add(ed.id + '_resize', 'mousedown', function(e) { + var mouseMoveHandler1, mouseMoveHandler2, + mouseUpHandler1, mouseUpHandler2, + startX, startY, startWidth, startHeight, width, height, ifrElm; + + function resizeOnMove(e) { + e.preventDefault(); + + width = startWidth + (e.screenX - startX); + height = startHeight + (e.screenY - startY); + + t.resizeTo(width, height); + }; + + function endResize(e) { + // Stop listening + Event.remove(DOM.doc, 'mousemove', mouseMoveHandler1); + Event.remove(ed.getDoc(), 'mousemove', mouseMoveHandler2); + Event.remove(DOM.doc, 'mouseup', mouseUpHandler1); + Event.remove(ed.getDoc(), 'mouseup', mouseUpHandler2); + + width = startWidth + (e.screenX - startX); + height = startHeight + (e.screenY - startY); + t.resizeTo(width, height, true); + + ed.nodeChanged(); + }; + + e.preventDefault(); + + // Get the current rect size + startX = e.screenX; + startY = e.screenY; + ifrElm = DOM.get(t.editor.id + '_ifr'); + startWidth = width = ifrElm.clientWidth; + startHeight = height = ifrElm.clientHeight; + + // Register envent handlers + mouseMoveHandler1 = Event.add(DOM.doc, 'mousemove', resizeOnMove); + mouseMoveHandler2 = Event.add(ed.getDoc(), 'mousemove', resizeOnMove); + mouseUpHandler1 = Event.add(DOM.doc, 'mouseup', endResize); + mouseUpHandler2 = Event.add(ed.getDoc(), 'mouseup', endResize); + }); + }); + } + + o.deltaHeight -= 21; + n = tb = null; + }, + + _updateUndoStatus : function(ed) { + var cm = ed.controlManager, um = ed.undoManager; + + cm.setDisabled('undo', !um.hasUndo() && !um.typing); + cm.setDisabled('redo', !um.hasRedo()); + }, + + _nodeChanged : function(ed, cm, n, co, ob) { + var t = this, p, de = 0, v, c, s = t.settings, cl, fz, fn, fc, bc, formatNames, matches; + + tinymce.each(t.stateControls, function(c) { + cm.setActive(c, ed.queryCommandState(t.controls[c][1])); + }); + + function getParent(name) { + var i, parents = ob.parents, func = name; + + if (typeof(name) == 'string') { + func = function(node) { + return node.nodeName == name; + }; + } + + for (i = 0; i < parents.length; i++) { + if (func(parents[i])) + return parents[i]; + } + }; + + cm.setActive('visualaid', ed.hasVisual); + t._updateUndoStatus(ed); + cm.setDisabled('outdent', !ed.queryCommandState('Outdent')); + + p = getParent('A'); + if (c = cm.get('link')) { + c.setDisabled((!p && co) || (p && !p.href)); + c.setActive(!!p && (!p.name && !p.id)); + } + + if (c = cm.get('unlink')) { + c.setDisabled(!p && co); + c.setActive(!!p && !p.name && !p.id); + } + + if (c = cm.get('anchor')) { + c.setActive(!co && !!p && (p.name || (p.id && !p.href))); + } + + p = getParent('IMG'); + if (c = cm.get('image')) + c.setActive(!co && !!p && n.className.indexOf('mceItem') == -1); + + if (c = cm.get('styleselect')) { + t._importClasses(); + + formatNames = []; + each(c.items, function(item) { + formatNames.push(item.value); + }); + + matches = ed.formatter.matchAll(formatNames); + c.select(matches[0]); + tinymce.each(matches, function(match, index) { + if (index > 0) { + c.mark(match); + } + }); + } + + if (c = cm.get('formatselect')) { + p = getParent(ed.dom.isBlock); + + if (p) + c.select(p.nodeName.toLowerCase()); + } + + // Find out current fontSize, fontFamily and fontClass + getParent(function(n) { + if (n.nodeName === 'SPAN') { + if (!cl && n.className) + cl = n.className; + } + + if (ed.dom.is(n, s.theme_advanced_font_selector)) { + if (!fz && n.style.fontSize) + fz = n.style.fontSize; + + if (!fn && n.style.fontFamily) + $( "#text-label_ifr" ).contents().find( "span" ).css("font-family",n.style.fontFamily); + $( "#text-label_ifr" ).contents().find( "em" ).css("font-family",n.style.fontFamily); + $( "#text-label_ifr").contents().find( "strong" ).css("font-family",n.style.fontFamily); + + $( "#text-label_ifr" ).contents().find( "span" ).attr("data-mce-style","color:"+n.style.color+";font-family:"+n.style.fontFamily+";"); + $( "#text-label_ifr" ).contents().find( "em" ).attr("data-mce-style","color:"+n.style.color+";font-family:"+n.style.fontFamily+";"); + $( "#text-label_ifr").contents().find( "strong" ).attr("data-mce-style","color:"+n.style.color+";font-family:"+n.style.fontFamily+";"); + + fn = n.style.fontFamily.replace(/[\"\']+/g, '').replace(/^([^,]+).*/, '$1').toLowerCase(); + + if (!fc && n.style.color) + + $( "#text-label_ifr" ).contents().find( "span" ).css("color",n.style.color); + $( "#text-label_ifr" ).contents().find( "em" ).css("color",n.style.color); + $( "#text-label_ifr").contents().find( "strong" ).css("color",n.style.color); + + $( "#text-label_ifr" ).contents().find( "span" ).attr("data-mce-style","color:"+n.style.color+";font-family:"+n.style.fontFamily+";"); + $( "#text-label_ifr" ).contents().find( "em" ).attr("data-mce-style","color:"+n.style.color+";font-family:"+n.style.fontFamily+";"); + $( "#text-label_ifr").contents().find( "strong" ).attr("data-mce-style","color:"+n.style.color+";font-family:"+n.style.fontFamily+";"); + + fc = n.style.color; + + if (!bc && n.style.backgroundColor) + bc = n.style.backgroundColor; + } + + return false; + }); + + if (c = cm.get('fontselect')) { + c.select(function(v) { + return v.replace(/^([^,]+).*/, '$1').toLowerCase() == fn; + }); + } + + // Select font size + if (c = cm.get('fontsizeselect')) { + // Use computed style + if (s.theme_advanced_runtime_fontsize && !fz && !cl) + fz = ed.dom.getStyle(n, 'fontSize', true); + + c.select(function(v) { + if (v.fontSize && v.fontSize === fz) + return true; + + if (v['class'] && v['class'] === cl) + return true; + }); + } + + if (s.theme_advanced_show_current_color) { + function updateColor(controlId, color) { + if (c = cm.get(controlId)) { + if (!color) + color = c.settings.default_color; + if (color !== c.value) { + c.displayColor(color); + } + } + } + updateColor('forecolor', fc); + updateColor('backcolor', bc); + } + + if (s.theme_advanced_show_current_color) { + function updateColor(controlId, color) { + if (c = cm.get(controlId)) { + if (!color) + color = c.settings.default_color; + if (color !== c.value) { + c.displayColor(color); + } + } + }; + + updateColor('forecolor', fc); + updateColor('backcolor', bc); + } + + if (s.theme_advanced_path && s.theme_advanced_statusbar_location) { + p = DOM.get(ed.id + '_path') || DOM.add(ed.id + '_path_row', 'span', {id : ed.id + '_path'}); + + if (t.statusKeyboardNavigation) { + t.statusKeyboardNavigation.destroy(); + t.statusKeyboardNavigation = null; + } + + DOM.setHTML(p, ''); + + getParent(function(n) { + var na = n.nodeName.toLowerCase(), u, pi, ti = ''; + + // Ignore non element and bogus/hidden elements + if (n.nodeType != 1 || na === 'br' || n.getAttribute('data-mce-bogus') || DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved')) + return; + + // Handle prefix + if (tinymce.isIE && n.scopeName !== 'HTML' && n.scopeName) + na = n.scopeName + ':' + na; + + // Remove internal prefix + na = na.replace(/mce\:/g, ''); + + // Handle node name + switch (na) { + case 'b': + na = 'strong'; + break; + + case 'i': + na = 'em'; + break; + + case 'img': + if (v = DOM.getAttrib(n, 'src')) + ti += 'src: ' + v + ' '; + + break; + + case 'a': + if (v = DOM.getAttrib(n, 'name')) { + ti += 'name: ' + v + ' '; + na += '#' + v; + } + + if (v = DOM.getAttrib(n, 'href')) + ti += 'href: ' + v + ' '; + + break; + + case 'font': + if (v = DOM.getAttrib(n, 'face')) + ti += 'font: ' + v + ' '; + + if (v = DOM.getAttrib(n, 'size')) + ti += 'size: ' + v + ' '; + + if (v = DOM.getAttrib(n, 'color')) + ti += 'color: ' + v + ' '; + + break; + + case 'span': + if (v = DOM.getAttrib(n, 'style')) + ti += 'style: ' + v + ' '; + + break; + } + + if (v = DOM.getAttrib(n, 'id')) + ti += 'id: ' + v + ' '; + + if (v = n.className) { + v = v.replace(/\b\s*(webkit|mce|Apple-)\w+\s*\b/g, ''); + + if (v) { + ti += 'class: ' + v + ' '; + + if (ed.dom.isBlock(n) || na == 'img' || na == 'span') + na += '.' + v; + } + } + + na = na.replace(/(html:)/g, ''); + na = {name : na, node : n, title : ti}; + t.onResolveName.dispatch(t, na); + ti = na.title; + na = na.name; + + //u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');"; + pi = DOM.create('a', {'href' : "javascript:;", role: 'button', onmousedown : "return false;", title : ti, 'class' : 'mcePath_' + (de++)}, na); + + if (p.hasChildNodes()) { + p.insertBefore(DOM.create('span', {'aria-hidden': 'true'}, '\u00a0\u00bb '), p.firstChild); + p.insertBefore(pi, p.firstChild); + } else + p.appendChild(pi); + }, ed.getBody()); + + if (DOM.select('a', p).length > 0) { + t.statusKeyboardNavigation = new tinymce.ui.KeyboardNavigation({ + root: ed.id + "_path_row", + items: DOM.select('a', p), + excludeFromTabOrder: true, + onCancel: function() { + ed.focus(); + } + }, DOM); + } + } + }, + + // Commands gets called by execCommand + + _sel : function(v) { + this.editor.execCommand('mceSelectNodeDepth', false, v); + }, + + _mceInsertAnchor : function(ui, v) { + var ed = this.editor; + + ed.windowManager.open({ + url : this.url + '/anchor.htm', + width : 320 + parseInt(ed.getLang('advanced.anchor_delta_width', 0)), + height : 90 + parseInt(ed.getLang('advanced.anchor_delta_height', 0)), + inline : true + }, { + theme_url : this.url + }); + }, + + _mceCharMap : function() { + var ed = this.editor; + + ed.windowManager.open({ + url : this.url + '/charmap.htm', + width : 550 + parseInt(ed.getLang('advanced.charmap_delta_width', 0)), + height : 265 + parseInt(ed.getLang('advanced.charmap_delta_height', 0)), + inline : true + }, { + theme_url : this.url + }); + }, + + _mceHelp : function() { + var ed = this.editor; + + ed.windowManager.open({ + url : this.url + '/about.htm', + width : 480, + height : 380, + inline : true + }, { + theme_url : this.url + }); + }, + + _mceShortcuts : function() { + var ed = this.editor; + ed.windowManager.open({ + url: this.url + '/shortcuts.htm', + width: 480, + height: 380, + inline: true + }, { + theme_url: this.url + }); + }, + + _mceColorPicker : function(u, v) { + var ed = this.editor; + + v = v || {}; + + ed.windowManager.open({ + url : this.url + '/color_picker.htm', + width : 375 + parseInt(ed.getLang('advanced.colorpicker_delta_width', 0)), + height : 250 + parseInt(ed.getLang('advanced.colorpicker_delta_height', 0)), + close_previous : false, + inline : true + }, { + input_color : v.color, + func : v.func, + theme_url : this.url + }); + }, + + _mceCodeEditor : function(ui, val) { + var ed = this.editor; + + ed.windowManager.open({ + url : this.url + '/source_editor.htm', + width : parseInt(ed.getParam("theme_advanced_source_editor_width", 720)), + height : parseInt(ed.getParam("theme_advanced_source_editor_height", 580)), + inline : true, + resizable : true, + maximizable : true + }, { + theme_url : this.url + }); + }, + + _mceImage : function(ui, val) { + var ed = this.editor; + + // Internal image object like a flash placeholder + if (ed.dom.getAttrib(ed.selection.getNode(), 'class', '').indexOf('mceItem') != -1) + return; + + ed.windowManager.open({ + url : this.url + '/image.htm', + width : 355 + parseInt(ed.getLang('advanced.image_delta_width', 0)), + height : 275 + parseInt(ed.getLang('advanced.image_delta_height', 0)), + inline : true + }, { + theme_url : this.url + }); + }, + + _mceLink : function(ui, val) { + var ed = this.editor; + + ed.windowManager.open({ + url : this.url + '/link.htm', + width : 310 + parseInt(ed.getLang('advanced.link_delta_width', 0)), + height : 200 + parseInt(ed.getLang('advanced.link_delta_height', 0)), + inline : true + }, { + theme_url : this.url + }); + }, + + _mceNewDocument : function() { + var ed = this.editor; + + ed.windowManager.confirm('advanced.newdocument', function(s) { + if (s) + ed.execCommand('mceSetContent', false, ''); + }); + }, + + _mceForeColor : function() { + var t = this; + + this._mceColorPicker(0, { + color: t.fgColor, + func : function(co) { + t.fgColor = co; + t.editor.execCommand('ForeColor', false, co); + } + }); + }, + + _mceBackColor : function() { + var t = this; + + this._mceColorPicker(0, { + color: t.bgColor, + func : function(co) { + t.bgColor = co; + t.editor.execCommand('HiliteColor', false, co); + } + }); + }, + + _ufirst : function(s) { + return s.substring(0, 1).toUpperCase() + s.substring(1); + } + }); + + tinymce.ThemeManager.add('advanced', tinymce.themes.AdvancedTheme); +}(tinymce)); From c8a33eb1159c181d3bb5caa71474d585547d1e66 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 18 Jan 2017 17:20:55 +0100 Subject: [PATCH 5/8] ip dinamic in policies --- .../agentes/module_manager_editor_network.php | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index c0a938e1c1..24d0105d42 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -66,10 +66,36 @@ $extra_title = __('Network server module'); $data = array (); $data[0] = __('Target IP'); //show agent_for defect; -if($ip_target == 'auto'){ - $ip_target = agents_get_address ($id_agente); + +if($page == 'enterprise/godmode/policies/policy_modules'){ + + if($ip_target != 'auto' && $ip_target != ''){ + $custom_ip_target = $ip_target; + $ip_target = 'custom'; + } + elseif($ip_target == ''){ + $ip_target = 'force_pri'; + $custom_ip_target = ''; + } + else{ + $custom_ip_target = ''; + } + + $target_ip_values = array(); + $target_ip_values['auto'] = __('Auto'); + $target_ip_values['force_pri'] = __('Force primary key'); + $target_ip_values['custom'] = __('Custom'); + + $data[1] = html_print_select ($target_ip_values, 'ip_target', $ip_target, '', '', '', + true, false, false, '', false, 'width:200px;'); + $data[1] .= html_print_input_text ('custom_ip_target', $custom_ip_target, '', 15, 60, true); +} +else{ + if($ip_target == 'auto'){ + $ip_target = agents_get_address ($id_agente); + } + $data[1] = html_print_input_text ('ip_target', $ip_target, '', 15, 60, true); } -$data[1] = html_print_input_text ('ip_target', $ip_target, '', 15, 60, true); // In ICMP modules, port is not configurable if ($id_module_type >= 6 && $id_module_type <= 7) { @@ -351,6 +377,18 @@ $(document).ready (function () { $('#snmp3_browser_privacy_pass').keyup(function() { $('#snmp3_privacy_pass').val($(this).val()); }); + var custom_ip_target = ""; + if(custom_ip_target == ''){ + $("#text-custom_ip_target").hide(); + } + $('#ip_target').change(function() { + if($(this).val() == 'custom') { + $("#text-custom_ip_target").show(); + } + else{ + $("#text-custom_ip_target").hide(); + } + }); }); // Show the SNMP browser window From fea876396a922e7d6a29273cd3131905763764d7 Mon Sep 17 00:00:00 2001 From: artica Date: Thu, 19 Jan 2017 00:01:12 +0100 Subject: [PATCH 6/8] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_console/pandoradb.data.oracle.sql | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index c73f075d40..3b41691fd7 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0dev-170118 +Version: 7.0dev-170119 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index d98f0772d4..96f3b28ecf 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0dev-170118" +pandora_version="7.0dev-170119" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 53a1c460f3..e44044b444 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0dev'; -use constant AGENT_BUILD => '170118'; +use constant AGENT_BUILD => '170119'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 5829120cab..0ae1fc0365 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0dev -%define release 170118 +%define release 170119 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 17faad82da..a8446ca7e4 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0dev -%define release 170118 +%define release 170119 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 41a5e4464f..22c31047de 100644 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0dev" -PI_BUILD="170118" +PI_BUILD="170119" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 4427733bdc..fb03a6b1ed 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{170118} +{170119} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 7655b03573..90f16ee923 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0dev(Build 170118)") +#define PANDORA_VERSION ("7.0dev(Build 170119)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 3867de9a7d..27e8efd193 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0dev(Build 170118))" + VALUE "ProductVersion", "(7.0dev(Build 170119))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 6ac8e0fe3a..965d4867c9 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0dev-170118 +Version: 7.0dev-170119 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index e54bc39475..da0e912778 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0dev-170118" +pandora_version="7.0dev-170119" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index ca9eb772f0..9fb228c6e6 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC170118'; +$build_version = 'PC170119'; $pandora_version = 'v7.0dev'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 529c590c1f..c9409d7a5c 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
Date: Thu, 19 Jan 2017 12:44:44 +0100 Subject: [PATCH 7/8] fixed errors in tree-view --- pandora_console/include/class/Tree.class.php | 2 +- pandora_console/include/functions_treeview.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index 8d2fc0c0e5..9c273e7962 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -1435,7 +1435,7 @@ class Tree { $module['type'] = 'module'; $module['id'] = (int) $module['id']; - $module['name'] = $module['name']; + $module['name'] = io_safe_output($module['name']); $module['id_module_type'] = (int) $module['id_tipo_modulo']; $module['server_type'] = (int) $module['id_modulo']; $module['status'] = $module['estado']; diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index d18d625a00..047be52917 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -71,9 +71,9 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head = //Module name if ($module["disabled"]) - $cellName = "" . ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . ""; + $cellName = "" . ui_print_truncate_text (io_safe_output($module["nombre"]), GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . ""; else - $cellName = ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;"); + $cellName = ui_print_truncate_text (io_safe_output($module["nombre"]), GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;"); $row = array(); $row['title'] = __('Name'); From f3d18132f36533c9b843dfdb31d14cf3efaf82d4 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 19 Jan 2017 13:24:57 +0100 Subject: [PATCH 8/8] fixed minor error in net_tool --- pandora_console/extensions/net_tools.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora_console/extensions/net_tools.php b/pandora_console/extensions/net_tools.php index f3fc3a9a74..fcd54fbfdc 100644 --- a/pandora_console/extensions/net_tools.php +++ b/pandora_console/extensions/net_tools.php @@ -292,7 +292,8 @@ function godmode_net_tools() { else { if (isset($config['network_tools_config'])) { - $network_tools_config = json_decode($config['network_tools_config'], true); + $network_tools_config_output = io_safe_output($config['network_tools_config']); + $network_tools_config = json_decode($network_tools_config_output, true); $traceroute_path = $network_tools_config['traceroute_path']; $ping_path = $network_tools_config['ping_path']; $nmap_path = $network_tools_config['nmap_path'];