From e316977d4b407bd7ae393d087de35bf930c7d947 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Wed, 16 Jan 2019 12:23:19 +0100 Subject: [PATCH] Refactorize and add two new fields to api_get_groups api function Former-commit-id: 2d59091279c284d549c09744ee61c8fee1e33564 --- pandora_console/include/functions_api.php | 34 +++++++++++------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 53479ae7ed..aa21faad1a 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -283,30 +283,28 @@ function api_get_test_event_replication_db() { //-------------------------DEFINED OPERATIONS FUNCTIONS----------------- function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db) { - if (defined ('METACONSOLE')) { - return; - } - 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]; - } - - $groups = users_get_groups ($user_in_db, "IR"); + $returnAllGroup = true; + $returnAllColumns = false; + + if (isset($other['data'][1])) + $returnAllGroup = ( $other['data'][1] == '1' ? true : false); + + if (isset($other['data'][2])) + $returnAllColumns = ( $other['data'][2] == '1' ? true : false); + + $groups = users_get_groups ($user_in_db, "IR", $returnAllGroup, $returnAllColumns); $data_groups = array(); foreach ($groups as $id => $group) { $data_groups[] = array($id, $group); } - + + if (!isset($other['data'][0])) + $separator = ';'; // by default + else + $separator = $other['data'][0]; + $data['type'] = 'array'; $data['data'] = $data_groups;