diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index c7839674da..3f46325f58 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2013-10-14 Miguel de Dios + + * operation/events/events.build_query.php, + operation/events/events_list.php, operation/events/events.php: added + the filter for events of group childrens of parent group selected. + 2013-10-14 Sergio Martin * include/functions_events.php diff --git a/pandora_console/operation/events/events.build_query.php b/pandora_console/operation/events/events.build_query.php index 54e0347c05..66208ca26b 100755 --- a/pandora_console/operation/events/events.build_query.php +++ b/pandora_console/operation/events/events.build_query.php @@ -24,8 +24,22 @@ if ($id_group > 0 && in_array ($id_group, array_keys ($groups))) { $sql_post = " AND group_name = '$group_name'"; } else { - //If a group is selected and it's in the groups allowed - $sql_post = " AND id_grupo = $id_group"; + if ($recursion) { + $childrens_ids = array($id_group); + + $childrens = groups_get_childrens($id_group); + if (!empty($childrens)) { + foreach ($childrens as $child) { + $childrens_ids[] = $child['id_grupo']; + } + } + + $sql_post = " AND id_grupo IN (" . implode(',', $childrens_ids) . ")"; + } + else { + //If a group is selected and it's in the groups allowed + $sql_post = " AND id_grupo = $id_group"; + } } } else { diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 3183fb7920..5fe3c9088a 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -181,6 +181,14 @@ if (is_ajax ()) { $offset = (int) get_parameter ("offset", 0); $id_group = (int) get_parameter('id_group', 0);//0 all +//********************************************************************** +// TODO +// This code is disabled for to enabled in Pandora 5.1 +// but it needs a field in tevent_filter. +// +//$recursion = (bool)get_parameter('recursion', false); //Flag show in child groups +//********************************************************************** +$recursion = (bool)get_parameter('recursion', true); //Flag show in child groups $event_type = get_parameter ("event_type", ''); // 0 all $severity = (int) get_parameter ("severity", -1); // -1 all $status = (int) get_parameter ("status", 3); // -1 all, 0 only new, 1 only validated, 2 only in process, 3 only not validated, @@ -225,6 +233,7 @@ $params = "search=" . rawurlencode(io_safe_input($search)) . "&severity=" . $severity . "&status=" . $status . "&id_group=" . $id_group . + "&recursion=" . $recursion . "&refr=" . (int)get_parameter("refr", 0) . "&id_agent=" . $id_agent . "&pagination=" . $pagination . @@ -238,7 +247,6 @@ $params = "search=" . rawurlencode(io_safe_input($search)) . "&toogle_filter=no" . "&filter_id=" . $filter_id . "&id_name=" . $id_name . - "&id_group=" . $id_group . "&history=" . (int)$history . "&section=" . $section . "&open_filter=" . $open_filter . @@ -435,13 +443,13 @@ if ($delete) { __('Successfully deleted'), __('Could not be deleted')); } - require_once($config['homedir'].'/operation/events/events_list.php'); + require_once($config['homedir'] . '/operation/events/events_list.php'); } else { switch ($section) { case 'list': case 'history': - require_once($config['homedir'].'/operation/events/events_list.php'); + require_once($config['homedir'] . '/operation/events/events_list.php'); break; } } @@ -473,16 +481,16 @@ $(document).ready( function() { $("input[name='validate_ids[]']").change (function() { var canDeleted = 1; $("input[name='validate_ids[]']").each(function() { - if($(this).attr('checked') == 'checked') { + if ($(this).attr('checked') == 'checked') { var classs = $(this).attr('class'); classs = classs.split(' '); - if(classs[0] != 'candeleted') { + if (classs[0] != 'candeleted') { canDeleted = 0; } } }); - if(canDeleted == 0) { + if (canDeleted == 0) { $('#button-delete_button').attr('disabled','disabled'); } else { @@ -520,12 +528,13 @@ $(document).ready( function() { } jQuery.post ("", - {"page" : "operation/events/events", - "validate_event" : 1, - "id" : id, - "comment" : comment, - "new_status" : select_validate, - "similars" : similars + { + "page" : "operation/events/events", + "validate_event" : 1, + "id" : id, + "comment" : comment, + "new_status" : select_validate, + "similars" : similars }, function (data, status) { if (data == "ok") { @@ -533,29 +542,35 @@ $(document).ready( function() { // Refresh interface elements, don't reload (awfull) // Validate if (select_validate == 1) { - $("#status_img_"+id).attr ("src", "images/spinner.gif"); + $("#status_img_"+id) + .attr ("src", "images/spinner.gif"); // Change status description - $("#status_row_"+id).html(); + $("#status_row_"+id) + .html(); // Get event comment jQuery.post ("", - {"page" : "operation/events/events", - "get_comment" : 1, - "id" : id + { + "page" : "operation/events/events", + "get_comment" : 1, + "id" : id }, function (data, status) { $("#comment_row_"+id).html(data); - }); + } + ); // Get event comment in header jQuery.post ("", - {"page" : "operation/events/events", - "get_comment_header" : 1, - "id" : id + { + "page" : "operation/events/events", + "get_comment_header" : 1, + "id" : id }, function (data, status) { $("#comment_header_"+id).html(data); - }); + } + ); // Change state image $("#validate-"+id).css("display", "none"); @@ -597,23 +612,27 @@ $(document).ready( function() { // Get event comment jQuery.post ("", - {"page" : "operation/events/events", - "get_comment" : 1, - "id" : id + { + "page" : "operation/events/events", + "get_comment" : 1, + "id" : id }, function (data, status) { $("#comment_row_"+id).html(data); - }); + } + ); // Get event comment in header jQuery.post ("", - {"page" : "operation/events/events", - "get_comment_header" : 1, - "id" : id + { + "page" : "operation/events/events", + "get_comment_header" : 1, + "id" : id }, function (data, status) { $("#comment_header_"+id).html(data); - }); + } + ); // Remove delete link (if event is not grouped and there is more than one event) if ($("#group_rep").val() == 1) { @@ -732,125 +751,125 @@ $(document).ready( function() { } } }); + +function toggleCommentForm(id_event) { + display = $('.event_form_' + id_event).css('display'); - function toggleCommentForm(id_event) { - display = $('.event_form_' + id_event).css('display'); - - $('#select_validate_' + id_event).change (function() { - $option = $('#select_validate_' + id_event).val(); - }); - - if (display != 'none') { - $('.event_form_' + id_event).css('display', 'none'); - // Hide All showed rows - $('.event_form').css('display', 'none'); - $(".select_validate").find('option:first').attr('selected', 'selected').parent('select'); - } - else { - $('.event_form_' + id_event).css('display', ''); - } + $('#select_validate_' + id_event).change (function() { + $option = $('#select_validate_' + id_event).val(); + }); + + if (display != 'none') { + $('.event_form_' + id_event).css('display', 'none'); + // Hide All showed rows + $('.event_form').css('display', 'none'); + $(".select_validate").find('option:first').attr('selected', 'selected').parent('select'); } + else { + $('.event_form_' + id_event).css('display', ''); + } +} + +function validate_event_advanced(id, new_status) { + $tr = $('#validate-'+id).parents ("tr"); - function validate_event_advanced(id, new_status) { - $tr = $('#validate-'+id).parents ("tr"); - - var grouped = $('#group_rep').val(); - - var similar_ids; - similar_ids = $('#hidden-similar_ids_'+id).val(); - meta = $('#hidden-meta').val(); - var history = $('#hidden-history').val(); - - $("#status_img_"+id).attr ("src", "images/spinner.gif"); - - jQuery.post ("", - {"page" : "include/ajax/events", - "change_status" : 1, - "event_ids" : similar_ids, - "new_status" : new_status, - "meta" : meta, - "history" : history - }, - function (data, status) { - if (data == "status_ok") { - // Refresh interface elements, don't reload (awful) - // Validate - if (new_status == 1) { - // Change status description - $("#status_row_"+id).html(); - - // Change state image - $("#validate-"+id).css("display", "none"); - $("#status_img_"+id).attr ("src", "images/tick.png"); - $("#status_img_"+id).attr ("title", ); - $("#status_img_"+id).attr ("alt", ); - } // In process - else if (new_status == 2) { - // Change status description - $("#status_row_"+id).html(); - - // Remove delete link (if event is not grouped and there is more than one event) - if (grouped == 1) { - if (parseInt($("#count_event_group_"+id).text()) <= 1) { - $("#delete-"+id).replaceWith('' + <?php echo + '" title="' + + '" src="images/cross.disabled.png">'); - } - } - else { // Remove delete link (if event is not grouped) + var grouped = $('#group_rep').val(); + + var similar_ids; + similar_ids = $('#hidden-similar_ids_'+id).val(); + meta = $('#hidden-meta').val(); + var history = $('#hidden-history').val(); + + $("#status_img_"+id).attr ("src", "images/spinner.gif"); + + jQuery.post ("", + {"page" : "include/ajax/events", + "change_status" : 1, + "event_ids" : similar_ids, + "new_status" : new_status, + "meta" : meta, + "history" : history + }, + function (data, status) { + if (data == "status_ok") { + // Refresh interface elements, don't reload (awful) + // Validate + if (new_status == 1) { + // Change status description + $("#status_row_"+id).html(); + + // Change state image + $("#validate-"+id).css("display", "none"); + $("#status_img_"+id).attr ("src", "images/tick.png"); + $("#status_img_"+id).attr ("title", ); + $("#status_img_"+id).attr ("alt", ); + } // In process + else if (new_status == 2) { + // Change status description + $("#status_row_"+id).html(); + + // Remove delete link (if event is not grouped and there is more than one event) + if (grouped == 1) { + if (parseInt($("#count_event_group_"+id).text()) <= 1) { $("#delete-"+id).replaceWith('' + <?php echo + '" title="' + + '" src="images/cross.disabled.png">'); } + } + else { // Remove delete link (if event is not grouped) + $("#delete-"+id).replaceWith('' + <?php echo + '" title="' + + '" src="images/cross.disabled.png">'); + } + + // Change state image + $("#status_img_"+id).attr ("src", "images/hourglass.png"); + $("#status_img_"+id).attr ("title", ); + $("#status_img_"+id).attr ("alt", ); + + // Remove row due to new state + if (($("#status").val() == 0) + || ($("#status").val() == 1)) { - // Change state image - $("#status_img_"+id).attr ("src", "images/hourglass.png"); - $("#status_img_"+id).attr ("title", ); - $("#status_img_"+id).attr ("alt", ); - - // Remove row due to new state - if (($("#status").val() == 0) - || ($("#status").val() == 1)) { + $.each($tr, function(index, value) { + row = value; - $.each($tr, function(index, value) { - row = value; + if ($(row).attr('id') != '') { - if ($(row).attr('id') != '') { - - row_id_name = $(row).attr('id').split('-').shift(); - row_id_number = $(row).attr('id').split('-').pop() - 1; - row_id_number_next = parseInt($(row).attr('id').split('-').pop()) + 1; - previous_row_id = $(row).attr('id'); - current_row_id = row_id_name + "-" + row_id_number; - selected_row_id = row_id_name + "-" + row_id_number + "-0"; - next_row_id = row_id_name + '-' + row_id_number_next; - - $("#"+previous_row_id).css('display', 'none'); - $("#"+current_row_id).css('display', 'none'); - $("#"+selected_row_id).css('display', 'none'); - $("#"+next_row_id).css('display', 'none'); - } - }); - - } + row_id_name = $(row).attr('id').split('-').shift(); + row_id_number = $(row).attr('id').split('-').pop() - 1; + row_id_number_next = parseInt($(row).attr('id').split('-').pop()) + 1; + previous_row_id = $(row).attr('id'); + current_row_id = row_id_name + "-" + row_id_number; + selected_row_id = row_id_name + "-" + row_id_number + "-0"; + next_row_id = row_id_name + '-' + row_id_number_next; + + $("#"+previous_row_id).css('display', 'none'); + $("#"+current_row_id).css('display', 'none'); + $("#"+selected_row_id).css('display', 'none'); + $("#"+next_row_id).css('display', 'none'); + } + }); + } } - else { - $("#result") - .showMessage ("") - .addClass ("error"); - } - }, - "html" - ); - } - - - // Autoload event giving the id as POST/GET parameter - - show_event_dialog(, 1); - - /* ]]> */ + } + else { + $("#result") + .showMessage ("") + .addClass ("error"); + } + }, + "html" + ); +} + + +// Autoload event giving the id as POST/GET parameter + + show_event_dialog(, 1); + +/* ]]> */ diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 5013a344a8..0e24f98c90 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -389,7 +389,7 @@ $data = array(); $data[0] = __('User ack.') . '
'; $user_users = users_get_user_users($config['id_user'], "ER", users_can_manage_group_all(0)); - + $data[0] .= html_print_select($user_users, "id_user_ack", $id_user_ack, '', __('Any'), 0, true); $data[1] = ''; @@ -413,12 +413,22 @@ $table->data = array(); $data = array(); $data[0] = __('Group') . '
'; $data[0] .= html_print_select_groups($config["id_user"], "ER", true, - 'id_group', $id_group, '', '', 0, true, false, false, 'w130'); + 'id_group', $id_group, '', '', 0, true, false, false, 'w130') . '
'; +//********************************************************************** +// TODO +// This code is disabled for to enabled in Pandora 5.1 +// but it needs a field in tevent_filter. +// +//$data[0] .= __('Group recursion') . ' '; +//$data[0] .= html_print_checkbox ("recursion", 1, $recursion, true, false); +//********************************************************************** + $data[1] = __('Event type') . '
'; $types = get_event_types (); // Expand standard array to add not_normal (not exist in the array, used only for searches) $types["not_normal"] = __("Not normal"); $data[1] .= html_print_select ($types, 'event_type', $event_type, '', __('All'), '', true); + $data[2] = __('Severity') . '
'; $data[2] .= html_print_select (get_priorities (), "severity", $severity, '', __('All'), '-1', true, false, false); $table->data[] = $data;