From 4f80eec179e808298d0d1f7f97b9084d97ae47c1 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 1 Oct 2020 13:42:41 +0200 Subject: [PATCH] recovered changes after merge request --- pandora_console/include/functions_api.php | 64 +++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 19560ab774..c1c539e8d3 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -2519,6 +2519,70 @@ function api_get_module_id($id, $thrash1, $name, $thrash3) } +/** + * Retrieves custom_id from given module_id. + * + * @param integer $id Module id. + * + * @return void + */ +function api_get_module_custom_id($id) +{ + if (is_metaconsole()) { + return; + } + + try { + $module = new Module($id); + if (!util_api_check_agent_and_print_error( + $module->id_agente(), + 'json' + ) + ) { + return; + } + } catch (Exception $e) { + returnError('id_not_found', 'json'); + } + + returnData('json', $module->custom_id()); +} + + +/** + * Retrieves custom_id from given module_id. + * + * @param integer $id Module id. + * + * @return void + */ +function api_set_module_custom_id($id, $value) +{ + if (is_metaconsole()) { + return; + } + + try { + $module = new Module($id); + if (!util_api_check_agent_and_print_error( + $module->id_agente(), + 'json', + 'AW' + ) + ) { + return; + } + + $module->custom_id($value); + $module->save(); + } catch (Exception $e) { + returnError('id_not_found', 'json'); + } + + returnData('json', ['type' => 'string', 'data' => $module->custom_id()]); +} + + /** * Get modules for an agent, and print all the result like a csv. *