Enhance Ringback (#1590)

created new class to look after generating the list of ringbacks
available
adjusted MOH class so legacy method is still possible (just not recommend) and utilizes optgroups as well
converted ring_groups and ivr_menus to use new method
added translations
implemented list_recordings in switch_recordings class
This commit is contained in:
Mafoo 2016-06-08 14:21:45 +01:00 committed by FusionPBX
parent 9f902e435c
commit d663891bd8
8 changed files with 405 additions and 191 deletions

View File

@ -28,6 +28,7 @@ require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
require_once "resources/classes/logging.php"; require_once "resources/classes/logging.php";
require_once "resources/classes/ringbacks.php";
if (permission_exists('ivr_menu_add') || permission_exists('ivr_menu_edit')) { if (permission_exists('ivr_menu_add') || permission_exists('ivr_menu_edit')) {
//access granted //access granted
} }
@ -305,6 +306,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
} }
} }
unset ($prep_statement); unset ($prep_statement);
}else{
$ivr_menu_ringback = 'default_ringback';
} }
//set defaults //set defaults
@ -789,57 +792,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
$select_options = ""; $ringbacks = new ringbacks;
if ($ivr_menu_ringback == "\${us-ring}" || $ivr_menu_ringback == "us-ring") { echo $ringbacks->select('ivr_menu_ringback', $ivr_menu_ringback);
$select_options .= " <option value='\${us-ring}' selected='selected'>us-ring</option>\n";
}
else {
$select_options .= " <option value='\${us-ring}'>us-ring</option>\n";
}
if ($ivr_menu_ringback == "\${pt-ring}" || $ivr_menu_ringback == "pt-ring") {
$select_options .= " <option value='\${pt-ring}' selected='selected'>pt-ring</option>\n";
}
else {
$select_options .= " <option value='\${pt-ring}'>pt-ring</option>\n";
}
if ($ivr_menu_ringback == "\${fr-ring}" || $ivr_menu_ringback == "fr-ring") {
$select_options .= " <option value='\${fr-ring}' selected='selected'>fr-ring</option>\n";
}
else {
$select_options .= " <option value='\${fr-ring}'>fr-ring</option>\n";
}
if ($ivr_menu_ringback == "\${uk-ring}" || $ivr_menu_ringback == "uk-ring") {
$select_options .= " <option value='\${uk-ring}' selected='selected'>uk-ring</option>\n";
}
else {
$select_options .= " <option value='\${uk-ring}'>uk-ring</option>\n";
}
if ($ivr_menu_ringback == "\${rs-ring}" || $ivr_menu_ringback == "rs-ring") {
$select_options .= " <option value='\${rs-ring}' selected='selected'>rs-ring</option>\n";
}
else {
$select_options .= " <option value='\${rs-ring}'>rs-ring</option>\n";
}
if ($ivr_menu_ringback == "\${it-ring}" || $ivr_menu_ringback == "it-ring") {
$select_options .= " <option value='\${it-ring}' selected='selected'>it-ring</option>\n";
}
else {
$select_options .= " <option value='\${it-ring}'>it-ring</option>\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 " <select class='formfld' name='ivr_menu_ringback'>\n";
//echo " <option value=''></option>\n";
echo $select_options;
echo " </select>\n";
}
echo "<br />\n"; echo "<br />\n";
echo $text['description-ring_back']."\n"; echo $text['description-ring_back']."\n";

View File

@ -11,6 +11,19 @@ $text['title-moh']['uk'] = "Музика на утриманні";
$text['title-moh']['de-at'] = "Haltemusik"; $text['title-moh']['de-at'] = "Haltemusik";
$text['title-moh']['he'] = "מוסיקה בהמתנה"; $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']['en-us'] = "New...";
$text['opt-new']['es-cl'] = "Nuevo..."; $text['opt-new']['es-cl'] = "Nuevo...";
$text['opt-new']['pt-pt'] = "Novo..."; $text['opt-new']['pt-pt'] = "Novo...";

