2013-02-05 Sergio Martin <sergio.martin@artica.es>
* operation/events/events_list.php godmode/events/event_edit_filter.php godmode/events/event_filter.php: Fix a lot of fails in the event filters editor and the reset of the tags list when select "none" filter * operation/events/events.build_query.php: Fix bad behavior in tags filter in events view git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7591 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
826a1ed377
commit
38dc19b4d6
|
@ -1,3 +1,14 @@
|
|||
2013-02-05 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* operation/events/events_list.php
|
||||
godmode/events/event_edit_filter.php
|
||||
godmode/events/event_filter.php: Fix a lot of fails in the
|
||||
event filters editor and the reset of the tags list when
|
||||
select "none" filter
|
||||
|
||||
* operation/events/events.build_query.php: Fix
|
||||
bad behavior in tags filter in events view
|
||||
|
||||
2013-02-05 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_modules.php: added function
|
||||
|
|
|
@ -53,8 +53,15 @@ if ($id) {
|
|||
$event_view_hr = $filter['event_view_hr'];
|
||||
$id_user_ack = $filter['id_user_ack'];
|
||||
$group_rep = $filter['group_rep'];
|
||||
$tag_with = io_safe_output($filter['tag_with']);
|
||||
$tag_without = io_safe_output($filter['tag_without']);
|
||||
|
||||
$tag_with_json = $filter['tag_with'];
|
||||
$tag_with_json_clean = io_safe_output($tag_with_json);
|
||||
$tag_with_base64 = base64_encode($tag_with_json_clean) ;
|
||||
|
||||
$tag_without_json = $filter['tag_without'];
|
||||
$tag_without_json_clean = io_safe_output($tag_without_json);
|
||||
$tag_without_base64 = base64_encode($tag_without_json_clean) ;
|
||||
|
||||
$filter_only_alert = $filter['filter_only_alert'];
|
||||
}
|
||||
else {
|
||||
|
@ -70,12 +77,14 @@ else {
|
|||
$event_view_hr = '';
|
||||
$id_user_ack = '';
|
||||
$group_rep = '';
|
||||
$tag_with = json_encode(array());
|
||||
$tag_without = json_encode(array());
|
||||
$tag_with_json = json_encode(array());
|
||||
$tag_with_base64 = base64_encode($tag_with_json);
|
||||
$tag_without_json = json_encode(array());
|
||||
$tag_without_base64 = base64_encode($tag_without_json);
|
||||
$filter_only_alert = '';
|
||||
}
|
||||
|
||||
if ($update) {
|
||||
if($update || $create) {
|
||||
$id_group = (string) get_parameter ('id_group');
|
||||
$id_group_filter = get_parameter('id_group_filter');
|
||||
$id_name = (string) get_parameter ('id_name');
|
||||
|
@ -88,59 +97,14 @@ if ($update) {
|
|||
$event_view_hr = get_parameter('event_view_hr', '');
|
||||
$id_user_ack = get_parameter('id_user_ack', '');
|
||||
$group_rep = get_parameter('group_rep', '');
|
||||
$tag_with = get_parameter('tag_with', json_encode(array()));
|
||||
$tag_without = get_parameter('tag_without', json_encode(array()));
|
||||
$filter_only_alert = get_parameter('filter_only_alert','');
|
||||
|
||||
if ($id_name == '') {
|
||||
ui_print_error_message (__('Not updated. Blank name'));
|
||||
}
|
||||
else {
|
||||
$values = array ('id_filter' => $id,
|
||||
'id_name' => $id_name,
|
||||
'id_group_filter' => $id_group_filter,
|
||||
'id_group' => $id_group,
|
||||
'event_type' => $event_type,
|
||||
'severity' => $severity,
|
||||
'status' => $status,
|
||||
'search' => $search,
|
||||
'text_agent' => $text_agent,
|
||||
'pagination' => $pagination,
|
||||
'event_view_hr' => $event_view_hr,
|
||||
'id_user_ack' => $id_user_ack,
|
||||
'group_rep' => $group_rep,
|
||||
'tag_with' => $tag_with,
|
||||
'tag_without' => $tag_without,
|
||||
'filter_only_alert' => $filter_only_alert
|
||||
);
|
||||
|
||||
$result = db_process_sql_update ('tevent_filter', $values, array ('id_filter' => $id));
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully updated'),
|
||||
__('Not updated. Error updating data'));
|
||||
}
|
||||
|
||||
$tag_with = io_safe_output($tag_with);
|
||||
$tag_without = io_safe_output($tag_without);
|
||||
}
|
||||
$tag_with_base64 = get_parameter('tag_with', json_encode(array()));
|
||||
$tag_with_json = io_safe_input(base64_decode($tag_with_base64));
|
||||
|
||||
if ($create) {
|
||||
$id_group = (string) get_parameter ('id_group');
|
||||
$id_name = (string) get_parameter ('id_name');
|
||||
$id_group_filter = get_parameter('id_group_filter');
|
||||
$event_type = get_parameter('event_type', '');
|
||||
$severity = get_parameter('severity', '');
|
||||
$status = get_parameter('status', '');
|
||||
$search = get_parameter('search', '');
|
||||
$text_agent = get_parameter('text_agent', '');
|
||||
$pagination = get_parameter('pagination', '');
|
||||
$event_view_hr = get_parameter('event_view_hr', '');
|
||||
$id_user_ack = get_parameter('id_user_ack', '');
|
||||
$group_rep = get_parameter('group_rep',' ');
|
||||
$tag_with = get_parameter('tag_with', json_encode(array()));
|
||||
$tag_without = get_parameter('tag_without', json_encode(array()));
|
||||
$filter_only_alert = get_parameter('filter_only_alert', '');
|
||||
$tag_without_base64 = get_parameter('tag_without', json_encode(array()));
|
||||
$tag_without_json = io_safe_input(base64_decode($tag_without_base64));
|
||||
|
||||
$filter_only_alert = get_parameter('filter_only_alert','');
|
||||
|
||||
$values = array (
|
||||
'id_name' => $id_name,
|
||||
|
@ -155,10 +119,25 @@ if ($create) {
|
|||
'event_view_hr' => $event_view_hr,
|
||||
'id_user_ack' => $id_user_ack,
|
||||
'group_rep' => $group_rep,
|
||||
'tag_with' => $tag_with,
|
||||
'tag_without' => $tag_without,
|
||||
'tag_with' => $tag_with_json,
|
||||
'tag_without' => $tag_without_json,
|
||||
'filter_only_alert' => $filter_only_alert);
|
||||
|
||||
}
|
||||
|
||||
if ($update) {
|
||||
if ($id_name == '') {
|
||||
ui_print_error_message (__('Not updated. Blank name'));
|
||||
}
|
||||
else {
|
||||
$result = db_process_sql_update ('tevent_filter', $values, array ('id_filter' => $id));
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully updated'),
|
||||
__('Not updated. Error updating data'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($create) {
|
||||
$id = db_process_sql_insert('tevent_filter', $values);
|
||||
|
||||
if ($id === false) {
|
||||
|
@ -167,9 +146,6 @@ if ($create) {
|
|||
else {
|
||||
ui_print_success_message ('Filter created successfully');
|
||||
}
|
||||
|
||||
$tag_with = io_safe_output($tag_with);
|
||||
$tag_without = io_safe_output($tag_without);
|
||||
}
|
||||
|
||||
$own_info = get_user_info ($config['id_user']);
|
||||
|
@ -252,12 +228,11 @@ $table->data[11][0] = '<b>' . __('Repeated') . '</b>';
|
|||
$table->data[11][1] = html_print_select ($repeated_sel, "group_rep", $group_rep, '', '', '', true);
|
||||
|
||||
|
||||
|
||||
$tag_with = json_decode($tag_with, true);
|
||||
$tag_with = json_decode($tag_with_json_clean, true);
|
||||
if(empty($tag_with)) {
|
||||
$tag_with = array();
|
||||
}
|
||||
$tag_without = json_decode($tag_without, true);
|
||||
$tag_without = json_decode($tag_without_json_clean, true);
|
||||
if(empty($tag_without)) {
|
||||
$tag_without = array();
|
||||
}
|
||||
|
@ -299,7 +274,7 @@ $table->data[15][0] = html_print_select ($tag_with_temp,
|
|||
'tag_with_temp', array(), '', '', 0, true, true,
|
||||
true, '', false, "width: 120px; height: 50px;");
|
||||
$table->data[15][0] .= html_print_input_hidden('tag_with',
|
||||
json_encode($tag_with), true);
|
||||
$tag_with_base64, true);
|
||||
$table->data[15][1] = html_print_button(__('Remove'),
|
||||
'remove_whith', $remove_with_tag_disabled, '', 'class="delete sub"', true);
|
||||
|
||||
|
@ -316,7 +291,7 @@ $table->data[18][0] = html_print_select ($tag_without_temp,
|
|||
'tag_without_temp', array(), '', '', 0, true, true,
|
||||
true, '', false, "width: 120px; height: 50px;");
|
||||
$table->data[18][0] .= html_print_input_hidden('tag_without',
|
||||
json_encode($tag_without), true);
|
||||
$tag_without_base64, true);
|
||||
$table->data[18][1] = html_print_button(__('Remove'), 'remove_whithout', $remove_without_tag_disabled,
|
||||
'', 'class="delete sub"', true);
|
||||
|
||||
|
@ -510,7 +485,7 @@ function replace_hidden_tags(what_button) {
|
|||
value_store.push(val);
|
||||
});
|
||||
|
||||
$(id_hidden).val(jQuery.toJSON(value_store));
|
||||
$(id_hidden).val(Base64.encode(jQuery.toJSON(value_store)));
|
||||
}
|
||||
/* ]]> */
|
||||
</script>
|
|
@ -125,7 +125,7 @@ $total_filters = $total_filters[0]['total'];
|
|||
foreach ($filters as $filter) {
|
||||
$data = array ();
|
||||
|
||||
$data[0] = '<a href="index.php?sec=geventos&sec2=godmode/events/events§ion=edit_filter&id='.$filter['id_filter'].'">'.$filter['id_name'].'</a>';
|
||||
$data[0] = '<a href="index.php?sec=geventos&sec2=godmode/events/events§ion=edit_filter&id=' . $filter['id_filter'] . '&pure=' . $config['pure'] . '">'.$filter['id_name'].'</a>';
|
||||
$data[1] = ui_print_group_icon ($filter['id_group_filter'], true);
|
||||
$data[2] = events_get_event_types($filter['event_type']);
|
||||
$data[3] = events_get_status($filter['status']);
|
||||
|
|
|
@ -136,7 +136,7 @@ if (!empty($tag_without)) {
|
|||
$first = true;
|
||||
foreach ($tag_without as $id_tag) {
|
||||
if ($first) $first = false;
|
||||
else $sql_post .= " OR ";
|
||||
else $sql_post .= " AND ";
|
||||
$sql_post .= "tags NOT LIKE '%" . tags_get_name($id_tag) . "%'";
|
||||
}
|
||||
$sql_post .= ' ) ';
|
||||
|
|
|
@ -49,8 +49,8 @@ if (is_ajax()) {
|
|||
$event_filter = events_get_event_filter($id_filter);
|
||||
|
||||
$event_filter['id_name'] = io_safe_output($event_filter['id_name']);
|
||||
$event_filter['tag_with'] = io_safe_output($event_filter['tag_with']);
|
||||
$event_filter['tag_without'] = io_safe_output($event_filter['tag_without']);
|
||||
$event_filter['tag_with'] = base64_encode(io_safe_output($event_filter['tag_with']));
|
||||
$event_filter['tag_without'] = base64_encode(io_safe_output($event_filter['tag_without']));
|
||||
|
||||
echo json_encode($event_filter);
|
||||
}
|
||||
|
@ -516,6 +516,8 @@ $(document).ready( function() {
|
|||
$("#row_name").css('visibility', 'hidden');
|
||||
$("#submit-update_filter").css('visibility', 'hidden');
|
||||
$("#id_group").val(0);
|
||||
|
||||
clear_tags_inputs();
|
||||
}
|
||||
// If filter selected then load filter
|
||||
else {
|
||||
|
@ -604,8 +606,8 @@ $(document).ready( function() {
|
|||
"event_view_hr" : $("#text-event_view_hr").val(),
|
||||
"id_user_ack" : $("#id_user_ack").val(),
|
||||
"group_rep" : $("#group_rep").val(),
|
||||
"tag_with": $("#hidden-tag_with").val(),
|
||||
"tag_without": $("#hidden-tag_without").val(),
|
||||
"tag_with": Base64.decode($("#hidden-tag_with").val()),
|
||||
"tag_without": Base64.decode($("#hidden-tag_without").val()),
|
||||
"filter_only_alert" : $("#filter_only_alert").val(),
|
||||
"id_group_filter": $("#id_group").val()
|
||||
},
|
||||
|
@ -676,8 +678,8 @@ $(document).ready( function() {
|
|||
"event_view_hr" : $("#text-event_view_hr").val(),
|
||||
"id_user_ack" : $("#id_user_ack").val(),
|
||||
"group_rep" : $("#group_rep").val(),
|
||||
"tag_with" : $("#hidden-tag_with").val(),
|
||||
"tag_without" : $("#hidden-tag_without").val(),
|
||||
"tag_with" : Base64.decode($("#hidden-tag_with").val()),
|
||||
"tag_without" : Base64.decode($("#hidden-tag_without").val()),
|
||||
"filter_only_alert" : $("#filter_only_alert").val(),
|
||||
"id_group_filter": $("#id_group").val()
|
||||
},
|
||||
|
@ -905,6 +907,12 @@ function replace_hidden_tags(what_button) {
|
|||
$(id_hidden).val(Base64.encode(jQuery.toJSON(value_store)));
|
||||
}
|
||||
|
||||
function clear_tags_inputs() {
|
||||
$("#hidden-tag_with").val(Base64.encode(jQuery.toJSON([])));
|
||||
$("#hidden-tag_without").val(Base64.encode(jQuery.toJSON([])));
|
||||
reorder_tags_inputs();
|
||||
}
|
||||
|
||||
function reorder_tags_inputs() {
|
||||
$('#select_with option[value="' + val_none + '"]').remove();
|
||||
jQuery.each($("#tag_with_temp option"), function(key, element) {
|
||||
|
@ -936,8 +944,8 @@ function reorder_tags_inputs() {
|
|||
|
||||
|
||||
|
||||
tags_json = $("#hidden-tag_with").val();
|
||||
tags = jQuery.evalJSON(tags_json);
|
||||
tags_base64 = $("#hidden-tag_with").val();
|
||||
tags = jQuery.evalJSON(Base64.decode(tags_base64));
|
||||
jQuery.each(tags, function(key, element) {
|
||||
if ($("#select_with option[value='" + element + "']").length == 1) {
|
||||
text = $("#select_with option[value='" + element + "']").text();
|
||||
|
@ -968,8 +976,8 @@ function reorder_tags_inputs() {
|
|||
|
||||
|
||||
|
||||
tags_json = $("#hidden-tag_without").val();
|
||||
tags = jQuery.evalJSON(tags_json);
|
||||
tags_base64 = $("#hidden-tag_without").val();
|
||||
tags = jQuery.evalJSON(Base64.decode(tags_base64));
|
||||
jQuery.each(tags, function(key, element) {
|
||||
if ($("#select_without option[value='" + element + "']").length == 1) {
|
||||
text = $("#select_without option[value='" + element + "']").text();
|
||||
|
|
Loading…
Reference in New Issue