diff --git a/app/extensions/extension_edit.php b/app/extensions/extension_edit.php index bea82718e6..ea69656f43 100644 --- a/app/extensions/extension_edit.php +++ b/app/extensions/extension_edit.php @@ -385,6 +385,7 @@ //if voicemail_uuid does not exist then get a new uuid if (!isset($voicemail_uuid)) { $voicemail_uuid = uuid(); + $voicemail_tutorial = 'true'; } //add the voicemail @@ -403,6 +404,7 @@ $voicemail_description = $description; } $array["voicemails"][$i]["voicemail_description"] = $voicemail_description; + $array["voicemails"][$i]["voicemail_tutorial"] = $voicemail_tutorial; } //increment the extension number @@ -650,6 +652,7 @@ $voicemail_local_after_email = $row["voicemail_local_after_email"]; $voicemail_enabled = $row["voicemail_enabled"]; $voicemail_description = $row["voicemail_description"]; + $voicemail_tutorial = $row["voicemail_tutorial"]; } unset ($prep_statement); //clean the variables diff --git a/app/voicemails/app_config.php b/app/voicemails/app_config.php index 016d071543..580b508907 100644 --- a/app/voicemails/app_config.php +++ b/app/voicemails/app_config.php @@ -200,6 +200,10 @@ $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "voicemail_tutorial"; + $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; + $z++; $y++; $apps[$x]['db'][$y]['table']['name'] = "v_voicemail_messages"; diff --git a/app/voicemails/app_languages.php b/app/voicemails/app_languages.php index b2db1b64b8..53b00adeb7 100644 --- a/app/voicemails/app_languages.php +++ b/app/voicemails/app_languages.php @@ -245,6 +245,17 @@ $text['label-voicemail_description']['uk'] = "Опис"; $text['label-voicemail_description']['de-at'] = "Beschreibung"; $text['label-voicemail_description']['he'] = "תאור"; +$text['label-voicemail_tutorial']['en-us'] = "Play Tutorial"; +$text['label-voicemail_tutorial']['es-cl'] = ""; +$text['label-voicemail_tutorial']['pt-pt'] = ""; +$text['label-voicemail_tutorial']['fr-fr'] = ""; +$text['label-voicemail_tutorial']['pt-br'] = ""; +$text['label-voicemail_tutorial']['pl'] = ""; +$text['label-voicemail_tutorial']['sv-se'] = ""; +$text['label-voicemail_tutorial']['uk'] = ""; +$text['label-voicemail_tutorial']['de-at'] = ""; +$text['label-voicemail_tutorial']['he'] = ""; + $text['label-tools']['en-us'] = "Tools"; $text['label-tools']['es-cl'] = "Herramientas"; $text['label-tools']['pt-pt'] = "Ferramentas"; @@ -753,6 +764,17 @@ $text['description-caller_id_name']['uk'] = "Caller ID Ім’я"; $text['description-caller_id_name']['de-at'] = "Anruferkennung (Name)"; $text['description-caller_id_name']['he'] = ""; +$text['description-voicemail_tutorial']['en-us'] = "Play the voicemail tutorial after the next voicemail login."; +$text['description-voicemail_tutorial']['es-cl'] = ""; +$text['description-voicemail_tutorial']['pt-pt'] = ""; +$text['description-voicemail_tutorial']['fr-fr'] = ""; +$text['description-voicemail_tutorial']['pt-br'] = ""; +$text['description-voicemail_tutorial']['pl'] = ""; +$text['description-voicemail_tutorial']['sv-se'] = ""; +$text['description-voicemail_tutorial']['uk'] = ""; +$text['description-voicemail_tutorial']['de-at'] = ""; +$text['description-voicemail_tutorial']['he'] = ""; + $text['button-toggle']['en-us'] = "Toggle"; $text['button-toggle']['es-cl'] = "Palanca"; $text['button-toggle']['pt-pt'] = "Alternar"; diff --git a/app/voicemails/voicemail_edit.php b/app/voicemails/voicemail_edit.php index 0b4ab712cb..ed5681691e 100644 --- a/app/voicemails/voicemail_edit.php +++ b/app/voicemails/voicemail_edit.php @@ -68,6 +68,7 @@ $voicemail_local_after_email = check_str($_POST["voicemail_local_after_email"]); $voicemail_enabled = check_str($_POST["voicemail_enabled"]); $voicemail_description = check_str($_POST["voicemail_description"]); + $voicemail_tutorial = check_str($_POST["voicemail_tutorial"]); //remove the space $voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to); @@ -153,6 +154,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "voicemail_mail_to, "; $sql .= "voicemail_sms_to, "; $sql .= "voicemail_transcription_enabled, "; + $sql .= "voicemail_tutorial, "; $sql .= "voicemail_file, "; $sql .= "voicemail_local_after_email, "; $sql .= "voicemail_enabled, "; @@ -169,6 +171,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "'".$voicemail_mail_to."', "; $sql .= "'".$voicemail_sms_to."', "; $sql .= "'".$voicemail_transcription_enabled."', "; + $sql .= "'".$voicemail_tutorial."', "; $sql .= "'".$voicemail_file."', "; $sql .= "'".$voicemail_local_after_email."', "; $sql .= "'".$voicemail_enabled."', "; @@ -189,6 +192,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "voicemail_mail_to = '".$voicemail_mail_to."', "; $sql .= "voicemail_sms_to = '".$voicemail_sms_to."', "; $sql .= "voicemail_transcription_enabled = '".$voicemail_transcription_enabled."', "; + $sql .= "voicemail_tutorial = '".$voicemail_tutorial."', "; $sql .= "voicemail_file = '".$voicemail_file."', "; $sql .= "voicemail_local_after_email = '".$voicemail_local_after_email."', "; $sql .= "voicemail_enabled = '".$voicemail_enabled."', "; @@ -287,6 +291,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $voicemail_mail_to = $row["voicemail_mail_to"]; $voicemail_sms_to = $row["voicemail_sms_to"]; $voicemail_transcription_enabled = $row["voicemail_transcription_enabled"]; + $voicemail_tutorial = $row["voicemail_tutorial"]; $voicemail_file = $row["voicemail_file"]; $voicemail_local_after_email = $row["voicemail_local_after_email"]; $voicemail_enabled = $row["voicemail_enabled"]; @@ -360,6 +365,20 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; + echo " ".$text['label-voicemail_tutorial']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-voicemail_tutorial']."\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo " ".$text['label-greeting']."\n"; diff --git a/resources/install/scripts/app/voicemail/index.lua b/resources/install/scripts/app/voicemail/index.lua index 3340b00b5d..98c1e98d0b 100644 --- a/resources/install/scripts/app/voicemail/index.lua +++ b/resources/install/scripts/app/voicemail/index.lua @@ -200,6 +200,7 @@ voicemail_attach_file = row["voicemail_attach_file"]; voicemail_local_after_email = row["voicemail_local_after_email"]; voicemail_transcription_enabled = row["voicemail_transcription_enabled"]; + voicemail_tutorial = row["voicemail_tutorial"]; end); --set default values if (voicemail_local_after_email == nil) then @@ -264,6 +265,7 @@ require "app.voicemail.resources.functions.record_name"; require "app.voicemail.resources.functions.message_count" require "app.voicemail.resources.functions.mwi_notify"; + require "app.voicemail.resources.functions.tutorial"; --send a message waiting event if (voicemail_action == "mwi") then @@ -314,7 +316,11 @@ --send to the main menu timeouts = 0; - main_menu(); + if (voicemail_tutorial == "true") then + tutorial("intro"); + else + main_menu(); + end end end diff --git a/resources/install/scripts/app/voicemail/resources/functions/change_password.lua b/resources/install/scripts/app/voicemail/resources/functions/change_password.lua index 0b6bab9f0a..a9ae10d437 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/change_password.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/change_password.lua @@ -24,7 +24,7 @@ -- POSSIBILITY OF SUCH DAMAGE. --check the voicemail password - function change_password(voicemail_id) + function change_password(voicemail_id, menu) if (session:ready()) then --flush dtmf digits from the input buffer session:flushDigits(); @@ -48,6 +48,11 @@ macro(session, "password_changed", 20, 3000, password); --advanced menu timeouts = 0; - advanced(); + if (menu == "advanced") then + advanced(); + end + if (menu == "tutorial") then + tutorial("record_greeting"); + end end - end \ No newline at end of file + end diff --git a/resources/install/scripts/app/voicemail/resources/functions/macro.lua b/resources/install/scripts/app/voicemail/resources/functions/macro.lua index 2ab2b65d00..d86dc56d5b 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/macro.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/macro.lua @@ -264,7 +264,42 @@ if (name == "goodbye") then table.insert(actions, {app="streamFile",data="voicemail/vm-goodbye.wav"}); end + --Tutorial + --Tutorial intro + if (name == "tutorial_intro") then + table.insert(actions, {app="streamFile",data="voicemail/vm-tutorial_yes_no.wav"}); + end + + --Tutorial to record your name 1 + if (name == "tutorial_to_record_name") then + table.insert(actions, {app="streamFile",data="voicemail/vm-tutorial_record_name.wav"}); + table.insert(actions, {app="streamFile",data="voicemail/vm-record_name2.wav"}); + table.insert(actions, {app="streamFile",data="voicemail/vm-press.wav"}); + table.insert(actions, {app="streamFile",data="digits/1.wav"}); + end + + --Tutorial to change your password press 1 + if (name == "tutorial_change_password") then + table.insert(actions, {app="streamFile",data="voicemail/vm-tutorial_change_pin.wav"}); + table.insert(actions, {app="streamFile",data="voicemail/vm-change_password.wav"}); + table.insert(actions, {app="streamFile",data="voicemail/vm-press.wav"}); + table.insert(actions, {app="streamFile",data="digits/1.wav"}); + end + --Tutorial to record your greeting press 1 + if (name == "tutorial_record_greeting") then + table.insert(actions, {app="streamFile",data="voicemail/vm-to_record_greeting.wav"}); + table.insert(actions, {app="streamFile",data="voicemail/vm-press.wav"}); + table.insert(actions, {app="streamFile",data="digits/1.wav"}); + end + + --Tutorial To skip + if (name == "tutorial_skip") then + table.insert(actions, {app="streamFile",data="ivr/ivr-to_skip.wav"}); + table.insert(actions, {app="streamFile",data="voicemail/vm-press.wav"}); + table.insert(actions, {app="streamFile",data="digits/2.wav"}); + end + --if actions table exists then process it if (actions) then --set default values diff --git a/resources/install/scripts/app/voicemail/resources/functions/record_greeting.lua b/resources/install/scripts/app/voicemail/resources/functions/record_greeting.lua index 053637e036..ebb628b76b 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/record_greeting.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/record_greeting.lua @@ -28,7 +28,7 @@ local Settings = require "resources.functions.lazy_settings" --define a function to record the greeting - function record_greeting(greeting_id) + function record_greeting(greeting_id, menu) local db = dbh or Database.new('system') local settings = Settings.new(db, domain_name, domain_uuid) @@ -88,7 +88,7 @@ --option to play, save, and re-record the greeting if (session:ready()) then timeouts = 0; - record_menu("greeting", voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".tmp.wav", greeting_id); + record_menu("greeting", voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".tmp.wav", greeting_id, menu); end else --invalid greeting_id @@ -101,10 +101,17 @@ if (session:ready()) then timeouts = timeouts + 1; if (timeouts < max_timeouts) then - record_greeting(); + record_greeting(nil, menu); else timeouts = 0; - advanced(); + if (menu == "tutorial") then + tutorial("finish") + end + if (menu == "advanced") then + advanced(); + else + advanced(); + end end end end @@ -116,4 +123,4 @@ end end - end \ No newline at end of file + end diff --git a/resources/install/scripts/app/voicemail/resources/functions/record_menu.lua b/resources/install/scripts/app/voicemail/resources/functions/record_menu.lua index 86f0a01759..864f2c7704 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/record_menu.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/record_menu.lua @@ -24,7 +24,7 @@ -- POSSIBILITY OF SUCH DAMAGE. --record message menu - function record_menu(type, tmp_file, greeting_id) + function record_menu(type, tmp_file, greeting_id, menu) if (session:ready()) then --clear the dtmf digits variable dtmf_digits = ''; @@ -55,7 +55,7 @@ session:streamFile(tmp_file); --session:streamFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext); --record menu (1=listen, 2=save, 3=re-record) - record_menu(type, tmp_file, greeting_id); + record_menu(type, tmp_file, greeting_id, menu); elseif (dtmf_digits == "2") then --save the message dtmf_digits = ''; @@ -161,10 +161,21 @@ voicemail_id = voicemail_id}; dbh:query(sql, params); - advanced(); + if (menu == "advanced") then + advanced(); + end + if (menu == "tutorial") then + tutorial("finish") + end end if (type == "name") then - advanced(); + if (menu == "advanced") then + advanced(); + end + if (menu == "tutorial") then + tutorial("change_password") + end + end elseif (dtmf_digits == "3") then --re-record the message @@ -178,10 +189,10 @@ if (file_exists(tmp_file)) then os.remove(tmp_file); end - record_greeting(greeting_id); + record_greeting(greeting_id, menu); end if (type == "name") then - record_name(); + record_name(menu); end elseif (dtmf_digits == "*") then if (type == "greeting") then @@ -200,7 +211,7 @@ if (session:ready()) then timeouts = timeouts + 1; if (timeouts < max_timeouts) then - record_menu(type, tmp_file, greeting_id); + record_menu(type, tmp_file, greeting_id, menu); else if (type == "message") then dtmf_digits = ''; @@ -213,10 +224,20 @@ if (file_exists(tmp_file)) then os.remove(tmp_file); end - advanced(); + if (menu == "advanced") then + advanced(); + end + if (menu == "tutorial") then + tutorial("finish") + end end if (type == "name") then - advanced(); + if (menu == "advanced") then + advanced(); + end + if (menu == "tutorial") then + tutorial("change_password") + end end end end diff --git a/resources/install/scripts/app/voicemail/resources/functions/record_name.lua b/resources/install/scripts/app/voicemail/resources/functions/record_name.lua index f6036947c4..549340db89 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/record_name.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/record_name.lua @@ -24,7 +24,7 @@ -- POSSIBILITY OF SUCH DAMAGE. --define a function to record the name - function record_name() + function record_name(menu) if (session:ready()) then --flush dtmf digits from the input buffer @@ -92,7 +92,7 @@ --option to play, save, and re-record the name if (session:ready()) then timeouts = 0; - record_menu("name", voicemail_dir.."/"..voicemail_id.."/recorded_name.wav"); + record_menu("name", voicemail_dir.."/"..voicemail_id.."/recorded_name.wav",nil, menu); if (storage_type == "base64") then --delete the greeting os.remove(voicemail_dir.."/"..voicemail_id.."/recorded_name.wav"); diff --git a/resources/install/scripts/app/voicemail/resources/functions/tutorial.lua b/resources/install/scripts/app/voicemail/resources/functions/tutorial.lua new file mode 100644 index 0000000000..414220ffe7 --- /dev/null +++ b/resources/install/scripts/app/voicemail/resources/functions/tutorial.lua @@ -0,0 +1,197 @@ +-- Part of FusionPBX +-- Copyright (C) 2013 Mark J Crane +-- All rights reserved. +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions are met: +-- +-- 1. Redistributions of source code must retain the above copyright notice, +-- this list of conditions and the following disclaimer. +-- +-- 2. Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- +-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +-- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +-- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +-- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +-- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +-- POSSIBILITY OF SUCH DAMAGE. + +--define function main menu + function tutorial (menu) + if (voicemail_uuid) then + --intro menu + if (menu == "intro") then + --clear the value + dtmf_digits = ''; + --flush dtmf digits from the input buffer + session:flushDigits(); + --play the tutorial press 1, to skip 2 + if (session:ready()) then + if (string.len(dtmf_digits) == 0) then + dtmf_digits = macro(session, "tutorial_intro", 1, 3000, ''); + end + end + --process the dtmf + if (session:ready()) then + if (dtmf_digits == "1") then + timeouts = 0; + tutorial("record_name"); + elseif (dtmf_digits == "2") then + timeouts = 0; + tutorial("finish"); + else + if (session:ready()) then + timeouts = timeouts + 1; + if (timeouts < max_timeouts) then + tutorial("intro"); + else + timeouts = 0; + tutorial("finish"); + end + end + end + end + end + --record name menu + if (menu == "record_name") then + --clear the value + dtmf_digits = ''; + --flush dtmf digits from the input buffer + session:flushDigits(); + --play the record name press 1 + if (session:ready()) then + if (string.len(dtmf_digits) == 0) then + dtmf_digits = macro(session, "tutorial_to_record_name", 1, 100, ''); + end + end + --skip the name and go to password press 2 + if (session:ready()) then + if (string.len(dtmf_digits) == 0) then + dtmf_digits = macro(session, "tutorial_skip", 1, 3000, ''); + end + end + --process the dtmf + if (session:ready()) then + if (dtmf_digits == "1") then + timeouts = 0; + record_name("tutorial"); + elseif (dtmf_digits == "2") then + timeouts = 0; + tutorial("change_password"); + else + if (session:ready()) then + timeouts = timeouts + 1; + if (timeouts < max_timeouts) then + tutorial("record_name"); + else + tutorial("change_password"); + end + end + end + end + end + --change password menu + if (menu == "change_password") then + --clear the value + dtmf_digits = ''; + --flush dtmf digits from the input buffer + session:flushDigits(); + --to change your password press 1 + if (session:ready()) then + if (string.len(dtmf_digits) == 0) then + dtmf_digits = macro(session, "tutorial_change_password", 1, 100, ''); + end + end + --skip the password and go to greeting press 2 + if (session:ready()) then + if (string.len(dtmf_digits) == 0) then + dtmf_digits = macro(session, "tutorial_skip", 1, 3000, ''); + end + end + --process the dtmf + if (session:ready()) then + if (dtmf_digits == "1") then + timeouts = 0; + change_password(voicemail_id, "tutorial"); + elseif (dtmf_digits == "2") then + timeouts = 0; + tutorial("record_greeting"); + else + if (session:ready()) then + timeouts = timeouts + 1; + if (timeouts < max_timeouts) then + tutorial("change_password"); + else + tutorial("record_greeting"); + end + end + end + end + end + --change greeting menu + if (menu == "record_greeting") then + --clear the value + dtmf_digits = ''; + --flush dtmf digits from the input buffer + session:flushDigits(); + --to record a greeting press 1 + if (session:ready()) then + if (string.len(dtmf_digits) == 0) then + dtmf_digits = macro(session, "tutorial_record_greeting", 1, 100, ''); + end + end + --skip the record greeting press 2. finishes the tutorial and routes to main menu + if (session:ready()) then + if (string.len(dtmf_digits) == 0) then + dtmf_digits = macro(session, "tutorial_skip", 1, 3000, ''); + end + end + --process the dtmf + if (session:ready()) then + if (dtmf_digits == "1") then + timeouts = 0; + record_greeting(nil, "tutorial"); + elseif (dtmf_digits == "2") then + timeouts = 0; + tutorial("finish"); + else + if (session:ready()) then + timeouts = timeouts + 1; + if (timeouts < max_timeouts) then + tutorial("record_greeting"); + else + tutorial("finish"); + end + end + end + end + end + if (menu == "finish") then + --clear the value + dtmf_digits = ''; + --flush dtmf digits from the input buffer + session:flushDigits(); + --update play tutorial in the datebase + local sql = [[UPDATE v_voicemails + set voicemail_tutorial = 'false' + WHERE domain_uuid = :domain_uuid + AND voicemail_id = :voicemail_id + AND voicemail_enabled = 'true' ]]; + local params = {domain_uuid = domain_uuid, + voicemail_id = voicemail_id}; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n"); + end + dbh:query(sql, params); + --go to main menu + main_menu(); + end + end + end