From a25c9a3e48bd4e69ea188b54afcab4e1de6a4f4d Mon Sep 17 00:00:00 2001 From: Mafoo Date: Wed, 25 May 2016 21:12:17 +0100 Subject: [PATCH] Added basic searching for moh (#1614) added basic searching for the default moh directory added app_defaults so moh is configured/repairable with app_defaults changed to use PROJECT_ROOT changed template replacement to be encased in comment so xml will validate changed to use preg_replace so leading spaces and tabs can be stripped (to output clean xml) local_stream_conf dos2unixed made default search consistent (they should all be music/default or music not a mixture) --- app/music_on_hold/app_defaults.php | 36 +++++++ .../classes/switch_music_on_hold.php | 14 ++- .../autoload_configs/local_stream.conf.xml | 100 +++++++++--------- 3 files changed, 96 insertions(+), 54 deletions(-) create mode 100644 app/music_on_hold/app_defaults.php diff --git a/app/music_on_hold/app_defaults.php b/app/music_on_hold/app_defaults.php new file mode 100644 index 0000000000..563befa8d2 --- /dev/null +++ b/app/music_on_hold/app_defaults.php @@ -0,0 +1,36 @@ + + Portions created by the Initial Developer are Copyright (C) 2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane + Matthew Vale +*/ + + if ($domains_processed == 1) { + + require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; + $moh = new switch_music_on_hold; + $moh->xml(); + $moh->save(); + } + +?> \ No newline at end of file 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 41f8f920bc..268695905a 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 @@ -184,11 +184,16 @@ include "root.php"; $file_contents = file_get_contents("/usr/share/examples/fusionpbx/resources/templates/conf/autoload_configs/local_stream.conf.xml"); } else { - $file_contents = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/conf/autoload_configs/local_stream.conf.xml"); + $file_contents = file_get_contents($_SERVER["PROJECT_ROOT"]."/resources/templates/conf/autoload_configs/local_stream.conf.xml"); } - - //replace the variable - $file_contents = str_replace("{v_moh_categories}", $this->xml, $file_contents); + //check where the default music is stored + $default_moh_prefix = 'music/default'; + if(file_exists($_SESSION['switch']['sounds']['dir'].'/music/8000')) { + $default_moh_prefix = 'music'; + } + //replace the variables + $file_contents = preg_replace("music\/default", $default_moh_prefix, $file_contents); + $file_contents = preg_replace("[\t ]*(?:)?", $this->xml, $file_contents); //write the XML config file $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/local_stream.conf.xml","w"); @@ -198,6 +203,7 @@ include "root.php"; //reload the XML $this->reload(); } + } //build and save the XML diff --git a/resources/templates/conf/autoload_configs/local_stream.conf.xml b/resources/templates/conf/autoload_configs/local_stream.conf.xml index 8be463fff1..a646d85966 100644 --- a/resources/templates/conf/autoload_configs/local_stream.conf.xml +++ b/resources/templates/conf/autoload_configs/local_stream.conf.xml @@ -1,50 +1,50 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {v_moh_categories} - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +