diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 60bb7566cc..91453d4acd 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2012-05-31 Santiago Munin + + * include/functions_tags.php: Added a method to get all tags. + * include/functions_api.php: Added de get_tags api call. + 2012-05-31 Juan Manuel Ramon * include/graphs/functions_pchart.php diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 463e5c3a3a..1a63496c3d 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -5102,4 +5102,31 @@ function set_enable_module_alerts ($agent_name, $module_name, $thrash3, $thrash4 returnData('string', array('type' => 'string', 'data' => "Correct alerts enable")); } +function get_tags($thrash1, $thrash2, $other, $returnType, $user_in_db) { + if ($other['type'] == 'string') { + if ($other['data'] != '') { + returnError('error_parameter', 'Error in the parameters.'); + return; + } + else {//Default values + $separator = ';'; + } + } + else if ($other['type'] == 'array') { + $separator = $other['data'][0]; + } + + $tags = tags_get_all_tags(); + + $data_tags = array(); + foreach ($tags as $id => $tag) { + $data_tags[] = array($id, $tag); + } + + $data['type'] = 'array'; + $data['data'] = $data_tags; + + returnData($returnType, $data, $separator); +} + ?> diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index a8895e92ad..eaaed06bd5 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -443,5 +443,24 @@ function tags_get_policy_module_tags ($id_policy_module){ return $return; } +/** + * Select all tags. + * + * @return mixed Array with tags. + */ +function tags_get_all_tags (){ + + $tags = db_get_all_fields_in_table('ttag', 'name'); + + if ($tags === false) + return false; + + $return = array(); + foreach ($tags as $id => $tag){ + $return[$id] = $tag['name']; + } + + return $return; +} ?>