From d11308b84406822b5be81c9183a5c8270e19c7fb Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Tue, 30 Apr 2024 18:21:42 -0600 Subject: [PATCH] New setting save_call_detail_record If blocked by call block option to save the call detail record true or false. --- app/call_block/app_config.php | 10 +++++++++- app/xml_cdr/resources/classes/xml_cdr.php | 24 +++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/app/call_block/app_config.php b/app/call_block/app_config.php index e46aa200ea..04913de6fa 100644 --- a/app/call_block/app_config.php +++ b/app/call_block/app_config.php @@ -39,6 +39,14 @@ $apps[$x]['default_settings'][$y]['default_setting_value'] = "50"; $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; $apps[$x]['default_settings'][$y]['default_setting_description'] = "Number of recent calls to show."; + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "47914bd9-e1c0-4e3d-87e0-41f95d58ce98"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "call_block"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "save_call_detail_record"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "boolean"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = "false"; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = "Choose whether to save the call detail record when the call is blocked."; //permission details $y=0; @@ -194,4 +202,4 @@ $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; -?> +?> \ No newline at end of file diff --git a/app/xml_cdr/resources/classes/xml_cdr.php b/app/xml_cdr/resources/classes/xml_cdr.php index 4810238b45..c071490b35 100644 --- a/app/xml_cdr/resources/classes/xml_cdr.php +++ b/app/xml_cdr/resources/classes/xml_cdr.php @@ -330,10 +330,27 @@ if (!class_exists('xml_cdr')) { return false; } + //skip call detail records for calls blocked by call block + if (isset($xml->variables->call_block) && !empty($this->setting->get('call_block', 'save_call_detail_record'))) { + if ($xml->variables->call_block == 'true' && $this->setting->get('call_block', 'save_call_detail_record') == 'false') { + //delete the xml cdr file + if (!empty($this->setting->get('switch', 'log'))) { + $xml_cdr_dir = $this->setting->get('switch', 'log').'/xml_cdr'; + if (file_exists($xml_cdr_dir.'/'.$this->file)) { + unlink($xml_cdr_dir.'/'.$this->file); + } + } + + //return without saving + return false; + } + } + //check for duplicate call uuid's $duplicate_uuid = false; $uuid = urldecode($xml->variables->uuid); if ($uuid != null && is_uuid($uuid)) { + //check for duplicates $sql = "select count(xml_cdr_uuid) "; $sql .= "from v_xml_cdr "; $sql .= "where xml_cdr_uuid = :xml_cdr_uuid "; @@ -350,6 +367,9 @@ if (!class_exists('xml_cdr')) { unlink($xml_cdr_dir.'/'.$this->file); } } + + //return without saving + return false; } unset($sql, $parameters); } @@ -364,7 +384,7 @@ if (!class_exists('xml_cdr')) { $accountcode = urldecode($xml->variables->accountcode); } - //process data if the call detail record is not a duplicate + //process call detail record data if ($duplicate_uuid == false && is_uuid($uuid)) { //get the caller ID from call flow caller profile @@ -2046,4 +2066,4 @@ if (!class_exists('xml_cdr')) { } //class } -?> +?> \ No newline at end of file