From c146f9fc4f43db9d4a761158ae03ad21be26d1d3 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 19 Nov 2015 14:30:06 +0300 Subject: [PATCH] Add. Allow specify DTMF in parentheses in phone number. E.g. `123456 (PP789)` --- app/fax/fax_send.php | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/app/fax/fax_send.php b/app/fax/fax_send.php index 0e710bcf07..e7fb27c8ef 100644 --- a/app/fax/fax_send.php +++ b/app/fax/fax_send.php @@ -177,14 +177,6 @@ if(!function_exists('gs_cmd')) { if (($_POST['action'] == "send")) { $fax_numbers = $_POST['fax_numbers']; - if (sizeof($fax_numbers) > 0) { - foreach ($fax_numbers as $index => $fax_number) { - $fax_numbers[$index] = preg_replace("~[^0-9]~", "", $fax_number); - if ($fax_numbers[$index] == '') { unset($fax_numbers[$index]); } - } - sort($fax_numbers); - } - $fax_uuid = check_str($_POST["id"]); $fax_caller_id_name = check_str($_POST['fax_caller_id_name']); $fax_caller_id_number = check_str($_POST['fax_caller_id_number']); @@ -206,6 +198,28 @@ if(!function_exists('gs_cmd')) { $continue = true; } + // cleanup numbers + if (isset($fax_numbers)) { + foreach ($fax_numbers as $index => $fax_number) { + $tmp=array(); + $fax_dtmf = ''; + if(preg_match('/^\s*(.*?)\s*\((.*)\)\s*$/', $fax_number, $tmp)){ + $fax_number = $tmp[1]; + $fax_dtmf = $tmp[2]; + } + $fax_number = preg_replace("~[^0-9]~", "", $fax_number); + $fax_dtmf = preg_replace("~[^0-9Pp*#]~", "", $fax_dtmf); + if ($fax_number != ''){ + if ($fax_dtmf != '') {$fax_number .= " (" . $fax_dtmf . ")";} + $fax_numbers[$index] = $fax_number; + } + else{ + unset($fax_numbers[$index]); + } + } + sort($fax_numbers); + } + if ($continue) { //determine page size switch ($fax_page_size) { @@ -621,6 +635,12 @@ if(!function_exists('gs_cmd')) { foreach ($fax_numbers as $fax_number) { $dial_string = $common_dial_string; + $tmp = array(); + $fax_dtmf = ''; + if(preg_match('/^\s*(.*?)\s*\((.*)\)\s*$/', $fax_number, $tmp)){ + $fax_number = $tmp[1]; + $fax_dtmf = $tmp[2]; + } //prepare the fax command $route_array = outbound_route_to_bridge($_SESSION['domain_uuid'], $fax_prefix . $fax_number); @@ -663,7 +683,6 @@ if(!function_exists('gs_cmd')) { $task_uuid = uuid(); $dial_string .= "task_uuid='" . $task_uuid . "',"; $wav_file = ''; //! @todo add custom message - $dtmf = ''; //! @todo add generate dtmf $description = ''; //! @todo add description $sql = <<bindValue(++$i, $wav_file); $stmt->bindValue(++$i, $fax_uri); $stmt->bindValue(++$i, $dial_string); - $stmt->bindValue(++$i, $dtmf); + $stmt->bindValue(++$i, $fax_dtmf); $stmt->bindValue(++$i, $description); if ($stmt->execute()) { $response = 'Enqueued';