From ddee7be012bf2e2a630946961b62eae3bf26065e Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Tue, 28 Apr 2015 09:54:02 +0000 Subject: [PATCH] Phrases: App Defaults now converts phrases between base64 compatible and back, enhanced interface with better js manipulation, easily add pauses to a phrase. Note: Currently DTMF tones are not recognized during phrase playback in IVR (rrrrr!). --- app/phrases/app_defaults.php | 50 +++++++ app/phrases/app_languages.php | 15 ++ app/phrases/phrase_edit.php | 272 ++++++++++++++++++++++------------ resources/switch.php | 2 +- 4 files changed, 243 insertions(+), 96 deletions(-) diff --git a/app/phrases/app_defaults.php b/app/phrases/app_defaults.php index 449d167adc..638afb500c 100644 --- a/app/phrases/app_defaults.php +++ b/app/phrases/app_defaults.php @@ -98,6 +98,56 @@ if ($domains_processed == 1) { } //if } //if + //if base64, convert existing incompatible phrases + if ($_SESSION['recordings']['storage_type']['text'] == 'base64') { + $sql = "select phrase_detail_uuid, phrase_detail_data "; + $sql .= "from v_phrase_details where phrase_detail_function = 'play-file' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (count($result) > 0) { + foreach ($result as &$row) { + $phrase_detail_uuid = $row['phrase_detail_uuid']; + $phrase_detail_data = $row['phrase_detail_data']; + //update function and data to be base64 compatible + $phrase_detail_data = "lua(streamfile.lua ".$phrase_detail_data.")"; + $sql = "update v_phrase_details set "; + $sql .= "phrase_detail_function = 'execute', "; + $sql .= "phrase_detail_data = '".$phrase_detail_data."' "; + $sql .= "where phrase_detail_uuid = '".$phrase_detail_uuid."' "; + $db->exec(check_sql($sql)); + unset($sql); + } + } + unset($sql, $prep_statement, $result, $row); + } + //if not base64, revert base64 phrases to standard method + else if ($_SESSION['recordings']['storage_type']['text'] != 'base64') { + $sql = "select phrase_detail_uuid, phrase_detail_data "; + $sql .= "from v_phrase_details where "; + $sql .= "phrase_detail_function = 'execute' "; + $sql .= "and phrase_detail_data like 'lua(streamfile.lua %)' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (count($result) > 0) { + foreach ($result as &$row) { + $phrase_detail_uuid = $row['phrase_detail_uuid']; + $phrase_detail_data = $row['phrase_detail_data']; + //update function and data to use standard method + $phrase_detail_data = str_replace('lua(streamfile.lua ', '', $phrase_detail_data); + $phrase_detail_data = str_replace(')', '', $phrase_detail_data); + $sql = "update v_phrase_details set "; + $sql .= "phrase_detail_function = 'play-file', "; + $sql .= "phrase_detail_data = '".$phrase_detail_data."' "; + $sql .= "where phrase_detail_uuid = '".$phrase_detail_uuid."' "; + $db->exec(check_sql($sql)); + unset($sql); + } + } + unset($sql, $prep_statement, $result, $row); + } + } ?> \ No newline at end of file diff --git a/app/phrases/app_languages.php b/app/phrases/app_languages.php index e601e67394..93c576f4a0 100644 --- a/app/phrases/app_languages.php +++ b/app/phrases/app_languages.php @@ -70,6 +70,14 @@ $text['label-structure']['fr-fr'] = "Structure"; $text['label-structure']['pt-br'] = "Estrutura"; $text['label-structure']['pl'] = "Struktura"; +$text['label-sounds']['en-us'] = "Sounds"; +$text['label-sounds']['es-cl'] = "Sonidos"; +$text['label-sounds']['pt-pt'] = "Sons"; +$text['label-sounds']['fr-fr'] = "Sons"; +$text['label-sounds']['pt-br'] = "Áudios"; +$text['label-sounds']['pl'] = "Dzwięki"; +$text['label-sounds']['sv-se'] = "Ljud"; + $text['label-say']['en-us'] = "Say"; $text['label-say']['es-cl'] = "Decir"; $text['label-say']['pt-pt'] = "Dizer"; @@ -77,6 +85,13 @@ $text['label-say']['fr-fr'] = "Dire"; $text['label-say']['pt-br'] = "Dizer"; $text['label-say']['pl'] = "Powiedz"; +$text['label-recordings']['en-us'] = "Recordings"; +$text['label-recordings']['es-cl'] = "Grabaciones"; +$text['label-recordings']['pt-pt'] = "Gravações"; +$text['label-recordings']['fr-fr'] = "Guides Vocaux"; +$text['label-recordings']['pt-br'] = "Configurações da Conta"; +$text['label-recordings']['pl'] = "Ustawienia konta"; + $text['label-play']['en-us'] = "Play"; $text['label-play']['es-cl'] = "Reproducir"; $text['label-play']['pt-pt'] = "Tocar"; diff --git a/app/phrases/phrase_edit.php b/app/phrases/phrase_edit.php index 53f57500e5..b048515d99 100644 --- a/app/phrases/phrase_edit.php +++ b/app/phrases/phrase_edit.php @@ -138,14 +138,14 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "'".$phrase_detail_uuid."', "; $sql .= "'".$phrase_uuid."', "; $sql .= "'".$domain_uuid."', "; - $sql .= "'".$_POST['phrase_detail_order']."', "; - $sql .= "'".$_POST['phrase_detail_tag']."', "; - $sql .= "'".$_POST['phrase_detail_pattern']."', "; - $sql .= "'".$_POST['phrase_detail_function']."', "; - $sql .= "'".$_POST['phrase_detail_data']."', "; - $sql .= "'".$_POST['phrase_detail_method']."', "; - $sql .= "'".$_POST['phrase_detail_type']."', "; - $sql .= "'".$_POST['phrase_detail_group']."' "; + $sql .= "'".check_str($_POST['phrase_detail_order'])."', "; + $sql .= "'".check_str($_POST['phrase_detail_tag'])."', "; + $sql .= "'".check_str($_POST['phrase_detail_pattern'])."', "; + $sql .= "'".check_str($_POST['phrase_detail_function'])."', "; + $sql .= "'".check_str($_POST['phrase_detail_data'])."', "; + $sql .= "'".check_str($_POST['phrase_detail_method'])."', "; + $sql .= "'".check_str($_POST['phrase_detail_type'])."', "; + $sql .= "'".check_str($_POST['phrase_detail_group'])."' "; $sql .= ") "; //echo $sql."

