From 8044a851ebae44eba2cc04d89853e34d74080db4 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 2 Oct 2019 15:41:49 -0600 Subject: [PATCH] CDR: Permissions to control data columns displayed. --- app/xml_cdr/app_config.php | 82 ++++++--- app/xml_cdr/app_languages.php | 24 +-- app/xml_cdr/xml_cdr.php | 303 ++++++++++++++++++++-------------- 3 files changed, 254 insertions(+), 155 deletions(-) diff --git a/app/xml_cdr/app_config.php b/app/xml_cdr/app_config.php index 44179e6696..d9b4f7ce4c 100644 --- a/app/xml_cdr/app_config.php +++ b/app/xml_cdr/app_config.php @@ -96,10 +96,73 @@ $apps[$x]['permissions'][$y]['name'] = "xml_cdr_search_advanced"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_direction"; + $apps[$x]['permissions'][$y]['groups'][] = "user"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; $apps[$x]['permissions'][$y]['name'] = "xml_cdr_extension"; $apps[$x]['permissions'][$y]['groups'][] = "admin"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_all"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_caller_id_name"; + $apps[$x]['permissions'][$y]['groups'][] = "user"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_caller_id_number"; + $apps[$x]['permissions'][$y]['groups'][] = "user"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_caller_destination"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_destination"; + $apps[$x]['permissions'][$y]['groups'][] = "user"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_recording"; + $apps[$x]['permissions'][$y]['groups'][] = "user"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_custom_fields"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_start"; + $apps[$x]['permissions'][$y]['groups'][] = "user"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_tta"; + $apps[$x]['permissions'][$y]['groups'][] = "user"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_duration"; + $apps[$x]['permissions'][$y]['groups'][] = "user"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_pdd"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_mos"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_hangup_cause"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; $apps[$x]['permissions'][$y]['name'] = "xml_cdr_domain"; $apps[$x]['permissions'][$y]['groups'][] = "admin"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; @@ -117,28 +180,9 @@ $apps[$x]['permissions'][$y]['groups'][] = "admin"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $y++; - $apps[$x]['permissions'][$y]['name'] = "xml_cdr_pdd"; - $apps[$x]['permissions'][$y]['groups'][] = "admin"; - $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; - $y++; - $apps[$x]['permissions'][$y]['name'] = "xml_cdr_mos"; - $apps[$x]['permissions'][$y]['groups'][] = "admin"; - $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; - $y++; - $apps[$x]['permissions'][$y]['name'] = "xml_cdr_all"; - $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; - $y++; $apps[$x]['permissions'][$y]['name'] = "xml_cdr_b_leg"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $y++; - $apps[$x]['permissions'][$y]['name'] = "xml_cdr_hangup_cause"; - $apps[$x]['permissions'][$y]['groups'][] = "admin"; - $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; - $y++; - $apps[$x]['permissions'][$y]['name'] = "xml_cdr_caller_destination"; - $apps[$x]['permissions'][$y]['groups'][] = "admin"; - $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; - $y++; $apps[$x]['permissions'][$y]['name'] = "xml_cdr_archive"; $apps[$x]['permissions'][$y]['groups'][] = "admin"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; diff --git a/app/xml_cdr/app_languages.php b/app/xml_cdr/app_languages.php index d520c64797..3a04c52f8c 100644 --- a/app/xml_cdr/app_languages.php +++ b/app/xml_cdr/app_languages.php @@ -2680,24 +2680,24 @@ $text['button-download_csv']['ru-ru'] = "Загрузить в формате CS $text['button-download_csv']['sv-se'] = "Ladda Ned CSV"; $text['button-download_csv']['uk-ua'] = ""; -$text['button-advanced_search']['en-us'] = "Advanced Search"; +$text['button-advanced_search']['en-us'] = "Advanced"; $text['button-advanced_search']['ar-eg'] = ""; -$text['button-advanced_search']['de-at'] = "Erweiterte Suche"; //copied from de-de -$text['button-advanced_search']['de-ch'] = "Erweiterte Suche"; //copied from de-de -$text['button-advanced_search']['de-de'] = "Erweiterte Suche"; -$text['button-advanced_search']['es-cl'] = "Búsqueda Avanzada"; -$text['button-advanced_search']['es-mx'] = "Búsqueda Avanzada"; //copied from es-cl -$text['button-advanced_search']['fr-ca'] = "Recherche Avancée"; //copied from fr-fr -$text['button-advanced_search']['fr-fr'] = "Recherche Avancée"; +$text['button-advanced_search']['de-at'] = "Erweiterte"; //copied from de-de +$text['button-advanced_search']['de-ch'] = "Erweiterte"; //copied from de-de +$text['button-advanced_search']['de-de'] = "Erweiterte"; +$text['button-advanced_search']['es-cl'] = "Avanzada"; +$text['button-advanced_search']['es-mx'] = "Avanzada"; //copied from es-cl +$text['button-advanced_search']['fr-ca'] = "Avancée"; //copied from fr-fr +$text['button-advanced_search']['fr-fr'] = "Avancée"; $text['button-advanced_search']['he-il'] = ""; -$text['button-advanced_search']['it-it'] = "Ricerca Avanzata"; +$text['button-advanced_search']['it-it'] = "Avanzata"; $text['button-advanced_search']['nl-nl'] = ""; $text['button-advanced_search']['pl-pl'] = "Zaawansowane wyszukiwanie"; -$text['button-advanced_search']['pt-br'] = "Pesquisa Avançada "; -$text['button-advanced_search']['pt-pt'] = "Pesquisa Avançada"; +$text['button-advanced_search']['pt-br'] = "Avançada "; +$text['button-advanced_search']['pt-pt'] = "Avançada"; $text['button-advanced_search']['ro-ro'] = ""; $text['button-advanced_search']['ru-ru'] = "Расширенный поиск"; -$text['button-advanced_search']['sv-se'] = "Avancerad Sökning"; +$text['button-advanced_search']['sv-se'] = "Avancerad"; $text['button-advanced_search']['uk-ua'] = ""; ?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index 5c904d365c..adeae6a4ad 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -135,12 +135,6 @@ echo " \n"; } } - if (permission_exists('xml_cdr_search_advanced')) { - if ($_REQUEST['show'] == 'all') { - $query_string = "show=all"; - } - echo " \n"; - } if ($_GET['call_result'] != 'missed') { echo " \n"; } @@ -385,15 +379,27 @@ if (permission_exists('xml_cdr_all')) { echo " \n"; } - echo " \n"; - echo " \n"; + if (permission_exists('xml_cdr_caller_id_name')) { + echo " \n"; + } + if (permission_exists('xml_cdr_caller_id_number')) { + echo " \n"; + } if (permission_exists('xml_cdr_caller_destination')) { echo " \n"; } - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + if (permission_exists('xml_cdr_destination')) { + echo " \n"; + } + if (permission_exists('xml_cdr_start')) { + echo " \n"; + } + if (permission_exists('xml_cdr_tta')) { + echo " \n"; + } + if (permission_exists('xml_cdr_duration')) { + echo " \n"; + } if (permission_exists('xml_cdr_pdd')) { echo " \n"; } @@ -403,20 +409,21 @@ if (permission_exists('xml_cdr_hangup_cause')) { echo " \n"; } - - if (is_array($_SESSION['cdr']['field'])) { - echo " \n"; - echo " \n"; - foreach ($_SESSION['cdr']['field'] as $field) { - $array = explode(",", $field); - $field_name = end($array); - $field_label = ucwords(str_replace("_", " ", $field_name)); - $field_label = str_replace("Sip", "SIP", $field_label); - if ($field_name != "destination_number") { - echo " \n"; + if (permission_exists('xml_cdr_custom_fields')) { + if (is_array($_SESSION['cdr']['field'])) { + echo " \n"; + echo " \n"; + foreach ($_SESSION['cdr']['field'] as $field) { + $array = explode(",", $field); + $field_name = end($array); + $field_label = ucwords(str_replace("_", " ", $field_name)); + $field_label = str_replace("Sip", "SIP", $field_label); + if ($field_name != "destination_number") { + echo " \n"; + } } + echo " \n"; } - echo " \n"; } echo " \n"; echo " \n"; } + if (permission_exists('xml_cdr_search_advanced')) { + if ($_REQUEST['show'] == 'all') { + $query_string = "show=all"; + } + echo " \n"; + } echo " \n"; echo " \n"; echo "\n"; @@ -447,7 +460,7 @@ $param = substr($param, 0, strrpos($param, '&order_by=')); //remove trailing order by //show the results - $col_count = 8; + $col_count = 0; echo "
\n"; echo "\n"; echo "\n"; @@ -457,39 +470,64 @@ } //column headings - echo "\n"; + if (permission_exists('xml_cdr_direction')) { + echo "\n"; + $col_count++; + } if (permission_exists('xml_cdr_extension')) { echo "\n"; + $col_count++; } - if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { + if (permission_exists('xml_cdr_all') && $_REQUEST['show'] == "all") { echo "\n"; $col_count++; } - echo "\n"; - echo "\n"; + if (permission_exists('xml_cdr_caller_id_name')) { + echo "\n"; + $col_count++; + } + if (permission_exists('xml_cdr_caller_id_number')) { + echo "\n"; + $col_count++; + } if (permission_exists('xml_cdr_caller_destination')) { echo "\n"; + $col_count++; } - echo "\n"; - if (permission_exists('recording_play') || permission_exists('recording_download')) { + if (permission_exists('xml_cdr_destination')) { + echo "\n"; + $col_count++; + } + if (permission_exists('xml_cdr_recording') && (permission_exists('recording_play') || permission_exists('recording_download'))) { echo "\n"; $col_count++; } - if (is_array($_SESSION['cdr']['field'])) { - foreach ($_SESSION['cdr']['field'] as $field) { - $array = explode(",", $field); - $field_name = $array[count($array) - 1]; - $field_label = ucwords(str_replace("_", " ", $field_name)); - $field_label = str_replace("Sip", "SIP", $field_label); - if ($field_name != "destination_number") { - echo "\n"; - $col_count++; + if (permission_exists('xml_cdr_custom_fields')) { + if (is_array($_SESSION['cdr']['field']) && @sizeof($_SESSION['cdr']['field'])) { + foreach ($_SESSION['cdr']['field'] as $field) { + $array = explode(",", $field); + $field_name = end($array); + $field_label = ucwords(str_replace("_", " ", $field_name)); + $field_label = str_replace("Sip", "SIP", $field_label); + if ($field_name != "destination_number") { + echo "\n"; + $col_count++; + } } } } - echo "\n"; - echo "\n"; - echo "\n"; + if (permission_exists('xml_cdr_start')) { + echo "\n"; + $col_count++; + } + if (permission_exists('xml_cdr_tta')) { + echo "\n"; + $col_count++; + } + if (permission_exists('xml_cdr_duration')) { + echo "\n"; + $col_count++; + } if (permission_exists('xml_cdr_pdd')) { echo "\n"; $col_count++; @@ -500,11 +538,13 @@ } if (permission_exists('xml_cdr_hangup_cause')) { echo "\n"; + $col_count++; } else { echo "\n"; + $col_count++; } - if (if_group("admin") || if_group("superadmin") || if_group("cdr")) { + if (permission_exists('xml_cdr_details')) { echo "\n"; } - if ($row['raw_data_exists'] && permission_exists('xml_cdr_details')) { + if (permission_exists('xml_cdr_details') && $row['raw_data_exists']) { $tr_link = "href='xml_cdr_details.php?id=".escape($row['xml_cdr_uuid']).(($_REQUEST['show']) ? "&show=all" : null)."'"; } else { @@ -586,30 +626,32 @@ } //determine call result and appropriate icon - $content .= "\n"; } - else { $content .= " "; } - $content .= "\n"; //extension if (permission_exists('xml_cdr_extension')) { $content .= " \n"; } //domain name - if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { + if (permission_exists('xml_cdr_all') && $_REQUEST['show'] == "all") { $content .= " \n"; } //caller id name - $content .= " \n"; + if (permission_exists('xml_cdr_caller_id_name')) { + $content .= " \n"; + } //source - $content .= " \n"; } - else { - $content .= " ".escape(substr($row['caller_id_number'], 0, 20)).' '; - } - $content .= " "; - $content .= " \n"; //caller destination if (permission_exists('xml_cdr_caller_destination')) { $content .= " \n"; } //destination - if ($_SESSION['cdr']['remove_prefix']['boolean'] == 'true') { - //get outbound prefix variable from json table if exists - $json_string = trim($row["json"]); - $array = json_decode($json_string,true); - $remove_prefix = false; - $prefix = false; - if (is_array($array["app_log"]["application"])) { - foreach ($array["app_log"]["application"] as $application) { - $app_data = urldecode($application["@attributes"]["app_data"]); - if (substr($app_data,0,7) == "prefix=") { - $prefix = substr($app_data,7); - $remove_prefix = true; + if (permission_exists('xml_cdr_destination')) { + if ($_SESSION['cdr']['remove_prefix']['boolean'] == 'true') { + //get outbound prefix variable from json table if exists + $json_string = trim($row["json"]); + $array = json_decode($json_string,true); + $remove_prefix = false; + $prefix = false; + if (is_array($array["app_log"]["application"])) { + foreach ($array["app_log"]["application"] as $application) { + $app_data = urldecode($application["@attributes"]["app_data"]); + if (substr($app_data,0,7) == "prefix=") { + $prefix = substr($app_data,7); + $remove_prefix = true; + } } } } - } - $content .= " \n"; } - else { - if ($remove_prefix == 'true') { - $content .= substr(format_phone(escape(substr($row['destination_number'], 0, 20))),strlen($prefix))."\n"; - } - else { - $content .= format_phone(escape(substr($row['destination_number'], 0, 20)))."\n"; - } - } - $content .= " \n"; - $content .= " \n"; //recording - if (permission_exists('recording_play') || permission_exists('recording_download')) { + if (permission_exists('xml_cdr_recording') && (permission_exists('recording_play') || permission_exists('recording_download'))) { if ($record_path != '' && file_exists($record_path.'/'.$record_name)) { $content .= " \n"; } } - //dynamic cdr fields - if (is_array($_SESSION['cdr']['field'])) { - foreach ($_SESSION['cdr']['field'] as $field) { - $array = explode(",", $field); - $field_name = $array[count($array) - 1]; - if ($field_name != "destination_number") { - $content .= " \n"; + //custom cdr fields + if (permission_exists('xml_cdr_custom_fields')) { + if (is_array($_SESSION['cdr']['field'])) { + foreach ($_SESSION['cdr']['field'] as $field) { + $array = explode(",", $field); + $field_name = $array[count($array) - 1]; + if ($field_name != "destination_number") { + $content .= " \n"; + } } } } //start - $content .= " \n"; + if (permission_exists('xml_cdr_start')) { + $content .= " \n"; + } //tta (time to answer) - $content .= " \n"; + if (permission_exists('xml_cdr_tta')) { + $content .= " \n"; + } //duration - $content .= " \n"; + if (permission_exists('xml_cdr_duration')) { + $content .= " \n"; + } //pdd (post dial delay) if (permission_exists("xml_cdr_pdd")) { $content .= " \n"; @@ -754,8 +809,8 @@ //control icons if (permission_exists('xml_cdr_details')) { $content .= "
  ".$text['label-extension']."".$text['label-domain']."".$text['label-caller_id_name']."".$text['label-caller_id_number']."".$text['label-caller_id_name']."".$text['label-caller_id_number']."".$text['label-caller_destination']."".$text['label-destination']."".$text['label-destination']."".$text['label-recording']."".$field_label."".$field_label."".$text['label-start']."".$text['label-tta']."".$text['label-duration']."".$text['label-start']."".$text['label-tta']."".$text['label-duration']."".$text['label-pdd']."".$text['label-hangup_cause']."".$text['label-status'].""; if (permission_exists('xml_cdr_delete') && $result_count > 0) { echo "".$v_link_label_delete.""; @@ -570,7 +610,7 @@ $content .= "
