Add get_group_id_by_name and get_timezone to api functions - #2756

This commit is contained in:
enriquecd 2018-10-05 17:01:11 +02:00
parent 740a7f0327
commit 112b4e3097
1 changed files with 44 additions and 0 deletions

View File

@ -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.');
}
}
?>