From 1e9f086caeab83599170d79acfe74cea0fe3f41a Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 5 Jan 2016 12:17:12 +0100 Subject: [PATCH] Fixes for the management groups in the API. TICKET: #3119 (cherry picked from commit f9ee9a7032fd7e3efab7b33a6a1b9ad30aa5c654) --- pandora_console/include/functions_api.php | 23 +++++++++++++------- pandora_console/include/functions_groups.php | 7 ++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 24da031036..95ef87da7d 100755 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -1611,7 +1611,7 @@ function api_get_locate_agent($id, $thrash1, $thrash2, $thrash3) { * and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_) * example: * - * api.php?op=get&op2=group_agent&return_type=csv&other=Pepito&other_mode=url_encode_separator_| + * api.php?op=get&op2=id_group_agent_by_name&return_type=csv&other=Pepito&other_mode=url_encode_separator_| * * @param $thrash3 Don't use. */ @@ -1651,8 +1651,8 @@ function api_get_id_group_agent_by_name($thrash1, $thrash2, $other, $thrash3) { } else { $agent_id = agents_get_agent_id($other['data'][0],true); - - $sql = sprintf("SELECT groups.nombre nombre + + $sql = sprintf("SELECT groups.id_grupo id_group FROM tagente agents, tgrupo groups WHERE id_agente = %d AND agents.id_grupo = groups.id_grupo",$agent_id); @@ -5497,23 +5497,30 @@ function api_set_create_group($id, $thrash1, $other, $thrash3) { $group_name = $id; + + if ($id == "") { - returnError('error_create_group', __('Error in group creation. Group_name cannot be left blank.')); + returnError('error_create_group', + __('Error in group creation. Group_name cannot be left blank.')); return; } if ($other['data'][0] == "") { - returnError('error_create_group', __('Error in group creation. Icon_name cannot be left blank.')); + returnError('error_create_group', + __('Error in group creation. Icon_name cannot be left blank.')); return; } + + $safe_other_data = io_safe_input($other['data']); - + if ($safe_other_data[1] != "") { - $group = groups_get_group_by_id($safe_other_data[1]); + $group = groups_get_group_by_id($safe_other_data[1]); if ($group == false) { - returnError('error_create_group', __('Error in group creation. Id_parent_group doesn\'t exists.')); + returnError('error_create_group', + __('Error in group creation. Id_parent_group doesn\'t exists.')); return; } } diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 3a6fca510a..181aa2053b 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -1128,6 +1128,13 @@ function groups_create_group($group_name, $rest_values) { $values = array_merge($rest_values, $array_tmp); + if (!isset($values['propagate'])) { + $values['propagate'] = 0; + } + if (!isset($values['disabled'])) { + $values['disabled'] = 0; + } + $check = db_get_value('nombre', 'tgrupo', 'nombre', $group_name); if (!$check) {