diff --git a/app/ring_groups/ring_group_edit.php b/app/ring_groups/ring_group_edit.php index 372c45468a..fce8e113fd 100644 --- a/app/ring_groups/ring_group_edit.php +++ b/app/ring_groups/ring_group_edit.php @@ -600,7 +600,7 @@ //get the sounds $sounds = new sounds; - $sounds = $sounds->get(); + $audio_files = $sounds->get(); //create token $object = new token; @@ -613,22 +613,22 @@ //show the content if (permission_exists('recording_play') || permission_exists('recording_download')) { echo "\n"; } + if (if_group("superadmin")) { + echo "\n"; + } echo "
\n"; @@ -697,72 +736,31 @@ echo "\n"; echo "\n"; + $instance_id = 'ring_group_greeting'; + $instance_label = 'greeting'; + $instance_value = $ring_group_greeting; echo "\n"; echo "\n"; - echo " ".$text['label-greeting']."\n"; + echo " ".$text['label-'.$instance_label]."\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; - if (if_group("superadmin")) { - $destination_id = "ring_group_greeting"; - $script = "\n"; - $script .= "\n"; - echo $script; - } - echo "\n"; echo " \n"; - $found = $playable_greeting = false; - if (!empty($sounds) && is_array($sounds) && @sizeof($sounds) != 0) { - foreach ($sounds as $key => $value) { + $found = $playable = false; + if (!empty($audio_files) && is_array($audio_files) && @sizeof($audio_files) != 0) { + foreach ($audio_files as $key => $value) { echo "\n"; foreach ($value as $row) { - if (!empty($ring_group_greeting) && $ring_group_greeting == $row["value"]) { + if (!empty($instance_value) && $instance_value == $row["value"]) { $selected = "selected='selected'"; if ($key == 'recordings') { - $playable_greeting = '../recordings/recordings.php?action=download&type=rec&filename='.$row["value"]; + $playable = '../recordings/recordings.php?action=download&type=rec&filename='.$row["value"]; } else if ($key == 'sounds') { - $playable_greeting = '../switch/sounds.php?action=download&filename='.$row["value"]; + $playable = '../switch/sounds.php?action=download&filename='.$row["value"]; } $found = true; } @@ -774,27 +772,26 @@ echo "\n"; } } - if (if_group("superadmin") && !empty($ring_group_greeting) && !$found) { - echo " \n"; + if (if_group("superadmin") && !empty($instance_value) && !$found) { + echo " \n"; } unset($selected); echo " \n"; if (if_group("superadmin")) { - echo ""; - unset($destination_id); + echo ""; } - if ((permission_exists('recording_play') || permission_exists('recording_download')) && !empty($playable_greeting)) { - switch (pathinfo($playable_greeting, PATHINFO_EXTENSION)) { - case 'wav' : $audio_file_type = 'audio/wav'; break; - case 'mp3' : $audio_file_type = 'audio/mpeg'; break; - case 'ogg' : $audio_file_type = 'audio/ogg'; break; + if ((permission_exists('recording_play') || permission_exists('recording_download')) && !empty($playable)) { + switch (pathinfo($playable, PATHINFO_EXTENSION)) { + case 'wav' : $mime_type = 'audio/wav'; break; + case 'mp3' : $mime_type = 'audio/mpeg'; break; + case 'ogg' : $mime_type = 'audio/ogg'; break; } } - echo ""; - echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_greeting','style'=>'display: '.(!empty($audio_file_type) ? 'inline' : 'none'),'onclick'=>"recording_play('greeting')"]); - unset($playable_greeting, $audio_file_type); + echo ""; + echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."')"]); + unset($playable, $mime_type); echo "
\n"; - echo $text['description-greeting']."\n"; + echo $text['description-'.$instance_label]."\n"; echo "\n"; echo "\n";