Get music on hold from list from the database.
This commit is contained in:
parent
9e175c3d3b
commit
11e51de389
|
|
@ -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_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_domain_uuid = ($row['domain_uuid'] != '') ? $row['domain_uuid'] : '_global_';
|
||||||
$moh_rate = $row['music_on_hold_rate'];
|
$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]['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]['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']),'/');
|
$mohs[$moh_domain_uuid][$moh_name_only][$moh_rate]['path'] = '/'.trim(str_replace('$${sounds_dir}', $_SESSION['switch']['sounds']['dir'], $row['music_on_hold_path']),'/');
|
||||||
|
|
|
||||||
|
|
@ -98,38 +98,31 @@ include "root.php";
|
||||||
$language = new text;
|
$language = new text;
|
||||||
$text = $language->get(null, 'app/music_on_hold');
|
$text = $language->get(null, 'app/music_on_hold');
|
||||||
|
|
||||||
$music_on_hold_dir = $_SESSION["switch"]["sounds"]["dir"]."/music";
|
//get moh records, build array
|
||||||
$array = array_merge(glob($music_on_hold_dir."/*/*", GLOB_ONLYDIR), glob($music_on_hold_dir."/".$_SESSION['domain_name']."/*/*", GLOB_ONLYDIR));
|
$sql = "select * from v_music_on_hold ";
|
||||||
foreach($array as $moh_dir) {
|
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||||
//set the directory
|
if (permission_exists('music_on_hold_global_view')) {
|
||||||
$moh_dir = substr($moh_dir, strlen($music_on_hold_dir."/"));
|
$sql .= "or domain_uuid is null ";
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
//detect source installed moh
|
$sql .= "order by domain_uuid desc, music_on_hold_rate asc, music_on_hold_name asc";
|
||||||
if(is_dir($music_on_hold_dir."/8000")) {
|
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||||
$moh_list["local_stream://default"] = $text['opt-default'];
|
$prep_statement->execute();
|
||||||
}
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||||
return $moh_list;
|
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() {
|
public function reload() {
|
||||||
|
|
@ -223,4 +216,4 @@ include "root.php";
|
||||||
//$moh->xml();
|
//$moh->xml();
|
||||||
//$moh->save();
|
//$moh->save();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Loading…
Reference in New Issue