"; $db->exec(check_sql($sql)); @@ -206,14 +206,14 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "'".$phrase_detail_uuid."', "; $sql .= "'".$phrase_uuid."', "; $sql .= "'".$domain_uuid."', "; - $sql .= "'".$_POST['phrase_detail_order']."', "; - $sql .= "'".$_POST['phrase_detail_tag']."', "; - $sql .= "'".$_POST['phrase_detail_pattern']."', "; - $sql .= "'".$_POST['phrase_detail_function']."', "; - $sql .= "'".$_POST['phrase_detail_data']."', "; - $sql .= "'".$_POST['phrase_detail_method']."', "; - $sql .= "'".$_POST['phrase_detail_type']."', "; - $sql .= "'".$_POST['phrase_detail_group']."' "; + $sql .= "'".check_str($_POST['phrase_detail_order'])."', "; + $sql .= "'".check_str($_POST['phrase_detail_tag'])."', "; + $sql .= "'".check_str($_POST['phrase_detail_pattern'])."', "; + $sql .= "'".check_str($_POST['phrase_detail_function'])."', "; + $sql .= "'".check_str($_POST['phrase_detail_data'])."', "; + $sql .= "'".check_str($_POST['phrase_detail_method'])."', "; + $sql .= "'".check_str($_POST['phrase_detail_type'])."', "; + $sql .= "'".check_str($_POST['phrase_detail_group'])."' "; $sql .= ") "; //echo $sql."

"; $db->exec(check_sql($sql)); @@ -244,7 +244,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //pre-populate the form if (count($_GET)>0 && $_POST["persistformvar"] != "true") { - $phrase_uuid = $_GET["id"]; + $phrase_uuid = check_str($_GET["id"]); $sql = "select * from v_phrases "; $sql .= "where domain_uuid = '".$domain_uuid."' "; $sql .= "and phrase_uuid = '".$phrase_uuid."' "; @@ -266,6 +266,136 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { if ($action == 'add') { $document['title'] = $text['title-add_phrase']; } if ($action == 'update') { $document['title'] = $text['title-edit_phrase']; } +//js to control action form input + echo "\n"; + //show the content echo "
\n"; echo "\n"; @@ -304,37 +434,6 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; - if (if_group("superadmin")) { - echo "\n"; - echo "\n"; - } echo ""; echo ""; echo "\n"; - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
".$text['label-structure'].""; @@ -355,9 +454,27 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result_count = count($result); foreach($result as $field) { + //clean up output for display + if ($_SESSION['recordings']['storage_type']['text'] == 'base64') { + if ($field['phrase_detail_function'] == 'execute' && substr($field['phrase_detail_data'], 0, 19) == 'lua(streamfile.lua ') { + $phrase_detail_function = $text['label-play']; + $phrase_detail_data = str_replace('lua(streamfile.lua ', '', $field['phrase_detail_data']); + $phrase_detail_data = str_replace(')', '', $phrase_detail_data); + } + } + if ($field['phrase_detail_function'] == 'execute' && substr($field['phrase_detail_data'], 0, 6) == 'sleep(') { + $phrase_detail_function = $text['label-pause']; + $phrase_detail_data = str_replace('sleep(', '', $field['phrase_detail_data']); + $phrase_detail_data = str_replace(')', '', $phrase_detail_data); + $phrase_detail_data = ($phrase_detail_data / 1000).'s'; // seconds + } + if ($field['phrase_detail_function'] == 'play-file') { + $phrase_detail_function = $text['label-play']; + $phrase_detail_data = $field['phrase_detail_data']; + } echo "
".$field['phrase_detail_function']." ".$field['phrase_detail_data']." ".$phrase_detail_function." ".$phrase_detail_data." ".$field['phrase_detail_order']." "; echo "".$v_link_label_delete.""; @@ -368,60 +485,25 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { unset($sql, $result); echo "
\n"; - echo " \n"; if ($_SESSION['recordings']['storage_type']['text'] == 'base64') { - echo " \n"; + echo " \n"; } else { - echo " \n"; + echo " \n"; } + echo " \n"; if (if_group("superadmin")) { - echo " \n"; + echo " \n"; } echo " \n"; echo " \n"; - echo " \n"; + echo " "; + if (if_group("superadmin")) { + echo " \n"; + } + echo " \n"; echo " \n"; echo "