From 848569453706c91ce3b1719263e656fb35010fae Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Sun, 15 Mar 2015 09:15:04 +0000 Subject: [PATCH] Voicemail: - Adjust for single-quotes in caller_id_name on insert query (hopefully addressing Issue 877). - If Keep Local is false, remove the recording from the file system. - Fix Forward Destinations so message is fully copied to other extension voicemail boxes, not just emailed. - Add script to Ext and VM Edit pages to prevent Listen or Download links being sent when Keep Local is false. - Minor language mods. --- app/extensions/app_languages.php | 10 +++---- app/extensions/extension_edit.php | 4 +-- app/voicemails/app_languages.php | 10 +++---- app/voicemails/voicemail_edit.php | 4 +-- .../install/scripts/app/voicemail/index.lua | 30 ++++++++++++------- .../resources/functions/send_email.lua | 10 +++++-- 6 files changed, 40 insertions(+), 28 deletions(-) diff --git a/app/extensions/app_languages.php b/app/extensions/app_languages.php index c7072394da..6f8206157f 100644 --- a/app/extensions/app_languages.php +++ b/app/extensions/app_languages.php @@ -65,7 +65,7 @@ $text['label-voicemail_mail_to']['es-cl'] = "Enviar correo de voz a"; $text['label-voicemail_mail_to']['pt-pt'] = "Enviar correio de voz para"; $text['label-voicemail_mail_to']['fr-fr'] = "Courriel destination"; -$text['label-voicemail_local_after_email']['en-us'] = "VM Keep Local After Email"; +$text['label-voicemail_local_after_email']['en-us'] = "Voicemail Keep Local"; $text['label-voicemail_local_after_email']['es-cl'] = "Mantener Mensaje de Voz despues de enviar por Email"; $text['label-voicemail_local_after_email']['pt-pt'] = "Manter mensagem de correio de voz depois de enviado o email"; $text['label-voicemail_local_after_email']['fr-fr'] = "Message gardé en local après courriel"; @@ -380,10 +380,10 @@ $text['description-voicemail_mail_to']['es-cl'] = "Ingrese una dirección de cor $text['description-voicemail_mail_to']['pt-pt'] = "Introduza o endereço de email para enviar o correio de voz (opcional)."; $text['description-voicemail_mail_to']['fr-fr'] = "Insérer le courriel où sera envoyé le message de notification (optionnel)."; -$text['description-voicemail_local_after_email']['en-us'] = "Keep local file after sending the email."; -$text['description-voicemail_local_after_email']['es-cl'] = "Mantener el archivo de forma local despues de enviar por correo electrónico."; -$text['description-voicemail_local_after_email']['pt-pt'] = "Manter o ficheiro local depois de enviar o email."; -$text['description-voicemail_local_after_email']['fr-fr'] = "Conserver ou non le message sur la messagerie vocale après l'envoi du courriel."; +$text['description-voicemail_local_after_email']['en-us'] = "Choose whether to keep the voicemail in the system after sending the email notification."; +$text['description-voicemail_local_after_email']['es-cl'] = "Escoja si desea mantener el buzón de voz en el sistema después de enviar la notificación por correo electrónico."; +$text['description-voicemail_local_after_email']['pt-pt'] = "Escolha se quer manter o correio de voz no sistema após o envio da notificação de e-mail."; +$text['description-voicemail_local_after_email']['fr-fr'] = "Choisissez si vous voulez garder la messagerie vocale dans le système après l'envoi de la notification par email."; $text['description-voicemail_enabled']['en-us'] = "Enable/disable voicemail for this extension."; $text['description-voicemail_enabled']['es-cl'] = "Activar/desactivar el correo de voz para esta extensión."; diff --git a/app/extensions/extension_edit.php b/app/extensions/extension_edit.php index ba6769f779..fe69e1809c 100644 --- a/app/extensions/extension_edit.php +++ b/app/extensions/extension_edit.php @@ -1486,7 +1486,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " ".$text['label-voicemail_file']."\n"; echo "\n"; echo "\n"; - echo " \n"; echo " \n"; echo " \n"; echo " \n"; @@ -1501,7 +1501,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " ".$text['label-voicemail_local_after_email']."\n"; echo "\n"; echo "\n"; - echo " \n"; if ($voicemail_local_after_email == "true") { echo " \n"; } diff --git a/app/voicemails/app_languages.php b/app/voicemails/app_languages.php index bc67986647..a493f592e9 100644 --- a/app/voicemails/app_languages.php +++ b/app/voicemails/app_languages.php @@ -96,15 +96,15 @@ $text['label-voicemail_file_attached']['pt-pt'] = "Ligado"; $text['label-voicemail_file_attached']['fr-fr'] = "Attaché"; - $text['label-voicemail_local_after_email']['en-us'] = "Local After Email"; + $text['label-voicemail_local_after_email']['en-us'] = "Keep Local"; $text['label-voicemail_local_after_email']['es-cl'] = "Conservar después de enviar"; $text['label-voicemail_local_after_email']['pt-pt'] = "Conservar Mensagem de Voz"; $text['label-voicemail_local_after_email']['fr-fr'] = "Conserver le message"; - $text['description-voicemail_local_after_email']['en-us'] = "Choose to keep the voicemail file after sending the email."; - $text['description-voicemail_local_after_email']['es-cl'] = "Indique si desea conservar el archivo despues de enviarlo por correo."; - $text['description-voicemail_local_after_email']['pt-pt'] = "Escolha se pretende manter o ficheiro de correio de voz depois de enviar email."; - $text['description-voicemail_local_after_email']['fr-fr'] = "Garder le message vocal dans la boite vocale après l'envoi du courriel."; + $text['description-voicemail_local_after_email']['en-us'] = "Choose whether to keep the voicemail in the system after sending the email notification."; + $text['description-voicemail_local_after_email']['es-cl'] = "Escoja si desea mantener el buzón de voz en el sistema después de enviar la notificación por correo electrónico."; + $text['description-voicemail_local_after_email']['pt-pt'] = "Escolha se quer manter o correio de voz no sistema após o envio da notificação de e-mail."; + $text['description-voicemail_local_after_email']['fr-fr'] = "Choisissez si vous voulez garder la messagerie vocale dans le système après l'envoi de la notification par email."; $text['label-forward_destinations']['en-us'] = "Forward Destinations"; $text['label-forward_destinations']['es-cl'] = "Destinos Adelante"; diff --git a/app/voicemails/voicemail_edit.php b/app/voicemails/voicemail_edit.php index faa21d905a..997f9b3300 100644 --- a/app/voicemails/voicemail_edit.php +++ b/app/voicemails/voicemail_edit.php @@ -448,7 +448,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " ".$text['label-voicemail_file']."\n"; echo "\n"; echo "\n"; - echo " \n"; echo " \n"; echo " \n"; echo " \n"; @@ -463,7 +463,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " ".$text['label-voicemail_local_after_email']."\n"; echo "\n"; echo "\n"; - echo " \n"; if ($voicemail_local_after_email == "true") { echo " \n"; } diff --git a/resources/install/scripts/app/voicemail/index.lua b/resources/install/scripts/app/voicemail/index.lua index 4bab4ef86c..cc10fc300d 100644 --- a/resources/install/scripts/app/voicemail/index.lua +++ b/resources/install/scripts/app/voicemail/index.lua @@ -293,8 +293,11 @@ --loop through the voicemail destinations for key,row in pairs(destinations) do + --get a new uuid + voicemail_message_uuid = api:execute("create_uuid"); --save the message to the voicemail messages if (tonumber(message_length) > 2) then + caller_id_name = string.gsub(caller_id_name,"'","''"); local sql = {} table.insert(sql, "INSERT INTO v_voicemail_messages "); table.insert(sql, "("); @@ -310,15 +313,15 @@ table.insert(sql, ") "); table.insert(sql, "VALUES "); table.insert(sql, "( "); - table.insert(sql, "'".. uuid .."', "); - table.insert(sql, "'".. domain_uuid .."', "); - table.insert(sql, "'".. row.voicemail_uuid_copy .."', "); - table.insert(sql, "'".. start_epoch .."', "); - table.insert(sql, "'".. caller_id_name .."', "); - table.insert(sql, "'".. caller_id_number .."', "); - table.insert(sql, "'".. message_length .."' "); - --table.insert(sql, "'".. message_status .."', "); - --table.insert(sql, "'".. message_priority .."' "); + table.insert(sql, "'"..voicemail_message_uuid.."', "); + table.insert(sql, "'"..domain_uuid.."', "); + table.insert(sql, "'"..row.voicemail_uuid_copy.."', "); + table.insert(sql, "'"..start_epoch.."', "); + table.insert(sql, "'"..caller_id_name.."', "); + table.insert(sql, "'"..caller_id_number.."', "); + table.insert(sql, "'"..message_length.."' "); + --table.insert(sql, "'"..message_status.."', "); + --table.insert(sql, "'"..message_priority.."' "); table.insert(sql, ") "); sql = table.concat(sql, "\n"); if (debug["sql"]) then @@ -364,7 +367,7 @@ --copy the voicemail to each destination if (file_exists(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext)) then - os.execute("cp "..voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext.." "..voicemail_dir.."/"..voicemail_id_copy.."/msg_"..uuid.."."..vm_message_ext); + os.execute("cp "..voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext.." "..voicemail_dir.."/"..voicemail_id_copy.."/msg_"..voicemail_message_uuid.."."..vm_message_ext); end --set the message waiting event @@ -378,9 +381,14 @@ --send the email with the voicemail recording attached if (tonumber(message_length) > 2) then - send_email(voicemail_id_copy, uuid); + send_email(voicemail_id_copy, voicemail_message_uuid); end end + + --remove initial recording file + if (file_exists(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext)) then + os.remove(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext); + end else --voicemail not enabled or does not exist diff --git a/resources/install/scripts/app/voicemail/resources/functions/send_email.lua b/resources/install/scripts/app/voicemail/resources/functions/send_email.lua index 5829202c7b..5d3bba5b34 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/send_email.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/send_email.lua @@ -133,13 +133,13 @@ body = trim(body); --send the email + file = voicemail_dir.."/"..id.."/msg_"..uuid.."."..vm_message_ext; if (voicemail_file == "attach") then if (voicemail_local_after_email == "false") then delete = "true"; else delete = "false"; end - file = voicemail_dir.."/"..id.."/msg_"..uuid.."."..vm_message_ext; cmd = "luarun email.lua "..voicemail_mail_to.." "..voicemail_mail_to.." "..headers.." '"..subject.."' '"..body.."' '"..file.."' "..delete; else cmd = "luarun email.lua "..voicemail_mail_to.." "..voicemail_mail_to.." "..headers.." '"..subject.."' '"..body.."'"; @@ -152,8 +152,8 @@ end --whether to keep the voicemail message and details local after email - if (voicemail_mail_to) then - if (voicemail_local_after_email == "false" and string.len(voicemail_mail_to) > 0) then + if (string.len(voicemail_mail_to) > 2) then + if (voicemail_local_after_email == "false") then --delete the voicemail message details sql = [[DELETE FROM v_voicemail_messages WHERE domain_uuid = ']] .. domain_uuid ..[[' @@ -163,6 +163,10 @@ freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n"); end status = dbh:query(sql); + --delete voicemail recording file + if (file_exists(file)) then + os.remove(file); + end --set message waiting indicator message_waiting(id, domain_uuid); --clear the variable