diff options
author | Peter Kozak <spag@golwen.net> | 2013-04-02 13:14:07 +0200 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-04-02 13:14:07 +0200 |
commit | edf06bf6f7d4f20d5a9145a5bbf8db409fe6ab1b (patch) | |
tree | 0e1cb173e5fab84fa47b106d30aa956d6a28bdd9 /misc/freeswitch/scripts/dialplan | |
parent | deae02d7ae971da152da39193c89ee2b85d6207e (diff) |
pin changing dialog added
Diffstat (limited to 'misc/freeswitch/scripts/dialplan')
-rw-r--r-- | misc/freeswitch/scripts/dialplan/voicemail.lua | 24 |
1 files changed, 21 insertions, 3 deletions
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 |