mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 15:54:29 +02:00
Merge branch 'ent-3497-event-responses-current-user-macro' into 'develop'
Added the _current_user_ macro to the event responses See merge request artica/pandorafms!2179 Former-commit-id: c468e43ec3add15487109c2c961630361bd9bdaf
This commit is contained in:
commit
d4cc0f6952
@ -90,9 +90,9 @@ if ($get_response_params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($get_response_target) {
|
if ($get_response_target) {
|
||||||
$response_id = get_parameter('response_id');
|
$response_id = (int) get_parameter('response_id');
|
||||||
$event_id = get_parameter('event_id');
|
$event_id = (int) get_parameter('event_id');
|
||||||
$server_id = get_parameter('server_id', 0);
|
$server_id = (int) get_parameter('server_id');
|
||||||
|
|
||||||
$event_response = db_get_row('tevent_response', 'id', $response_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);
|
echo events_get_response_target($event_id, $response_id, $server_id);
|
||||||
|
|
||||||
return;
|
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
|
* Replace macros in the target of a response and return it.
|
||||||
function events_get_response_target($event_id, $response_id, $server_id, $history=false)
|
* 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;
|
global $config;
|
||||||
|
|
||||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
// If server_id > 0, it's a metaconsole query.
|
||||||
|
$meta = $server_id > 0;
|
||||||
if ($server_id > 0) {
|
|
||||||
$meta = true;
|
|
||||||
} else {
|
|
||||||
$meta = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$event_table = events_get_events_table($meta, $history);
|
$event_table = events_get_events_table($meta, $history);
|
||||||
|
|
||||||
$event = db_get_row($event_table, 'id_evento', $event_id);
|
$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']);
|
$target = io_safe_output($event_response['target']);
|
||||||
|
|
||||||
// Substitute each macro
|
// Substitute each macro.
|
||||||
if (strpos($target, '_agent_address_') !== false) {
|
if (strpos($target, '_agent_address_') !== false) {
|
||||||
if ($meta) {
|
if ($meta) {
|
||||||
$agente_table_name = 'tmetaconsole_agent';
|
$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);
|
$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) {
|
if ($ip === false) {
|
||||||
$ip = __('N/A');
|
$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);
|
$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'])) {
|
if (!empty($event['custom_data'])) {
|
||||||
$custom_data = json_decode(base64_decode($event['custom_data']));
|
$custom_data = json_decode(base64_decode($event['custom_data']));
|
||||||
foreach ($custom_data as $key => $value) {
|
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;
|
return $target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ The accepted macros are:
|
|||||||
<li><b>Event associated module name:</b> _module_name_</li>
|
<li><b>Event associated module name:</b> _module_name_</li>
|
||||||
<li><b>Event owner user:</b> _owner_user_</li>
|
<li><b>Event owner user:</b> _owner_user_</li>
|
||||||
<li><b>User ID:</b> _user_id_</li>
|
<li><b>User ID:</b> _user_id_</li>
|
||||||
|
<li><b>Id of the user who fires the response:</b> _current_user_</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h4>Custom fields</h4>
|
<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>Nombre del módulo asociado al evento:</b> _module_name_</li>
|
||||||
<li><b>Usuario propietario del evento:</b> _owner_user_</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:</b> _user_id_</li>
|
||||||
|
<li><b>Id del usuario que ejecuta la respuesta:</b> _current_user_</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h4>Campos personalizados</h4>
|
<h4>Campos personalizados</h4>
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
<li><b>Event associated module name:</b> _module_name_</li>
|
<li><b>Event associated module name:</b> _module_name_</li>
|
||||||
<li><b>Event owner user:</b> _owner_user_</li>
|
<li><b>Event owner user:</b> _owner_user_</li>
|
||||||
<li><b>User ID:</b> _user_id_</li>
|
<li><b>User ID:</b> _user_id_</li>
|
||||||
|
<li><b>Id of the user who fires the response:</b> _current_user_</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h4>Custom fields</h4>
|
<h4>Custom fields</h4>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user