\n"; - if ($theme_cdr_images_exist) { - if ($row['direction'] == 'inbound' || $row['direction'] == 'local') { - if ($row['answer_stamp'] != '' && $row['bridge_uuid'] != '') { $call_result = 'answered'; } - else if ($row['answer_stamp'] != '' && $row['bridge_uuid'] == '') { $call_result = 'voicemail'; } - else if ($row['answer_stamp'] == '' && $row['bridge_uuid'] == '' && $row['sip_hangup_disposition'] != 'send_refuse') { $call_result = 'cancelled'; } - else { $call_result = 'failed'; } - } - else if ($row['direction'] == 'outbound') { - if ($row['answer_stamp'] != '' && $row['bridge_uuid'] != '') { $call_result = 'answered'; } - else if ($row['answer_stamp'] == '' && $row['bridge_uuid'] != '') { $call_result = 'cancelled'; } - else { $call_result = 'failed'; } - } - if (strlen($row['direction']) > 0) { - $image_name = "icon_cdr_" . $row['direction'] . "_" . $call_result; - if($row['leg'] == 'b') { - $image_name .= '_b'; + if (permission_exists('xml_cdr_direction')) { + $content .= "\n"; + if ($theme_cdr_images_exist) { + if ($row['direction'] == 'inbound' || $row['direction'] == 'local') { + if ($row['answer_stamp'] != '' && $row['bridge_uuid'] != '') { $call_result = 'answered'; } + else if ($row['answer_stamp'] != '' && $row['bridge_uuid'] == '') { $call_result = 'voicemail'; } + else if ($row['answer_stamp'] == '' && $row['bridge_uuid'] == '' && $row['sip_hangup_disposition'] != 'send_refuse') { $call_result = 'cancelled'; } + else { $call_result = 'failed'; } + } + else if ($row['direction'] == 'outbound') { + if ($row['answer_stamp'] != '' && $row['bridge_uuid'] != '') { $call_result = 'answered'; } + else if ($row['answer_stamp'] == '' && $row['bridge_uuid'] != '') { $call_result = 'cancelled'; } + else { $call_result = 'failed'; } + } + if (strlen($row['direction']) > 0) { + $image_name = "icon_cdr_" . $row['direction'] . "_" . $call_result; + if($row['leg'] == 'b') { + $image_name .= '_b'; + } + $image_name .= ".png"; + $content .= "\n"; } - $image_name .= ".png"; - $content .= "\n"; } + else { $content .= " "; } + $content .= ""; @@ -617,24 +659,28 @@ $content .= " "; $content .= $row['domain_name'].' '; $content .= " ".escape(substr($row['caller_id_name'], 0, 20))." ".escape(substr($row['caller_id_name'], 0, 20))."  ".escape($row[$field_name])."".escape($row[$field_name])."".escape($tmp_start_epoch)."".escape($tmp_start_epoch)."".(($row['tta'] > 0) ? $row['tta']."s" : " ")."".(($row['tta'] > 0) ? $row['tta']."s" : " ")."".gmdate("G:i:s", $seconds)."".gmdate("G:i:s", $seconds)."".number_format(escape($row['pdd_ms'])/1000,2)."s