From edf06bf6f7d4f20d5a9145a5bbf8db409fe6ab1b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 2 Apr 2013 13:14:07 +0200 Subject: pin changing dialog added --- misc/freeswitch/scripts/dialplan/voicemail.lua | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'misc/freeswitch/scripts/dialplan/voicemail.lua') diff --git a/misc/freeswitch/scripts/dialplan/voicemail.lua b/misc/freeswitch/scripts/dialplan/voicemail.lua index e955101..e5579f8 100644 --- a/misc/freeswitch/scripts/dialplan/voicemail.lua +++ b/misc/freeswitch/scripts/dialplan/voicemail.lua @@ -135,9 +135,6 @@ end function Voicemail.menu_main(self, caller, authorized) - -- authorized = false; - self.settings.pin = '1234'; - self.caller = caller; require 'dialplan.ivr'; @@ -430,4 +427,25 @@ function Voicemail.pin_change(self) self.caller:send_display('Enter new PIN'); digits = self.ivr:read_phrase('voicemail_enter_pass', nil, self.settings.pin_length_max, self.settings.pin_length_min, self.settings.pin_timeout, self.settings.terminator_key); end + + if digits:len() < self.settings.pin_length_min or digits:len() > self.settings.pin_length_max then + self.caller:send_display('PIN not changed'); + return false; + end + + local sql_query = 'UPDATE `voicemail_settings` \ + SET `value` = ' .. self.database:escape(digits, '"') .. ', `class_type` = "String", `updated_at` = NOW() \ + WHERE `name`="pin" AND `voicemail_account_id` = ' .. self.id; + if not self.settings.pin then + sql_query = 'INSERT INTO `voicemail_settings` \ + (`voicemail_account_id`, `name`, `value`, `class_type`, `description`, `created_at`, `updated_at`) \ + VALUES (' .. self.id .. ', "pin", "' .. digits .. '", "String", "Voicemail PIN", NOW(), NOW())'; + end + + if self.database:query(sql_query) then + self.settings.pin = digits; + self.caller:send_display('PIN changed'); + self.caller.session:sayPhrase('voicemail_change_pass_success'); + return true; + end end -- cgit v1.2.3