From b52e4206627853b2c5e9bb51657bbf55eeb5d67c Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Wed, 1 Apr 2015 10:19:47 +0000 Subject: [PATCH] Get the list of recordings from the database. --- resources/switch.php | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/resources/switch.php b/resources/switch.php index 46e3771aef..2ff66c9903 100644 --- a/resources/switch.php +++ b/resources/switch.php @@ -969,26 +969,35 @@ function switch_select_destination($select_type, $select_label, $select_name, $s //recordings if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/recordings/app_config.php")) { if ($select_type == "dialplan" || $select_type == "ivr") { - if($dh = opendir($_SESSION['switch']['recordings']['dir']."/")) { - $files = Array(); + $sql = "select * from v_recordings "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "order by recording_name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $options[] = ""; + foreach ($result as &$row) { + $name = $row["recording_name"]; + $filename = $row["recording_filename"]; $options[] = ""; - while($file = readdir($dh)) { - if($file != "." && $file != ".." && $file[0] != '.') { - if (!is_dir($_SESSION['switch']['recordings']['dir']."/".$file)) { - if ($select_type == "dialplan") { - $selected = ($select_value == "lua:streamfile.lua ".$_SESSION['switch']['recordings']['dir']."/".$file) ? true : false; - $options[] = ""; - } - if ($select_type == "ivr") { - $selected = ($select_value == "menu-exec-app:lua streamfile.lua ".$_SESSION['switch']['recordings']['dir']."/".$file) ? true : false; - $options[] = ""; - } - if ($selected) { $selection_found = true; } - } + if ($select_type == "dialplan") { + if ($select_value == "lua:streamfile.lua ".$_SESSION['switch']['recordings']['dir']."/".$filename) { + $selected = "selected='selected'"; + } elseif ($select_value == "lua:streamfile.lua ".$filename) { + $selected = "selected='selected'"; } + $options[] = ""; } + if ($select_type == "ivr") { + if ($select_value == "menu-exec-app:lua streamfile.lua ".$_SESSION['switch']['recordings']['dir']."/".$filename) { + $selected = "selected='selected'"; + } elseif ($select_value == "menu-exec-app:lua streamfile.lua ".$_SESSION['switch']['recordings']['dir']."/".$filename) { + $selected = "selected='selected'"; + } + $options[] = ""; + } + if (isset($selected)) { $selection_found = true; } $options[] = ""; - closedir($dh); } } }