Update music_on_hold.php

Music on hold - combine the same name with multiple rates under the heading. Improve indentation and comments.
This commit is contained in:
FusionPBX 2016-06-29 21:42:12 -06:00 committed by GitHub
parent b05a525be2
commit 5fbb7b66fb
1 changed files with 133 additions and 106 deletions

View File

@ -538,27 +538,45 @@
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
//set the variable with an empty string
$previous_name = '';
//show the array of data
if (is_array($streams)) {
//start the table
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0' style='margin-bottom: 3px;'>\n";
//loop through the array
foreach($streams as $row) {
//set the variables and work with them
$music_on_hold_name = $row['music_on_hold_name'];
$name_array = explode("/", $music_on_hold_name);
if (count($name_array) == 2) { $music_on_hold_name = $name_array[0]; }
if (count($name_array) == 3) { $music_on_hold_name = $name_array[1]; }
echo "<b><i>".$music_on_hold_name."</i></b>\n";
if ($row['domain_uuid'] == null) {
echo "&nbsp;&nbsp;- ".$text['label-global']."\n";
}
//$name_array = explode("/", $music_on_hold_name);
//if (count($name_array) == 2) { $music_on_hold_name = $name_array[0]; }
//if (count($name_array) == 3) { $music_on_hold_name = $name_array[1]; }
//echo "<b><i>".$music_on_hold_name."</i></b>\n";
$moh_scope = $row['domain_uuid'];
if (!$moh_scope) $moh_scope = '_global_';
$tmp = explode('/', $row['music_on_hold_name']);
$moh_name_only = $tmp[0];
$moh_rate = $row['music_on_hold_rate'];
$moh_settings = $mohs[$moh_scope][$moh_name_only][$moh_rate];
//start the table
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0' style='margin-bottom: 3px;'>\n";
//add a vertical space
echo "<tr class='tr_link_void'><td colspan='5'><div style='width: 1px; height: 25px;'></div></td></tr>\n";
//add the name
if ($previous_name != $music_on_hold_name) {
echo "<tr class='tr_link_void'>\n";
echo " <td colspan='5'><b><i>".$music_on_hold_name."</i></b>";
if ($row['domain_uuid'] == null) {
echo "&nbsp;&nbsp;- ".$text['label-global']."\n";
}
echo " </td>\n";
echo "</tr>\n";
}
//determine if rate was set to auto or not
$auto_rate = (substr_count($moh_settings['name'], '/') == 0) ? true : false;
@ -592,6 +610,8 @@
$icons .= "<span class='glyphicon ".$moh_icon['glyphicon']." icon_glyphicon_body' title='".$moh_icon['title']."' style='width: 12px; height: 12px; margin-left: ".(($moh_icon['margin'] != '') ? $moh_icon['margin'] : 8)."px; vertical-align: text-top; cursor: help;'></span>";
}
}
//show the table header
echo " <tr>\n";
echo " <th class='listhdr'>".(($auto_rate) ? ($moh_rate/1000).' kHz / '.$text['option-default'] : ($moh_rate/1000)." kHz").$icons."</th>\n";
echo " <th class='listhdr' style='width: 55px;'>".$text['label-tools']."</th>\n";
@ -608,6 +628,7 @@
echo " </tr>";
unset($moh_icons, $icons);
//add the uuid of to the link
if (permission_exists('music_on_hold_edit')) {
$tr_link = "href='music_on_hold_edit.php?id=".$row['music_on_hold_uuid']."'";
}
@ -616,6 +637,7 @@
$moh_path = $row['music_on_hold_path'];
$moh_path = str_replace("\$\${sounds_dir}",$_SESSION['switch']['sounds']['dir'], $moh_path);
//show the files
if (file_exists($moh_path)) {
$moh_files = array_merge(glob($moh_path.'/*.wav'), glob($moh_path.'/*.mp3'), glob($moh_path.'/*.ogg'));
foreach ($moh_files as $moh_file_path) {
@ -651,12 +673,17 @@
}
}
echo "<tr class='tr_link_void'><td colspan='5'><div style='width: 1px; height: 15px;'></div></td></tr>\n";
echo "</table><br />\n";
//set the previous music_on_hold_name
$previous_name = $music_on_hold_name;
//toggle the light highlighting
if ($c==0) { $c=1; } else { $c=0; }
} //end foreach
unset($sql, $result, $row_count);
//end the table
echo "</table>\n";
} //end if results
echo "<tr>\n";