From 09f92fef5f3719ef3730a4b6eb01f5313bb660dd Mon Sep 17 00:00:00 2001 From: fusionate Date: Tue, 7 Nov 2023 02:21:54 +0000 Subject: [PATCH] Call Flow - Edit: Make audio playback code consistent with other apps. --- app/call_flows/call_flow_edit.php | 54 +++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/app/call_flows/call_flow_edit.php b/app/call_flows/call_flow_edit.php index 5444c1a3e3..7de365c31f 100644 --- a/app/call_flows/call_flow_edit.php +++ b/app/call_flows/call_flow_edit.php @@ -579,15 +579,29 @@ foreach ($audio_files as $key => $value) { echo "\n"; foreach ($value as $row) { - if (!empty($instance_value) && $instance_value == $row["value"]) { - $selected = "selected='selected'"; - if ($key == 'recordings') { - $playable = '../recordings/recordings.php?action=download&type=rec&filename='.$row["value"]; + if ($key == 'recordings') { + if ( + !empty($instance_value) && + ($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) && + file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) + ) { + $selected = "selected='selected'"; + $playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME); + $found = true; } - else if ($key == 'sounds') { + else { + unset($selected); + } + } + else if ($key == 'sounds') { + if (!empty($instance_value) && $instance_value == $row["value"]) { + $selected = "selected='selected'"; $playable = '../switch/sounds.php?action=download&filename='.$row["value"]; + $found = true; + } + else { + unset($selected); } - $found = true; } else { unset($selected); @@ -667,15 +681,29 @@ foreach ($audio_files as $key => $value) { echo "\n"; foreach ($value as $row) { - if (!empty($instance_value) && $instance_value == $row["value"]) { - $selected = "selected='selected'"; - if ($key == 'recordings') { - $playable = '../recordings/recordings.php?action=download&type=rec&filename='.$row["value"]; + if ($key == 'recordings') { + if ( + !empty($instance_value) && + ($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) && + file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) + ) { + $selected = "selected='selected'"; + $playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME); + $found = true; } - else if ($key == 'sounds') { + else { + unset($selected); + } + } + else if ($key == 'sounds') { + if (!empty($instance_value) && $instance_value == $row["value"]) { + $selected = "selected='selected'"; $playable = '../switch/sounds.php?action=download&filename='.$row["value"]; + $found = true; + } + else { + unset($selected); } - $found = true; } else { unset($selected); @@ -693,7 +721,7 @@ if (if_group("superadmin")) { echo ""; } - if ((permission_exists('recording_play') || permission_exists('recording_download')) && !empty($playable)) { + if ((permission_exists('recording_play') || permission_exists('recording_download')) && (!empty($playable) || empty($instance_value))) { switch (pathinfo($playable, PATHINFO_EXTENSION)) { case 'wav' : $mime_type = 'audio/wav'; break; case 'mp3' : $mime_type = 'audio/mpeg'; break;