MOH: List view updates.

This commit is contained in:
Nate
2019-12-16 12:00:33 -07:00
parent 0dace3cc3c
commit 2e21be8cd4
4 changed files with 385 additions and 260 deletions

View File

@@ -781,25 +781,25 @@ $text['header-music_on_hold_settings']['ru-ru'] = "Музыка на удерж
$text['header-music_on_hold_settings']['sv-se'] = "Väntmusik inställningar";
$text['header-music_on_hold_settings']['uk-ua'] = "Музика на утриманні настройки";
$text['desc-music_on_hold']['en-us'] = "Music on hold can be in WAV or MP3 format. To play an MP3 file you must have mod_shout enabled on the 'Modules' tab. You can adjust the volume of the MP3 audio from the 'Settings' tab. For best performance upload 16 bit, 8/16/32/48 kHz <i>mono</i> WAV files.";
$text['desc-music_on_hold']['ar-eg'] = "";
$text['desc-music_on_hold']['de-at'] = "Haltemusik können Dateien im WAV oder MP3 Format sein. Um MP3 Dateien abzuspielen zu können, muss mod_shout installiert und aktiviert sein. Sie können die Lautstärke der MP3 Dateien in den Einstellungen verändern. Für beste Funktionalität laden Sie 16bit, 8/16/32/48 kHz mono WAV Dateien hoch."; //copied from de-de
$text['desc-music_on_hold']['de-ch'] = "Haltemusik können Dateien im WAV oder MP3 Format sein. Um MP3 Dateien abzuspielen zu können, muss mod_shout installiert und aktiviert sein. Sie können die Lautstärke der MP3 Dateien in den Einstellungen verändern. Für beste Funktionalität laden Sie 16bit, 8/16/32/48 kHz mono WAV Dateien hoch."; //copied from de-de
$text['desc-music_on_hold']['de-de'] = "Haltemusik können Dateien im WAV oder MP3 Format sein. Um MP3 Dateien abzuspielen zu können, muss mod_shout installiert und aktiviert sein. Sie können die Lautstärke der MP3 Dateien in den Einstellungen verändern. Für beste Funktionalität laden Sie 16bit, 8/16/32/48 kHz mono WAV Dateien hoch.";
$text['desc-music_on_hold']['es-cl'] = "La música en espera puede estar en formato WAV o MP3. Para reproducir un archivo en frmato MP3 debe tener activado el módulo mod_shout. Puede ajustar el volumen del MP3 desde la pestaña 'Configuraciones'. Para el mejor rendimiento se recomienda utilizar archivos en formato WAV 16 bit, 8/16/32/48 kHz <i>mono</i>.";
$text['desc-music_on_hold']['es-mx'] = "La música en espera puede estar en formato WAV o MP3. Para reproducir un archivo en frmato MP3 debe tener activado el módulo mod_shout. Puede ajustar el volumen del MP3 desde la pestaña 'Configuraciones'. Para el mejor rendimiento se recomienda utilizar archivos en formato WAV 16 bit, 8/16/32/48 kHz <i>mono</i>."; //copied from es-cl
$text['desc-music_on_hold']['fr-ca'] = "La Musique d'attente peut être en WAV ou en MP3. Pour le MP3, mod_shout doit être activé dans la section modules. Le volume peut être réglé dans la partie configuration. Pour de meilleures performances, utiliser des fichiers WAV 16 bit, 8/16/32/48 kHz <i>mono</i>."; //copied from fr-fr
$text['desc-music_on_hold']['fr-fr'] = "La Musique d'attente peut être en WAV ou en MP3. Pour le MP3, mod_shout doit être activé dans la section modules. Le volume peut être réglé dans la partie configuration. Pour de meilleures performances, utiliser des fichiers WAV 16 bit, 8/16/32/48 kHz <i>mono</i>.";
$text['desc-music_on_hold']['he-il'] = "";
$text['desc-music_on_hold']['it-it'] = "La musica di attesa può essere in formato WAV o MP3. Per suonare i file MP3 è necessario avere mod_shout abilitato nella sezione 'Moduli'. Si può regolare il volume dei file MP3 dalla sezione Parametri. Per una migliore qualità caricare file 16 bit, 8/16/32/48 kHz <i>mono</i> WAV files.";
$text['desc-music_on_hold']['nl-nl'] = "Wachtmuziek mag in WAV of MP3 formaat zijn. Om een MP3 bestand te spelen moet mod_shout aan staan bij de Modulen tab. Het volume van de MP3 audio kan op de instellingen tab ingevoerd worden. Voor de beste prestaties gebruik 16 bit, 8/16/32/48 kHz <i>mono</i> WAV files.";
$text['desc-music_on_hold']['pl-pl'] = "Muzyka na czekanie może być w formacie wav lub mp3. Aby odtwarzać mp3 konieczne jest zainstalowanie modułu mod_shout (można to zrobić w zakładce Moduły). Można także zmienić głośność formatu mp3 w zakładce Ustawienia. W celu osiągniecia najlepszej jakości prześlij pliki w formacie wav o następującej specyfikacji: 16 bit, 8/16/32/48 kHz mono.";
$text['desc-music_on_hold']['pt-br'] = "Música em espera pode ser com base em arquivos com o formato WAV ou MP3. Para ouvir um ficheiro MP3 deverá ter o mod_shout activado na tab 'Módulos'. Pode ajustar o volume do áudio MP3 a partir da tab 'Definições'. Para um melhor desempenho carregue ficheiros WAV de 16 bit, 8/16/32/48 kHz mono.";
$text['desc-music_on_hold']['pt-pt'] = "Música em espera pode ser com base em ficheiros com o formato WAV ou MP3. Para ouvir um ficheiro MP3 deverá ter o mod_shout activado na tab 'Módulos'. Pode ajustar o volume do áudio MP3 a partir da tab 'Definições'. Para um melhor desempenho carregue ficheiros WAV de 16 bit, 8/16/32/48 kHz <i>mono</i>.";
$text['desc-music_on_hold']['ro-ro'] = "";
$text['desc-music_on_hold']['ru-ru'] = "Музыка на удержании может быть в формате WAV или MP3. Чтобы воспроизвести файл MP3, на вкладке «Модули» необходимо включить mod_shout. Вы можете отрегулировать громкость звука MP3 на вкладке «Настройки». Для лучшей производительности загружайте 16-битные, 8/16/32/48 кГц <i> моно </ i> файлы WAV.";
$text['desc-music_on_hold']['sv-se'] = "Väntmusik kan vara i formaten WAV eller MP3. För att spela upp en MP3 fil så måste 'mod_shout' vara aktiverat i 'moduler' fliken. Du kan justera volymen på MP3 filerna genom inställnings fliken. För bästa prestanda, ladda upp 16 bit, 8/16/32/48 kHz mono WAV filer.";
$text['desc-music_on_hold']['uk-ua'] = "Музика на утриманні може бути в WAV або MP3 формат. Для відтворення файлів MP3 ви повинні включити mod_shout на вкладці 'модулі'. Ви можете налаштувати гучність MP3-аудіо на вкладці «Налаштування». Для кращої продуктивності завантаження 16 біт, моно 8/16/32/48 кГц WAV файлів.";
$text['title_description-music_on_hold']['en-us'] = "Music on hold can be in WAV or MP3 format. To play an MP3 file you must have mod_shout enabled on the 'Modules' tab. You can adjust the volume of the MP3 audio from the 'Settings' tab. For best performance upload 16 bit, 8/16/32/48 kHz <i>mono</i> WAV files.";
$text['title_description-music_on_hold']['ar-eg'] = "";
$text['title_description-music_on_hold']['de-at'] = "Haltemusik können Dateien im WAV oder MP3 Format sein. Um MP3 Dateien abzuspielen zu können, muss mod_shout installiert und aktiviert sein. Sie können die Lautstärke der MP3 Dateien in den Einstellungen verändern. Für beste Funktionalität laden Sie 16bit, 8/16/32/48 kHz mono WAV Dateien hoch."; //copied from de-de
$text['title_description-music_on_hold']['de-ch'] = "Haltemusik können Dateien im WAV oder MP3 Format sein. Um MP3 Dateien abzuspielen zu können, muss mod_shout installiert und aktiviert sein. Sie können die Lautstärke der MP3 Dateien in den Einstellungen verändern. Für beste Funktionalität laden Sie 16bit, 8/16/32/48 kHz mono WAV Dateien hoch."; //copied from de-de
$text['title_description-music_on_hold']['de-de'] = "Haltemusik können Dateien im WAV oder MP3 Format sein. Um MP3 Dateien abzuspielen zu können, muss mod_shout installiert und aktiviert sein. Sie können die Lautstärke der MP3 Dateien in den Einstellungen verändern. Für beste Funktionalität laden Sie 16bit, 8/16/32/48 kHz mono WAV Dateien hoch.";
$text['title_description-music_on_hold']['es-cl'] = "La música en espera puede estar en formato WAV o MP3. Para reproducir un archivo en frmato MP3 debe tener activado el módulo mod_shout. Puede ajustar el volumen del MP3 desde la pestaña 'Configuraciones'. Para el mejor rendimiento se recomienda utilizar archivos en formato WAV 16 bit, 8/16/32/48 kHz <i>mono</i>.";
$text['title_description-music_on_hold']['es-mx'] = "La música en espera puede estar en formato WAV o MP3. Para reproducir un archivo en frmato MP3 debe tener activado el módulo mod_shout. Puede ajustar el volumen del MP3 desde la pestaña 'Configuraciones'. Para el mejor rendimiento se recomienda utilizar archivos en formato WAV 16 bit, 8/16/32/48 kHz <i>mono</i>."; //copied from es-cl
$text['title_description-music_on_hold']['fr-ca'] = "La Musique d'attente peut être en WAV ou en MP3. Pour le MP3, mod_shout doit être activé dans la section modules. Le volume peut être réglé dans la partie configuration. Pour de meilleures performances, utiliser des fichiers WAV 16 bit, 8/16/32/48 kHz <i>mono</i>."; //copied from fr-fr
$text['title_description-music_on_hold']['fr-fr'] = "La Musique d'attente peut être en WAV ou en MP3. Pour le MP3, mod_shout doit être activé dans la section modules. Le volume peut être réglé dans la partie configuration. Pour de meilleures performances, utiliser des fichiers WAV 16 bit, 8/16/32/48 kHz <i>mono</i>.";
$text['title_description-music_on_hold']['he-il'] = "";
$text['title_description-music_on_hold']['it-it'] = "La musica di attesa può essere in formato WAV o MP3. Per suonare i file MP3 è necessario avere mod_shout abilitato nella sezione 'Moduli'. Si può regolare il volume dei file MP3 dalla sezione Parametri. Per una migliore qualità caricare file 16 bit, 8/16/32/48 kHz <i>mono</i> WAV files.";
$text['title_description-music_on_hold']['nl-nl'] = "Wachtmuziek mag in WAV of MP3 formaat zijn. Om een MP3 bestand te spelen moet mod_shout aan staan bij de Modulen tab. Het volume van de MP3 audio kan op de instellingen tab ingevoerd worden. Voor de beste prestaties gebruik 16 bit, 8/16/32/48 kHz <i>mono</i> WAV files.";
$text['title_description-music_on_hold']['pl-pl'] = "Muzyka na czekanie może być w formacie wav lub mp3. Aby odtwarzać mp3 konieczne jest zainstalowanie modułu mod_shout (można to zrobić w zakładce Moduły). Można także zmienić głośność formatu mp3 w zakładce Ustawienia. W celu osiągniecia najlepszej jakości prześlij pliki w formacie wav o następującej specyfikacji: 16 bit, 8/16/32/48 kHz mono.";
$text['title_description-music_on_hold']['pt-br'] = "Música em espera pode ser com base em arquivos com o formato WAV ou MP3. Para ouvir um ficheiro MP3 deverá ter o mod_shout activado na tab 'Módulos'. Pode ajustar o volume do áudio MP3 a partir da tab 'Definições'. Para um melhor desempenho carregue ficheiros WAV de 16 bit, 8/16/32/48 kHz mono.";
$text['title_description-music_on_hold']['pt-pt'] = "Música em espera pode ser com base em ficheiros com o formato WAV ou MP3. Para ouvir um ficheiro MP3 deverá ter o mod_shout activado na tab 'Módulos'. Pode ajustar o volume do áudio MP3 a partir da tab 'Definições'. Para um melhor desempenho carregue ficheiros WAV de 16 bit, 8/16/32/48 kHz <i>mono</i>.";
$text['title_description-music_on_hold']['ro-ro'] = "";
$text['title_description-music_on_hold']['ru-ru'] = "Музыка на удержании может быть в формате WAV или MP3. Чтобы воспроизвести файл MP3, на вкладке «Модули» необходимо включить mod_shout. Вы можете отрегулировать громкость звука MP3 на вкладке «Настройки». Для лучшей производительности загружайте 16-битные, 8/16/32/48 кГц <i> моно </ i> файлы WAV.";
$text['title_description-music_on_hold']['sv-se'] = "Väntmusik kan vara i formaten WAV eller MP3. För att spela upp en MP3 fil så måste 'mod_shout' vara aktiverat i 'moduler' fliken. Du kan justera volymen på MP3 filerna genom inställnings fliken. För bästa prestanda, ladda upp 16 bit, 8/16/32/48 kHz mono WAV filer.";
$text['title_description-music_on_hold']['uk-ua'] = "Музика на утриманні може бути в WAV або MP3 формат. Для відтворення файлів MP3 ви повинні включити mod_shout на вкладці 'модулі'. Ви можете налаштувати гучність MP3-аудіо на вкладці «Налаштування». Для кращої продуктивності завантаження 16 біт, моно 8/16/32/48 кГц WAV файлів.";
$text['button-upload']['en-us'] = "Upload";
$text['button-upload']['ar-eg'] = "";

