From 6a93b03cd99575037c95aa69853a67752afe0a87 Mon Sep 17 00:00:00 2001 From: Chris Black Date: Wed, 4 May 2016 16:03:01 -0700 Subject: [PATCH] Allow outside transcription service to be called (#1578) Allows users to create a function called get_transcription that they can use to call any transcription service such as AT&T, Google, iSpeech, etc and return just the translated text to be included in the email. --- secure/v_mailto.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/secure/v_mailto.php b/secure/v_mailto.php index 63bb485b3b..51e7865a3d 100644 --- a/secure/v_mailto.php +++ b/secure/v_mailto.php @@ -79,6 +79,10 @@ //includes require('resources/pop3/mime_parser.php'); require('resources/pop3/rfc822_addresses.php'); + + if (file_exists($_SERVER["PROJECT_ROOT"]."/app/emails/email_translation.php")) { + require_once($_SERVER["PROJECT_ROOT"]."/app/emails/email_translation.php"); + } //parse the email message $mime=new mime_parser_class; @@ -282,6 +286,13 @@ //add an attachment $mail->AddStringAttachment($parts_array["Body"],$file,$encoding,$mime_type); + if (function_exists(get_transcription)) { + $attachments_array=$mail->GetAttachments(); + $transcription=get_transcription($attachments_array[0]); + echo "Transcription: " . $transcription; + } else { + $transcription = ''; + } } } } @@ -291,13 +302,13 @@ //echo "body_plain = $body_plain\n"; if ((substr($body, 0, 5) == "ContentType = "text/html"; - $mail->Body = $body; - $mail->AltBody = $body_plain; + $mail->Body = $body."

".nl2br($transcription); + $mail->AltBody = $body_plain."\n\n$transcription"; } else { // $mail->Body = ($body != '') ? $body : $body_plain; - $mail->Body = $body_plain; - $mail->AltBody = $body_plain; + $mail->Body = $body_plain."\n\n$transcription"; + $mail->AltBody = $body_plain."\n\n$transcription"; } //send the email