From 28097670debdb8dc4781b0d18873566ab39689e4 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Sat, 14 Jun 2014 07:07:04 +0000 Subject: [PATCH] In advanced -> default settings add the following cdr->format->text = xml,json and cdr->storage->text = db,dir --- app/xml_cdr/v_xml_cdr_import.php | 39 ++++++++++++++++------ core/default_settings/default_settings.php | 21 +++++++++--- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/app/xml_cdr/v_xml_cdr_import.php b/app/xml_cdr/v_xml_cdr_import.php index fedd6652e8..be4579c50f 100644 --- a/app/xml_cdr/v_xml_cdr_import.php +++ b/app/xml_cdr/v_xml_cdr_import.php @@ -193,6 +193,7 @@ } //determine where the xml cdr will be archived + /* $sql = "select * from v_vars "; $sql .= "where var_name = 'xml_cdr_archive' "; $row = $db->query($sql)->fetch(); @@ -217,14 +218,15 @@ $xml_cdr_archive = 'dir'; break; } + */ - //if xml_cdr_archive is set to db then insert it. - if ($xml_cdr_archive == "xml" || $xml_cdr_archive == "db") { + //save to the database in xml format + if ($_SESSION['cdr']['format']['text'] == "xml" && $_SESSION['cdr']['storage']['text'] == "db") { $database->fields['xml'] = check_str($xml_string); } - //if xml_cdr_archive is set to db then insert it. - if ($xml_cdr_archive == "json") { + //save to the database in json format + if ($_SESSION['cdr']['format']['text'] == "json" && $_SESSION['cdr']['storage']['text'] == "db") { $database->fields['json'] = json_encode($xml); } @@ -256,16 +258,24 @@ if(!file_exists($tmp_dir)) { mkdir($tmp_dir, 0777, true); } - $tmp_file = $uuid.'.xml'; - $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); - fwrite($fh, $xml_string); + if ($_SESSION['cdr']['format']['text'] == "xml") { + $tmp_file = $uuid.'.xml'; + $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); + fwrite($fh, $xml_string); + } + else { + $tmp_file = $uuid.'.json'; + $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); + fwrite($fh, json_encode($xml)); + } fclose($fh); if ($debug) { echo $e->getMessage(); } $error = "true"; } - //if xml_cdr_archive is set to dir, then store it. + + if ($_SESSION['cdr']['storage']['text'] == "dir" && $error != "true") { if ($xml_cdr_archive == "dir" && $error != "true") { if (strlen($uuid) > 0) { $tmp_time = strtotime($start_stamp); @@ -276,9 +286,16 @@ if(!file_exists($tmp_dir)) { mkdir($tmp_dir, 0777, true); } - $tmp_file = $uuid.'.xml'; - $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); - fwrite($fh, $xml_string); + if ($_SESSION['cdr']['format']['text'] == "xml") { + $tmp_file = $uuid.'.xml'; + $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); + fwrite($fh, $xml_string); + } + else { + $tmp_file = $uuid.'.json'; + $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); + fwrite($fh, json_encode($xml)); + } fclose($fh); } } diff --git a/core/default_settings/default_settings.php b/core/default_settings/default_settings.php index 615b6afede..4833acb6b7 100644 --- a/core/default_settings/default_settings.php +++ b/core/default_settings/default_settings.php @@ -118,10 +118,23 @@ require_once "resources/paging.php"; foreach($result as $row) { if ($previous_category != $row['default_setting_category']) { - echo "\n"; - if ($previous_category != '') { echo "

"; } - echo "
\n"; - echo " ".ucfirst($row['default_setting_category'])." \n"; + echo "\n"; + echo " \n"; + if ($previous_category != '') { echo "

"; } + echo "
\n"; + echo " \n"; + if (strtolower($row['default_setting_category']) == "cdr") { + echo " CDR"; + } + elseif (strtolower($row['default_setting_category']) == "ldap") { + echo " LDAP"; + } + else { + echo " ".ucfirst($row['default_setting_category']); + } + echo " \n"; + echo " \n"; + echo "\n"; echo "\n"; echo th_order_by('default_setting_subcategory', $text['label-subcategory'], $order_by, $order); echo th_order_by('default_setting_name', $text['label-type'], $order_by, $order);