mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-02-01 05:29:18 +00:00
* Update macro.lua Add additional macros for the tutorial. * Create tutorial.lua * Update index.lua * Update record_greeting.lua Add menu variable to route back to appropriate place in the flow. * Update record_menu.lua Add menu variable to accommodate the tutorial. * Update change_password.lua Add menu variable to accommodate the tutorial. * Update record_name.lua Add menu variable to accommodate the tutorial. * Update voicemail_edit.php Add option to play tutorial on next login. * Update app_languages.php * Update app_config.php Add voicemail_tutorial to database. * Update extension_edit.php Set "voicemail_tutorial" to true for new extensions.
198 lines
6.4 KiB
Lua
198 lines
6.4 KiB
Lua
-- Part of FusionPBX
|
|
-- Copyright (C) 2013 Mark J Crane <markjcrane@fusionpbx.com>
|
|
-- 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
|