Update conference_center_edit.php

Get recordings from the database and move phrases database requests out of the content.
This commit is contained in:
FusionPBX 2016-08-11 15:40:09 -06:00 committed by GitHub
parent 38b504a6e5
commit 36013475d0
1 changed files with 45 additions and 29 deletions

View File

@ -17,22 +17,26 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2014 Portions created by the Initial Developer are Copyright (C) 2008-2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
require_once "root.php";
require_once "resources/require.php"; //includes
require_once "resources/check_auth.php"; require_once "root.php";
if (permission_exists('conference_center_add') || permission_exists('conference_center_edit')) { require_once "resources/require.php";
//access granted require_once "resources/check_auth.php";
}
else { //check permissions
echo "access denied"; if (permission_exists('conference_center_add') || permission_exists('conference_center_edit')) {
exit; //access granted
} }
else {
echo "access denied";
exit;
}
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
@ -256,6 +260,21 @@ else {
if (strlen($conference_center_enabled) == 0) { $conference_center_enabled = "true"; } if (strlen($conference_center_enabled) == 0) { $conference_center_enabled = "true"; }
if (strlen($conference_center_pin_length) == 0) { $conference_center_pin_length = 9; } if (strlen($conference_center_pin_length) == 0) { $conference_center_pin_length = 9; }
//get the recordings
$sql = "select recording_name, recording_filename from v_recordings ";
$sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' ";
$sql .= "order by recording_name asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$recordings = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
//get the phrases
$sql = "select * from v_phrases ";
$sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$phrases = $prep_statement->fetchAll(PDO::FETCH_NAMED);
//show the header //show the header
require_once "resources/header.php"; require_once "resources/header.php";
@ -339,31 +358,28 @@ else {
echo " <select name='conference_center_greeting' class='formfld' ".((permission_exists('conference_center_add') || permission_exists('conference_center_edit')) ? "onchange='changeToInput(this);'" : null).">\n"; echo " <select name='conference_center_greeting' class='formfld' ".((permission_exists('conference_center_add') || permission_exists('conference_center_edit')) ? "onchange='changeToInput(this);'" : null).">\n";
echo " <option></option>\n"; echo " <option></option>\n";
//recordings //recordings
if($dh = opendir($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/")) { $tmp_selected = false;
$tmp_selected = false; if (is_array($recordings)) {
$files = Array();
echo "<optgroup label='Recordings'>\n"; echo "<optgroup label='Recordings'>\n";
while ($file = readdir($dh)) { foreach ($recordings as &$row) {
if ($file != "." && $file != ".." && $file[0] != '.') { $recording_name = $row["recording_name"];
if (!is_dir($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$file)) { $recording_filename = $row["recording_filename"];
$selected = ($conference_center_greeting == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$file && strlen($conference_center_greeting) > 0) ? true : false; $recording_path = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'];
echo " <option value='".$_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$file."' ".(($selected) ? "selected='selected'" : null).">".$file."</option>\n"; $selected = '';
if ($selected) { $tmp_selected = true; } if ($conference_center_greeting == $recording_path."/".$recording_filename) {
} $selected = "selected='selected'";
} }
echo " <option value='".$recording_path."/".$recording_filename."' ".$selected.">".$recording_name."</option>\n";
unset($selected);
} }
closedir($dh);
echo "</optgroup>\n"; echo "</optgroup>\n";
} }
//phrases //phrases
$sql = "select * from v_phrases where domain_uuid = '".$domain_uuid."' "; if (count($phrases) > 0) {
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
if (count($result) > 0) {
echo "<optgroup label='Phrases'>\n"; echo "<optgroup label='Phrases'>\n";
foreach ($result as &$row) { foreach ($phrases as &$row) {
$selected = ($conference_center_greeting == "phrase:".$row["phrase_uuid"]) ? true : false; $selected = ($conference_center_greeting == "phrase:".$row["phrase_uuid"]) ? true : false;
echo " <option value='phrase:".$row["phrase_uuid"]."' ".(($selected) ? "selected='selected'" : null).">".$row["phrase_name"]."</option>\n"; echo " <option value='phrase:".$row["phrase_uuid"]."' ".(($selected) ? "selected='selected'" : null).">".$row["phrase_name"]."</option>\n";
if ($selected) { $tmp_selected = true; } if ($selected) { $tmp_selected = true; }
@ -474,4 +490,4 @@ else {
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>