From 0d95b97b0916a645e472caf2ecb230193dfc0dce Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 30 Oct 2013 15:00:46 +0000 Subject: [PATCH] 2013-10-30 Miguel de Dios * include/functions_api.php: fixed the output of data as csv when the data have a return carriges. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8981 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 +++++ pandora_console/include/functions_api.php | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 1357d8263d..34e8ec7801 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2013-10-30 Miguel de Dios + + * include/functions_api.php: fixed the output of data as csv when + the data have a return carriges. + 2013-10-22 Hirofumi Kosaka * include/help/en/help_alert_config.php, diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index d393cfe51b..cae553ac6a 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -123,7 +123,7 @@ function returnData($returnType, $data, $separator = ';') { foreach($data['data'] as $dataContent) { foreach($data['list_index'] as $index) { if (array_key_exists($index, $dataContent)) - echo $dataContent[$index]; + echo str_replace("\n", " ", $dataContent[$index]); if (end($data['list_index']) == $index) echo "\n"; else @@ -135,7 +135,11 @@ function returnData($returnType, $data, $separator = ';') { if (!empty($data['data'])) { foreach($data['data'] as $dataContent) { $clean = array_map("array_apply_io_safe_output", $dataContent); - echo implode($separator, $clean) . "\n"; + $row = implode($separator, $clean); + $row = str_replace("\r", "\n", $row); + $row = str_replace("\n", " ", $row); + + echo $row . "\n"; } } } @@ -5406,7 +5410,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db $sql_post .= " AND id_grupo != 0"; } - switch($status) { + switch ($status) { case 0: case 1: case 2: @@ -5619,8 +5623,10 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db $data['data'] = $result; returnData($returnType, $data, $separator); + if (empty($result)) return false; + return true; }