mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
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:
@@ -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 "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
|
||||
$select_options = "";
|
||||
if ($ivr_menu_ringback == "\${us-ring}" || $ivr_menu_ringback == "us-ring") {
|
||||
$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";
|
||||
}
|
||||
$ringbacks = new ringbacks;
|
||||
echo $ringbacks->select('ivr_menu_ringback', $ivr_menu_ringback);
|
||||
|
||||
echo "<br />\n";
|
||||
echo $text['description-ring_back']."\n";
|
||||
|
||||
@@ -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...";
|
||||
|
||||
@@ -17,20 +17,20 @@
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2010
|
||||
Portions created by the Initial Developer are Copyright (C) 2010-2016
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
James Rose <james.o.rose@gmail.com>
|
||||
Matthew Vale <github@mafoo.org>
|
||||
*/
|
||||
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 = " <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
|
||||
$array = glob($music_on_hold_dir."/*/*", GLOB_ONLYDIR);
|
||||
//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);
|
||||
}
|
||||
//moh
|
||||
$options = $this->list_moh();
|
||||
if (sizeof($options) > 0) {
|
||||
$select .= "<optgroup label='".$text['label-music_on_hold']."'>";
|
||||
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 .= "</optgroup>\n";
|
||||
}
|
||||
//recordings
|
||||
$recordings_dir = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/";
|
||||
if($dh = opendir($recordings_dir)) {
|
||||
$tmp_selected = false;
|
||||
$files = Array();
|
||||
//$select .= "<optgroup label='recordings'>\n";
|
||||
while($file = readdir($dh)) {
|
||||
if($file != "." && $file != ".." && $file[0] != '.') {
|
||||
if(is_dir($recordings_dir . $file)) {
|
||||
//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";
|
||||
}
|
||||
}
|
||||
if (is_dir($_SERVER["PROJECT_ROOT"].'/app/recordings')) {
|
||||
require_once "app/recordings/resources/classes/switch_recordings.php";
|
||||
$recordings_c = new recordings;
|
||||
$recordings = $recordings_c->list_recordings();
|
||||
if (sizeof($recordings) > 0) {
|
||||
$select .= "<optgroup label='".$text['label-recordings']."'>";
|
||||
foreach($recordings as $recording_value => $recording_name){
|
||||
$select .= "<option value='".$recording_value."' ".(($this->select_value == $recording_value) ? 'selected="selected"' : null).">".$recording_name."</option>\n";
|
||||
}
|
||||
$select .= "</optgroup>\n";
|
||||
}
|
||||
closedir($dh);
|
||||
//$select .= "</optgroup>\n";
|
||||
}
|
||||
//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
|
||||
$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']);
|
||||
|
||||
60
app/recordings/resources/classes/switch_recordings.php
Normal file
60
app/recordings/resources/classes/switch_recordings.php
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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";
|
||||
|
||||
@@ -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 "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
|
||||
$select_options = "";
|
||||
if ($ring_group_ringback == "\${us-ring}" || $ring_group_ringback == "us-ring") {
|
||||
$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";
|
||||
}
|
||||
$ringbacks = new ringbacks;
|
||||
echo $ringbacks->select('ring_group_ringback', $ring_group_ringback);
|
||||
|
||||
echo "<br />\n";
|
||||
echo $text['description-ringback']."\n";
|
||||
|
||||
Reference in New Issue
Block a user