Update app_defaults for muisc on hold so it reads local_stream.conf.xml and loads the information in the database. Remove music_on_hold_category.
This commit is contained in:
parent
2972dbe80b
commit
6a58bb97dd
|
|
@ -58,10 +58,6 @@
|
|||
$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_category";
|
||||
$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";
|
||||
|
|
|
|||
|
|
@ -22,15 +22,82 @@
|
|||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Matthew Vale <github@mafoo.org>
|
||||
*/
|
||||
|
||||
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();
|
||||
//require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php";
|
||||
//$moh = new switch_music_on_hold;
|
||||
//$moh->xml();
|
||||
//$moh->save();
|
||||
|
||||
//add the music_on_hold list to the database
|
||||
$sql = "select count(*) as num_rows from v_music_on_hold; ";
|
||||
$prep_statement = $db->prepare($sql);
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row['num_rows'] == 0) {
|
||||
|
||||
//set the directory
|
||||
$xml_dir = $_SESSION["switch"]["conf"]["dir"].'/autoload_configs';
|
||||
$xml_file = $xml_dir."/local_stream.conf.xml";
|
||||
$xml_file_alt = $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/resources/templates/conf/autoload_configs/local_stream.conf';
|
||||
|
||||
//load the xml and save it into an array
|
||||
if (file_exists($xml_file)) {
|
||||
$xml_string = file_get_contents($xml_file);
|
||||
}
|
||||
elseif (file_exists($xml_file_alt)) {
|
||||
$xml_string = file_get_contents(xml_file_alt);
|
||||
}
|
||||
$xml_object = simplexml_load_string($xml_string);
|
||||
$json = json_encode($xml_object);
|
||||
$conf_array = json_decode($json, true);
|
||||
|
||||
//process the array
|
||||
foreach ($conf_array['directory'] as $row) {
|
||||
//get the data from the array
|
||||
$stream_name = $row['@attributes']['name'];
|
||||
$stream_path = $row['@attributes']['path'];
|
||||
foreach ($row['param'] as $p) {
|
||||
$name = $p['@attributes']['name'];
|
||||
$name = str_replace("-", "_", $name);
|
||||
$$name = $p['@attributes']['value'];
|
||||
}
|
||||
|
||||
//insert the data into the database
|
||||
$music_on_hold_uuid = uuid();
|
||||
$sql = "insert into v_music_on_hold ";
|
||||
$sql .= "(";
|
||||
$sql .= "music_on_hold_uuid, ";
|
||||
$sql .= "music_on_hold_name, ";
|
||||
if (isset($rate)) $sql .= "music_on_hold_rate, ";
|
||||
if (isset($shuffle)) $sql .= "music_on_hold_shuffle, ";
|
||||
if (isset($timer_name)) $sql .= "music_on_hold_timer, ";
|
||||
if (isset($chime_list)) $sql .= "music_on_hold_chime_list, ";
|
||||
if (isset($chime_freq)) $sql .= "music_on_hold_chime_freq, ";
|
||||
if (isset($chime_max)) $sql .= "music_on_hold_chime_max, ";
|
||||
$sql .= "music_on_hold_path ";
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "( ";
|
||||
$sql .= "'".$music_on_hold_uuid."', ";
|
||||
$sql .= "'".check_str($stream_name)."', ";
|
||||
if (isset($rate)) $sql .= "'".check_str($rate)."', ";
|
||||
if (isset($shuffle)) $sql .= "'".check_str($shuffle)."', ";
|
||||
if (isset($timer_name)) $sql .= "'".check_str($timer_name)."', ";
|
||||
if (isset($chime_list)) $sql .= "'".check_str($chime_list)."', ";
|
||||
if (isset($chime_max)) $sql .= "'".check_str($chime_max)."', ";
|
||||
$sql .= "'".check_str($stream_path)."' ";
|
||||
$sql .= ");";
|
||||
//echo $sql."\n";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
//rename the file
|
||||
rename($xml_dir.'/local_stream.conf.xml', $xml_dir.'/local_stream.conf');
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue