diff --git a/app/ivr_menus/ivr_menu_edit.php b/app/ivr_menus/ivr_menu_edit.php index 2b0eceddc0..64c5be8bca 100644 --- a/app/ivr_menus/ivr_menu_edit.php +++ b/app/ivr_menus/ivr_menu_edit.php @@ -28,6 +28,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; require_once "resources/classes/logging.php"; +require_once "resources/classes/ringbacks.php"; if (permission_exists('ivr_menu_add') || permission_exists('ivr_menu_edit')) { //access granted } @@ -305,6 +306,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } } unset ($prep_statement); + }else{ + $ivr_menu_ringback = 'default_ringback'; } //set defaults @@ -789,57 +792,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; - $select_options = ""; - if ($ivr_menu_ringback == "\${us-ring}" || $ivr_menu_ringback == "us-ring") { - $select_options .= " \n"; - } - else { - $select_options .= " \n"; - } - if ($ivr_menu_ringback == "\${pt-ring}" || $ivr_menu_ringback == "pt-ring") { - $select_options .= " \n"; - } - else { - $select_options .= " \n"; - } - if ($ivr_menu_ringback == "\${fr-ring}" || $ivr_menu_ringback == "fr-ring") { - $select_options .= " \n"; - } - else { - $select_options .= " \n"; - } - if ($ivr_menu_ringback == "\${uk-ring}" || $ivr_menu_ringback == "uk-ring") { - $select_options .= " \n"; - } - else { - $select_options .= " \n"; - } - if ($ivr_menu_ringback == "\${rs-ring}" || $ivr_menu_ringback == "rs-ring") { - $select_options .= " \n"; - } - else { - $select_options .= " \n"; - } - if ($ivr_menu_ringback == "\${it-ring}" || $ivr_menu_ringback == "it-ring") { - $select_options .= " \n"; - } - else { - $select_options .= " \n"; - } - if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/music_on_hold')) { - require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; - $moh = new switch_music_on_hold; - $moh->select_name = "ivr_menu_ringback"; - $moh->select_value = $ivr_menu_ringback; - $moh->select_options = $select_options; - echo $moh->select(); - } - else { - echo " \n"; - } + $ringbacks = new ringbacks; + echo $ringbacks->select('ivr_menu_ringback', $ivr_menu_ringback); echo "
\n"; echo $text['description-ring_back']."\n"; diff --git a/app/music_on_hold/app_languages.php b/app/music_on_hold/app_languages.php index c6d8f32a8a..404bb105ec 100644 --- a/app/music_on_hold/app_languages.php +++ b/app/music_on_hold/app_languages.php @@ -11,6 +11,19 @@ $text['title-moh']['uk'] = "Музика на утриманні"; $text['title-moh']['de-at'] = "Haltemusik"; $text['title-moh']['he'] = "מוסיקה בהמתנה"; +$text['label-others']['en-us'] = "Others"; +$text['label-others']['pt-pt'] = "Outras"; +$text['label-others']['pt-br'] = "Outras"; +$text['label-others']['fr-fr'] = "Autres"; +$text['label-others']['nl-nl'] = "oaren"; +$text['label-others']['pl'] = "Pozostałe"; +$text['label-others']['sv-se'] = "Andra"; +$text['label-others']['uk'] = "інші"; +$text['label-others']['de-at'] = "Andere"; +$text['label-others']['he'] = "אחרים"; +$text['label-others']['ar-eg'] = "آخرون"; +$text['label-others']['ru-ru'] = "другие"; + $text['opt-new']['en-us'] = "New..."; $text['opt-new']['es-cl'] = "Nuevo..."; $text['opt-new']['pt-pt'] = "Novo..."; diff --git a/app/music_on_hold/resources/classes/switch_music_on_hold.php b/app/music_on_hold/resources/classes/switch_music_on_hold.php index a83296d6fd..d49ad0414b 100644 --- a/app/music_on_hold/resources/classes/switch_music_on_hold.php +++ b/app/music_on_hold/resources/classes/switch_music_on_hold.php @@ -17,20 +17,20 @@ The Initial Developer of the Original Code is Mark J Crane - Copyright (C) 2010 + Portions created by the Initial Developer are Copyright (C) 2010-2016 All Rights Reserved. Contributor(s): Mark J Crane James Rose + Matthew Vale */ include "root.php"; -//define the directory class +//define the switch_music_on_hold class class switch_music_on_hold { public $domain_uuid; - public $domain_name; public $select_name; public $select_value; public $select_options; @@ -38,7 +38,7 @@ include "root.php"; public function __construct() { require_once "resources/classes/database.php"; - $this->app_uuid = ''; + $this->domain_uuid = $_SESSION['domain_uuid']; } public function __destruct() { @@ -47,80 +47,89 @@ include "root.php"; } } + //it is NOT recommended to use this function anymore you should be using the ringback class + //see app/ring_groups/ring_group_edit.php for example public function select() { - //build the list of categories - $music_on_hold_dir = $_SESSION["switch"]["sounds"]["dir"]."/music"; - if (count($_SESSION['domains']) > 1) { - $music_on_hold_dir = $music_on_hold_dir."/".$_SESSION['domain_name']; - } - + $trace = debug_backtrace(); + $caller = $trace[1]; + $what = $caller['function']; + if (isset($caller['class'])) { + $what .= " in {$caller['class']}"; + } + trigger_error("Legacy call to select in switch_music_on_hold class by $what", E_USER_WARNING); //add multi-lingual support $language = new text; - $text = $language->get($_SESSION['domain']['language']['code'], 'app/music_on_hold'); + $text = $language->get(); //start the select $select = " \n"; return $select; } + public function list_moh() { + //add multi-lingual support + $language = new text; + $text = $language->get(null, 'app/music_on_hold'); + + $moh_list[''] = $text['opt-default']; + $music_on_hold_dir = $_SESSION["switch"]["sounds"]["dir"]."/music"; + $array = array_merge(glob($music_on_hold_dir."/*/*", GLOB_ONLYDIR), glob($music_on_hold_dir."/".$_SESSION['domain_name']."/*/*", GLOB_ONLYDIR)); + foreach($array as $moh_dir) { + //set the directory + $moh_dir = substr($moh_dir, strlen($music_on_hold_dir."/")); + if (stristr($moh_dir, $_SESSION['domain_name'])) { + $domain_moh = 1; + $moh_dir = substr($moh_dir, strlen($_SESSION['domain_name']."/")); + } + //get and set the rate + $sub_array = explode("/", $moh_dir); + $moh_rate = end($sub_array); + //set the name + $moh_name = $moh_dir; + $moh_name = substr($moh_dir, 0, strlen($moh_name)-(strlen($moh_rate))); + $moh_name = rtrim($moh_name, "/"); + if ($domain_moh) { + $moh_value = "local_stream://".$_SESSION['domain_name']."/".$moh_name; + } + else { + $moh_value = "local_stream://".$moh_name; + } + $moh_list[$moh_value] = str_replace('_', ' ', $moh_name); + } + return $moh_list; + } + public function reload() { //if the handle does not exist create it $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); diff --git a/app/recordings/resources/classes/switch_recordings.php b/app/recordings/resources/classes/switch_recordings.php new file mode 100644 index 0000000000..bde392616c --- /dev/null +++ b/app/recordings/resources/classes/switch_recordings.php @@ -0,0 +1,60 @@ + + Portions created by the Initial Developer are Copyright (C) 2016 + All Rights Reserved. + + Contributor(s): + Mark J Crane + Matthew Vale +*/ +include "root.php"; + +//define the switch_recordings class + class switch_recordings { + + public $domain_uuid; + + public function __construct() { + require_once "resources/classes/database.php"; + $this->domain_uuid = $_SESSION['domain_uuid']; + } + + public function __destruct() { + foreach ($this as $key => $value) { + unset($this->$key); + } + } + + public function list_recordings() { + $sql = "select recording_uuid, recording_filename, recording_base64 from v_recordings "; + $sql .= "where domain_uuid = '".$this->domain_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $recordings[$_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name']."/".$row['recording_filename']] = $row['recording_filename']; + } + unset ($prep_statement); + return $recordings; + } + + } + +?> \ No newline at end of file diff --git a/app/ring_groups/app_languages.php b/app/ring_groups/app_languages.php index 450eb5c3dc..147237a6b7 100644 --- a/app/ring_groups/app_languages.php +++ b/app/ring_groups/app_languages.php @@ -11,28 +11,6 @@ $text['title-ring_groups']['uk'] = "Групи"; $text['title-ring_groups']['de-at'] = "Rufgruppen"; $text['title-ring_groups']['he'] = "קבוצות חיוג"; -$text['option-usring']['en-us'] = "us-ring"; -$text['option-usring']['es-cl'] = "us-ring"; -$text['option-usring']['fr-fr'] = "États-Unis"; -$text['option-usring']['pt-pt'] = "us-ring"; -$text['option-usring']['pt-br'] = "USRing"; -$text['option-usring']['pl'] = "us-ring"; -$text['option-usring']['sv-se'] = "us-ring"; -$text['option-usring']['uk'] = "us-ring"; -$text['option-usring']['de-at'] = "us-ring"; -$text['option-usring']['he'] = "צלצול אמריקאי"; - -$text['option-ukring']['en-us'] = "uk-ring"; -$text['option-ukring']['es-cl'] = "uk-ring"; -$text['option-ukring']['fr-fr'] = "Grande Bretagne"; -$text['option-ukring']['pt-pt'] = "uk-ring"; -$text['option-ukring']['pt-br'] = "UKRing"; -$text['option-ukring']['pl'] = "uk-ring "; -$text['option-ukring']['sv-se'] = "uk-ring"; -$text['option-ukring']['uk'] = "uk-ring"; -$text['option-ukring']['de-at'] = "uk-ring"; -$text['option-ukring']['he'] = "צלצול אנגלי"; - $text['option-simultaneous']['en-us'] = "Simultaneous"; $text['option-simultaneous']['es-cl'] = "Simultaneos"; $text['option-simultaneous']['fr-fr'] = "Simultané"; @@ -55,17 +33,6 @@ $text['option-sequence']['uk'] = ""; $text['option-sequence']['de-at'] = "sequenziell"; $text['option-sequence']['he'] = "אחד אחרי השני"; -$text['option-rsring']['en-us'] = "rs-ring"; -$text['option-rsring']['es-cl'] = "rs-ring"; -$text['option-rsring']['fr-fr'] = "Serbie"; -$text['option-rsring']['pt-pt'] = "rs-ring"; -$text['option-rsring']['pt-br'] = "RSRing"; -$text['option-rsring']['pl'] = "rs-ring"; -$text['option-rsring']['sv-se'] = "rs-ring"; -$text['option-rsring']['uk'] = "rs-ring"; -$text['option-rsring']['de-at'] = "rs-ring"; -$text['option-rsring']['he'] = "צלצול רוסי"; - $text['option-rollover']['en-us'] = "Rollover"; $text['option-rollover']['es-cl'] = "Rollover"; $text['option-rollover']['pt-pt'] = "Rollover"; diff --git a/app/ring_groups/ring_group_edit.php b/app/ring_groups/ring_group_edit.php index 05e1c58cd6..72e493de39 100644 --- a/app/ring_groups/ring_group_edit.php +++ b/app/ring_groups/ring_group_edit.php @@ -28,6 +28,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; +require_once "resources/classes/ringbacks.php"; if (permission_exists('ring_group_add') || permission_exists('ring_group_edit')) { //access granted } @@ -404,6 +405,8 @@ else { if (strlen($ring_group_timeout_app) > 0) { $ring_group_timeout_action = $ring_group_timeout_app.":".$ring_group_timeout_data; } + }else{ + $ring_group_ringback = 'default_ringback'; } //get the ring group destination array @@ -642,57 +645,8 @@ else { echo "\n"; echo "\n"; - $select_options = ""; - if ($ring_group_ringback == "\${us-ring}" || $ring_group_ringback == "us-ring") { - $select_options .= " \n"; - } - else { - $select_options .= " \n"; - } - if ($ring_group_ringback == "\${pt-ring}" || $ring_group_ringback == "pt-ring") { - $select_options .= " \n"; - } - else { - $select_options .= " \n"; - } - if ($ring_group_ringback == "\${fr-ring}" || $ring_group_ringback == "fr-ring") { - $select_options .= " \n"; - } - else { - $select_options .= " \n"; - } - if ($ring_group_ringback == "\${uk-ring}" || $ring_group_ringback == "uk-ring") { - $select_options .= " \n"; - } - else { - $select_options .= " \n"; - } - if ($ring_group_ringback == "\${rs-ring}" || $ring_group_ringback == "rs-ring") { - $select_options .= " \n"; - } - else { - $select_options .= " \n"; - } - if ($ring_group_ringback == "\${it-ring}" || $ring_group_ringback == "it-ring") { - $select_options .= " \n"; - } - else { - $select_options .= " \n"; - } - if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/music_on_hold')) { - require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; - $moh = new switch_music_on_hold; - $moh->select_name = "ring_group_ringback"; - $moh->select_value = $ring_group_ringback; - $moh->select_options = $select_options; - echo $moh->select(); - } - else { - echo " \n"; - } + $ringbacks = new ringbacks; + echo $ringbacks->select('ring_group_ringback', $ring_group_ringback); echo "
\n"; echo $text['description-ringback']."\n"; diff --git a/resources/app_languages.php b/resources/app_languages.php index 9874bb920a..14773aa6c0 100644 --- a/resources/app_languages.php +++ b/resources/app_languages.php @@ -665,6 +665,115 @@ $text['label-delete']['sv-se'] = "Ta Bort"; $text['label-delete']['uk'] = "Видалити"; $text['label-delete']['de-at'] = "Löschen"; +$text['label-ringback']['en-us'] = "Ringback"; +$text['label-ringback']['es-cl'] = "Volver a llamar"; +$text['label-ringback']['pt-pt'] = "Ringback"; +$text['label-ringback']['pt-br'] = "Ringback"; +$text['label-ringback']['pl'] = "Oddzwonienie"; +$text['label-ringback']['fr-fr'] = "Rappeler"; +$text['label-ringback']['nl-nl'] = "Werombelje"; +$text['label-ringback']['sv-se'] = "Ring tillbaka"; +$text['label-ringback']['uk'] = "відповідний"; +$text['label-ringback']['de-at'] = "Zurückrufen"; +$text['label-ringback']['he'] = "לצלצל בחזרה"; +$text['label-ringback']['ru-ru'] = "Перезвонить"; + +$text['label-music_on_hold']['en-us'] = "Music on Hold"; +$text['label-music_on_hold']['es-cl'] = "Musica en Espera"; +$text['label-music_on_hold']['pt-pt'] = "Música em Espera"; +$text['label-music_on_hold']['pt-br'] = "Música de espera "; +$text['label-music_on_hold']['fr-fr'] = "Musique d'attente"; +$text['label-music_on_hold']['nl-nl'] = "Music op Hold"; +$text['label-music_on_hold']['pl'] = "Muzyka na czekanie"; +$text['label-music_on_hold']['sv-se'] = "Väntmusik"; +$text['label-music_on_hold']['uk'] = "Музика на утриманні"; +$text['label-music_on_hold']['de-at'] = "Haltemusik"; +$text['label-music_on_hold']['he'] = "מוסיקה בהמתנה"; +$text['label-music_on_hold']['ar-eg'] = "موسيقى المؤجلة"; +$text['label-music_on_hold']['ru-ru'] = "Музыка на удержании"; + +$text['label-recordings']['en-us'] = "Recordings"; +$text['label-recordings']['es-cl'] = "Grabaciones"; +$text['label-recordings']['pt-pt'] = "Gravações"; +$text['label-recordings']['pt-br'] = "Gravações"; +$text['label-recordings']['fr-fr'] = "Recordings"; +$text['label-recordings']['nl-nl'] = "Recordings"; +$text['label-recordings']['pl'] = "Nagrania"; +$text['label-recordings']['sv-se'] = "Inspelningar"; +$text['label-recordings']['uk'] = "записи"; +$text['label-recordings']['de-at'] = "Aufzeichnung"; +$text['label-recordings']['he'] = "הקלטות"; +$text['label-recordings']['ar-eg'] = "التسجيلات"; +$text['label-recordings']['ru-ru'] = "Записи"; + +$text['label-default']['en-us'] = "Default"; +$text['label-default']['es-cl'] = "Defecto"; +$text['label-default']['pt-pt'] = "Padrão"; +$text['label-default']['pt-br'] = "Padrão"; +$text['label-default']['pl'] = "Domyślne"; +$text['label-default']['fr-fr'] = "Défaut"; +$text['label-default']['nl-nl'] = " ôfwêzichheid"; +$text['label-default']['sv-se'] = "uteblivande"; +$text['label-default']['uk'] = "дефолт"; +$text['label-default']['de-at'] = "Default"; +$text['label-default']['he'] = "Default"; +$text['label-default']['ar-eg'] = "בְּרִירַת מֶחדָל"; +$text['label-default']['ru-ru'] = "По умолчанию"; + +$text['label-us-ring']['en-us'] = "us-ring"; +$text['label-us-ring']['es-cl'] = "us-ring"; +$text['label-us-ring']['fr-fr'] = "États-Unis-ring"; +$text['label-us-ring']['pt-pt'] = "us-ring"; +$text['label-us-ring']['pt-br'] = "us-ring"; +$text['label-us-ring']['pl'] = "us-ring"; +$text['label-us-ring']['sv-se'] = "us-ring"; +$text['label-us-ring']['uk'] = "us-ring"; +$text['label-us-ring']['de-at'] = "us-ring"; +$text['label-us-ring']['he'] = "צלצול אמריקאי"; + +$text['label-uk-ring']['en-us'] = "uk-ring"; +$text['label-uk-ring']['es-cl'] = "uk-ring"; +$text['label-uk-ring']['fr-fr'] = "Grande Bretagne-ring"; +$text['label-uk-ring']['pt-pt'] = "uk-ring"; +$text['label-uk-ring']['pt-br'] = "uk-ring"; +$text['label-uk-ring']['pl'] = "uk-ring "; +$text['label-uk-ring']['sv-se'] = "uk-ring"; +$text['label-uk-ring']['uk'] = "uk-ring"; +$text['label-uk-ring']['de-at'] = "uk-ring"; +$text['label-uk-ring']['he'] = "צלצול אנגלי"; + +$text['label-pt-ring']['en-us'] = "pt-ring"; +$text['label-pt-ring']['es-cl'] = "pt-ring"; +$text['label-pt-ring']['fr-fr'] = "Portugal-ring"; +$text['label-pt-ring']['pt-pt'] = "pt-ring"; +$text['label-pt-ring']['pt-br'] = "pt-ring"; +$text['label-pt-ring']['pl'] = "pt-ring "; +$text['label-pt-ring']['sv-se'] = "pt-ring"; +$text['label-pt-ring']['uk'] = "pt-ring"; +$text['label-pt-ring']['de-at'] = "pt-ring"; +$text['label-pt-ring']['he'] = "צלצול פולני"; + +$text['label-it-ring']['en-us'] = "it-ring"; +$text['label-it-ring']['es-cl'] = "it-ring"; +$text['label-it-ring']['fr-fr'] = "Italie-ring"; +$text['label-it-ring']['pt-pt'] = "it-ring"; +$text['label-it-ring']['pt-br'] = "it-ring"; +$text['label-it-ring']['pl'] = "it-ring "; +$text['label-it-ring']['sv-se'] = "it-ring"; +$text['label-it-ring']['uk'] = "it-ring"; +$text['label-it-ring']['de-at'] = "it-ring"; +$text['label-it-ring']['he'] = "צלצול איטלקי"; + +$text['label-fr-ring']['en-us'] = "fr-ring"; +$text['label-fr-ring']['es-cl'] = "fr-ring"; +$text['label-fr-ring']['fr-fr'] = "France-ring"; +$text['label-fr-ring']['pt-pt'] = "fr-ring"; +$text['label-fr-ring']['pt-br'] = "fr-ring"; +$text['label-fr-ring']['pl'] = "fr-ring "; +$text['label-fr-ring']['sv-se'] = "fr-ring"; +$text['label-fr-ring']['uk'] = "fr-ring"; +$text['label-fr-ring']['de-at'] = "fr-ring"; +$text['label-fr-ring']['he'] = "צלצול צרפתי"; //option (present for compatibility, should use label-true/false instead) diff --git a/resources/classes/ringbacks.php b/resources/classes/ringbacks.php new file mode 100644 index 0000000000..4395e7ed24 --- /dev/null +++ b/resources/classes/ringbacks.php @@ -0,0 +1,148 @@ + + Portions created by the Initial Developer are Copyright (C) 2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane + Matthew Vale +*/ + +if (!class_exists('ringbacks')) { + class ringbacks { + + //define variables + public $db; + private $ringbacks; + private $moh_list; + private $recordings_list; + private $default_ringback_label; + + //class constructor + public function __construct() { + //connect to the database if not connected + if (!$this->db) { + require_once "resources/classes/database.php"; + $database = new database; + $database->connect(); + $this->db = $database->db; + } + + //add multi-lingual support + $language = new text; + $text = $language->get(); + + //get the ringback types + $sql = "select * from v_vars "; + $sql .= "where var_cat = 'Defaults' "; + $sql .= "and var_name LIKE '%-ring' "; + $sql .= "order by var_name asc "; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $ringbacks = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + foreach($ringbacks as $ringback) { + $ringback = $ringback['var_name']; + $label = $text['label-'.$ringback]; + if ($label == "") { + $label = $ringback; + } + $ringback_list[$ringback] = $label; + } + $this->ringbacks = $ringback_list; + unset($ringback_list); + + //get the default_ringback label + $sql = "select * from v_vars where var_name = 'ringback' "; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetch(); + unset ($prep_statement, $sql); + $default_ringback = (string) $result['var_value']; + $default_ringback = preg_replace('/\A\$\${/',"",$default_ringback); + $default_ringback = preg_replace('/}\z/',"",$default_ringback); + #$label = $text['label-'.$default_ringback]; + #if($label == "") { + $label = $default_ringback; + #} + $this->default_ringback_label = $label; + unset($results, $default_ringback, $label); + + //get music on hold and recordings + if (is_dir($_SERVER["PROJECT_ROOT"].'/app/music_on_hold')) { + require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; + $moh = new switch_music_on_hold; + $this->moh_list = $moh->list_moh(); + } + if (is_dir($_SERVER["PROJECT_ROOT"].'/app/recordings')) { + require_once "app/recordings/resources/classes/switch_recordings.php"; + $recordings = new switch_recordings; + $this->recordings_list = $recordings->list_recordings(); + } + } + + public function select ($name, $selected) { + //add multi-lingual support + $language = new text; + $text = $language->get(); + + //start the select + $select = "\n"; + return $select; + } + } +} + +?> \ No newline at end of file