Added the _current_user_ macro to the event responses
Former-commit-id: 1a5860bc7a62efecba44d467df9eb9cf7e25070b
This commit is contained in:
parent
b8fe20e373
commit
d554dcc7db
|
@ -90,9 +90,9 @@ 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);
|
||||
$response_id = (int) get_parameter('response_id');
|
||||
$event_id = (int) get_parameter('event_id');
|
||||
$server_id = (int) get_parameter('server_id');
|
||||
|
||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
||||
|
||||
|
@ -101,7 +101,6 @@ if ($get_response_target) {
|
|||
}
|
||||
|
||||
echo events_get_response_target($event_id, $response_id, $server_id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -2089,27 +2089,34 @@ function events_page_responses($event, $childrens_ids=[])
|
|||
}
|
||||
|
||||
|
||||
// Replace macros in the target of a response and return it
|
||||
// If server_id > 0, is a metaconsole query
|
||||
function events_get_response_target($event_id, $response_id, $server_id, $history=false)
|
||||
{
|
||||
/**
|
||||
* 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
|
||||
) {
|
||||
global $config;
|
||||
|
||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
||||
|
||||
if ($server_id > 0) {
|
||||
$meta = true;
|
||||
} else {
|
||||
$meta = false;
|
||||
}
|
||||
|
||||
// If server_id > 0, it's a metaconsole query.
|
||||
$meta = $server_id > 0;
|
||||
$event_table = events_get_events_table($meta, $history);
|
||||
|
||||
$event = db_get_row($event_table, 'id_evento', $event_id);
|
||||
|
||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
||||
$target = io_safe_output($event_response['target']);
|
||||
|
||||
// Substitute each macro
|
||||
// Substitute each macro.
|
||||
if (strpos($target, '_agent_address_') !== false) {
|
||||
if ($meta) {
|
||||
$agente_table_name = 'tmetaconsole_agent';
|
||||
|
@ -2123,7 +2130,7 @@ function events_get_response_target($event_id, $response_id, $server_id, $histor
|
|||
}
|
||||
|
||||
$ip = db_get_value_filter('direccion', $agente_table_name, $filter);
|
||||
// If agent has not an ip, display N/A
|
||||
// If agent has not an IP, display N/A.
|
||||
if ($ip === false) {
|
||||
$ip = __('N/A');
|
||||
}
|
||||
|
@ -2288,7 +2295,7 @@ function events_get_response_target($event_id, $response_id, $server_id, $histor
|
|||
$target = str_replace('_group_custom_id_', $group_custom_id, $target);
|
||||
}
|
||||
|
||||
// Parse the event custom data
|
||||
// Parse the event custom data.
|
||||
if (!empty($event['custom_data'])) {
|
||||
$custom_data = json_decode(base64_decode($event['custom_data']));
|
||||
foreach ($custom_data as $key => $value) {
|
||||
|
@ -2296,6 +2303,11 @@ function events_get_response_target($event_id, $response_id, $server_id, $histor
|
|||
}
|
||||
}
|
||||
|
||||
// This will replace the macro with the current logged user.
|
||||
if (strpos($target, '_current_user_') !== false) {
|
||||
$target = str_replace('_current_user_', $config['id_user'], $target);
|
||||
}
|
||||
|
||||
return $target;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ The accepted macros are:
|
|||
<li><b>Event associated module name:</b> _module_name_</li>
|
||||
<li><b>Event owner user:</b> _owner_user_</li>
|
||||
<li><b>User ID:</b> _user_id_</li>
|
||||
<li><b>Id of the user who fires the response:</b> _current_user_</li>
|
||||
</ul>
|
||||
|
||||
<h4>Custom fields</h4>
|
||||
|
|
|
@ -33,6 +33,7 @@ Las macros aceptadas son las siguientes:
|
|||
<li><b>Nombre del módulo asociado al evento:</b> _module_name_</li>
|
||||
<li><b>Usuario propietario del evento:</b> _owner_user_</li>
|
||||
<li><b>Id del usuario:</b> _user_id_</li>
|
||||
<li><b>Id del usuario que ejecuta la respuesta:</b> _current_user_</li>
|
||||
</ul>
|
||||
|
||||
<h4>Campos personalizados</h4>
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<li><b>Event associated module name:</b> _module_name_</li>
|
||||
<li><b>Event owner user:</b> _owner_user_</li>
|
||||
<li><b>User ID:</b> _user_id_</li>
|
||||
<li><b>Id of the user who fires the response:</b> _current_user_</li>
|
||||
</ul>
|
||||
|
||||
<h4>Custom fields</h4>
|
||||
|
|
Loading…
Reference in New Issue