Update switch_music_on_hold.php

Music on hold select list use the UUIDs instead of the names.
This commit is contained in:
FusionPBX
2016-06-29 16:52:32 -06:00
committed by GitHub
parent eb8b64dcd3
commit 9f815b908e

View File

@@ -60,12 +60,12 @@ include "root.php";
//start the select
$select = "<select class='formfld' name='".$name."' id='".$name."' style='width: auto;'>\n";
//moh
$options = $this->list_moh();
//music on hold
$options = $this->streams();
if (sizeof($options) > 0) {
$select .= " <optgroup label='".$text['label-music_on_hold']."'>";
foreach($options as $moh_value => $moh_name) {
$select .= " <option value='".$moh_value."' ".(($selected == $moh_value) ? 'selected="selected"' : null).">".$moh_name."</option>\n";
foreach($options as $row) {
$select .= " <option value='local_stream://".$row['music_on_hold_uuid']."' ".(($selected == "local_stream://".$row['music_on_hold_uuid']) ? 'selected="selected"' : null).">".$row['music_on_hold_name']."</option>\n";
}
$select .= " </optgroup>\n";
}
@@ -93,7 +93,7 @@ include "root.php";
return $select;
}
public function list_moh() {
public function streams() {
//add multi-lingual support
$language = new text;
$text = $language->get(null, 'app/music_on_hold');
@@ -107,40 +107,7 @@ include "root.php";
$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);
//build the names array without the rates
$names = array();
foreach($result as $row) {
//convert the strings into arrays
$name_array = explode("/", $row['music_on_hold_name']);
//name with the domain
if (count($name_array) == "3") {
$stream_name = $name_array[0].'/'.$name_array[1];
}
//name without the domain
if (count($name_array) == "2") {
$stream_name = $name_array[0];
}
//prevent duplicate names in the array
if (!in_array($stream_name, $names)) {
$names[] = $stream_name;
}
}
//add the value and name to the array before it is returned
foreach($names as $name) {
$value = "local_stream://".$name;
if($stream == 'default') {
$name = $text['option-default'];
}
$array[$value] = str_replace('_', ' ', $name);
}
//return the array
return $array;
return $prep_statement->fetchAll(PDO::FETCH_NAMED);
}
public function reload() {