2012-12-20 Sergio Martin <sergio.martin@artica.es>
* include/ajax/events.php include/functions_events.php include/javascript/pandora_events.js: Adapt responses to metaconsole connection (retrieving of event address macro) and set format to tags in event view git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7317 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
54dd8cbc00
commit
e8f3153d11
|
@ -1,3 +1,11 @@
|
|||
2012-12-20 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/ajax/events.php
|
||||
include/functions_events.php
|
||||
include/javascript/pandora_events.js: Adapt responses
|
||||
to metaconsole connection (retrieving of event address macro)
|
||||
and set format to tags in event view
|
||||
|
||||
2012-12-20 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_groups.php: Added missed translation of
|
||||
|
|
|
@ -89,6 +89,7 @@ if($get_response_params) {
|
|||
if($get_response_target) {
|
||||
$response_id = get_parameter ('response_id');
|
||||
$event_id = get_parameter ('event_id');
|
||||
$server_id = get_parameter ('server_id', 0);
|
||||
|
||||
$event_response = db_get_row('tevent_response','id',$response_id);
|
||||
|
||||
|
@ -96,7 +97,7 @@ if($get_response_target) {
|
|||
return;
|
||||
}
|
||||
|
||||
echo events_get_response_target($event_id, $response_id);
|
||||
echo events_get_response_target($event_id, $response_id, $server_id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -315,7 +316,7 @@ if($get_extended_event) {
|
|||
$custom_fields = events_page_custom_fields($event);
|
||||
|
||||
if($meta) {
|
||||
metaconsole_restore_db();
|
||||
metaconsole_restore_db_force();
|
||||
}
|
||||
|
||||
$general = events_page_general($event);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
// GNU General Public License for more details.
|
||||
|
||||
include_once($config['homedir'] . "/include/functions_ui.php");
|
||||
include_once($config['homedir'] . "/include/functions_tags.php");
|
||||
enterprise_include_once ('meta/include/functions_events_meta.php');
|
||||
|
||||
/**
|
||||
|
@ -1427,7 +1428,15 @@ function events_page_responses ($event) {
|
|||
$responses[$v['id']] = $v['name'];
|
||||
}
|
||||
$data[1] .= html_print_select($responses,'select_custom_response','','','','',true, false, false);
|
||||
$data[1] .= html_print_button(__('Execute'),'custom_response_button',false,'execute_response('.$event['id_evento'].')',"class='sub next'",true);
|
||||
|
||||
if(isset($event['server_id'])) {
|
||||
$server_id = $event['server_id'];
|
||||
}
|
||||
else {
|
||||
$server_id = 0;
|
||||
}
|
||||
|
||||
$data[1] .= html_print_button(__('Execute'),'custom_response_button',false,'execute_response('.$event['id_evento'].','.$server_id.')',"class='sub next'",true);
|
||||
}
|
||||
|
||||
$table_responses->data[] = $data;
|
||||
|
@ -1460,19 +1469,36 @@ function events_page_responses ($event) {
|
|||
}
|
||||
|
||||
// Replace macros in the target of a response and return it
|
||||
function events_get_response_target($event_id, $response_id) {
|
||||
// If server_id > 0, is a metaconsole query
|
||||
function events_get_response_target($event_id, $response_id, $server_id) {
|
||||
global $config;
|
||||
$event_response = db_get_row('tevent_response','id',$response_id);
|
||||
|
||||
$event = db_get_row('tevento','id_evento',$event_id);
|
||||
|
||||
if($server_id > 0) {
|
||||
$event = db_get_row('tmetaconsole_event','id_evento', $event_id);
|
||||
}
|
||||
else {
|
||||
$event = db_get_row('tevento','id_evento',$event_id);
|
||||
}
|
||||
|
||||
$macros = array_keys(events_get_macros());
|
||||
|
||||
$target = io_safe_output($event_response['target']);
|
||||
|
||||
foreach($macros as $macro) {
|
||||
$subst = '';
|
||||
switch($macro) {
|
||||
case '_agent_address_':
|
||||
if($server_id > 0) {
|
||||
$server = metaconsole_get_connection_by_id ($server_id);
|
||||
metaconsole_connect($server);
|
||||
}
|
||||
|
||||
$subst = agents_get_address($event['id_agente']);
|
||||
|
||||
if($server_id > 0) {
|
||||
metaconsole_restore_db_force();
|
||||
}
|
||||
break;
|
||||
case '_agent_id_':
|
||||
$subst = $event['id_agente'];
|
||||
|
@ -1895,8 +1921,27 @@ function events_page_general ($event) {
|
|||
$data[0] = __('Tags');
|
||||
|
||||
if ($event["tags"] != '') {
|
||||
$tags = str_replace(' ','',$event["tags"]);
|
||||
$tags_array = explode(',',$event["tags"]);
|
||||
|
||||
$tags = array();
|
||||
foreach($tags_array as $t) {
|
||||
$tag_url = explode(' ', $t);
|
||||
$tag = $tag_url[0];
|
||||
if(isset($tag_url[1]) && $tag_url[1] != '') {
|
||||
$title = __($tag_url[1]);
|
||||
$link = '<a href="'.$tag_url[1].'" target="_blank">'.html_print_image('images/zoom.png',true, array('alt' => $title, 'title' => $title)).'</a>';
|
||||
}
|
||||
else {
|
||||
$link = '';
|
||||
}
|
||||
|
||||
$tags[] = $tag.$link;
|
||||
}
|
||||
|
||||
$tags = implode(',',$tags);
|
||||
|
||||
$tags = str_replace(',',' , ',$tags);
|
||||
|
||||
$data[1] = $tags;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -76,7 +76,7 @@ function show_event_dialog(event_id, group_rep, dialog_page, result) {
|
|||
}
|
||||
|
||||
// Check the response type and open it in a modal dialog or new window
|
||||
function execute_response(event_id) {
|
||||
function execute_response(event_id, server_id) {
|
||||
var response_id = $('#select_custom_response option:selected').val();
|
||||
|
||||
var response = get_response(response_id);
|
||||
|
@ -86,7 +86,7 @@ function execute_response(event_id) {
|
|||
return;
|
||||
}
|
||||
|
||||
response['target'] = get_response_target(event_id, response_id);
|
||||
response['target'] = get_response_target(event_id, response_id, server_id);
|
||||
|
||||
switch(response['type']) {
|
||||
case 'command':
|
||||
|
@ -252,7 +252,7 @@ function add_row_param(id_table, param) {
|
|||
}
|
||||
|
||||
// Get an event response from db
|
||||
function get_response_target(event_id, response_id) {
|
||||
function get_response_target(event_id, response_id, server_id) {
|
||||
var ajax_file = $('#hidden-ajax_file').val();
|
||||
|
||||
var target = '';
|
||||
|
@ -263,6 +263,7 @@ function get_response_target(event_id, response_id) {
|
|||
params.push("get_response_target=1");
|
||||
params.push("event_id="+event_id);
|
||||
params.push("response_id="+response_id);
|
||||
params.push("server_id="+server_id);
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params.join ("&"),
|
||||
|
|
Loading…
Reference in New Issue