View File

@@ -28,9 +28,9 @@
//includes
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
require_once "resources/check_auth.php";
if (permission_exists('music_on_hold_view')) {
//access granted
}
@@ -56,6 +56,27 @@
$database = new database;
$streams = $database->select($sql, $parameters, 'all');
//get the http post data
if (is_array($_POST['moh']) || is_array($_POST['moh_files'])) {
$action = $_POST['action'];
$moh = $_POST['moh'];
}
//process the http post data by action
if ($action != '' && is_array($moh) && @sizeof($moh) != 0) {
switch ($action) {
case 'delete':
if (permission_exists('music_on_hold_delete')) {
$obj = new switch_music_on_hold;
$obj->delete($moh);
}
break;
}
header('Location: music_on_hold.php');
exit;
}
//download music on hold file
if ($_GET['action'] == "download"
&& is_uuid($_GET['id'])
@@ -88,7 +109,6 @@
$stream_full_path = path_join($stream_path, $stream_file);
//download the file
session_cache_limiter('public');
if (file_exists($stream_full_path)) {
$fd = fopen($stream_full_path, "rb");
if ($_GET['t'] == "bin") {
@@ -121,6 +141,14 @@
&& is_array($streams)
&& @sizeof($streams) != 0) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: music_on_hold.php');
exit;
}
//determine name
if ($_POST['name_new'] != '') {
//set the action
@@ -192,14 +220,13 @@
}
//define default path
$stream_path = path_join($_SESSION['switch']['sounds']['dir'], 'music', $_SESSION['domain_name'],$stream_name, $path_rate);
$stream_path = path_join($_SESSION['switch']['sounds']['dir'], 'music', $_SESSION['domain_name'], $stream_name, $path_rate);
//find whether the path already exists
$stream_new_name = true;
foreach ($streams as $row) {
$alternate_path = str_replace('$${sounds_dir}', $_SESSION['switch']['sounds']['dir'], $row['music_on_hold_path']);
if ($stream_path == $row['music_on_hold_path']
|| $stream_path == $alternate_path) {
if ($stream_path == $row['music_on_hold_path'] || $stream_path == $alternate_path) {
$stream_new_name = false;
break;
}
@@ -260,6 +287,7 @@
exit;
}
/*
//delete the music on hold file
if ($_GET['action'] == "delete"
&& is_uuid($_GET['id'])
@@ -314,165 +342,128 @@
header("Location: music_on_hold.php");
exit;
}
*/
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header
require_once "resources/header.php";
$document['title'] = $text['title-music_on_hold'];
require_once "resources/header.php";
//script
echo "<script language='JavaScript' type='text/javascript'>\n";
echo " function check_filetype(file_input) {\n";
echo " file_ext = file_input.value.substr((~-file_input.value.lastIndexOf('.') >>> 0) + 2);\n";
echo " if (file_ext != 'mp3' && file_ext != 'wav' && file_ext != 'ogg' && file_ext != '') {\n";
echo " display_message(\"".$text['message-unsupported_file_type']."\", 'negative', '2750');\n";
echo " }\n";
echo " var selected_file_path = file_input.value;\n";
echo " selected_file_path = selected_file_path.replace(\"C:\\\\fakepath\\\\\",'');\n";
echo " document.getElementById('file_label').innerHTML = selected_file_path;\n";
echo " }\n";
//file type check
echo " function check_file_type(file_input) {\n";
echo " file_ext = file_input.value.substr((~-file_input.value.lastIndexOf('.') >>> 0) + 2);\n";
echo " if (file_ext != 'mp3' && file_ext != 'wav' && file_ext != 'ogg' && file_ext != '') {\n";
echo " display_message(\"".$text['message-unsupported_file_type']."\", 'negative', '2750');\n";
echo " }\n";
echo " }\n";
echo " function name_mode(mode) {\n";
echo " if (mode == 'new') {\n";
echo " document.getElementById('name_select').style.display='none';\n";
echo " document.getElementById('btn_new').style.display='none';\n";
echo " document.getElementById('name_new').style.display='';\n";
echo " document.getElementById('btn_select').style.display='';\n";
echo " document.getElementById('name_new').focus();\n";
echo " }\n";
echo " else if (mode == 'select') {\n";
echo " document.getElementById('name_new').style.display='none';\n";
echo " document.getElementById('name_new').value = '';\n";
echo " document.getElementById('btn_select').style.display='none';\n";
echo " document.getElementById('name_select').selectedIndex = 0;\n";
echo " document.getElementById('name_select').style.display='';\n";
echo " document.getElementById('btn_new').style.display='';\n";
echo " }\n";
echo " }\n";
//custom name (category)
echo " function name_mode(mode) {\n";
echo " if (mode == 'new') {\n";
echo " document.getElementById('name_select').style.display='none';\n";
echo " document.getElementById('btn_new').style.display='none';\n";
echo " document.getElementById('name_new').style.display='';\n";
echo " document.getElementById('btn_select').style.display='';\n";
echo " document.getElementById('rate').style.display='';\n";
echo " document.getElementById('name_new').focus();\n";
echo " }\n";
echo " else if (mode == 'select') {\n";
echo " document.getElementById('name_new').style.display='none';\n";
echo " document.getElementById('name_new').value = '';\n";
echo " document.getElementById('rate').style.display='none';\n";
echo " document.getElementById('btn_select').style.display='none';\n";
echo " document.getElementById('name_select').selectedIndex = 0;\n";
echo " document.getElementById('name_select').style.display='';\n";
echo " document.getElementById('btn_new').style.display='';\n";
echo " }\n";
echo " }\n";
echo "</script>\n";
echo "<script language='JavaScript' type='text/javascript' src='".PROJECT_PATH."/resources/javascript/reset_file_input.js'></script>\n";
echo "</script>";
echo "<b>".$text['label-music_on_hold']."</b>";
echo "<br /><br />\n";
echo $text['desc-music_on_hold']."\n";
echo "<br /><br />\n";
//show the upload form
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-music_on_hold']."</b></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('music_on_hold_add')) {
echo "<b>".$text['label-upload-music_on_hold']."</b>\n";
echo "<br><br>\n";
echo "<form id='form_upload' class='inline' method='post' enctype='multipart/form-data'>\n";
echo "<input name='action' type='hidden' value='upload'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','onclick'=>"$(this).fadeOut(250, function(){ $('span#form_upload').fadeIn(250); });"]);
echo "<span id='form_upload' style='display: none;'>";
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_upload_reset','onclick'=>"$('span#form_upload').fadeOut(250, function(){ name_mode('select'); document.getElementById('form_upload').reset(); $('#btn_add').fadeIn(250) });"]);
//name (category)
echo "<select name='name' id='name_select' class='formfld' style='width: auto;'>\n";
echo " <option value='' selected='selected' disabled='disabled'>".$text['label-category']."</option>\n";
echo "<form name='frm' id='frm' method='post' enctype='multipart/form-data'>\n";
echo "<input name='action' type='hidden' value='upload'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='40%' style='vertical-align: top;'>\n";
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td class='vncell' width='30%' valign='top' nowrap='nowrap'>\n";
echo " ".$text['label-category']."\n";
echo " </td>\n";
echo " <td class='vtable' width='70%' style='white-space: nowrap;'>\n";
echo " <select name='name' id='name_select' class='formfld' style='width: auto;'>\n";
if (permission_exists('music_on_hold_domain')) {
echo " <optgroup label='".$text['option-global']."'>\n";
if (permission_exists('music_on_hold_domain')) {
echo " <optgroup label='".$text['option-global']."'>\n";
foreach ($streams as $row) {
if (strlen($row['domain_uuid']) == 0) {
if (strlen($row['music_on_hold_rate']) == 0) { $option_name = $row['music_on_hold_name']; }
if (strlen($row['music_on_hold_rate']) > 0) { $option_name = $row['music_on_hold_name'] .'/'.$row['music_on_hold_rate']; }
echo " <option value='".escape($row['music_on_hold_uuid'])."'>".escape($option_name)."</option>\n";
}
}
echo " </optgroup>\n";
}
if (permission_exists('music_on_hold_domain')) {
echo " <optgroup label='".$text['option-local']."'>\n";
}
foreach ($streams as $row) {
if (strlen($row['domain_uuid']) == 0) {
if (strlen($row['music_on_hold_rate']) == 0) { $option_name = $row['music_on_hold_name']; }
if (strlen($row['music_on_hold_rate']) > 0) { $option_name = $row['music_on_hold_name'] .'/'.$row['music_on_hold_rate']; }
echo " <option value='".escape($row['music_on_hold_uuid'])."'>".escape($option_name)."</option>\n";
if (strlen($row['domain_uuid']) > 0) {
if (strlen($row['music_on_hold_rate']) == 0) { $option_name = $row['music_on_hold_name']; }
if (strlen($row['music_on_hold_rate']) > 0) { $option_name = $row['music_on_hold_name'] .'/'.$row['music_on_hold_rate']; }
echo " <option value='".escape($row['music_on_hold_uuid'])."'>".escape($option_name)."</option>\n";
}
}
echo " </optgroup>\n";
}
if (permission_exists('music_on_hold_domain')) {
echo " <optgroup label='".$text['option-local']."'>\n";
}
foreach ($streams as $row) {
if (strlen($row['domain_uuid']) > 0) {
if (strlen($row['music_on_hold_rate']) == 0) { $option_name = $row['music_on_hold_name']; }
if (strlen($row['music_on_hold_rate']) > 0) { $option_name = $row['music_on_hold_name'] .'/'.$row['music_on_hold_rate']; }
echo " <option value='".escape($row['music_on_hold_uuid'])."'>".escape($option_name)."</option>\n";
if (permission_exists('music_on_hold_domain')) {
echo " </optgroup>\n";
}
}
if (permission_exists('music_on_hold_domain')) {
echo " </optgroup>\n";
}
echo " </select>";
echo " <button type='button' id='btn_new' class='btn btn-default list_control_icon' style='margin-left: 3px;' onclick=\"name_mode('new');\"><span class='fas fa-plus'></span></button>";
echo " <input class='formfld' style='width: 100px; display: none;' type='text' name='name_new' id='name_new' maxlength='255' value=''>";
echo " <button type='button' id='btn_select' class='btn btn-default list_control_icon' style='display: none; margin-left: 3px;' onclick=\"name_mode('select');\"><span class='fas fa-list'></span></button>";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "</td>\n";
echo "<td width='30%' style='vertical-align: top;'>\n";
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td class='vncell' width='30%' valign='top' nowrap='nowrap'>\n";
echo " ".$text['label-rate']."\n";
echo " </td>\n";
echo " <td class='vtable' width='70%'>\n";
echo " <select id='rate' name='rate' class='formfld' style='width: auto;'>\n";
echo " <option value=''>".$text['option-default']."</option>\n";
echo " <option value='8000'>8 kHz</option>\n";
echo " <option value='16000'>16 kHz</option>\n";
echo " <option value='32000'>32 kHz</option>\n";
echo " <option value='48000'>48 kHz</option>\n";
echo " </select>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "</td>\n";
echo "<td width='30%' style='vertical-align: top;'>\n";
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td class='vncell' width='30%' valign='top' nowrap='nowrap'>\n";
echo " ".$text['label-file-path'];
echo " </td>\n";
echo " <td class='vtable' width='70%'>\n";
echo " <input name='file' id='file' type='file' style='display: none;' onchange=\"check_filetype(this);\">";
echo " <label id='file_label' for='file' class='txt' style='width: 150px; overflow: hidden; white-space: nowrap;'>".$text['label-select_a_file']."</label>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<div style='float: right; margin-top: 6px;'>";
echo " <input type='reset' class='btn' value='".$text['button-reset']."' onclick=\"reset_file_input('file'); document.getElementById('file_label').innerHTML = '".$text['label-select_a_file']."'; name_mode('select'); return true;\">\n";
echo " <input name='submit' type='submit' class='btn' id='upload' value='".$text['button-upload']."'>\n";
echo "</div>\n";
echo "</form>\n";
echo " </select>";
echo "<input class='formfld' style='width: 100px; display: none;' type='text' name='name_new' id='name_new' maxlength='255' placeholder=\"".$text['label-category']."\" value=''>";
//rate
echo "<select id='rate' name='rate' class='formfld' style='display: none; width: auto;'>\n";
echo " <option value='' selected='selected' disabled='disabled'>".$text['label-rate']."</option>\n";
echo " <option value=''>".$text['option-default']."</option>\n";
echo " <option value='8000'>8 kHz</option>\n";
echo " <option value='16000'>16 kHz</option>\n";
echo " <option value='32000'>32 kHz</option>\n";
echo " <option value='48000'>48 kHz</option>\n";
echo "</select>";
echo button::create(['type'=>'button','title'=>$text['label-new'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_new','onclick'=>"name_mode('new');"]);
echo button::create(['type'=>'button','title'=>$text['label-select'],'icon'=>'list','id'=>'btn_select','style'=>'display: none;','onclick'=>"name_mode('select');"]);
//file
echo "<input type='text' class='txt' style='width: 100px; cursor: pointer;' id='filename' placeholder='Select...' onclick=\"document.getElementById('file').click(); this.blur();\" onfocus='this.blur();'>";
echo "<input type='file' id='file' name='file' style='display: none;' accept='.wav,.mp3,.ogg' onchange=\"document.getElementById('filename').value = this.files.item(0).name; check_file_type(this);\">";
//submit
$margin_right = permission_exists('music_on_hold_delete') ? 'margin-right: 15px;' : null;
echo button::create(['type'=>'submit','label'=>$text['button-upload'],'style'=>$margin_right,'icon'=>$_SESSION['theme']['button_icon_upload']]);
echo "</span>\n";
echo "</form>";
}
if (permission_exists('music_on_hold_delete') && $streams) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
//set the row styles
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo $text['title_description-music_on_hold']."\n";
echo "<br /><br />\n";
//set the variable with an empty string
$previous_name = '';
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
//show the array of data
if (is_array($streams) && @sizeof($streams) != 0) {
//start the table
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0' style='margin-bottom: 3px;'>\n";
$previous_name = '';
//loop through the array
foreach ($streams as $row) {
@@ -481,25 +472,13 @@
$music_on_hold_name = $row['music_on_hold_name'];
$music_on_hold_rate = $row['music_on_hold_rate'];
$stream_rate = $row['music_on_hold_rate'];
//add vertical space
echo "<tr class='tr_link_void'><td colspan='5'><div style='width: 1px; height: 10px;'></div></td></tr>\n";
//add the name
//add the name (category)
if ($previous_name != $music_on_hold_name) {
echo "<tr class='tr_link_void'><td colspan='5'><div style='width: 1px; height: 20px;'></div></td></tr>\n";
echo "<tr class='tr_link_void'>\n";
echo " <td colspan='5'><b><i>".escape($music_on_hold_name)."</i></b>";
if ($row['domain_uuid'] == null) {
echo "&nbsp;&nbsp;- ".$text['label-global']."\n";
}
echo " </td>\n";
echo "</tr>\n";
echo "<b><i>".escape($music_on_hold_name)."</i></b>".(!is_uuid($row['domain_uuid']) ? '&nbsp;&nbsp;&nbsp;('.$text['label-global'].')' : null)."<br />\n";
}
//determine if rate was set to auto or not
$auto_rate = (strlen($music_on_hold_rate) == 0) ? true : false;
$auto_rate = strlen($music_on_hold_rate) == 0 ? true : false;
//determine icons to show
$stream_icons = array();
@@ -527,112 +506,100 @@
}
if (is_array($stream_icons) && sizeof($stream_icons) > 0) {
foreach ($stream_icons as $stream_icon) {
$icons .= "<span class='fas ".$stream_icon['icon']." icon_body' title='".escape($stream_icon['title'])."' style='width: 12px; height: 12px; margin-left: ".(($stream_icon['margin'] != '') ? $stream_icon['margin'] : 8)."px; vertical-align: text-top; cursor: help;'></span>";
$icons .= "<span class='fas ".$stream_icon['icon']." icon_body' title='".escape($stream_icon['title'])."' style='width: 12px; height: 12px; margin-left: ".($stream_icon['margin'] != '' ? $stream_icon['margin'] : 8)."px; vertical-align: text-top; cursor: help;'></span>";
}
}
//set the rate label
if ($auto_rate) {
$stream_details = $text['option-default'].' '.$icons;
$stream_rate = $auto_rate ? $text['option-default'] : ($music_on_hold_rate/1000).' kHz';
if (permission_exists('music_on_hold_edit')) {
$stream_details = "<a href='music_on_hold_edit.php?id=".urlencode($row['music_on_hold_uuid'])."'>".$stream_rate.'</a> '.$icons;
}
else {
$stream_details = ($music_on_hold_rate/1000).' kHz / '.$icons;
$stream_details = $stream_rate.' '.$icons;
}
//show the table header
echo " <tr>\n";
echo " <th class='listhdr'>".$stream_details."</th>\n";
echo " <th class='listhdr' style='width: 55px;'>".$text['label-tools']."</th>\n";
echo " <th class='listhdr' style='width: 65px; text-align: right; white-space: nowrap;'>".$text['label-file-size']."</th>\n";
echo " <th class='listhdr' style='width: 150px; text-align: right;'>".$text['label-uploaded']."</th>\n";
echo " <td class='".((!permission_exists('music_on_hold_domain')) ? 'list_control_icon' : 'list_control_icons')." tr_link_void'>";
if (permission_exists('music_on_hold_edit')) {
echo "<a href='music_on_hold_edit.php?id=".escape($row['music_on_hold_uuid'])."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
//get the music on hold path and files
$stream_path = str_replace("\$\${sounds_dir}",$_SESSION['switch']['sounds']['dir'], $row['music_on_hold_path']);
if (file_exists($stream_path)) {
$stream_files = array_merge(glob($stream_path.'/*.wav'), glob($stream_path.'/*.mp3'), glob($stream_path.'/*.ogg'));
}
//start the table
echo "<table class='list'>\n";
echo " <tr class='list-header'>\n";
if (permission_exists('music_on_hold_delete')) {
echo "<a href='music_on_hold_delete.php?id=".escape($row['music_on_hold_uuid'])."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_".$row['music_on_hold_uuid']."' name='moh[".$row['music_on_hold_uuid']."][checked]' value='true' onclick=\"list_all_toggle('".$row['music_on_hold_uuid']."');\">\n";
echo " </th>\n";
}
echo "</td>\n";
echo " <th class='pct-50'>".$stream_details."</th>\n";
echo " <th class='center shrink'>".$text['label-tools']."</th>\n";
echo " <th class='right hide-xs no-wrap pct-20'>".$text['label-file-size']."</th>\n";
echo " <th class='right hide-sm-dn pct-30'>".$text['label-uploaded']."</th>\n";
// if (permission_exists('music_on_hold_delete')) {
// echo "<a href='music_on_hold_delete.php?id=".escape($row['music_on_hold_uuid'])."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
// }
echo " </tr>";
unset($stream_icons, $icons);
//add the uuid of to the link
if (permission_exists('music_on_hold_edit')) {
$tr_link = "href='music_on_hold_edit.php?id=".escape($row['music_on_hold_uuid'])."'";
}
//get the music on hold path
$stream_path = $row['music_on_hold_path'];
$stream_path = str_replace("\$\${sounds_dir}",$_SESSION['switch']['sounds']['dir'], $stream_path);
//show the files
if (file_exists($stream_path)) {
$stream_files = array_merge(glob($stream_path.'/*.wav'), glob($stream_path.'/*.mp3'), glob($stream_path.'/*.ogg'));
if (is_array($stream_files) && @sizeof($stream_files) != 0) {
foreach ($stream_files as $stream_file_path) {
$stream_file = pathinfo($stream_file_path, PATHINFO_BASENAME);
$stream_file_size = byte_convert(filesize($stream_file_path));
$stream_file_date = date("M d, Y H:i:s", filemtime($stream_file_path));
$stream_file_ext = pathinfo($stream_file, PATHINFO_EXTENSION);
switch ($stream_file_ext) {
case "wav" : $stream_file_type = "audio/wav"; break;
case "mp3" : $stream_file_type = "audio/mpeg"; break;
case "ogg" : $stream_file_type = "audio/ogg"; break;
}
$row_uuid = uuid();
echo "<tr id='recording_progress_bar_".$row_uuid."' style='display: none;'><td colspan='4' class='".$row_style[$c]." playback_progress_bar_background' style='padding: 0; border: none;'><span class='playback_progress_bar' id='recording_progress_".$row_uuid."'></span></td></tr>\n";
$tr_link = "href=\"javascript:recording_play('".$row_uuid."');\"";
echo "<tr ".$tr_link.">\n";
echo " <td class='".$row_style[$c]."'>".escape($stream_file)."</td>\n";
echo " <td valign='top' class='".$row_style[$c]." row_style_slim tr_link_void'>";
echo "<audio id='recording_audio_".$row_uuid."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".$row_uuid."')\" onended=\"recording_reset('".$row_uuid."');\" src='?action=download&id=".escape($row['music_on_hold_uuid'])."&file=".urlencode($stream_file)."' type='".escape($stream_file_type)."'></audio>";
echo "<span id='recording_button_".$row_uuid."' onclick=\"recording_play('".$row_uuid."')\" title='".$text['label-play']." / ".$text['label-pause']."'>".$v_link_label_play."</span>";
echo "<span onclick=\"recording_stop('".$row_uuid."')\" title='".$text['label-stop']."'>".$v_link_label_stop."</span>";
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='text-align: right; white-space: nowrap;'>".escape($stream_file_size)."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='text-align: right; white-space: nowrap;'>".escape($stream_file_date)."</td>\n";
echo " <td valign='top' class='".((!permission_exists('music_on_hold_domain')) ? 'list_control_icon' : 'list_control_icons')."'>\n";
echo "<a href='?action=download&id=".escape($row['music_on_hold_uuid'])."&file=".urlencode($stream_file)."' title='".$text['label-download']."'>".$v_link_label_download."</a>";
if ( (!is_uuid($domain_uuid) && permission_exists('music_on_hold_domain')) || (is_uuid($domain_uuid) && permission_exists('music_on_hold_delete')) ) {
echo "<a href='?action=delete&id=".urlencode($row['music_on_hold_uuid'])."&file=".urlencode($stream_file)."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
}
echo " </td>\n";
echo "</tr>\n";
$c = ($c) ? 0 : 1;
//list the stream files
if (is_array($stream_files) && @sizeof($stream_files) != 0) {
$x = 0;
foreach ($stream_files as $stream_file_path) {
$row_uuid = uuid();
$stream_file = pathinfo($stream_file_path, PATHINFO_BASENAME);
$stream_file_size = byte_convert(filesize($stream_file_path));
$stream_file_date = date("M d, Y H:i:s", filemtime($stream_file_path));
$stream_file_ext = pathinfo($stream_file, PATHINFO_EXTENSION);
switch ($stream_file_ext) {
case "wav" : $stream_file_type = "audio/wav"; break;
case "mp3" : $stream_file_type = "audio/mpeg"; break;
case "ogg" : $stream_file_type = "audio/ogg"; break;
}
//playback progress bar
echo "<tr class='list-row' id='recording_progress_bar_".$row_uuid."' style='display: none;'><td class='playback_progress_bar_background' style='padding: 0; border: none;' colspan='5'><span class='playback_progress_bar' id='recording_progress_".$row_uuid."'></span></td></tr>\n";
echo "<tr class='list-row' style='display: none;'><td></td></tr>\n"; // dummy row to maintain alternating background color
$list_row_link = "javascript:recording_play('".$row_uuid."');";
echo "<tr class='list-row' href=\"".$list_row_link."\">\n";
if (permission_exists('music_on_hold_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='moh[".$row['music_on_hold_uuid']."][$x][checked]' id='checkbox_".$x."' class='checkbox_".$row['music_on_hold_uuid']."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all_".$row['music_on_hold_uuid']."').checked = false; }\">\n";
echo " <input type='hidden' name='moh[".$row['music_on_hold_uuid']."][$x][file_name]' value=\"".urlencode($stream_file)."\" />\n";
echo " </td>\n";
}
echo " <td class='overflow'>".escape($stream_file)."</td>\n";
echo " <td class='button center no-link no-wrap'>";
echo "<audio id='recording_audio_".$row_uuid."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".$row_uuid."')\" onended=\"recording_reset('".$row_uuid."');\" src='?action=download&id=".escape($row['music_on_hold_uuid'])."&file=".urlencode($stream_file)."' type='".escape($stream_file_type)."'></audio>";
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.$row_uuid,'onclick'=>"recording_play('".$row_uuid."');"]);
// echo button::create(['type'=>'button','title'=>$text['label-stop'],'icon'=>$_SESSION['theme']['button_icon_stop'],'onclick'=>"recording_stop('".$row_uuid."'); this.blur(); return false;"]);
echo button::create(['type'=>'button','title'=>$text['label-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'link'=>"?action=download&id=".urlencode($row['music_on_hold_uuid'])."&file=".urlencode($stream_file)]);
echo " </td>\n";
echo " <td class='right no-wrap hide-xs'>".escape($stream_file_size)."</td>\n";
echo " <td class='right no-wrap hide-sm-dn'>".escape($stream_file_date)."</td>\n";
// if ( (!is_uuid($domain_uuid) && permission_exists('music_on_hold_domain')) || (is_uuid($domain_uuid) && permission_exists('music_on_hold_delete')) ) {
// echo "<a href='?action=delete&id=".urlencode($row['music_on_hold_uuid'])."&file=".urlencode($stream_file)."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
// }
echo "</tr>\n";
$x++;
}
}
echo "</table>\n";
echo "<br />\n";
//set the previous music_on_hold_name
$previous_name = $music_on_hold_name;
//toggle the light highlighting
$c = ($c) ? 0 : 1;
}
unset($streams, $row);
//end the table
echo "</table>\n";
}
echo "<tr>\n";
echo "<td colspan='11' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
echo " <td class='list_control_icons'>";
echo " &nbsp;";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "<br /><br />";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>
?>

View File

@@ -28,15 +28,39 @@
include "root.php";
//define the switch_music_on_hold class
if (!class_exists('switch_music_on_hold')) {
class switch_music_on_hold {
public $domain_uuid;
/**
* declare private variables
*/
private $xml;
private $app_name;
private $app_uuid;
private $permission_prefix;
private $list_page;
private $table;
private $uuid_prefix;
/**
* called when the object is created
*/
public function __construct() {
$this->domain_uuid = $_SESSION['domain_uuid'];
//assign private variables
$this->app_name = 'music_on_hold';
$this->app_uuid = '1dafe0f8-c08a-289b-0312-15baf4f20f81';
$this->permission_prefix = 'music_on_hold_';
$this->list_page = 'music_on_hold.php';
$this->table = 'music_on_hold';
$this->uuid_prefix = 'music_on_hold_';
}
/**
* called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
@@ -214,7 +238,141 @@ include "root.php";
$this->reload();
}
}
/**
* delete records/files
*/
public function delete($records) {
if (permission_exists($this->permission_prefix.'delete')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//filter checked records
foreach ($records as $music_on_hold_uuid => $record) {
if (is_uuid($music_on_hold_uuid)) {
if ($record['checked'] == 'true') {
foreach ($record as $key => $array) {
if (is_numeric($key) && is_array($array) && @sizeof($array) != 0) {
$moh[$music_on_hold_uuid][] = $array['file_name'];
}
}
$moh[$music_on_hold_uuid]['delete'] = true;
continue;
}
foreach ($record as $key => $array) {
if (is_numeric($key) && is_array($array) && @sizeof($array) != 0 && $array['checked'] == 'true') {
$moh[$music_on_hold_uuid][] = $array['file_name'];
}
}
}
}
unset($array);
// view_array($moh);
//loop checked records
$files_deleted = 0;
if (is_array($moh) && @sizeof($moh) != 0) {
//get music on hold details
$sql = "select * from v_music_on_hold ";
$sql .= "where (domain_uuid = :domain_uuid ".(!permission_exists('music_on_hold_domain') ?: "or domain_uuid is null ").") ";
$sql .= "and music_on_hold_uuid in ('".implode("','", array_keys($moh))."') ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$streams[$row['music_on_hold_uuid']] = $row;
}
}
unset($sql, $parameters, $rows, $row);
//delete files, folders, build delete array
$x = 0;
foreach ($moh as $music_on_hold_uuid => $row) {
//prepare path
$stream_path = $streams[$music_on_hold_uuid]['music_on_hold_path'];
$stream_path = str_replace('$${sounds_dir}', $_SESSION['switch']['sounds']['dir'], $stream_path);
//delete checked files
foreach ($row as $key => $stream_file) {
if (is_numeric($key)) {
$stream_file_path = str_replace('../', '', path_join($stream_path, $stream_file));
if (@unlink($stream_file_path)) {
$files_deleted++;
}
}
}
//delete name rate
if ($row['delete']) {
//build delete array
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $music_on_hold_uuid;
if (!permission_exists('music_on_hold_domain')) {
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
}
$x++;
//delete rate folder
@rmdir($stream_path);
//delete name (category) folder, if empty
$name_path = dirname($stream_path);
if (@sizeof(scandir($name_path)) == 2) { //empty (only /.. and /. remaining)
@rmdir($name_path);
}
}
}
}
//delete the moh records
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
//set flag
$moh_deleted = true;
}
unset($records, $moh);
//post delete
if ($moh_deleted || $files_deleted) {
//reload moh
$this->reload();
//set message
message::add($text['message-delete']);
}
}
}
} //method
} //class
}
//build and save the XML
//require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php";
@@ -222,4 +380,4 @@ include "root.php";
//$moh->xml();
//$moh->save();
?>
?>

View File

@@ -59,7 +59,7 @@ if (!class_exists('button')) {
!$array['label']
)) {
$icon_class = is_array($array['icon']) ? $array['icon']['text'] : 'fas fa-'.$array['icon'];
$button .= "<span class='".$icon_class."'></span>";
$button .= "<span class='".$icon_class." fa-fw'></span>";
}
//label
if ($array['label'] && (