View File

@ -17,20 +17,20 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Copyright (C) 2010 Portions created by the Initial Developer are Copyright (C) 2010-2016
All Rights Reserved. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
James Rose <james.o.rose@gmail.com> James Rose <james.o.rose@gmail.com>
Matthew Vale <github@mafoo.org>
*/ */
include "root.php"; include "root.php";
//define the directory class //define the switch_music_on_hold class
class switch_music_on_hold { class switch_music_on_hold {
public $domain_uuid; public $domain_uuid;
public $domain_name;
public $select_name; public $select_name;
public $select_value; public $select_value;
public $select_options; public $select_options;
@ -38,7 +38,7 @@ include "root.php";
public function __construct() { public function __construct() {
require_once "resources/classes/database.php"; require_once "resources/classes/database.php";
$this->app_uuid = ''; $this->domain_uuid = $_SESSION['domain_uuid'];
} }
public function __destruct() { 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() { public function select() {
//build the list of categories $trace = debug_backtrace();
$music_on_hold_dir = $_SESSION["switch"]["sounds"]["dir"]."/music"; $caller = $trace[1];
if (count($_SESSION['domains']) > 1) { $what = $caller['function'];
$music_on_hold_dir = $music_on_hold_dir."/".$_SESSION['domain_name']; 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 //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get($_SESSION['domain']['language']['code'], 'app/music_on_hold'); $text = $language->get();
//start the select //start the select
$select = " <select class='formfld' name='".$this->select_name."' id='".$this->select_name."' style='width: auto;'>\n"; $select = " <select class='formfld' name='".$this->select_name."' id='".$this->select_name."' style='width: auto;'>\n";
$select .= " <option value='' style='font-style: italic;'>".$text['opt-default']."</option>\n";
//categories //moh
$array = glob($music_on_hold_dir."/*/*", GLOB_ONLYDIR); $options = $this->list_moh();
//list the categories
$moh_xml = "";
foreach($array as $moh_dir) {
//set the directory
$moh_dir = substr($moh_dir, strlen($music_on_hold_dir."/"));
//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 (count($_SESSION['domains']) > 1) {
$moh_value = "local_stream://".$_SESSION['domain_name']."/".$moh_name;
}
else {
$moh_value = "local_stream://".$moh_name;
}
$options[$moh_value] = str_replace('_', ' ', $moh_name);
}
if (sizeof($options) > 0) { if (sizeof($options) > 0) {
$select .= "<optgroup label='".$text['label-music_on_hold']."'>";
foreach($options as $moh_value => $moh_name) { foreach($options as $moh_value => $moh_name) {
$select .= "<option value='".$moh_value."' ".(($this->select_value == $moh_value) ? 'selected="selected"' : null).">".$moh_name."</option>\n"; $select .= "<option value='".$moh_value."' ".(($this->select_value == $moh_value) ? 'selected="selected"' : null).">".$moh_name."</option>\n";
} }
$select .= "</optgroup>\n";
} }
//recordings //recordings
$recordings_dir = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/"; if (is_dir($_SERVER["PROJECT_ROOT"].'/app/recordings')) {
if($dh = opendir($recordings_dir)) { require_once "app/recordings/resources/classes/switch_recordings.php";
$tmp_selected = false; $recordings_c = new recordings;
$files = Array(); $recordings = $recordings_c->list_recordings();
//$select .= "<optgroup label='recordings'>\n"; if (sizeof($recordings) > 0) {
while($file = readdir($dh)) { $select .= "<optgroup label='".$text['label-recordings']."'>";
if($file != "." && $file != ".." && $file[0] != '.') { foreach($recordings as $recording_value => $recording_name){
if(is_dir($recordings_dir . $file)) { $select .= "<option value='".$recording_value."' ".(($this->select_value == $recording_value) ? 'selected="selected"' : null).">".$recording_name."</option>\n";
//this is a directory
}
else {
if ($this->select_value == $recordings_dir . $file && strlen($this->select_value) > 0) {
$tmp_selected = true;
$select .= " <option value='".$recordings_dir.$file."' selected='selected'>".$file."</option>\n";
}
else {
$select .= " <option value='".$recordings_dir.$file."'>".$file."</option>\n";
}
}
} }
$select .= "</optgroup>\n";
} }
closedir($dh);
//$select .= "</optgroup>\n";
} }
//add additional options //add additional options
$select .= $this->select_options; if (sizeof($this->select_options) > 0) {
$select .= "<optgroup label='".$text['label-others']."'>";
$select .= $this->select_options;
$select .= "</optgroup>\n";
}
//end the select and return it //end the select and return it
$select .= " </select>\n"; $select .= " </select>\n";
return $select; 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() { public function reload() {
//if the handle does not exist create it //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']); $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);

View File

@ -0,0 +1,60 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016
All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Matthew Vale <github@mafoo.org>
*/
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;
}
}
?>

View File

@ -11,28 +11,6 @@ $text['title-ring_groups']['uk'] = "Групи";
$text['title-ring_groups']['de-at'] = "Rufgruppen"; $text['title-ring_groups']['de-at'] = "Rufgruppen";
$text['title-ring_groups']['he'] = "קבוצות חיוג"; $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']['en-us'] = "Simultaneous";
$text['option-simultaneous']['es-cl'] = "Simultaneos"; $text['option-simultaneous']['es-cl'] = "Simultaneos";
$text['option-simultaneous']['fr-fr'] = "Simultané"; $text['option-simultaneous']['fr-fr'] = "Simultané";
@ -55,17 +33,6 @@ $text['option-sequence']['uk'] = "";
$text['option-sequence']['de-at'] = "sequenziell"; $text['option-sequence']['de-at'] = "sequenziell";
$text['option-sequence']['he'] = "אחד אחרי השני"; $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']['en-us'] = "Rollover";
$text['option-rollover']['es-cl'] = "Rollover"; $text['option-rollover']['es-cl'] = "Rollover";
$text['option-rollover']['pt-pt'] = "Rollover"; $text['option-rollover']['pt-pt'] = "Rollover";

View File

@ -28,6 +28,7 @@
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
require_once "resources/classes/ringbacks.php";
if (permission_exists('ring_group_add') || permission_exists('ring_group_edit')) { if (permission_exists('ring_group_add') || permission_exists('ring_group_edit')) {
//access granted //access granted
} }
@ -404,6 +405,8 @@ else {
if (strlen($ring_group_timeout_app) > 0) { if (strlen($ring_group_timeout_app) > 0) {
$ring_group_timeout_action = $ring_group_timeout_app.":".$ring_group_timeout_data; $ring_group_timeout_action = $ring_group_timeout_app.":".$ring_group_timeout_data;
} }
}else{
$ring_group_ringback = 'default_ringback';
} }
//get the ring group destination array //get the ring group destination array
@ -642,57 +645,8 @@ else {
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
$select_options = ""; $ringbacks = new ringbacks;
if ($ring_group_ringback == "\${us-ring}" || $ring_group_ringback == "us-ring") { echo $ringbacks->select('ring_group_ringback', $ring_group_ringback);
$select_options .= " <option value='\${us-ring}' selected='selected'>".$text['option-usring']."</option>\n";
}
else {
$select_options .= " <option value='\${us-ring}'>".$text['option-usring']."</option>\n";
}
if ($ring_group_ringback == "\${pt-ring}" || $ring_group_ringback == "pt-ring") {
$select_options .= " <option value='\${pt-ring}' selected='selected'>".$text['option-ptring']."</option>\n";
}
else {
$select_options .= " <option value='\${pt-ring}'>".$text['option-ptring']."</option>\n";
}
if ($ring_group_ringback == "\${fr-ring}" || $ring_group_ringback == "fr-ring") {
$select_options .= " <option value='\${fr-ring}' selected='selected'>".$text['option-frring']."</option>\n";
}
else {
$select_options .= " <option value='\${fr-ring}'>".$text['option-frring']."</option>\n";
}
if ($ring_group_ringback == "\${uk-ring}" || $ring_group_ringback == "uk-ring") {
$select_options .= " <option value='\${uk-ring}' selected='selected'>".$text['option-ukring']."</option>\n";
}
else {
$select_options .= " <option value='\${uk-ring}'>".$text['option-ukring']."</option>\n";
}
if ($ring_group_ringback == "\${rs-ring}" || $ring_group_ringback == "rs-ring") {
$select_options .= " <option value='\${rs-ring}' selected='selected'>".$text['option-rsring']."</option>\n";
}
else {
$select_options .= " <option value='\${rs-ring}'>".$text['option-rsring']."</option>\n";
}
if ($ring_group_ringback == "\${it-ring}" || $ring_group_ringback == "it-ring") {
$select_options .= " <option value='\${it-ring}' selected='selected'>".$text['option-itring']."</option>\n";
}
else {
$select_options .= " <option value='\${it-ring}'>".$text['option-itring']."</option>\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 " <select class='formfld' name='ring_group_ringback'>\n";
//echo " <option value=''></option>\n";
echo $select_options;
echo " </select>\n";
}
echo "<br />\n"; echo "<br />\n";
echo $text['description-ringback']."\n"; echo $text['description-ringback']."\n";

View File

@ -665,6 +665,115 @@ $text['label-delete']['sv-se'] = "Ta Bort";
$text['label-delete']['uk'] = "Видалити"; $text['label-delete']['uk'] = "Видалити";
$text['label-delete']['de-at'] = "Löschen"; $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) //option (present for compatibility, should use label-true/false instead)

View File

@ -0,0 +1,148 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Matthew Vale <github@mafoo.org>
*/
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 = "<select class='formfld' name='".$name."' id='".$name."' style='width: auto;'>\n";
//moh
if (sizeof($this->moh_list) > 0) {
$select .= " <optgroup label='".$text['label-music_on_hold']."'>";
foreach($this->moh_list as $moh_value => $moh_name) {
$select .= " <option value='".$moh_value."' ".(($selected == $moh_value) ? 'selected="selected"' : '').">".$moh_name."</option>\n";
}
$select .= " </optgroup>\n";
}
//recordings
if (sizeof($this->recordings_list) > 0) {
$select .= " <optgroup label='".$text['label-recordings']."'>";
foreach($this->recordings_list as $recording_value => $recording_name){
$select .= " <option value='".$recording_value."' ".(($selected == $recording_value) ? 'selected="selected"' : '').">".$recording_name."</option>\n";
}
$select .= " </optgroup>\n";
}
//ringbacks
if (sizeof($this->ringbacks) > 0) {
$selected_ringback = $selected;
$selected_ringback = preg_replace('/\A\${/',"",$selected_ringback);
$selected_ringback = preg_replace('/}\z/',"",$selected_ringback);
$select .= " <optgroup label='".$text['label-ringback']."'>";
$select .= " <option value='default_ringback'".(($selected == "default_ringback") ? ' selected="selected"' : '').">".$text['label-default']." (".$this->default_ringback_label.")</option>\n";
foreach($this->ringbacks as $ringback_value => $ringback_name) {
$select .= " <option value='\${".$ringback_value."}'".(($selected_ringback == $ringback_value) ? ' selected="selected"' : '').">".$ringback_name."</option>\n";
}
$select .= " </optgroup>\n";
unset($selected_ringback);
}
//end the select and return it
$select .= "</select>\n";
return $select;
}
}
}
?>