From 112b4e3097fa0afe35a3a253b0a581478b699c32 Mon Sep 17 00:00:00 2001 From: enriquecd Date: Fri, 5 Oct 2018 17:01:11 +0200 Subject: [PATCH] Add get_group_id_by_name and get_timezone to api functions - #2756 --- pandora_console/include/functions_api.php | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index e66fb3dcaf..70defdb489 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -11748,6 +11748,50 @@ function api_set_validate_traps ($id, $thrash2, $other, $thrash3) { 'data' => __('Deleted traps.'))); } } + + function api_get_group_id_by_name($thrash1, $thrash2, $other, $thrash3) { + if (defined ('METACONSOLE')) { + return; + } + + $sql = sprintf('SELECT id_grupo + FROM tgrupo WHERE nombre = "'.$other['data'].'"'); + + $group_id = db_get_all_rows_sql($sql); + + if (count($group_id) > 0 and $group_id !== false) { + $data = array('type' => 'array', 'data' => $group_id); + + returnData('csv', $data, ';'); + } + else { + returnError('error_group_name', 'No groups retrieved.'); + } + } + + function api_get_timezone($thrash1, $thrash2, $other, $thrash3) { + if (defined ('METACONSOLE')) { + return; + } + + $sql = sprintf('SELECT value + FROM tconfig WHERE token = "timezone"'); + + $timezone = db_get_all_rows_sql($sql); + + if (count($timezone) > 0 and $timezone !== false) { + + $data = array('type' => 'string', 'data' => $timezone); + + returnData('string',array('type' => 'string','data' => $data['data'][0]['value'])); + + } + else { + returnError('error_timezone', 'No timezone retrieved.'); + } + } + + ?>