From 68238e9ce4910ec044c20d5b8513ad0b55b9d707 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Wed, 8 Dec 2021 13:49:15 -0700 Subject: [PATCH] Account for destination_prefix larger than one character. Also account for trunk prefix when not using the area code. --- app/destinations/resources/classes/destinations.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/destinations/resources/classes/destinations.php b/app/destinations/resources/classes/destinations.php index 38db669146..b91933c9ae 100644 --- a/app/destinations/resources/classes/destinations.php +++ b/app/destinations/resources/classes/destinations.php @@ -90,6 +90,11 @@ if (!class_exists('destinations')) { $destination_regex .= "^".$array['destination_area_code'].$array['destination_number']."\$|"; $destination_regex .= "^".$array['destination_number']."\$)"; } + elseif (isset($array['destination_prefix']) && isset($array['destination_trunk_prefix']) && isset($array['destination_number'])) { + $destination_regex = "(\+?".$array['destination_prefix'].$array['destination_number']."\$|"; + $destination_regex .= "^".$array['destination_trunk_prefix'].$array['destination_number']."\$|"; + $destination_regex .= "^".$array['destination_number']."\$)"; + } elseif (isset($array['destination_prefix']) && isset($array['destination_area_code']) && isset($array['destination_number'])) { $destination_regex = "(\+?".$array['destination_prefix'].$array['destination_area_code'].$array['destination_number']."\$|"; $destination_regex .= "^".$array['destination_area_code'].$array['destination_number']."\$|"; @@ -109,12 +114,13 @@ if (!class_exists('destinations')) { //add prefix if (strlen($destination_prefix) > 0) { - if (strlen($destination_prefix) > 0 && strlen($destination_prefix) < 4) { - $plus = (substr($destination_prefix, 0, 1) == "+") ? '' : '\+?'; + $destination_prefix = str_replace("+", "", $destination_prefix); + $plus = '\+?'; + if (strlen($destination_prefix) == 1) { $destination_prefix = $plus.$destination_prefix.'?'; } else { - $destination_prefix = '(?:'.$destination_prefix.')?'; + $destination_prefix = $plus.'(?:'.$destination_prefix.')?'; } }