Get music on hold from list from the database.

This commit is contained in:
markjcrane 2016-06-22 20:28:20 -06:00
parent 9e175c3d3b
commit 11e51de389
2 changed files with 26 additions and 32 deletions

View File

@ -59,6 +59,7 @@ else {
$moh_name_only = (substr_count($row['music_on_hold_name'], '/') > 0) ? substr($row['music_on_hold_name'], 0, strpos($row['music_on_hold_name'], '/')) : $row['music_on_hold_name'];
$moh_domain_uuid = ($row['domain_uuid'] != '') ? $row['domain_uuid'] : '_global_';
$moh_rate = $row['music_on_hold_rate'];
$mohs[$moh_domain_uuid][$moh_name_only][$moh_rate]['uuid'] = $row['music_on_hold_uuid'];
$mohs[$moh_domain_uuid][$moh_name_only][$moh_rate]['name'] = $row['music_on_hold_name']; //value may include '/[rate]'
$mohs[$moh_domain_uuid][$moh_name_only][$moh_rate]['path'] = '/'.trim(str_replace('$${sounds_dir}', $_SESSION['switch']['sounds']['dir'], $row['music_on_hold_path']),'/');

View File

@ -98,38 +98,31 @@ include "root.php";
$language = new text;
$text = $language->get(null, 'app/music_on_hold');
$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;
}
if($moh_name == 'default') {
$moh_name = $text['opt-default'];
}
$moh_list[$moh_value] = str_replace('_', ' ', $moh_name);
//get moh records, build array
$sql = "select * from v_music_on_hold ";
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
if (permission_exists('music_on_hold_global_view')) {
$sql .= "or domain_uuid is null ";
}
//detect source installed moh
if(is_dir($music_on_hold_dir."/8000")) {
$moh_list["local_stream://default"] = $text['opt-default'];
}
return $moh_list;
$sql .= "order by domain_uuid desc, music_on_hold_rate asc, music_on_hold_name asc";
$prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach($result as $row) {
//set the variables
$moh_name = $row['music_on_hold_name'];
$moh_rate = $row['music_on_hold_rate'];
//set the value
$moh_value = "local_stream://".$moh_name;
if($moh_name == 'default') {
$moh_name = $text['option-default'];
}
$array[$moh_value] = str_replace('_', ' ', $moh_name);
}
//return the array
return $array;
}
public function reload() {
@ -223,4 +216,4 @@ include "root.php";
//$moh->xml();
//$moh->save();
?>
?>