refactor events meta pandora_enterprise#9086
This commit is contained in:
parent
080c10aad7
commit
8ad6d350af
|
@ -55,7 +55,6 @@ if (! check_acl($config['id_user'], 0, 'ER')
|
|||
return;
|
||||
}
|
||||
|
||||
$get_events_details = (bool) get_parameter('get_events_details');
|
||||
$get_extended_event = (bool) get_parameter('get_extended_event');
|
||||
$change_status = (bool) get_parameter('change_status');
|
||||
$change_owner = (bool) get_parameter('change_owner');
|
||||
|
@ -66,7 +65,6 @@ $get_response = (bool) get_parameter('get_response');
|
|||
$get_response_target = (bool) get_parameter('get_response_target');
|
||||
$get_response_params = (bool) get_parameter('get_response_params');
|
||||
$get_response_description = (bool) get_parameter('get_response_description');
|
||||
$get_event_name = (bool) get_parameter('get_event_name');
|
||||
$meta = get_parameter('meta', 0);
|
||||
$history = get_parameter('history', 0);
|
||||
$table_events = get_parameter('table_events', 0);
|
||||
|
@ -79,9 +77,9 @@ $load_filter_modal = get_parameter('load_filter_modal', 0);
|
|||
$get_filter_values = get_parameter('get_filter_values', 0);
|
||||
$update_event_filter = get_parameter('update_event_filter', 0);
|
||||
$save_event_filter = get_parameter('save_event_filter', 0);
|
||||
$in_process_event = get_parameter('in_process_event', 0);
|
||||
$validate_event = get_parameter('validate_event', 0);
|
||||
$delete_event = get_parameter('delete_event', 0);
|
||||
$in_process_event = (bool) get_parameter('in_process_event', 0);
|
||||
$validate_event = (bool) get_parameter('validate_event', 0);
|
||||
$delete_event = (bool) get_parameter('delete_event', 0);
|
||||
$get_event_filters = get_parameter('get_event_filters', 0);
|
||||
$get_comments = (bool) get_parameter('get_comments', false);
|
||||
$get_events_fired = (bool) get_parameter('get_events_fired');
|
||||
|
@ -169,11 +167,20 @@ if ($get_event_filters) {
|
|||
}
|
||||
|
||||
// Delete event (filtered or not).
|
||||
if ($delete_event) {
|
||||
if ($delete_event === true) {
|
||||
$filter = get_parameter('filter', []);
|
||||
$id_evento = get_parameter('id_evento', 0);
|
||||
$id_evento = (int) get_parameter('id_evento', 0);
|
||||
$server_id = (int) get_parameter('server_id', 0);
|
||||
$event_rep = get_parameter('event_rep', 0);
|
||||
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node = new Node($server_id);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
if ($event_rep === 0) {
|
||||
// Disable group by when there're result is unique.
|
||||
$filter['group_rep'] = 0;
|
||||
|
@ -185,21 +192,22 @@ if ($delete_event) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($node_id > 0) {
|
||||
try {
|
||||
$node = new Node($node_id);
|
||||
$node->connect();
|
||||
$r = events_delete($id_evento, $filter, false, true);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
$node->disconnect();
|
||||
$success = false;
|
||||
echo 'owner_error';
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$r = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
} else {
|
||||
$r = events_delete($id_evento, $filter);
|
||||
}
|
||||
|
||||
if ($r === false) {
|
||||
|
@ -212,11 +220,20 @@ if ($delete_event) {
|
|||
}
|
||||
|
||||
// Validates an event (filtered or not).
|
||||
if ($validate_event) {
|
||||
if ($validate_event === true) {
|
||||
$filter = get_parameter('filter', []);
|
||||
$id_evento = get_parameter('id_evento', 0);
|
||||
$id_evento = (int) get_parameter('id_evento', 0);
|
||||
$server_id = (int) get_parameter('server_id', 0);
|
||||
$event_rep = get_parameter('event_rep', 0);
|
||||
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node = new Node($server_id);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
if ($event_rep === 0) {
|
||||
// Disable group by when there're result is unique.
|
||||
$filter['group_rep'] = 0;
|
||||
|
@ -228,7 +245,28 @@ if ($validate_event) {
|
|||
return;
|
||||
}
|
||||
|
||||
$r = events_update_status($id_evento, EVENT_VALIDATE, $filter);
|
||||
$r = events_update_status(
|
||||
$id_evento,
|
||||
EVENT_VALIDATE,
|
||||
$filter
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$r = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($r === false) {
|
||||
echo 'Failed';
|
||||
} else {
|
||||
|
@ -239,11 +277,20 @@ if ($validate_event) {
|
|||
}
|
||||
|
||||
// Sets status to in progress.
|
||||
if ($in_process_event) {
|
||||
if ($in_process_event === true) {
|
||||
$filter = get_parameter('filter', []);
|
||||
$id_evento = get_parameter('id_evento', 0);
|
||||
$id_evento = (int) get_parameter('id_evento', 0);
|
||||
$server_id = (int) get_parameter('server_id', 0);
|
||||
$event_rep = get_parameter('event_rep', 0);
|
||||
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node = new Node($server_id);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
if ($event_rep === 0) {
|
||||
// Disable group by when there're result is unique.
|
||||
$filter['group_rep'] = 0;
|
||||
|
@ -255,7 +302,28 @@ if ($in_process_event) {
|
|||
return;
|
||||
}
|
||||
|
||||
$r = events_update_status($id_evento, EVENT_PROCESS, $filter);
|
||||
$r = events_update_status(
|
||||
$id_evento,
|
||||
EVENT_PROCESS,
|
||||
$filter
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$r = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($r === false) {
|
||||
echo 'Failed';
|
||||
} else {
|
||||
|
@ -415,7 +483,13 @@ if ($get_filter_values) {
|
|||
'filter_id' => 0,
|
||||
];
|
||||
} else {
|
||||
$event_filter['module_search'] = io_safe_output(db_get_value_filter('nombre', 'tagente_modulo', ['id_agente_modulo' => $event_filter['id_agent_module']]));
|
||||
$event_filter['module_search'] = io_safe_output(
|
||||
db_get_value_filter(
|
||||
'nombre',
|
||||
'tagente_modulo',
|
||||
['id_agente_modulo' => $event_filter['id_agent_module']]
|
||||
)
|
||||
);
|
||||
$a = array_keys(users_get_groups(false));
|
||||
$event_filter['group_name'] = '';
|
||||
foreach ($a as $key => $value) {
|
||||
|
@ -969,24 +1043,6 @@ $(document).ready(function (){
|
|||
}
|
||||
|
||||
|
||||
if ($get_event_name) {
|
||||
$event_id = get_parameter('event_id');
|
||||
|
||||
if ($meta) {
|
||||
$name = events_meta_get_event_name($event_id, $history);
|
||||
} else {
|
||||
$name = db_get_value('evento', 'tevento', 'id_evento', $event_id);
|
||||
}
|
||||
|
||||
if ($name === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
ui_print_truncate_text(strip_tags(io_safe_output($name)), 75, false, false, false, '...');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_response_description) {
|
||||
$response_id = get_parameter('response_id');
|
||||
|
||||
|
@ -1023,7 +1079,7 @@ if ($get_response_params) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($get_response_target) {
|
||||
if ($get_response_target === true) {
|
||||
if (! check_acl($config['id_user'], 0, 'EW')) {
|
||||
echo 'unauthorized';
|
||||
return;
|
||||
|
@ -1033,28 +1089,81 @@ if ($get_response_target) {
|
|||
$event_id = (int) get_parameter('event_id');
|
||||
$server_id = (int) get_parameter('server_id');
|
||||
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node = new Node($server_id);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
||||
|
||||
if (empty($event_response)) {
|
||||
if (empty($event_response) === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo events_get_response_target($event_id, $response_id, $server_id);
|
||||
echo events_get_response_target($event_id, $response_id);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
return;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_response) {
|
||||
if ($get_response === true) {
|
||||
if (! check_acl($config['id_user'], 0, 'EW')) {
|
||||
echo 'unauthorized';
|
||||
return;
|
||||
}
|
||||
|
||||
$response_id = get_parameter('response_id');
|
||||
$server_id = (int) get_parameter('server_id');
|
||||
|
||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node = new Node($server_id);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
if (empty($event_response)) {
|
||||
$event_response = db_get_row(
|
||||
'tevent_response',
|
||||
'id',
|
||||
$response_id
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
return;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($event_response) === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1063,7 +1172,7 @@ if ($get_response) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($perform_event_response) {
|
||||
if ($perform_event_response === true) {
|
||||
global $config;
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'EW')) {
|
||||
|
@ -1076,17 +1185,45 @@ if ($perform_event_response) {
|
|||
$event_id = (int) get_parameter('event_id');
|
||||
$server_id = (int) get_parameter('server_id', 0);
|
||||
|
||||
if (empty($target)) {
|
||||
$command = events_get_response_target($event_id, $response_id, $server_id);
|
||||
} else {
|
||||
$command = $target;
|
||||
if (empty($target) === true) {
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node = new Node($server_id);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
||||
|
||||
$command_timeout = $event_response !== false ? $event_response['command_timeout'] : 90;
|
||||
if (empty($event_response) === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (enterprise_installed()) {
|
||||
$command = events_get_response_target($event_id, $response_id, $server_id);
|
||||
|
||||
$command_timeout = ($event_response !== false) ? $event_response['command_timeout'] : 90;
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
return;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$command = $target;
|
||||
}
|
||||
|
||||
if (enterprise_installed() === true) {
|
||||
if ($event_response['server_to_exec'] != 0 && $event_response['type'] == 'command') {
|
||||
$commandExclusions = [
|
||||
'vi',
|
||||
|
@ -1231,14 +1368,22 @@ if ($dialogue_event_response) {
|
|||
} else {
|
||||
echo "<div class='left'>";
|
||||
|
||||
echo $prompt."Executing command: $command_str";
|
||||
echo $prompt.'Executing command: '.$command_str;
|
||||
echo '</div><br>';
|
||||
|
||||
echo "<div id='response_loading_command' style='display:none'>".html_print_image('images/spinner.gif', true).'</div>';
|
||||
echo "<div id='response_loading_command' style='display:none'>";
|
||||
echo html_print_image('images/spinner.gif', true);
|
||||
echo '</div>';
|
||||
echo "<br><br><br><div id='response_out' class='left'></div>";
|
||||
|
||||
echo "<br><div id='re_exec_command' style='display:none'><br><br>";
|
||||
html_print_button(__('Execute again'), 'btn_str', false, "perform_response({'target':'".$command."','event_id':".$event_id.",'server_id':".$server_id.'}, '.$response_id.');', "class='sub next'");
|
||||
html_print_button(
|
||||
__('Execute again'),
|
||||
'btn_str',
|
||||
false,
|
||||
"perform_response({'target':'".$command."','event_id':".$event_id.",'server_id':".$server_id.'}, '.$response_id.');',
|
||||
"class='sub next'"
|
||||
);
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
@ -1306,12 +1451,16 @@ if ($add_comment === true) {
|
|||
if ($change_status === true) {
|
||||
$event_ids = get_parameter('event_ids');
|
||||
$new_status = get_parameter('new_status');
|
||||
$server_id = 0;
|
||||
if (is_metaconsole() === true) {
|
||||
$server_id = (int) get_parameter('server_id');
|
||||
}
|
||||
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $node_id > 0
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node = new Node($node_id);
|
||||
$node = new Node($server_id);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
|
@ -1322,7 +1471,7 @@ if ($change_status === true) {
|
|||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $node_id > 0
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
@ -1331,7 +1480,7 @@ if ($change_status === true) {
|
|||
echo 'owner_error';
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $node_id > 0
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
@ -1375,20 +1524,20 @@ if ($change_status === true) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($change_owner) {
|
||||
$new_owner = get_parameter('new_owner');
|
||||
$event_id = get_parameter('event_id');
|
||||
$similars = true;
|
||||
if ($change_owner === true) {
|
||||
$new_owner = get_parameter('new_owner', '');
|
||||
$event_id = (int) get_parameter('event_id', 0);
|
||||
$server_id = (int) get_parameter('server_id', 0);
|
||||
|
||||
if ($new_owner == -1) {
|
||||
if ($new_owner === -1) {
|
||||
$new_owner = '';
|
||||
}
|
||||
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $node_id > 0
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node = new Node($node_id);
|
||||
$node = new Node($server_id);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
|
@ -1400,7 +1549,7 @@ if ($change_owner) {
|
|||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $node_id > 0
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
@ -1408,7 +1557,7 @@ if ($change_owner) {
|
|||
$return = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $node_id > 0
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
@ -1438,19 +1587,7 @@ if ($get_extended_event) {
|
|||
$event_id = $event['id_evento'];
|
||||
|
||||
$readonly = false;
|
||||
if (!$meta
|
||||
&& isset($config['event_replication'])
|
||||
&& $config['event_replication'] == 1
|
||||
&& $config['show_events_in_local'] == 1
|
||||
|| enterprise_hook(
|
||||
'enterprise_acl',
|
||||
[
|
||||
$config['id_user'],
|
||||
'eventos',
|
||||
'execute_event_responses',
|
||||
]
|
||||
) === false
|
||||
) {
|
||||
if (enterprise_hook('enterprise_acl', [$config['id_user'], 'eventos', 'execute_event_responses']) === false) {
|
||||
$readonly = true;
|
||||
}
|
||||
|
||||
|
@ -1458,7 +1595,7 @@ if ($get_extended_event) {
|
|||
$event['clean_tags'] = events_clean_tags($event['tags']);
|
||||
|
||||
// If the event is not found, we abort.
|
||||
if (empty($event)) {
|
||||
if (empty($event) === true) {
|
||||
ui_print_error_message('Event not found');
|
||||
return false;
|
||||
}
|
||||
|
@ -1471,7 +1608,7 @@ if ($get_extended_event) {
|
|||
$timestamp_first = $event['timestamp_first'];
|
||||
$timestamp_last = $event['timestamp_last'];
|
||||
$server_id = $event['server_id'];
|
||||
if (empty($server_id) && !empty($event['server_name']) && is_metaconsole()) {
|
||||
if (empty($server_id) === true && empty($event['server_name']) === false && is_metaconsole() === true) {
|
||||
$server_id = metaconsole_get_id_server($event['server_name']);
|
||||
}
|
||||
|
||||
|
@ -1479,7 +1616,7 @@ if ($get_extended_event) {
|
|||
|
||||
$event['similar_ids'] = $similar_ids;
|
||||
|
||||
if (!isset($comments)) {
|
||||
if (isset($comments) === false) {
|
||||
$comments = $event['user_comment'];
|
||||
}
|
||||
|
||||
|
@ -1646,28 +1783,25 @@ if ($get_extended_event) {
|
|||
[]
|
||||
)))
|
||||
) {
|
||||
$responses = events_page_responses($event);
|
||||
$responses = events_page_responses($event, $server_id);
|
||||
} else {
|
||||
$responses = '';
|
||||
}
|
||||
|
||||
$console_url = '';
|
||||
// If metaconsole switch to node to get details and custom fields.
|
||||
if ($meta || (is_metaconsole() && !empty($server_id))) {
|
||||
$server = metaconsole_get_connection_by_id($server_id);
|
||||
} else {
|
||||
$server = '';
|
||||
}
|
||||
|
||||
$details = events_page_details($event, $server);
|
||||
$details = events_page_details($event, $server_id);
|
||||
|
||||
$related = '';
|
||||
if (events_has_extended_info($event['id_evento']) === true) {
|
||||
$related = events_page_related($event, $server);
|
||||
$related = events_page_related(
|
||||
$event,
|
||||
$server
|
||||
);
|
||||
}
|
||||
|
||||
$connected = true;
|
||||
if ($meta || (is_metaconsole() && !empty($server_id))) {
|
||||
if (is_metaconsole() === true && empty($server_id) === false) {
|
||||
$server = metaconsole_get_connection_by_id($server_id);
|
||||
if (metaconsole_connect($server) === NOERR) {
|
||||
$connected = true;
|
||||
} else {
|
||||
|
@ -1680,7 +1814,7 @@ if ($get_extended_event) {
|
|||
$custom_data = events_page_custom_data($event);
|
||||
}
|
||||
|
||||
if ($meta && $connected === true) {
|
||||
if (is_metaconsole() === true && empty($server_id) === false) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
|
@ -1688,13 +1822,55 @@ if ($get_extended_event) {
|
|||
|
||||
$comments = '<div id="extended_event_comments_page" class="extended_event_pages"></div>';
|
||||
|
||||
$notifications = '<div id="notification_comment_error" class="invisible_events">'.ui_print_error_message(__('Error adding comment'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_comment_success" class="invisible_events">'.ui_print_success_message(__('Comment added successfully'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_status_error" class="invisible_events">'.ui_print_error_message(__('Error changing event status'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_status_success" class="invisible_events">'.ui_print_success_message(__('Event status changed successfully'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_owner_error" class="invisible_events">'.ui_print_error_message(__('Error changing event owner'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_owner_success" class="invisible_events">'.ui_print_success_message(__('Event owner changed successfully'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_delete_error" class="invisible_events">'.ui_print_error_message(__('Error deleting event'), '', true).'</div>';
|
||||
$notifications = '<div id="notification_comment_error" class="invisible_events">';
|
||||
$notifications .= ui_print_error_message(
|
||||
__('Error adding comment'),
|
||||
'',
|
||||
true
|
||||
);
|
||||
$notifications .= '</div>';
|
||||
$notifications .= '<div id="notification_comment_success" class="invisible_events">';
|
||||
$notifications .= ui_print_success_message(
|
||||
__('Comment added successfully'),
|
||||
'',
|
||||
true
|
||||
);
|
||||
$notifications .= '</div>';
|
||||
$notifications .= '<div id="notification_status_error" class="invisible_events">';
|
||||
$notifications .= ui_print_error_message(
|
||||
__('Error changing event status'),
|
||||
'',
|
||||
true
|
||||
);
|
||||
$notifications .= '</div>';
|
||||
$notifications .= '<div id="notification_status_success" class="invisible_events">';
|
||||
$notifications .= ui_print_success_message(
|
||||
__('Event status changed successfully'),
|
||||
'',
|
||||
true
|
||||
);
|
||||
$notifications .= '</div>';
|
||||
$notifications .= '<div id="notification_owner_error" class="invisible_events">';
|
||||
$notifications .= ui_print_error_message(
|
||||
__('Error changing event owner'),
|
||||
'',
|
||||
true
|
||||
);
|
||||
$notifications .= '</div>';
|
||||
$notifications .= '<div id="notification_owner_success" class="invisible_events">';
|
||||
$notifications .= ui_print_success_message(
|
||||
__('Event owner changed successfully'),
|
||||
'',
|
||||
true
|
||||
);
|
||||
$notifications .= '</div>';
|
||||
$notifications .= '<div id="notification_delete_error" class="invisible_events">';
|
||||
$notifications .= ui_print_error_message(
|
||||
__('Error deleting event'),
|
||||
'',
|
||||
true
|
||||
);
|
||||
$notifications .= '</div>';
|
||||
|
||||
|
||||
$loading = '<div id="response_loading" class="invisible_events">'.html_print_image('images/spinner.gif', true).'</div>';
|
||||
|
@ -1796,91 +1972,6 @@ if ($get_extended_event) {
|
|||
echo $out.$js;
|
||||
}
|
||||
|
||||
if ($get_events_details) {
|
||||
$event_ids = explode(',', get_parameter('event_ids'));
|
||||
$events = db_get_all_rows_filter(
|
||||
'tevento',
|
||||
[
|
||||
'id_evento' => $event_ids,
|
||||
'order' => 'utimestamp ASC',
|
||||
],
|
||||
[
|
||||
'evento',
|
||||
'utimestamp',
|
||||
'estado',
|
||||
'criticity',
|
||||
'id_usuario',
|
||||
],
|
||||
'AND',
|
||||
true
|
||||
);
|
||||
|
||||
$out = '<table class="eventtable eventtable_class"">';
|
||||
$out .= '<tr class="tr_eventtable"><td></td><td></td></tr>';
|
||||
foreach ($events as $event) {
|
||||
switch ($event['estado']) {
|
||||
case 0:
|
||||
$img = ui_get_full_url('images/star.png', false, false, false);
|
||||
$title = __('New event');
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$img = ui_get_full_url('images/tick.png', false, false, false);
|
||||
$title = __('Event validated');
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$img = ui_get_full_url('images/hourglass.png', false, false, false);
|
||||
$title = __('Event in process');
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
$out .= '<tr class="'.get_priority_class($event['criticity']).' height_25px">';
|
||||
$out .= '<td class="'.get_priority_class($event['criticity']).' font_7pt" colspan=2>';
|
||||
$out .= io_safe_output($event['evento']);
|
||||
$out .= '</td></tr>';
|
||||
|
||||
$out .= '<tr class="'.get_priority_class($event['criticity']).' font_0px height_25px">';
|
||||
$out .= '<td class="'.get_priority_class($event['criticity']).' w18px center">';
|
||||
$out .= html_print_image(ui_get_full_url('images/clock.png', false, false, false), true, ['title' => __('Timestamp'), 'class' => 'invert_filter'], false, true);
|
||||
|
||||
$out .= '</td>';
|
||||
$out .= '<td class="'.get_priority_class($event['criticity']).' font_17pt">';
|
||||
$out .= date($config['date_format'], $event['utimestamp']);
|
||||
$out .= '</td></tr>';
|
||||
|
||||
$out .= '<tr class="'.get_priority_class($event['criticity']).' font_0px height_25px">';
|
||||
$out .= '<td class="'.get_priority_class($event['criticity']).' w18px center">';
|
||||
$out .= html_print_image($img, true, ['title' => $title], false, true);
|
||||
$out .= '</td>';
|
||||
$out .= '<td class="'.get_priority_class($event['criticity']).' font_17pt">';
|
||||
$out .= $title;
|
||||
if ($event['estado'] == 1) {
|
||||
if (empty($event['id_usuario'])) {
|
||||
$ack_user = '<i>'.__('Auto').'</i>';
|
||||
} else {
|
||||
$ack_user = $event['id_usuario'];
|
||||
}
|
||||
|
||||
$out .= ' ('.$ack_user.')';
|
||||
}
|
||||
|
||||
$out .= '</td></tr>';
|
||||
|
||||
$out .= '<tr class="tr_ackuser"><td></td><td>';
|
||||
$out .= '</td></tr><tr class="tr_eventtable"><td></td><td>';
|
||||
$out .= '</td></tr>';
|
||||
}
|
||||
|
||||
$out .= '</table>';
|
||||
|
||||
echo $out;
|
||||
}
|
||||
|
||||
if ($table_events) {
|
||||
include_once 'include/functions_events.php';
|
||||
include_once 'include/functions_graph.php';
|
||||
|
|
|
@ -466,16 +466,14 @@ function events_update_status($id_evento, $status, $filter=null)
|
|||
global $config;
|
||||
|
||||
if (!$status) {
|
||||
error_log('No hay estado');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($id_evento) || $id_evento <= 0) {
|
||||
error_log('No hay id_evento');
|
||||
if (isset($id_evento) === false || $id_evento <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($filter) || !is_array($filter)) {
|
||||
if (isset($filter) === false || is_array($filter) === false) {
|
||||
$filter = ['group_rep' => 0];
|
||||
}
|
||||
|
||||
|
@ -510,7 +508,7 @@ function events_update_status($id_evento, $status, $filter=null)
|
|||
// Sort_field.
|
||||
null,
|
||||
// Historical table.
|
||||
$history,
|
||||
false,
|
||||
// Return_sql.
|
||||
true
|
||||
);
|
||||
|
@ -1475,6 +1473,10 @@ function events_get_all(
|
|||
$having
|
||||
);
|
||||
|
||||
if ($return_sql === true) {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
if (!$user_is_admin) {
|
||||
// XXX: Confirm there's no extra grants unhandled!.
|
||||
$can_manage = '0 as user_can_manage';
|
||||
|
@ -1646,10 +1648,6 @@ function events_get_all(
|
|||
}
|
||||
}
|
||||
|
||||
if ($return_sql) {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
return db_get_all_rows_sql($sql);
|
||||
}
|
||||
|
||||
|
@ -1870,8 +1868,6 @@ function events_change_status(
|
|||
* owner will be set, if empty, will be cleaned.
|
||||
* @param boolean $force Flag to force the change or not (not force is
|
||||
* change only when it hasn't owner).
|
||||
* @param boolean $meta Metaconsole mode flag.
|
||||
* @param boolean $history History mode flag.
|
||||
*
|
||||
* @return boolean Whether or not it was successful.
|
||||
*/
|
||||
|
@ -3058,16 +3054,12 @@ function events_get_event_filter_select($manage=true)
|
|||
* Called from include/ajax/events.php.
|
||||
*
|
||||
* @param mixed $event Event.
|
||||
* @param array $childrens_ids Children_ids.
|
||||
*
|
||||
* @return string HTML.
|
||||
*/
|
||||
function events_page_responses($event, $childrens_ids=[])
|
||||
function events_page_responses($event)
|
||||
{
|
||||
global $config;
|
||||
//
|
||||
// Responses.
|
||||
//
|
||||
$table_responses = new StdClass();
|
||||
$table_responses->cellspacing = 2;
|
||||
$table_responses->cellpadding = 2;
|
||||
|
@ -3079,51 +3071,47 @@ function events_page_responses($event, $childrens_ids=[])
|
|||
$table_responses->style[2] = 'text-align:right;';
|
||||
$table_responses->class = 'table_modal_alternate';
|
||||
|
||||
if (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids)) {
|
||||
$acl_tags_event_manager = tags_checks_event_acl(
|
||||
$config['id_user'],
|
||||
$event['id_grupo'],
|
||||
'EM',
|
||||
$event['clean_tags']
|
||||
);
|
||||
|
||||
if ($acl_tags_event_manager === true) {
|
||||
// Owner.
|
||||
$data = [];
|
||||
$data[0] = __('Change owner');
|
||||
// Owner change can be done to users that belong to the event group
|
||||
// with ER permission.
|
||||
$profiles_view_events = db_get_all_rows_filter('tperfil', ['event_view' => '1'], 'id_perfil');
|
||||
$profiles_view_events = db_get_all_rows_filter(
|
||||
'tperfil',
|
||||
['event_view' => '1'],
|
||||
'id_perfil'
|
||||
);
|
||||
|
||||
foreach ($profiles_view_events as $k => $v) {
|
||||
$profiles_view_events[$k] = reset($v);
|
||||
}
|
||||
|
||||
// Juanma (05/05/2014) Fix : Propagate ACL.
|
||||
$_user_groups = array_keys(
|
||||
users_get_groups($config['id_user'], 'ER', users_can_manage_group_all())
|
||||
users_get_groups(
|
||||
$config['id_user'],
|
||||
'ER',
|
||||
users_can_manage_group_all()
|
||||
)
|
||||
);
|
||||
$strict_user = db_get_value(
|
||||
'strict_acl',
|
||||
'tusuario',
|
||||
'id_user',
|
||||
$config['id_user']
|
||||
);
|
||||
if ($strict_user) {
|
||||
$user_name = db_get_value(
|
||||
'id_user',
|
||||
'tusuario',
|
||||
'id_user',
|
||||
$config['id_user']
|
||||
);
|
||||
|
||||
$users = [];
|
||||
$users[0]['id_user'] = $config['id_user'];
|
||||
$users[0]['fullname'] = $user_name;
|
||||
} else {
|
||||
$users = groups_get_users(
|
||||
$_user_groups,
|
||||
['id_perfil' => $profiles_view_events],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($users as $u) {
|
||||
$owners[$u['id_user']] = $u['id_user'];
|
||||
}
|
||||
|
||||
if ($event['owner_user'] == '') {
|
||||
if (empty($event['owner_user']) === true) {
|
||||
$owner_name = __('None');
|
||||
} else {
|
||||
$owner_name = db_get_value(
|
||||
|
@ -3153,7 +3141,7 @@ function events_page_responses($event, $childrens_ids=[])
|
|||
__('Update'),
|
||||
'owner_button',
|
||||
false,
|
||||
'event_change_owner();',
|
||||
'event_change_owner('.$event['id_evento'].', '.$event['server_id'].');',
|
||||
'class="sub next w70p"',
|
||||
true
|
||||
);
|
||||
|
@ -3171,8 +3159,7 @@ function events_page_responses($event, $childrens_ids=[])
|
|||
$config['id_user'],
|
||||
$event['id_grupo'],
|
||||
'EM',
|
||||
$event['clean_tags'],
|
||||
$childrens_ids
|
||||
$event['clean_tags']
|
||||
)
|
||||
) {
|
||||
// If the user has manager acls, the status can be changed to all
|
||||
|
@ -3243,14 +3230,12 @@ function events_page_responses($event, $childrens_ids=[])
|
|||
$config['id_user'],
|
||||
$event['id_grupo'],
|
||||
'EM',
|
||||
$event['clean_tags'],
|
||||
$childrens_ids
|
||||
$event['clean_tags']
|
||||
)) || (tags_checks_event_acl(
|
||||
$config['id_user'],
|
||||
$event['id_grupo'],
|
||||
'EW',
|
||||
$event['clean_tags'],
|
||||
$childrens_ids
|
||||
$event['clean_tags']
|
||||
))
|
||||
) {
|
||||
$table_responses->data[] = $data;
|
||||
|
@ -3275,8 +3260,7 @@ function events_page_responses($event, $childrens_ids=[])
|
|||
$config['id_user'],
|
||||
$event['id_grupo'],
|
||||
'EM',
|
||||
$event['clean_tags'],
|
||||
$childrens_ids
|
||||
$event['clean_tags']
|
||||
)
|
||||
) {
|
||||
// Delete.
|
||||
|
@ -3357,7 +3341,6 @@ function events_page_responses($event, $childrens_ids=[])
|
|||
var params = get_response_params(id_response);
|
||||
var description = get_response_description(id_response);
|
||||
$('.params_rows').remove();
|
||||
|
||||
$('#responses_table')
|
||||
.append('<tr class=\"params_rows\"><td>".__('Description')."</td><td class=\"height_30px\" colspan=\"2\">'+description+'</td></tr>');
|
||||
|
||||
|
@ -3383,20 +3366,15 @@ function events_page_responses($event, $childrens_ids=[])
|
|||
|
||||
/**
|
||||
* Replace macros in the target of a response and return it.
|
||||
* If server_id > 0, it's a metaconsole query.
|
||||
*
|
||||
* @param integer $event_id Event identifier.
|
||||
* @param integer $response_id Event response identifier.
|
||||
* @param integer $server_id Node identifier (for metaconsole).
|
||||
* @param boolean $history Use the history database or not.
|
||||
*
|
||||
* @return string The response text with the macros applied.
|
||||
*/
|
||||
function events_get_response_target(
|
||||
int $event_id,
|
||||
int $response_id,
|
||||
int $server_id=0,
|
||||
bool $history=false
|
||||
int $response_id
|
||||
) {
|
||||
global $config;
|
||||
|
||||
|
@ -3408,59 +3386,28 @@ function events_get_response_target(
|
|||
$eventObjt = new PandoraFMS\Event();
|
||||
}
|
||||
|
||||
// If server_id > 0, it's a metaconsole query.
|
||||
$meta = $server_id > 0 || is_metaconsole();
|
||||
$event_table = 'tevento';
|
||||
$event = db_get_row($event_table, 'id_evento', $event_id);
|
||||
|
||||
$event = db_get_row('tevento', 'id_evento', $event_id);
|
||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
||||
$target = io_safe_output($event_response['target']);
|
||||
|
||||
if (strpos($target, '_agent_alias_') !== false) {
|
||||
if ($meta) {
|
||||
$agente_table_name = 'tmetaconsole_agent';
|
||||
$filter = [
|
||||
'id_tagente' => $event['id_agente'],
|
||||
'id_tmetaconsole_setup' => $server_id,
|
||||
];
|
||||
} else {
|
||||
$agente_table_name = 'tagente';
|
||||
$filter = ['id_agente' => $event['id_agente']];
|
||||
}
|
||||
|
||||
$alias = db_get_value_filter('alias', $agente_table_name, $filter);
|
||||
$target = str_replace('_agent_alias_', io_safe_output($alias), $target);
|
||||
}
|
||||
|
||||
if (strpos($target, '_agent_name_') !== false) {
|
||||
if ($meta) {
|
||||
$agente_table_name = 'tmetaconsole_agent';
|
||||
$filter = [
|
||||
'id_tagente' => $event['id_agente'],
|
||||
'id_tmetaconsole_setup' => $server_id,
|
||||
];
|
||||
} else {
|
||||
$agente_table_name = 'tagente';
|
||||
$filter = ['id_agente' => $event['id_agente']];
|
||||
}
|
||||
|
||||
$name = db_get_value_filter('nombre', $agente_table_name, $filter);
|
||||
$target = str_replace('_agent_name_', io_safe_output($name), $target);
|
||||
}
|
||||
|
||||
// Substitute each macro.
|
||||
if (strpos($target, '_agent_address_') !== false) {
|
||||
if ($meta) {
|
||||
$agente_table_name = 'tmetaconsole_agent';
|
||||
$filter = [
|
||||
'id_tagente' => $event['id_agente'],
|
||||
'id_tmetaconsole_setup' => $server_id,
|
||||
];
|
||||
} else {
|
||||
$agente_table_name = 'tagente';
|
||||
$filter = ['id_agente' => $event['id_agente']];
|
||||
}
|
||||
|
||||
$ip = db_get_value_filter('direccion', $agente_table_name, $filter);
|
||||
// If agent has not an IP, display N/A.
|
||||
if ($ip === false || $ip === '') {
|
||||
|
@ -3478,18 +3425,21 @@ function events_get_response_target(
|
|||
|| (strpos($target, '_module_name_') !== false)
|
||||
) {
|
||||
if ($event['id_agentmodule'] !== 0) {
|
||||
if ($meta) {
|
||||
$server = metaconsole_get_connection_by_id($server_id);
|
||||
metaconsole_connect($server);
|
||||
}
|
||||
|
||||
$module = db_get_row('tagente_modulo', 'id_agente_modulo', $event['id_agentmodule']);
|
||||
if (empty($module['ip_target'])) {
|
||||
$module = db_get_row(
|
||||
'tagente_modulo',
|
||||
'id_agente_modulo',
|
||||
$event['id_agentmodule']
|
||||
);
|
||||
if (empty($module['ip_target']) === true) {
|
||||
$module['ip_target'] = __('N/A');
|
||||
}
|
||||
|
||||
$target = str_replace('_module_address_', $module['ip_target'], $target);
|
||||
if (empty($module['nombre'])) {
|
||||
$target = str_replace(
|
||||
'_module_address_',
|
||||
$module['ip_target'],
|
||||
$target
|
||||
);
|
||||
if (empty($module['nombre']) === true) {
|
||||
$module['nombre'] = __('N/A');
|
||||
}
|
||||
|
||||
|
@ -3498,10 +3448,6 @@ function events_get_response_target(
|
|||
io_safe_output($module['nombre']),
|
||||
$target
|
||||
);
|
||||
|
||||
if ($meta) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
} else {
|
||||
$target = str_replace('_module_address_', __('N/A'), $target);
|
||||
$target = str_replace('_module_name_', __('N/A'), $target);
|
||||
|
@ -3513,7 +3459,7 @@ function events_get_response_target(
|
|||
}
|
||||
|
||||
if (strpos($target, '_user_id_') !== false) {
|
||||
if (!empty($event['id_usuario'])) {
|
||||
if (empty($event['id_usuario']) === false) {
|
||||
$target = str_replace('_user_id_', $event['id_usuario'], $target);
|
||||
} else {
|
||||
$target = str_replace('_user_id_', __('N/A'), $target);
|
||||
|
@ -3567,13 +3513,17 @@ function events_get_response_target(
|
|||
if (strpos($target, '_alert_id_') !== false) {
|
||||
$target = str_replace(
|
||||
'_alert_id_',
|
||||
empty($event['id_alert_am']) ? __('N/A') : $event['id_alert_am'],
|
||||
(empty($event['id_alert_am']) === true) ? __('N/A') : $event['id_alert_am'],
|
||||
$target
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($target, '_event_severity_id_') !== false) {
|
||||
$target = str_replace('_event_severity_id_', $event['criticity'], $target);
|
||||
$target = str_replace(
|
||||
'_event_severity_id_',
|
||||
$event['criticity'],
|
||||
$target
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($target, '_event_severity_text_') !== false) {
|
||||
|
@ -3593,15 +3543,27 @@ function events_get_response_target(
|
|||
}
|
||||
|
||||
if (strpos($target, '_event_extra_id_') !== false) {
|
||||
if (empty($event['id_extra'])) {
|
||||
$target = str_replace('_event_extra_id_', __('N/A'), $target);
|
||||
if (empty($event['id_extra']) === true) {
|
||||
$target = str_replace(
|
||||
'_event_extra_id_',
|
||||
__('N/A'),
|
||||
$target
|
||||
);
|
||||
} else {
|
||||
$target = str_replace('_event_extra_id_', $event['id_extra'], $target);
|
||||
$target = str_replace(
|
||||
'_event_extra_id_',
|
||||
$event['id_extra'],
|
||||
$target
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($target, '_event_source_') !== false) {
|
||||
$target = str_replace('_event_source_', $event['source'], $target);
|
||||
$target = str_replace(
|
||||
'_event_source_',
|
||||
$event['source'],
|
||||
$target
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($target, '_event_instruction_') !== false) {
|
||||
|
@ -3673,7 +3635,7 @@ function events_get_response_target(
|
|||
}
|
||||
|
||||
if (strpos($target, '_owner_user_') !== false) {
|
||||
if (empty($event['owner_user'])) {
|
||||
if (empty($event['owner_user']) === true) {
|
||||
$target = str_replace('_owner_user_', __('N/A'), $target);
|
||||
} else {
|
||||
$target = str_replace('_owner_user_', $event['owner_user'], $target);
|
||||
|
@ -3895,17 +3857,20 @@ function events_page_related($event, $server='')
|
|||
* Generates the 'details' page in event view.
|
||||
*
|
||||
* @param array $event To be displayed.
|
||||
* @param string $server Server (if in metaconsole environment).
|
||||
* @param integer $server Server (if in metaconsole environment).
|
||||
*
|
||||
* @return string HTML to be displayed.
|
||||
*/
|
||||
function events_page_details($event, $server='')
|
||||
function events_page_details($event, $server_id=0)
|
||||
{
|
||||
global $img_sev;
|
||||
global $config;
|
||||
|
||||
// If server is provided, get the hash parameters.
|
||||
if (!empty($server) && is_metaconsole()) {
|
||||
// If metaconsole switch to node to get details and custom fields.
|
||||
$hashstring = '';
|
||||
$serverstring = '';
|
||||
if (is_metaconsole() === true && empty($server_id) === false) {
|
||||
$server = metaconsole_get_connection_by_id($server_id);
|
||||
$hashdata = metaconsole_get_server_hashdata($server);
|
||||
$hashstring = '&loginhash=auto&loginhash_data='.$hashdata.'&loginhash_user='.str_rot13($config['id_user']);
|
||||
$serverstring = $server['server_url'].'/';
|
||||
|
@ -3913,9 +3878,6 @@ function events_page_details($event, $server='')
|
|||
if (metaconsole_connect($server) !== NOERR) {
|
||||
return ui_print_error_message(__('There was an error connecting to the node'), '', true);
|
||||
}
|
||||
} else {
|
||||
$hashstring = '';
|
||||
$serverstring = '';
|
||||
}
|
||||
|
||||
$table_class = 'table_modal_alternate';
|
||||
|
@ -3929,21 +3891,6 @@ function events_page_details($event, $server='')
|
|||
$table_details->cellpadding = 0;
|
||||
$table_details->class = $table_class;
|
||||
|
||||
/*
|
||||
* Useless switch.
|
||||
|
||||
switch ($event['event_type']) {
|
||||
case 'going_unknown':
|
||||
case 'going_up_warning':
|
||||
case 'going_down_warning':
|
||||
case 'going_up_critical':
|
||||
case 'going_down_critical':
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
if ($event['id_agente'] != 0) {
|
||||
$agent = db_get_row('tagente', 'id_agente', $event['id_agente']);
|
||||
} else {
|
||||
|
@ -3954,7 +3901,7 @@ function events_page_details($event, $server='')
|
|||
$data[1] = empty($agent) ? '<i>'.__('N/A').'</i>' : '';
|
||||
$table_details->data[] = $data;
|
||||
|
||||
if (!empty($agent)) {
|
||||
if (empty($agent) === false) {
|
||||
$data = [];
|
||||
$data[0] = '<div class="normal_weight mrgn_lft_20px">'.__('Name').'</div>';
|
||||
if (can_user_access_node() && is_metaconsole() && empty($event['server_id']) === true) {
|
||||
|
@ -3996,7 +3943,7 @@ function events_page_details($event, $server='')
|
|||
$data = [];
|
||||
$data[0] = '<div class="normal_weight mrgn_lft_20px">'.__('OS').'</div>';
|
||||
$data[1] = ui_print_os_icon($agent['id_os'], true, true);
|
||||
if (!empty($agent['os_version'])) {
|
||||
if (empty($agent['os_version']) === false) {
|
||||
$data[1] .= ' ('.$agent['os_version'].')';
|
||||
}
|
||||
|
||||
|
@ -4042,7 +3989,7 @@ function events_page_details($event, $server='')
|
|||
$data[1] = empty($module) ? '<i>'.__('N/A').'</i>' : '';
|
||||
$table_details->data[] = $data;
|
||||
|
||||
if (!empty($module)) {
|
||||
if (empty($module) === false) {
|
||||
// Module name.
|
||||
$data = [];
|
||||
$data[0] = '<div class="normal_weight mrgn_lft_20px">'.__('Name').'</div>';
|
||||
|
@ -4071,14 +4018,7 @@ function events_page_details($event, $server='')
|
|||
|
||||
// ACL.
|
||||
$acl_graph = false;
|
||||
$strict_user = (bool) db_get_value(
|
||||
'strict_acl',
|
||||
'tusuario',
|
||||
'id_user',
|
||||
$config['id_user']
|
||||
);
|
||||
|
||||
if (!empty($agent['id_grupo'])) {
|
||||
if (empty($agent['id_grupo']) === false) {
|
||||
$acl_graph = check_acl(
|
||||
$config['id_user'],
|
||||
$agent['id_grupo'],
|
||||
|
@ -4114,7 +4054,7 @@ function events_page_details($event, $server='')
|
|||
'refresh' => SECONDS_10MINUTES,
|
||||
];
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
if (is_metaconsole() === true && empty($server_id) === false) {
|
||||
// Set the server id.
|
||||
$graph_params['server'] = $server['id'];
|
||||
}
|
||||
|
@ -4229,7 +4169,7 @@ function events_page_details($event, $server='')
|
|||
|
||||
$details = '<div id="extended_event_details_page" class="extended_event_pages">'.html_print_table($table_details, true).'</div>';
|
||||
|
||||
if (!empty($server) && is_metaconsole()) {
|
||||
if (is_metaconsole() === true && empty($server_id) === false) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
|
|
|
@ -2945,39 +2945,6 @@ function set_watermark(graph_id, plot, watermark_src) {
|
|||
);
|
||||
}
|
||||
|
||||
function get_event_details(event_ids) {
|
||||
table = "";
|
||||
if (typeof event_ids != "undefined") {
|
||||
var inputs = [];
|
||||
var table;
|
||||
inputs.push("get_events_details=1");
|
||||
inputs.push("event_ids=" + event_ids);
|
||||
inputs.push("page=include/ajax/events");
|
||||
|
||||
// Autologin
|
||||
if ($("#hidden-loginhash").val() != undefined) {
|
||||
inputs.push("loginhash=" + $("#hidden-loginhash").val());
|
||||
inputs.push("loginhash_data=" + $("#hidden-loginhash_data").val());
|
||||
inputs.push("loginhash_user=" + $("#hidden-loginhash_user").val());
|
||||
}
|
||||
|
||||
jQuery.ajax({
|
||||
data: inputs.join("&"),
|
||||
type: "GET",
|
||||
url: (action = "../../ajax.php"),
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
async: false,
|
||||
success: function(data) {
|
||||
table = data;
|
||||
//forced_title_callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
//Ajusta la grafica pequenña con el desplazamiento del eje y
|
||||
function adjust_left_width_canvas(adapter_id, adapted_id) {
|
||||
var adapter_left_margin = $("#" + adapter_id + " .yAxis .tickLabel").width();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*global jQuery,$,forced_title_callback,Base64, dt_events*/
|
||||
/*global jQuery, $, forced_title_callback, dt_events, confirmDialog*/
|
||||
|
||||
// Show the modal window of an event
|
||||
function show_event_dialog(event, dialog_page, result) {
|
||||
|
@ -117,7 +117,7 @@ function show_event_dialog(event, dialog_page, result) {
|
|||
function execute_response(event_id, server_id) {
|
||||
var response_id = $("#select_custom_response option:selected").val();
|
||||
|
||||
var response = get_response(response_id);
|
||||
var response = get_response(response_id, server_id);
|
||||
|
||||
// If cannot get response abort it
|
||||
if (response == null) {
|
||||
|
@ -232,13 +232,14 @@ function show_massive_response_dialog(
|
|||
}
|
||||
|
||||
// Get an event response from db
|
||||
function get_response(response_id) {
|
||||
function get_response(response_id, server_id) {
|
||||
var response = "";
|
||||
|
||||
var params = [];
|
||||
params.push("page=include/ajax/events");
|
||||
params.push("get_response=1");
|
||||
params.push("response_id=" + response_id);
|
||||
params.push("server_id=" + server_id);
|
||||
|
||||
jQuery.ajax({
|
||||
data: params.join("&"),
|
||||
|
@ -300,31 +301,6 @@ function get_response_description(response_id) {
|
|||
return response_description;
|
||||
}
|
||||
|
||||
// Get an event response description from db
|
||||
function get_event_name(event_id, meta, history) {
|
||||
var name = "";
|
||||
|
||||
var params = [];
|
||||
params.push("page=include/ajax/events");
|
||||
params.push("get_event_name=1");
|
||||
params.push("event_id=" + event_id);
|
||||
params.push("meta=" + meta);
|
||||
params.push("history=" + history);
|
||||
|
||||
jQuery.ajax({
|
||||
data: params.join("&"),
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: false,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
name = data;
|
||||
}
|
||||
});
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
function add_row_param(id_table, param) {
|
||||
$("#" + id_table).append(
|
||||
'<tr class="params_rows"><td style="text-align:left; padding-left:40px; font-weight: normal; font-style: italic;">' +
|
||||
|
@ -458,7 +434,7 @@ function perform_response_massive(response, response_id, out_iterator) {
|
|||
}
|
||||
|
||||
// Change the status of an event to new, in process or validated.
|
||||
function event_change_status(event_ids, node_id) {
|
||||
function event_change_status(event_ids, server_id) {
|
||||
var new_status = $("#estado").val();
|
||||
|
||||
$("#button-status_button").attr("disabled", "disabled");
|
||||
|
@ -470,7 +446,7 @@ function event_change_status(event_ids, node_id) {
|
|||
change_status: 1,
|
||||
event_ids: event_ids,
|
||||
new_status: new_status,
|
||||
node_id: node_id
|
||||
server_id: server_id
|
||||
},
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
|
@ -517,12 +493,8 @@ function event_change_status(event_ids, node_id) {
|
|||
}
|
||||
|
||||
// Change te owner of an event to one user of empty
|
||||
function event_change_owner() {
|
||||
var event_id = $("#hidden-id_event").val();
|
||||
function event_change_owner(event_id, server_id) {
|
||||
var new_owner = $("#id_owner").val();
|
||||
var meta = $("#hidden-meta").val();
|
||||
var history = $("#hidden-history").val();
|
||||
var node_id = $("#hidden-node_id").val();
|
||||
|
||||
$("#button-owner_button").attr("disabled", "disabled");
|
||||
$("#response_loading").show();
|
||||
|
@ -532,10 +504,8 @@ function event_change_owner() {
|
|||
page: "include/ajax/events",
|
||||
change_owner: 1,
|
||||
event_id: event_id,
|
||||
new_owner: new_owner,
|
||||
meta: meta,
|
||||
node_id: node_id,
|
||||
history: history
|
||||
server_id: server_id,
|
||||
new_owner: new_owner
|
||||
},
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
|
@ -588,11 +558,6 @@ function event_comment(current_event) {
|
|||
|
||||
var comment = $("#textarea_comment").val();
|
||||
|
||||
var history = 0;
|
||||
if ($("#hidden-history").val() != undefined) {
|
||||
history = $("#hidden-history").val();
|
||||
}
|
||||
|
||||
if (comment == "") {
|
||||
show_event_dialog(current_event, "comments", "comment_error");
|
||||
return false;
|
||||
|
@ -608,7 +573,6 @@ function event_comment(current_event) {
|
|||
}
|
||||
params.push("comment=" + comment);
|
||||
params.push("server_id=" + event.server_id);
|
||||
params.push("history=" + history);
|
||||
|
||||
$("#button-comment_button").attr("disabled", "disabled");
|
||||
$("#response_loading").show();
|
||||
|
@ -617,9 +581,8 @@ function event_comment(current_event) {
|
|||
data: params.join("&"),
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: true,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
success: function() {
|
||||
$("#button-comment_button").removeAttr("disabled");
|
||||
$("#response_loading").hide();
|
||||
$("#link_comments").click();
|
||||
|
@ -678,7 +641,7 @@ function show_event_response_command_dialog(id, response, total_checked) {
|
|||
}
|
||||
|
||||
var processed = 0;
|
||||
function update_event(table, id_evento, type, event_rep, row) {
|
||||
function update_event(table, id_evento, type, event_rep, row, server_id) {
|
||||
var inputs = $("#events_form :input");
|
||||
var values = {};
|
||||
var redraw = false;
|
||||
|
@ -697,6 +660,7 @@ function update_event(table, id_evento, type, event_rep, row) {
|
|||
in_process_event: type.in_process_event,
|
||||
delete_event: type.delete_event,
|
||||
id_evento: id_evento,
|
||||
server_id: server_id,
|
||||
event_rep: event_rep,
|
||||
filter: values
|
||||
},
|
||||
|
@ -726,7 +690,7 @@ function update_event(table, id_evento, type, event_rep, row) {
|
|||
}
|
||||
// Update events matching current filters and id_evento selected.
|
||||
|
||||
function validate_event(table, id_evento, event_rep, row) {
|
||||
function validate_event(table, id_evento, event_rep, row, server_id) {
|
||||
var button = document.getElementById("val-" + id_evento);
|
||||
if (!button) {
|
||||
// Button does not exist. Ignore.
|
||||
|
@ -736,10 +700,17 @@ function validate_event(table, id_evento, event_rep, row) {
|
|||
|
||||
button.children[0];
|
||||
button.children[0].src = "images/spinner.gif";
|
||||
return update_event(table, id_evento, { validate_event: 1 }, event_rep, row);
|
||||
return update_event(
|
||||
table,
|
||||
id_evento,
|
||||
{ validate_event: 1 },
|
||||
event_rep,
|
||||
row,
|
||||
server_id
|
||||
);
|
||||
}
|
||||
|
||||
function in_process_event(table, id_evento, event_rep, row) {
|
||||
function in_process_event(table, id_evento, event_rep, row, server_id) {
|
||||
var button = document.getElementById("proc-" + id_evento);
|
||||
if (!button) {
|
||||
// Button does not exist. Ignore.
|
||||
|
@ -754,11 +725,12 @@ function in_process_event(table, id_evento, event_rep, row) {
|
|||
id_evento,
|
||||
{ in_process_event: 1 },
|
||||
event_rep,
|
||||
row
|
||||
row,
|
||||
server_id
|
||||
);
|
||||
}
|
||||
|
||||
function delete_event(table, id_evento, event_rep, row) {
|
||||
function delete_event(table, id_evento, event_rep, row, server_id) {
|
||||
var button = document.getElementById("del-" + id_evento);
|
||||
if (!button) {
|
||||
// Button does not exist. Ignore.
|
||||
|
@ -779,7 +751,8 @@ function delete_event(table, id_evento, event_rep, row) {
|
|||
id_evento,
|
||||
{ delete_event: 1 },
|
||||
event_rep,
|
||||
row
|
||||
row,
|
||||
server_id
|
||||
);
|
||||
},
|
||||
onDeny: function() {
|
||||
|
|
|
@ -2209,10 +2209,10 @@ function process_datatables_item(item) {
|
|||
// Validate.
|
||||
item.options += '<a href="javascript:" onclick="validate_event(dt_<?php echo $table_id; ?>,';
|
||||
if (item.max_id_evento) {
|
||||
item.options += item.max_id_evento+', '+ item.event_rep +', this)" id="val-'+item.max_id_evento+'">';
|
||||
item.options += item.max_id_evento+', '+ item.event_rep +', this, '+item.server_id+')" id="val-'+item.max_id_evento+'">';
|
||||
item.options += '<?php echo html_print_image('images/tick.png', true, ['title' => __('Validate events'), 'class' => 'invert_filter']); ?></a>';
|
||||
} else {
|
||||
item.options += item.id_evento+', 0, this)" id="val-'+item.id_evento+'">';
|
||||
item.options += item.id_evento+', 0, this, '+item.server_id+')" id="val-'+item.id_evento+'">';
|
||||
item.options += '<?php echo html_print_image('images/tick.png', true, ['title' => __('Validate event'), 'class' => 'invert_filter']); ?></a>';
|
||||
}
|
||||
}
|
||||
|
@ -2221,9 +2221,9 @@ function process_datatables_item(item) {
|
|||
// In process.
|
||||
item.options += '<a href="javascript:" onclick="in_process_event(dt_<?php echo $table_id; ?>,';
|
||||
if (item.max_id_evento) {
|
||||
item.options += item.max_id_evento+', '+ item.event_rep +', this)" id="proc-'+item.max_id_evento+'">';
|
||||
item.options += item.max_id_evento+', '+ item.event_rep +', this, '+item.server_id+')" id="proc-'+item.max_id_evento+'">';
|
||||
} else {
|
||||
item.options += item.id_evento+', 0, this)" id="proc-'+item.id_evento+'">';
|
||||
item.options += item.id_evento+', 0, this, '+item.server_id+')" id="proc-'+item.id_evento+'">';
|
||||
}
|
||||
item.options += '<?php echo html_print_image('images/hourglass.png', true, ['title' => __('Change to in progress status'), 'class' => 'invert_filter']); ?></a>';
|
||||
}
|
||||
|
@ -2233,10 +2233,10 @@ function process_datatables_item(item) {
|
|||
// Delete.
|
||||
item.options += '<a href="javascript:" onclick="delete_event(dt_<?php echo $table_id; ?>,';
|
||||
if (item.max_id_evento) {
|
||||
item.options += item.max_id_evento+', '+ item.event_rep +', this)" id="del-'+item.max_id_evento+'">';
|
||||
item.options += item.max_id_evento+', '+ item.event_rep +', this, '+item.server_id+')" id="del-'+item.max_id_evento+'">';
|
||||
item.options += '<?php echo html_print_image('images/cross.png', true, ['title' => __('Delete events'), 'class' => 'invert_filter']); ?></a>';
|
||||
} else {
|
||||
item.options += item.id_evento+', 0, this)" id="del-'+item.id_evento+'">';
|
||||
item.options += item.id_evento+', 0, this, '+item.server_id+')" id="del-'+item.id_evento+'">';
|
||||
item.options += '<?php echo html_print_image('images/cross.png', true, ['title' => __('Delete event'), 'class' => 'invert_filter']); ?></a>';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue