diff --git a/app/music_on_hold/app_config.php b/app/music_on_hold/app_config.php index ab5bfb0d06..c49b7bd241 100644 --- a/app/music_on_hold/app_config.php +++ b/app/music_on_hold/app_config.php @@ -20,28 +20,43 @@ $apps[$x]['description']['pt-br'] = ""; //permission details - $apps[$x]['permissions'][0]['name'] = "music_on_hold_default_view"; - $apps[$x]['permissions'][0]['menu']['uuid'] = "1cd1d6cb-912d-db32-56c3-e0d5699feb9d"; - $apps[$x]['permissions'][0]['groups'][] = "superadmin"; - - $apps[$x]['permissions'][1]['name'] = "music_on_hold_default_add"; - $apps[$x]['permissions'][1]['groups'][] = "superadmin"; - - $apps[$x]['permissions'][2]['name'] = "music_on_hold_default_delete"; - $apps[$x]['permissions'][2]['groups'][] = "superadmin"; - - $apps[$x]['permissions'][3]['name'] = "music_on_hold_view"; - $apps[$x]['permissions'][3]['menu']['uuid'] = "1cd1d6cb-912d-db32-56c3-e0d5699feb9d"; - $apps[$x]['permissions'][3]['groups'][] = "superadmin"; - $apps[$x]['permissions'][3]['groups'][] = "admin"; - - $apps[$x]['permissions'][4]['name'] = "music_on_hold_add"; - $apps[$x]['permissions'][4]['groups'][] = "superadmin"; - $apps[$x]['permissions'][4]['groups'][] = "admin"; - - $apps[$x]['permissions'][5]['name'] = "music_on_hold_delete"; - $apps[$x]['permissions'][5]['groups'][] = "superadmin"; - $apps[$x]['permissions'][5]['groups'][] = "admin"; + $y = 0; + $apps[$x]['permissions'][$y]['name'] = "music_on_hold_global_view"; + $apps[$x]['permissions'][$y]['menu']['uuid'] = "1cd1d6cb-912d-db32-56c3-e0d5699feb9d"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "music_on_hold_global_add"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "music_on_hold_global_edit"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "music_on_hold_global_delete"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "music_on_hold_view"; + $apps[$x]['permissions'][$y]['menu']['uuid'] = "1cd1d6cb-912d-db32-56c3-e0d5699feb9d"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "music_on_hold_add"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "music_on_hold_edit"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "music_on_hold_delete"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "music_on_hold_domain"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "music_on_hold_path"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; //schema details $y = 0; //table array index @@ -67,19 +82,27 @@ $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $z++; - $apps[$x]['db'][$y]['fields'][$z]['name'] = "music_on_hold_rate"; - $apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric"; - $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "8000,16000,32000,48000"; - $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = "music_on_hold_path"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "music_on_hold_rate"; + $apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "8000,16000,32000,48000"; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = "music_on_hold_shuffle"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "true/false"; $z++; - $apps[$x]['db'][$y]['fields'][$z]['name'] = "music_on_hold_timer"; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "music_on_hold_channels"; + $apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "1-mono, 2-stereo"; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "music_on_hold_interval"; + $apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "milliseconds"; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "music_on_hold_timer_name"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "soft"; $z++; diff --git a/app/music_on_hold/app_languages.php b/app/music_on_hold/app_languages.php index 404bb105ec..16de802f5e 100644 --- a/app/music_on_hold/app_languages.php +++ b/app/music_on_hold/app_languages.php @@ -1,10 +1,21 @@ mono WAV files."; $text['desc-moh']['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 mono."; $text['desc-moh']['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 mono."; diff --git a/app/music_on_hold/music_on_hold.php b/app/music_on_hold/music_on_hold.php index ba2f967187..b8d588af0f 100644 --- a/app/music_on_hold/music_on_hold.php +++ b/app/music_on_hold/music_on_hold.php @@ -24,11 +24,12 @@ Mark J Crane James Rose */ +ini_set('max_execution_time', 7200); include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('music_on_hold_view') || permission_exists('music_on_hold_default_view')) { +if (permission_exists('music_on_hold_view') || permission_exists('music_on_hold_global_view')) { //access granted } else { @@ -43,253 +44,300 @@ else { //include paging require_once "resources/paging.php"; -//set the music on hold directory - if (file_exists('/var/lib/fusionpbx/sounds/music')) { - $music_on_hold_dir = $_SESSION['switch']['sounds']['dir'].'/music/fusionpbx'; +//get moh records, build array + $sql = "select * from v_music_on_hold "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + if (permission_exists('music_on_hold_global_view')) { + $sql .= "or domain_uuid is null "; } - else { - $music_on_hold_dir = $_SESSION['switch']['sounds']['dir'].'/music'; - } - ini_set(max_execution_time,7200); + $sql .= "order by domain_uuid desc, music_on_hold_rate asc, music_on_hold_name asc"; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (count($result) > 0) { + foreach($result as $row) { + $moh_name_only = (substr_count($row['music_on_hold_name'], '/') > 0) ? substr($row['music_on_hold_name'], 0, strpos($row['music_on_hold_name'], '/')) : $row['music_on_hold_name']; + $moh_domain_uuid = ($row['domain_uuid'] != '') ? $row['domain_uuid'] : '_global_'; + $moh_rate = $row['music_on_hold_rate']; + $mohs[$moh_domain_uuid][$moh_name_only][$moh_rate]['uuid'] = $row['music_on_hold_uuid']; + $mohs[$moh_domain_uuid][$moh_name_only][$moh_rate]['name'] = $row['music_on_hold_name']; //value may include '/[rate]' + $mohs[$moh_domain_uuid][$moh_name_only][$moh_rate]['path'] = '/'.trim(str_replace('$${sounds_dir}', $_SESSION['switch']['sounds']['dir'], $row['music_on_hold_path']),'/'); + $mohs[$moh_domain_uuid][$moh_name_only][$moh_rate]['shuffle'] = $row['music_on_hold_shuffle']; + $mohs[$moh_domain_uuid][$moh_name_only][$moh_rate]['channels'] = $row['music_on_hold_channels']; + $mohs[$moh_domain_uuid][$moh_name_only][$moh_rate]['interval'] = $row['music_on_hold_interval']; + $mohs[$moh_domain_uuid][$moh_name_only][$moh_rate]['chime_list'] = $row['music_on_hold_chime_list']; + $mohs[$moh_domain_uuid][$moh_name_only][$moh_rate]['chime_freq'] = $row['music_on_hold_chime_freq']; + $mohs[$moh_domain_uuid][$moh_name_only][$moh_rate]['chime_max'] = $row['music_on_hold_chime_max']; -//set the order by - $order_by = check_str($_GET["order_by"]); - $order = check_str($_GET["order"]); + $moh_names[(($moh_domain_uuid == '_global_') ? 'global' : 'local')][] = $moh_name_only; + $moh_paths[$row['music_on_hold_uuid']] = '/'.trim(str_replace('$${sounds_dir}', $_SESSION['switch']['sounds']['dir'], $row['music_on_hold_path']),'/'); + $moh_domains[$row['music_on_hold_uuid']][] = $row['domain_uuid']; + } + } + unset($sql, $prep_statement, $result); + foreach ($mohs as $domain_uuid => &$moh) { ksort($moh); } + $moh_names['global'] = array_unique($moh_names['global']); + $moh_names['local'] = array_unique($moh_names['local']); + sort($moh_names['global'], SORT_NATURAL); + sort($moh_names['local'], SORT_NATURAL); + //echo "".print_r($mohs, true)."\n\n\n\n\n"; exit; //download moh file - if ($_GET['a'] == "download") { - $slashes = array("/", "\\"); - $_GET['category'] = str_replace($slashes, "", $_GET['category']); - $_GET['file_name'] = str_replace($slashes, "", $_GET['file_name']); - - $category_dir = $_GET['category']; - $sampling_rate_dir = $_GET['sampling_rate']; - - if ($category_dir != '') { - $path_mod = $category_dir."/"; - if (count($_SESSION['domains']) > 1) { - $path_mod = $_SESSION["domain_name"]."/".$path_mod; - } - } + if ($_GET['action'] == "download") { + $moh_uuid = $_GET['id']; + $moh_file = base64_decode($_GET['file']); session_cache_limiter('public'); - if ($_GET['type'] = "moh") { - if (file_exists($music_on_hold_dir."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['file_name']))) { - $fd = fopen($music_on_hold_dir."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['file_name']), "rb"); - if ($_GET['t'] == "bin") { - header("Content-Type: application/force-download"); - header("Content-Type: application/octet-stream"); - header("Content-Type: application/download"); - header("Content-Description: File Transfer"); - } - else { - $file_ext = substr(base64_decode($_GET['file_name']), -3); - if ($file_ext == "wav") { - header("Content-Type: audio/x-wav"); - } - if ($file_ext == "mp3") { - header("Content-Type: audio/mpeg"); - } - } - header('Content-Disposition: attachment; filename="'.base64_decode($_GET['file_name']).'"'); - header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 - header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past - header("Content-Length: " . filesize($music_on_hold_dir."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['file_name']))); - fpassthru($fd); + if (file_exists($moh_paths[$moh_uuid].'/'.$moh_file)) { + $fd = fopen($moh_paths[$moh_uuid].'/'.$moh_file, "rb"); + if ($_GET['t'] == "bin") { + header("Content-Type: application/force-download"); + header("Content-Type: application/octet-stream"); + header("Content-Type: application/download"); + header("Content-Description: File Transfer"); } + else { + $moh_file_ext = pathinfo($moh_file, PATHINFO_EXTENSION); + switch ($moh_file_ext) { + case "wav" : header("Content-Type: audio/x-wav"); break; + case "mp3" : header("Content-Type: audio/mpeg"); break; + case "ogg" : header("Content-Type: audio/ogg"); break; + } + } + header('Content-Disposition: attachment; filename="'.$moh_file.'"'); + header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 + header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past + header("Content-Length: ".filesize($moh_paths[$moh_uuid].'/'.$moh_file)); + fpassthru($fd); } exit; } //upload moh file - if (is_uploaded_file($_FILES['upload_file']['tmp_name'])) { - $file_ext = strtolower(pathinfo($_FILES['upload_file']['name'], PATHINFO_EXTENSION)); - if ($file_ext == 'wav' || $file_ext == 'mp3') { - if ($_POST['type'] == 'moh' && permission_exists('music_on_hold_add')) { - - //remove the slashes + if ($_POST['action'] == 'upload' && is_array($_FILES) && is_uploaded_file($_FILES['file']['tmp_name'])) { + //determine name & scope + if ($_POST['name_new'] != '') { + $moh_scope = (permission_exists('music_on_hold_global_add')) ? $_POST['scope'] : 'local'; + $moh_name_only = strtolower($_POST['name_new']); + $moh_new_name = true; + } + else { + $tmp = explode('|', $_POST['name']); + $moh_scope = $tmp[0]; + $moh_name_only = $tmp[1]; + $moh_new_name = false; + } + //get remaining values + $moh_rate = $_POST['rate']; + $moh_file_name_temp = $_FILES['file']['tmp_name']; + $moh_file_name = $_FILES['file']['name']; + $moh_file_ext = strtolower(pathinfo($moh_file_name, PATHINFO_EXTENSION)); + //check file type + $valid_file_type = ($moh_file_ext == 'wav' || $moh_file_ext == 'mp3' || $moh_file_ext == 'ogg') ? true : false; + //check permissions + $has_permission = ( ($moh_scope == 'global' && permission_exists('music_on_hold_global_add')) || ($moh_scope == 'local' && permission_exists('music_on_hold_add')) ) ? true : false; + //process, if possible + if (!$valid_file_type) { + $_SESSION['message'] = $text['message-unsupported_file_type']; + } + else if ($has_permission) { + //strip slashes, replace spaces $slashes = array("/", "\\"); - $_POST['upload_category_new'] = str_replace($slashes, "", $_POST['upload_category_new']); - $_FILES['upload_file']['name'] = str_replace($slashes, "", $_FILES['upload_file']['name']); - - //replace any spaces in the file_name with dashes - $new_file_name = str_replace(' ', '-', $_FILES['upload_file']['name']); - - //convert sampling rate from value passed by form - if ($file_ext == 'mp3') { - $sampling_rate_dirs = Array(8000, 16000, 32000, 48000); + $moh_name_only = str_replace($slashes, '', $moh_name_only); + $moh_name_only = str_replace(' ', '_', $moh_name_only); + $moh_file_name = str_replace($slashes, '', $moh_file_name); + $moh_file_name = str_replace(' ', '-', $moh_file_name); + //detect auto rate + if ($moh_rate == 'auto') { + $moh_rate = '48000'; + $moh_rate_auto = true; } else { - $sampling_rate_dirs[] = $_POST['upload_sampling_rate'] * 1000; + $moh_rate_auto = false; } - - //if multi-tenant, modify directory paths - if (count($_SESSION['domains']) > 1) { - $path_mod = $_SESSION["domain_name"]."/"; + //define default path + $moh_path = $_SESSION['switch']['sounds']['dir'].'/music/'.(($moh_scope == 'global') ? 'global' : $_SESSION['domain_name']).'/'.$moh_name_only.'/'.$moh_rate; + $moh_path_found = false; + //begin query + $music_on_hold_uuid = uuid(); + $sql = "insert into v_music_on_hold "; + $sql .= "( "; + $sql .= "music_on_hold_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "music_on_hold_name, "; + $sql .= "music_on_hold_path, "; + $sql .= "music_on_hold_rate, "; + $sql .= "music_on_hold_shuffle, "; + $sql .= "music_on_hold_channels, "; + $sql .= "music_on_hold_interval, "; + $sql .= "music_on_hold_timer_name, "; + $sql .= "music_on_hold_chime_list, "; + $sql .= "music_on_hold_chime_freq, "; + $sql .= "music_on_hold_chime_max "; + $sql .= ") values "; + //new name + if ($moh_new_name) { + $sql .= "( "; + $sql .= "'".$music_on_hold_uuid."',"; + $sql .= (($moh_scope == 'global') ? 'null' : "'".$domain_uuid."'").", "; + $sql .= "'".check_str($moh_name_only.((!$moh_rate_auto) ? '/'.$moh_rate : null))."', "; + $sql .= "'".check_str(str_replace($_SESSION['switch']['sounds']['dir'], '$${sounds_dir}', $moh_path))."', "; + $sql .= "'".check_str($moh_rate)."', "; + $sql .= "'false', "; + $sql .= "1, "; + $sql .= "20, "; + $sql .= "'soft', "; + $sql .= "null, "; + $sql .= "null, "; + $sql .= "null "; + $sql .= ") "; } - - //create new category, if necessary - if ($_POST['upload_category'] == '_NEW_CAT_' && $_POST['upload_category_new'] != '') { - $new_category_name = str_replace(' ', '_', $_POST['upload_category_new']); - //process sampling rate(s) - if (isset($sampling_rate_dirs)) foreach ($sampling_rate_dirs as $sampling_rate_dir) { - if (!is_dir($music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir)) { - mkdir($music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir, 02770, true); - } - if (is_dir($music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir)) { - copy($_FILES['upload_file']['tmp_name'], $music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir."/".$new_file_name); - $target_dir = $music_on_hold_dir."/".$path_mod.$new_category_name."/".$sampling_rate_dir; - } + //existing name + else { + //get existing path + $moh_settings = $mohs[(($moh_scope == 'global') ? '_global_' : $domain_uuid)][$moh_name_only][$moh_rate]; + if ( + ($moh_rate_auto && $moh_name_only == $moh_settings['name']) || + (!$moh_rate_auto && $moh_name_only.'/'.$moh_rate == $moh_settings['name']) + ) { + $moh_path = $moh_settings['path']; + $moh_path_found = true; } - //delete temp file - @unlink($_FILES['upload_file']['tmp_name']); - } - //use existing category directory - else if ($_POST['upload_category'] != '' && $_POST['upload_category'] != '_NEW_CAT_') { - //process sampling rate(s) - if (isset($sampling_rate_dirs)) foreach ($sampling_rate_dirs as $sampling_rate_dir) { - if (!is_dir($music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir)) { - mkdir($music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir, 02770, true); - } - if (is_dir($music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir)) { - copy($_FILES['upload_file']['tmp_name'], $music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir."/".$new_file_name); - $target_dir = $music_on_hold_dir."/".$path_mod.$_POST['upload_category']."/".$sampling_rate_dir; - } + //not found, finish query + else { + $sql .= "( "; + $sql .= "'".$music_on_hold_uuid."',"; + $sql .= (($moh_scope == 'global') ? 'null' : "'".$domain_uuid."'").", "; + $sql .= "'".check_str($moh_name_only.((!$moh_rate_auto) ? '/'.$moh_rate : null))."', "; + $sql .= "'".check_str(str_replace($_SESSION['switch']['sounds']['dir'], '$${sounds_dir}', $moh_path))."', "; + $sql .= "'".check_str($moh_rate)."', "; + $sql .= "'false', "; + $sql .= "1, "; + $sql .= "20, "; + $sql .= "'soft', "; + $sql .= "null, "; + $sql .= "null, "; + $sql .= "null "; + $sql .= ") "; } - //delete temp file - @unlink($_FILES['upload_file']['tmp_name']); } - //use default directory - else if ($_POST['upload_category'] == '') { - if (permission_exists('music_on_hold_default_add')) { - //process sampling rate(s) - if (isset($sampling_rate_dirs)) foreach ($sampling_rate_dirs as $sampling_rate_dir) { - if (!is_dir($music_on_hold_dir."/".$sampling_rate_dir)) { - mkdir($music_on_hold_dir."/".$sampling_rate_dir, 02770, true); - } - if (is_dir($music_on_hold_dir."/".$sampling_rate_dir)) { - copy($_FILES['upload_file']['tmp_name'], $music_on_hold_dir."/".$sampling_rate_dir."/".$new_file_name); - $target_dir = $music_on_hold_dir."/".$sampling_rate_dir; - } - } - //delete temp file - @unlink($_FILES['upload_file']['tmp_name']); + //execute query + if (!$moh_path_found) { + $db->exec(check_sql($sql)); + unset($sql); + } + //check target folder, move uploaded file + if (!is_dir($moh_path)) { + mkdir($moh_path, 02770, true); + } + if (is_dir($moh_path)) { + if (copy($moh_file_name_temp, $moh_path.'/'.$moh_file_name)) { + @unlink($moh_file_name_temp); } } + //set message + $_SESSION['message'] = $text['message-upload_completed']; + } + + //redirect + header("Location: music_on_hold.php"); + exit; + } + +//delete moh/file + if ($_GET['action'] == "delete") { + //get submitted values + $moh_uuid = check_str($_GET['id']); + $moh_file = check_str(base64_decode($_GET['file'])); + //check permissions + if ( + ($moh_domains[$moh_uuid] == '' && permission_exists('music_on_hold_global_delete')) || + ($moh_domains[$moh_uuid] != '' && permission_exists('music_on_hold_delete')) + ) { + //remove specified file + if ($moh_file != '') { + @unlink($moh_paths[$moh_uuid].'/'.$moh_file); + } + //remove all audio files else { - //delete temp file and exit - @unlink($_FILES['upload_file']['tmp_name']); - exit(); + array_map('unlink', glob($moh_paths[$moh_uuid].'/*.wav')); + array_map('unlink', glob($moh_paths[$moh_uuid].'/*.mp3')); + array_map('unlink', glob($moh_paths[$moh_uuid].'/*.ogg')); } - - //build and save the XML - require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; - $moh = new switch_music_on_hold; - $moh->xml(); - $moh->save(); - - //set an upload message - $save_msg = "Uploaded file to ".$target_dir."/".htmlentities($_FILES['upload_file']['name']); + //remove record and folder(s), if empty + $file_count = 0; + $file_count += ($files = glob($moh_paths[$moh_uuid].'/*.wav')) ? count($files) : 0; + $file_count += ($files = glob($moh_paths[$moh_uuid].'/*.mp3')) ? count($files) : 0; + $file_count += ($files = glob($moh_paths[$moh_uuid].'/*.ogg')) ? count($files) : 0; + if ($file_count == 0) { + //remove rate folder + rmdir($moh_paths[$moh_uuid]); + //remove record + $sql = "delete from v_music_on_hold "; + $sql .= "where music_on_hold_uuid = '".$moh_uuid."' "; + if (!permission_exists('music_on_hold_global_delete')) { + $sql .= "and domain_uuid = '".$domain_uuid."' "; + } + //echo $sql; exit; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + //remove parent folder, if empty + $parent_path = dirname($moh_paths[$moh_uuid]); + $parent_path_files = glob($parent_path.'/*'); + if (sizeof($parent_files) === 0) { rmdir($parent_path); } + } + //set message + $_SESSION['message'] = $text['message-delete']; } - } - - $_SESSION['message'] = $text['message-upload_completed']; - header("Location: music_on_hold.php"); - exit; + //redirect + header("Location: music_on_hold.php"); + exit; } -//define valid sampling rates - $sampling_rate_dirs = Array(8000, 16000, 32000, 48000); - -//delete moh file - if ($_GET['act'] == "del" && permission_exists('music_on_hold_delete')) { - if ($_GET['type'] == 'moh') { - //remove the slashes - $slashes = array("/", "\\"); - $_GET['category'] = str_replace($slashes, "", $_GET['category']); - $_GET['file_name'] = str_replace($slashes, "", $_GET['file_name']); - //set the variables - $sampling_rate_dir = $_GET['sampling_rate']; - $category_dir = $_GET['category']; - //default category - if ($category_dir == "") { - if (!permission_exists('music_on_hold_default_delete')) { - echo "access denied"; - exit; - } - } - //other categories - if ($category_dir != "") { - $path_mod = $category_dir."/"; - - if (count($_SESSION['domains']) > 1) { - $path_mod = $_SESSION["domain_name"]."/".$path_mod; - } - } - //remove the directory - unlink($music_on_hold_dir."/".$path_mod.$sampling_rate_dir."/".base64_decode($_GET['file_name'])); - - //build and save the XML - require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; - $moh = new switch_music_on_hold; - $moh->xml(); - $moh->save(); - - //redirect the browser - header("Location: music_on_hold.php"); - exit; - } - - if ($_GET['type'] == 'cat') { - $category_dir = $_GET['category']; - if (strlen($category_dir) > 0) { - // adjus the path for multiple domains - if (count($_SESSION['domains']) > 1) { - $path_mod = $_SESSION["domain_name"]."/"; - } - - // remove sampling rate directory (if any) - if (isset($sampling_rate_dirs)) foreach ($sampling_rate_dirs as $sampling_rate_dir) { - rmdir($music_on_hold_dir."/".$path_mod.(base64_decode($category_dir))."/".$sampling_rate_dir); - } - - // remove category directory - if (rmdir($music_on_hold_dir."/".$path_mod.(base64_decode($category_dir)))) { - sleep(5); // allow time for the OS to catch up (at least Windows, anyway) - } - } - - //build and save the XML - require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; - $moh = new switch_music_on_hold; - $moh->xml(); - $moh->save(); - - //redirect the browser - header("Location: music_on_hold.php"); - exit; - } - } //include the header require_once "resources/header.php"; $document['title'] = $text['title-moh']; echo "\n"; echo "\n"; @@ -306,70 +354,104 @@ else { echo "\n"; //show the upload form - if (permission_exists('music_on_hold_add')) { + if (permission_exists('music_on_hold_add') || permission_exists('music_on_hold_global_add')) { echo "".$text['label-upload-moh']."\n"; echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " ".$text['label-file-path']; - echo " "; - echo "\n"; - echo " \n"; - echo " "; - echo " ".$text['label-sampling']; - echo " \n"; - echo " 8 kHz\n"; - echo " 16 kHz\n"; - echo " 32 kHz\n"; - echo " 48 kHz\n"; - echo " \n"; - echo " \n"; - echo " ".$text['label-category'].""; - echo " \n"; - if (permission_exists('music_on_hold_default_add')) { - echo " ".$text['opt-default']."\n"; - } - if (count($_SESSION['domains']) > 1) { - $music_on_hold_category_parent_dir = $music_on_hold_dir."/".$_SESSION['domain_name']; - } - else { - $music_on_hold_category_parent_dir = $music_on_hold_dir; - } + echo "\n"; + echo "\n"; - if ($handle = opendir($music_on_hold_category_parent_dir)) { - while (false !== ($directory = readdir($handle))) { - if ( - $directory != "." && - $directory != ".." && - $directory != "8000" && - $directory != "16000" && - $directory != "32000" && - $directory != "48000" && - is_dir($music_on_hold_category_parent_dir."/".$directory) - ) { - echo "".(str_replace('_', ' ', $directory))."\n"; - $category_dirs[] = $directory; // array used to output category directory contents below - } + echo "\n"; + echo "\n"; + + echo "\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " ".$text['label-category']."\n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (is_array($moh_names['local']) && sizeof($moh_names['local']) > 0) { + if (permission_exists('music_on_hold_global_view') && permission_exists('music_on_hold_global_add')) { + echo " \n"; + } + foreach ($moh_names['local'] as $local_moh_name) { + echo " ".str_replace('_',' ',$local_moh_name)."\n"; + } + if (permission_exists('music_on_hold_global_view') && permission_exists('music_on_hold_global_add')) { + echo " \n"; } - closedir($handle); } + if (permission_exists('music_on_hold_global_add') && is_array($moh_names['global']) && sizeof($moh_names['global']) > 0) { + echo " \n"; + foreach ($moh_names['global'] as $global_moh_name) { + echo " ".str_replace('_',' ',$global_moh_name)."\n"; + } + echo " \n"; + } + echo " "; + echo " "; + if (permission_exists('music_on_hold_global_view') && permission_exists('music_on_hold_global_add')) { + echo " \n"; + echo " ".$text['option-local']."\n"; + echo " ".$text['option-global']."\n"; + echo " \n"; + } + echo " "; + echo " "; + echo " \n"; + echo " \n"; + echo " \n"; - echo " ".$text['opt-new']."\n"; - echo " \n"; - echo " "; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " ".$text['label-sampling']."\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " 8 kHz\n"; + echo " 16 kHz\n"; + echo " 32 kHz\n"; + echo " 48 kHz / ".$text['option-default']."\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " ".$text['label-file-path']; + echo " \n"; + echo " \n"; + echo " "; + echo " ".$text['label-select_a_file']."\n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo "\n"; + + echo "\n"; echo "\n"; + + echo ""; + echo " \n"; + echo " \n"; + echo "\n"; + echo "\n"; - echo "\n"; + + echo "\n"; } //set the row styles @@ -377,167 +459,124 @@ else { $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; -//show the default category - if (permission_exists('music_on_hold_default_view')) { - echo "".$text['label-default']."\n"; - if (count($_SESSION['domains']) > 1) { - echo " - ".$text['message-available-to-all']."\n"; - } +//output moh list + foreach ($mohs as $domain_uuid => &$moh) { - echo "\n"; - echo "\n"; - echo " \n"; - echo " ".$text['label-file_name']."\n"; - echo " ".$text['label-tools']."\n"; - echo " ".$text['label-uploaded']."\n"; - echo " ".$text['label-file-size']."\n"; - echo " ".$text['label-sampling']."\n"; - echo " \n"; - echo " "; + foreach ($moh as $moh_name => &$moh_rates) { - if (isset($sampling_rate_dirs)) foreach ($sampling_rate_dirs as $sampling_rate_dir) { - $directory = $music_on_hold_dir."/".$sampling_rate_dir; - if (file_exists($directory) && $handle = opendir($directory)) { - while (false !== ($file = readdir($handle))) { - if ($file != "." && $file != ".." && is_file($music_on_hold_dir."/".$sampling_rate_dir."/".$file)) { - $row_uuid = uuid(); - - $file_size = filesize($music_on_hold_dir."/".$sampling_rate_dir."/".$file); - $file_size = byte_convert($file_size); - - //playback progress bar - echo "\n"; - - echo "\n"; - echo " ".$file."\n"; - if (strlen($file) > 0) { - echo " "; - $recording_file_path = $file; - $recording_file_name = strtolower(pathinfo($recording_file_path, PATHINFO_BASENAME)); - $recording_file_ext = pathinfo($recording_file_name, PATHINFO_EXTENSION); - switch ($recording_file_ext) { - case "wav" : $recording_type = "audio/wav"; break; - case "mp3" : $recording_type = "audio/mpeg"; break; - case "ogg" : $recording_type = "audio/ogg"; break; - } - echo ""; - echo "".$v_link_label_play.""; - echo "".$v_link_label_download.""; - } - else { - echo " "; - echo " "; - } - echo " \n"; - echo " ".date ("F d Y H:i:s", filemtime($music_on_hold_dir."/".$sampling_rate_dir."/".$file))."\n"; - echo " ".$file_size."\n"; - echo " ".($sampling_rate_dir / 1000)." kHz\n"; - echo " \n"; - if (permission_exists('music_on_hold_default_delete')) { - echo "$v_link_label_delete"; - } - echo " \n"; - echo "\n"; - $c = ($c==0) ? 1 : 0; - } - } - closedir($handle); + $moh_name = str_replace('_', ' ', $moh_name); + if ($domain_uuid == '_global_') { + echo "".$moh_name." - ".$text['label-global']."\n"; } - } - echo "\n"; - } + else { + echo "".$moh_name."\n"; + } + echo "\n"; + + echo "\n"; + + foreach ($moh_rates as $moh_rate => $moh_settings) { + $c = 0; + + //determine if rate was set to auto or not + $auto_rate = (substr_count($moh_settings['name'], '/') == 0) ? true : false; + + //determine icons to show + $moh_icons = array(); + $i = 0; + if (permission_exists('music_on_hold_path')) { + $moh_icons[$i]['glyphicon'] = 'glyphicon-folder-open'; + $moh_icons[$i]['title'] = $moh_paths[$moh_settings['uuid']]; + $i++; + } + if ($moh_settings['shuffle'] == 'true') { + $moh_icons[$i]['glyphicon'] = 'glyphicon-random'; + $moh_icons[$i]['title'] = $text['label-shuffle']; + $i++; + } + if ($moh_settings['chime_list'] != '') { + $moh_icons[$i]['glyphicon'] = 'glyphicon-bell'; + $moh_icons[$i]['title'] = $text['label-chime_list'].': '.$moh_settings['chime_list']; + $i++; + } + if ($moh_settings['channels'] == '2') { + $moh_icons[$i]['glyphicon'] = 'glyphicon-headphones'; + $moh_icons[$i]['title'] = $text['label-stereo']; + $moh_icons[$i]['margin'] = 6; + $i++; + } + if (is_array($moh_icons) && sizeof($moh_icons) > 0) { + foreach ($moh_icons as $moh_icon) { + $icons .= ""; + } + } + echo " \n"; + echo " ".(($auto_rate) ? ($moh_rate/1000).' kHz / '.$text['option-default'] : ($moh_rate/1000)." kHz").$icons."\n"; + echo " \n"; + echo " ".$text['label-file-size']."\n"; + echo " ".$text['label-uploaded']."\n"; + echo " "; + if ( ($domain_uuid == '_global_' && permission_exists('music_on_hold_global_edit')) || ($domain_uuid != '_global_' && permission_exists('music_on_hold_edit')) ) { + echo "".$v_link_label_edit.""; + } + if ( ($domain_uuid == '_global_' && permission_exists('music_on_hold_global_delete')) || ($domain_uuid != '_global_' && permission_exists('music_on_hold_delete')) ) { + echo "".$v_link_label_delete.""; + } + echo "\n"; + echo " "; + unset($moh_icons, $icons); + + //show moh files + if (isset($moh_settings['path'])) { + $moh_path = $moh_settings['path']; + if (file_exists($moh_path)) { + $moh_files = array_merge(glob($moh_path.'/*.wav'), glob($moh_path.'/*.mp3'), glob($moh_path.'/*.ogg')); + foreach ($moh_files as $moh_file_path) { + $moh_file = strtolower(pathinfo($moh_file_path, PATHINFO_BASENAME)); + $moh_file_size = byte_convert(filesize($moh_file_path)); + $moh_file_date = date("M d, Y H:i:s", filemtime($moh_file_path)); + $moh_file_ext = pathinfo($moh_file, PATHINFO_EXTENSION); + switch ($moh_file_ext) { + case "wav" : $moh_file_type = "audio/wav"; break; + case "mp3" : $moh_file_type = "audio/mpeg"; break; + case "ogg" : $moh_file_type = "audio/ogg"; break; + } + $row_uuid = uuid(); + echo "\n"; + $tr_link = "href=\"javascript:recording_play('".$row_uuid."');\""; + echo "\n"; + echo " ".$moh_file."\n"; + echo " "; + echo ""; + echo "".$v_link_label_play.""; + echo "".$v_link_label_stop.""; + echo " \n"; + echo " ".$moh_file_size."\n"; + echo " ".$moh_file_date."\n"; + echo " \n"; + echo "".$v_link_label_download.""; + if ( ($domain_uuid == '_global_' && permission_exists('music_on_hold_global_delete')) || ($domain_uuid != '_global_' && permission_exists('music_on_hold_delete')) ) { + echo "".$v_link_label_delete.""; + } + echo " \n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + } + } + + echo "\n"; + + } + + echo "\n"; + echo "\n"; + + } - if ($v_path_show) { - echo "".$text['label-location'].": ".$music_on_hold_dir."\n"; } echo "\n"; -//show additional categories - if (isset($category_dirs)) foreach ($category_dirs as $category_number => $category_dir) { - $c = 0; - - echo "".(str_replace('_', ' ', $category_dir))."\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " ".$text['label-file_name']."\n"; - echo " ".$text['label-tools']."\n"; - echo " ".$text['label-uploaded']."\n"; - echo " ".$text['label-file-size']."\n"; - echo " ".$text['label-sampling']."\n"; - echo " \n"; - echo " "; - - $moh_found = false; - - if (isset($sampling_rate_dirs)) foreach ($sampling_rate_dirs as $sampling_rate_dir) { - $directory = $music_on_hold_category_parent_dir."/".$category_dir."/".$sampling_rate_dir; - if (file_exists($directory) && $handle = opendir($directory)) { - while (false !== ($file = readdir($handle))) { - if ($file != "." && $file != ".." && is_file($directory."/".$file)) { - $row_uuid = uuid(); - - $file_size = filesize($directory."/".$file); - $file_size = byte_convert($file_size); - - //playback progress bar - echo "\n"; - - echo "\n"; - echo " ".$file."\n"; - if (strlen($file) > 0) { - echo " "; - $recording_file_path = $file; - $recording_file_name = strtolower(pathinfo($row['recording_filename'], PATHINFO_BASENAME)); - $recording_file_ext = pathinfo($recording_file_name, PATHINFO_EXTENSION); - switch ($recording_file_ext) { - case "wav" : $recording_type = "audio/wav"; break; - case "mp3" : $recording_type = "audio/mpeg"; break; - case "ogg" : $recording_type = "audio/ogg"; break; - } - echo ""; - echo "".$v_link_label_play.""; - echo "".$v_link_label_download.""; - } - else { - echo " "; - echo " "; - } - echo " \n"; - echo " ".date ("F d Y H:i:s", filemtime($music_on_hold_category_parent_dir."/".$category_dir."/".$sampling_rate_dir."/".$file))."\n"; - echo " ".$file_size."\n"; - echo " ".($sampling_rate_dir / 1000)." kHz\n"; - echo " "; - if (permission_exists('music_on_hold_delete')) { - echo "$v_link_label_delete"; - } - echo " \n"; - echo "\n"; - $c = ($c==0) ? 1 : 0; - - $moh_found = true; - } - } - closedir($handle); - } - } - - if (!$moh_found) { - echo "\n"; - echo " \n"; - echo " ".$text['message-nofiles'].""; - echo " \n"; - echo " \n"; - echo "\n"; - } - - echo "\n"; - if ($v_path_show) { - echo "".$text['label-location'].": ".$music_on_hold_category_parent_dir."/".$category_dir."\n"; - } - echo "\n"; - } - //include the footer require_once "resources/footer.php"; diff --git a/app/music_on_hold/music_on_hold_edit.php b/app/music_on_hold/music_on_hold_edit.php new file mode 100644 index 0000000000..d9d08570e8 --- /dev/null +++ b/app/music_on_hold/music_on_hold_edit.php @@ -0,0 +1,341 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('music_on_hold_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get current moh record, build array + $sql = "select * from v_music_on_hold "; + $sql .= "where music_on_hold_uuid = '".$_GET['id']."' "; + if (!permission_exists('music_on_hold_global_edit')) { + $sql .= "and domain_uuid = '".$domain_uuid."' "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_NAMED); + foreach ($row as $index => $value) { + $moh[str_replace('music_on_hold_','',$index)] = $value; + $moh['name_only'] = (substr_count($moh['name'], '/') > 0) ? substr($moh['name'], 0, strpos($moh['name'],'/')) : $moh['name']; + } + unset($sql, $prep_statement, $row); + //echo "".print_r($moh, true).""; exit; + +if (is_array($_POST) && sizeof($_POST) > 0) { + //retrieve posted values + $moh_uuid = check_str($_POST['uuid']); + $moh_shuffle = check_str($_POST['shuffle']); + $moh_channels = check_str($_POST['channels']); + $moh_interval = check_str($_POST['interval']); + $moh_chime_list = check_str($_POST['chime_list']); + $moh_chime_freq = check_str($_POST['chime_freq']); + $moh_chime_max = check_str($_POST['chime_max']); + $moh_domain_uuid = check_str($_POST['domain_uuid']); + $moh_path = check_str($_POST['path']); + + //update the moh record + $sql = "update v_music_on_hold set "; + if (permission_exists('music_on_hold_domain')) { + $sql .= "domain_uuid = ".(($moh_domain_uuid != '') ? "'".$moh_domain_uuid."'" : 'null').", "; + } + if (permission_exists('music_on_hold_path')) { + $sql .= "music_on_hold_path = ".(($moh_path != '') ? "'".$moh_path."'" : '$${sounds_dir}/music').", "; + } + $sql .= "music_on_hold_shuffle = '".$moh_shuffle."', "; + $sql .= "music_on_hold_channels = ".$moh_channels.", "; + $sql .= "music_on_hold_interval = ".(($moh_interval != '') ? $moh_interval : '20').", "; + $sql .= "music_on_hold_timer_name = 'soft', "; + $sql .= "music_on_hold_chime_list = '".$moh_chime_list."', "; + $sql .= "music_on_hold_chime_freq = ".(($moh_chime_freq != '') ? $moh_chime_freq : 'null').", "; + $sql .= "music_on_hold_chime_max = ".(($moh_chime_max != '') ? $moh_chime_max : 'null')." "; + $sql .= "where music_on_hold_uuid = '".$moh_uuid."' "; + if (!permission_exists('music_on_hold_domain')) { + $sql .= "and domain_uuid = '".$domain_uuid."' "; + } + //echo $sql.""; exit; + $db->exec(check_sql($sql)); + unset($sql); + + //set message + $_SESSION["message"] = $text['message-update']; + + //redirect + header("Location: music_on_hold.php"); + exit; +} + +//show the header + require_once "resources/header.php"; + $document['title'] = $text['title-moh_settings']; + +//show the content + if (if_group("superadmin")) { + echo "\n"; + echo "\n"; + } + + echo "\n"; + echo "\n"; + + echo "\n"; + echo " "; + echo " \n"; + echo "\n"; + echo "".$text['header-moh_settings'].": ".$moh['name_only']." (".($moh['rate']/1000).' kHz'.(($moh['rate'] == '48000') ? ' / '.$text['option-default'] : null).")"; + echo "\n\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo " ".$text['label-shuffle']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " ".$text['label-false']."\n"; + echo " ".$text['label-true']."\n"; + echo " \n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo " ".$text['label-channels']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " ".$text['label-mono']."\n"; + echo " ".$text['label-stereo']."\n"; + echo " \n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo " ".$text['label-interval']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo " ".$text['label-chime_list']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + //misc optgroup + /* + if (if_group("superadmin")) { + echo "\n"; + echo " phrase:\n"; + echo " say:\n"; + echo " tone_stream:\n"; + echo "\n"; + } + */ + //recordings + $tmp_selected = false; + $sql = "select * from v_recordings where domain_uuid = '".$domain_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $recordings = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (count($recordings) > 0) { + echo "\n"; + foreach ($recordings as &$row) { + $recording_name = $row["recording_name"]; + $recording_filename = $row["recording_filename"]; + if ($moh['chime_list'] == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$recording_filename && strlen($moh['chime_list']) > 0) { + $tmp_selected = true; + echo " ".$recording_name."\n"; + } + else if ($moh['chime_list'] == $recording_filename && strlen($moh['chime_list']) > 0) { + $tmp_selected = true; + echo " ".$recording_name."\n"; + } + else { + echo " ".$recording_name."\n"; + } + } + echo "\n"; + } + //phrases + $sql = "select * from v_phrases where domain_uuid = '".$domain_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (count($result) > 0) { + echo "\n"; + foreach ($result as &$row) { + if ($moh['chime_list'] == "phrase:".$row["phrase_uuid"]) { + $tmp_selected = true; + echo " ".$row["phrase_name"]."\n"; + } + else { + echo " ".$row["phrase_name"]."\n"; + } + } + unset ($prep_statement); + echo "\n"; + } + //sounds + $dir_path = $_SESSION['switch']['sounds']['dir']; + recur_sounds_dir($_SESSION['switch']['sounds']['dir']); + if (count($dir_array) > 0) { + echo "\n"; + foreach ($dir_array as $key => $value) { + if (strlen($value) > 0) { + if (substr($moh['chime_list'], 0, 71) == "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}/") { + $moh['chime_list'] = substr($moh['chime_list'], 71); + } + if ($moh['chime_list'] == $key) { + $tmp_selected = true; + echo " $key\n"; + } + else { + echo " $key\n"; + } + } + } + echo "\n"; + } + //select + if (if_group("superadmin")) { + if (!$tmp_selected && strlen($moh['chime_list']) > 0) { + echo "\n"; + if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$moh['chime_list'])) { + echo " ".$moh['chime_list']."\n"; + } + else if (substr($moh['chime_list'], -3) == "wav" || substr($moh['chime_list'], -3) == "mp3") { + echo " ".$moh['chime_list']."\n"; + } + echo "\n"; + } + unset($tmp_selected); + } + echo " \n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo " ".$text['label-chime_frequency']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo " ".$text['label-chime_maximum']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "\n"; + + if (permission_exists('music_on_hold_domain')) { + echo " \n"; + echo " \n"; + echo " ".$text['label-domain']."\n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('music_on_hold_global_view') && permission_exists('music_on_hold_global_add')) { + echo " ".$text['label-global']."\n"; + } + foreach ($_SESSION['domains'] as $row) { + echo " ".$row['domain_name']."\n"; + } + echo " \n"; + echo " \n"; + echo " \n"; + } + + if (permission_exists('music_on_hold_path')) { + echo "\n"; + echo "\n"; + echo " ".$text['label-path']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "\n"; + } + + echo ""; + echo ""; + + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + + echo ""; + +//include the footer + require_once "resources/footer.php"; +?> diff --git a/app/voicemail_greetings/voicemail_greetings.php b/app/voicemail_greetings/voicemail_greetings.php index 3f5bf828ed..9b580efeea 100644 --- a/app/voicemail_greetings/voicemail_greetings.php +++ b/app/voicemail_greetings/voicemail_greetings.php @@ -379,7 +379,7 @@ require_once "resources/check_auth.php"; foreach($result as $row) { //playback progress bar if (permission_exists('voicemail_greeting_play')) { - echo "\n"; + echo "\n"; } $tr_link = (permission_exists('voicemail_greeting_edit')) ? "href='voicemail_greeting_edit.php?id=".$row['voicemail_greeting_uuid']."&voicemail_id=".$voicemail_id."'" : null; echo "\n"; diff --git a/core/users/group_permissions.php b/core/users/group_permissions.php index d342972436..be5fc38ea2 100644 --- a/core/users/group_permissions.php +++ b/core/users/group_permissions.php @@ -336,6 +336,18 @@ require_once "resources/require.php"; echo " });\n"; echo "\n"; +//prevent enter key submit on search field + echo "\n"; + //show the content echo "\n"; echo "\n"; diff --git a/themes/default/app_defaults.php b/themes/default/app_defaults.php index 32a02328ed..8d628f0113 100644 --- a/themes/default/app_defaults.php +++ b/themes/default/app_defaults.php @@ -1379,6 +1379,21 @@ if ($domains_processed == 1) { $array[$x]['default_setting_enabled'] = 'false'; $array[$x]['default_setting_description'] = "API key that allows access to the available fonts list."; $x++; + /* icons */ + $array[$x]['default_setting_category'] = 'theme'; + $array[$x]['default_setting_subcategory'] = 'body_icon_color'; + $array[$x]['default_setting_name'] = 'text'; + $array[$x]['default_setting_value'] = 'rgba(255,255,255,0.25)'; + $array[$x]['default_setting_enabled'] = 'false'; + $array[$x]['default_setting_description'] = 'Set the color (and opacity) for the icons in the body.'; + $x++; + $array[$x]['default_setting_category'] = 'theme'; + $array[$x]['default_setting_subcategory'] = 'body_icon_color_hover'; + $array[$x]['default_setting_name'] = 'text'; + $array[$x]['default_setting_value'] = 'rgba(255,255,255,0.50)'; + $array[$x]['default_setting_enabled'] = 'false'; + $array[$x]['default_setting_description'] = 'Set the hover color (and opacity) for the icons in the body.'; + $x++; if(!$set_session_theme) { @@ -1389,7 +1404,7 @@ if ($domains_processed == 1) { $prep_statement->execute(); $default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset ($prep_statement, $sql); - + //find the missing default settings $i = 0; foreach ($array as $setting) { @@ -1398,19 +1413,19 @@ if ($domains_processed == 1) { foreach ($default_settings as $row) { if (trim($row['default_setting_subcategory']) == trim($setting['default_setting_subcategory'])) { $found = true; - + //remove items from the array that were found unset($missing[$i]); } } $i++; } - + //get the missing count $i = 0; foreach ($missing as $row) { $i++; } $missing_count = $i; - + //add the missing default settings if (count($missing) > 0) { $sql = "insert into v_default_settings ("; diff --git a/themes/default/config.php b/themes/default/config.php index e71a0851ab..ed4b513c11 100644 --- a/themes/default/config.php +++ b/themes/default/config.php @@ -7,6 +7,7 @@ $v_link_label_view = ""; $v_link_label_play = ""; $v_link_label_pause = ""; + $v_link_label_stop = ""; $v_link_label_download = ""; ?> diff --git a/themes/default/css.php b/themes/default/css.php index 1f0d0f4c8c..9063e67cf3 100644 --- a/themes/default/css.php +++ b/themes/default/css.php @@ -569,6 +569,19 @@ $default_login = ($_REQUEST['login'] == 'default') ? true : false; opacity: 1.0; } +/* ICONS *********************************************************************/ + + span.icon_glyphicon_body { + width: 16px; + height: 16px; + color: ; + border: 0; + } + + span.icon_glyphicon_body:hover { + color: ; + } + /* DOMAIN SELECTOR ***********************************************************/ #domains_container { @@ -783,11 +796,13 @@ $default_login = ($_REQUEST['login'] == 'default') ? true : false; input[type=text].txt, input[type=number].txt, input[type=password].txt, + label.txt, select.formfld, textarea.formfld, input[type=text].formfld, input[type=number].formfld, - input[type=password].formfld { + input[type=password].formfld, + label.formfld { font-family: ; font-size: ; color: ; @@ -847,10 +862,12 @@ $default_login = ($_REQUEST['login'] == 'default') ? true : false; input[type=text].txt:hover, input[type=number].txt:hover, input[type=password].txt:hover, + label.txt:hover, textarea.formfld:hover, input[type=text].formfld:hover, input[type=number].formfld:hover, - input[type=password].formfld:hover { + input[type=password].formfld:hover, + label.formfld:hover { border-color: ; } @@ -858,10 +875,12 @@ $default_login = ($_REQUEST['login'] == 'default') ? true : false; input[type=text].txt:focus, input[type=number].txt:focus, input[type=password].txt:focus, + label.txt:focus, textarea.formfld:focus, input[type=text].formfld:focus, input[type=number].formfld:focus, - input[type=password].formfld:focus { + input[type=password].formfld:focus, + label.formfld:focus { border-color: ; /* first clear */ -webkit-box-shadow: none; @@ -1030,9 +1049,30 @@ $default_login = ($_REQUEST['login'] == 'default') ? true : false; } span.playback_progress_bar { - background-color: #c43e42; - height: 1px; + background-color: #b90004; + width: 17px; + height: 4px; + margin-bottom: 3px; display: block; + -moz-border-radius: 0 0 6px 6px; + -webkit-border-radius: 0 0 6px 6px; + -khtml-border-radius: 0 0 6px 6px; + border-radius: 0 0 6px 6px; + -webkit-box-shadow: 0 0 3px 0px rgba(255,0,0,0.9); + -moz-box-shadow: 0 0 3px 0px rgba(255,0,0,0.9); + box-shadow: 0 0 3px 0px rgba(255,0,0,0.9); + } + + td.playback_progress_bar_background { + padding: 0; + border-bottom: none; + background-image: -ms-linear-gradient(top, rgba(0,0,0,0.15) 0%, transparent 100%); + background-image: -moz-linear-gradient(top, rgba(0,0,0,0.15) 0%, transparent 100%); + background-image: -o-linear-gradient(top, rgba(0,0,0,0.15) 0%, transparent 100%); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgba(0,0,0,0.15)), color-stop(1, transparent)); + background-image: -webkit-linear-gradient(top, rgba(0,0,0,0.15) 0%, transparent 100%); + background-image: linear-gradient(to bottom, rgba(0,0,0,0.15) 0%, transparent 100%); + overflow: hidden; } div.pwstrength_progress { @@ -1148,6 +1188,7 @@ $default_login = ($_REQUEST['login'] == 'default') ? true : false; color: ; font-family: ; font-size: ; + vertical-align: top; } .vncellreq { /* form_label_required */ @@ -1166,6 +1207,7 @@ $default_login = ($_REQUEST['login'] == 'default') ? true : false; font-family: ; font-size: ; font-weight: ; + vertical-align: top; } .vtable { /* form_field */ diff --git a/themes/default/template.php b/themes/default/template.php index f3dd467227..cd75ba3356 100644 --- a/themes/default/template.php +++ b/themes/default/template.php @@ -239,7 +239,7 @@ if (document.getElementById('recording_progress_bar_'+recording_id)) { document.getElementById('recording_progress_bar_'+recording_id).style.display=''; } - recording_audio = document.getElementById('recording_audio_'+recording_id) + recording_audio = document.getElementById('recording_audio_'+recording_id); if (recording_audio.paused) { recording_audio.volume = 1; @@ -252,7 +252,14 @@ } } + function recording_stop(recording_id) { + recording_reset(recording_id); + } + function recording_reset(recording_id) { + recording_audio = document.getElementById('recording_audio_'+recording_id); + recording_audio.pause(); + recording_audio.currentTime = 0; if (document.getElementById('recording_progress_bar_'+recording_id)) { document.getElementById('recording_progress_bar_'+recording_id).style.display='none'; } @@ -266,7 +273,7 @@ if (recording_audio.currentTime > 0) { value = (100 / recording_audio.duration) * recording_audio.currentTime; } - recording_progress.style.width = value + "%"; + recording_progress.style.marginLeft = value + "%"; }
".print_r($mohs, true)."
".print_r($moh, true)."