From 7b25e81a8d8dec115342c8ffbb54d702df64e4db Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Wed, 31 May 2023 23:52:32 -0600 Subject: [PATCH] Update call_forward_edit.php changes for PHP 8.1 --- app/call_forward/call_forward_edit.php | 47 +++++++++++++++----------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/app/call_forward/call_forward_edit.php b/app/call_forward/call_forward_edit.php index b8baa7f0fe..29b8ebc2e8 100644 --- a/app/call_forward/call_forward_edit.php +++ b/app/call_forward/call_forward_edit.php @@ -94,7 +94,7 @@ $effective_caller_id_number = $row["effective_caller_id_number"]; $outbound_caller_id_name = $row["outbound_caller_id_name"]; $outbound_caller_id_number = $row["outbound_caller_id_number"]; - $do_not_disturb = $row["do_not_disturb"] != '' ? $row["do_not_disturb"] : 'false'; + $do_not_disturb = !empty($row["do_not_disturb"]) ? $row["do_not_disturb"] : 'false'; $forward_all_destination = $row["forward_all_destination"]; $forward_all_enabled = $row["forward_all_enabled"]; $forward_busy_destination = $row["forward_busy_destination"]; @@ -125,8 +125,8 @@ $forward_user_not_registered_enabled = $_POST["forward_user_not_registered_enabled"]; $forward_user_not_registered_destination = $_POST["forward_user_not_registered_destination"]; - $cid_name_prefix = $_POST["cid_name_prefix"]; - $cid_number_prefix = $_POST["cid_number_prefix"]; + $cid_name_prefix = $_POST["cid_name_prefix"] ?? ''; + $cid_number_prefix = $_POST["cid_number_prefix"] ?? ''; $follow_me_enabled = $_POST["follow_me_enabled"]; $follow_me_ignore_busy = $_POST["follow_me_ignore_busy"]; @@ -138,7 +138,7 @@ $destinations[$n]['delay'] = $field['delay']; $destinations[$n]['prompt'] = $field['prompt']; $destinations[$n]['timeout'] = $field['timeout']; - if ($field['destination'] != '') { + if (!empty($field['destination'])) { $destination_found = true; } $n++; @@ -234,7 +234,7 @@ $d = 0; $destination_found = false; foreach ($destinations as $field) { - if ($field['destination'] != '') { + if (!empty($field['destination'])) { //sanitize the destination $field['destination'] = preg_replace('#[^\*0-9]#', '', $field['destination']); @@ -266,7 +266,6 @@ $database->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d'; $database->save($array); unset($array); - //$message = $database->message; //remove the temporary permission $p->delete("extension_edit", "temp"); @@ -351,7 +350,7 @@ */ //send feature event notify to the phone - if ($_SESSION['device']['feature_sync']['boolean'] == "true") { + if (!empty($_SESSION['device']['feature_sync']['boolean']) && $_SESSION['device']['feature_sync']['boolean'] == "true") { $ring_count = ceil($call_timeout / 6); $feature_event_notify = new feature_event_notify; $feature_event_notify->domain_name = $_SESSION['domain_name']; @@ -434,7 +433,7 @@ } //synchronize configuration - if (is_readable($_SESSION['switch']['extensions']['dir'])) { + if (!empty($_SESSION['switch']['extensions']['dir']) && is_readable($_SESSION['switch']['extensions']['dir'])) { require_once "app/extensions/resources/classes/extension.php"; $ext = new extension; $ext->xml(); @@ -476,7 +475,7 @@ $sql = "select * from v_follow_me_destinations "; $sql .= "where follow_me_uuid = :follow_me_uuid "; - $sql .= "order by follow_me_delay, follow_me_destination asc "; + $sql .= "order by follow_me_order asc "; $parameters['follow_me_uuid'] = $follow_me_uuid; $database = new database; $result = $database->select($sql, $parameters ?? null, 'all'); @@ -492,6 +491,15 @@ unset($sql, $parameters, $result, $row); } } + +//add the pre-defined follow me destinations + for ($n = 0; $n <= (((!empty($_SESSION['follow_me']['max_destinations']['numeric'])) ? $_SESSION['follow_me']['max_destinations']['numeric'] : 5) - 1); $n++) { + if (empty($destinations[$n]['uuid'])) { $destinations[$n]['uuid'] = null; } + if (empty($destinations[$n]['destination'])) { $destinations[$n]['destination'] = null; } + if (empty($destinations[$n]['delay'])) { $destinations[$n]['delay'] = null; } + if (empty($destinations[$n]['prompt'])) { $destinations[$n]['prompt'] = null; } + if (empty($destinations[$n]['timeout'])) { $destinations[$n]['timeout'] = 30; } + } //get the extensions array - used with autocomplete $sql = "select * from v_extensions "; @@ -524,7 +532,7 @@ } } echo " ];\n"; - for ($n = 0; $n <= ((($_SESSION['follow_me']['max_destinations']['numeric'] != '') ? $_SESSION['follow_me']['max_destinations']['numeric'] : 5) - 1); $n++) { + for ($n = 0; $n <= (((!empty($_SESSION['follow_me']['max_destinations']['numeric'])) ? $_SESSION['follow_me']['max_destinations']['numeric'] : 5) - 1); $n++) { echo " \$(\"#destination_".$n."\").autocomplete({\n"; echo " source: extensions\n"; echo " });\n"; @@ -629,14 +637,14 @@ echo "\n"; $on_click = "document.getElementById('forward_all_disabled').checked=true; "; $on_click .= "document.getElementById('dnd_disabled').checked=true; "; - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; unset($on_click); echo "\n"; echo "\n"; echo "\n"; - if ($follow_me_enabled == "true" && $dnd_enabled != "true" && $forward_all_enabled != "true") { $style = ''; } else { $style = 'display: none;'; } + if (!empty($follow_me_enabled) && $follow_me_enabled == "true" && $dnd_enabled != "true" && $forward_all_enabled != "true") { $style = ''; } else { $style = 'display: none;'; } echo "
\n"; echo "\n"; @@ -657,21 +665,22 @@ echo " \n"; //output destinations - for ($n = 0; $n <= ((($_SESSION['follow_me']['max_destinations']['numeric'] != '') ? $_SESSION['follow_me']['max_destinations']['numeric'] : 5) - 1); $n++) { - echo " \n"; + $on_click = ""; + foreach ($destinations as $n => $destination) { + echo " \n"; echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; echo " \n"; if (permission_exists('follow_me_prompt')) { echo " \n";
\n"; - destination_select('destinations['.$n.'][delay]', $destinations[$n]['delay'], '0'); + destination_select('destinations['.$n.'][delay]', $destination['delay'], '0'); echo " \n"; - destination_select('destinations['.$n.'][timeout]', $destinations[$n]['timeout'], (($_SESSION['follow_me']['timeout']['numeric'] != '') ? $_SESSION['follow_me']['timeout']['numeric'] : 30)); + destination_select('destinations['.$n.'][timeout]', $destination['timeout'], ((!empty($_SESSION['follow_me']['timeout']['numeric'])) ? $_SESSION['follow_me']['timeout']['numeric'] : 30)); echo " \n"; echo " \n"; echo "