diff --git a/app/fax/app_config.php b/app/fax/app_config.php index b8a8560809..820bc6734e 100644 --- a/app/fax/app_config.php +++ b/app/fax/app_config.php @@ -536,6 +536,11 @@ $apps[$x]['db'][$y]['fields'][$z]['search'] = 'true'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "fax_file"; + $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['search'] = 'true'; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = "fax_email_connection_type"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "IMAP or POP3 connection."; diff --git a/app/fax/app_defaults.php b/app/fax/app_defaults.php index 5b2607d4e2..b32e6ace46 100644 --- a/app/fax/app_defaults.php +++ b/app/fax/app_defaults.php @@ -19,6 +19,7 @@ $array['email_templates'][$x]['template_body'] .= "Extension: \${fax_extension}
"; $array['email_templates'][$x]['template_body'] .= "Messages: \${fax_messages}
"; $array['email_templates'][$x]['template_body'] .= "\${fax_file_warning}
"; + $array['email_templates'][$x]['template_body'] .= "\${fax_file_message}
"; $array['email_templates'][$x]['template_body'] .= "\n"; $array['email_templates'][$x]['template_body'] .= "\n"; $array['email_templates'][$x]['template_type'] = "html"; @@ -58,6 +59,7 @@ $array['email_templates'][$x]['template_body'] .= "Extension: \${fax_extension}
"; $array['email_templates'][$x]['template_body'] .= "Messages: \${fax_messages}
"; $array['email_templates'][$x]['template_body'] .= "\${fax_file_warning}
"; + $array['email_templates'][$x]['template_body'] .= "\${fax_file_message}
"; $array['email_templates'][$x]['template_body'] .= "\n"; $array['email_templates'][$x]['template_body'] .= "\n"; $array['email_templates'][$x]['template_type'] = "html"; @@ -139,6 +141,7 @@ $array['email_templates'][$x]['template_body'] .= "Nebenstelle: \${fax_extension}
"; $array['email_templates'][$x]['template_body'] .= "Nachrichten: \${fax_messages}
"; $array['email_templates'][$x]['template_body'] .= "\${fax_file_warning}
"; + $array['email_templates'][$x]['template_body'] .= "\${fax_file_message}
"; $array['email_templates'][$x]['template_body'] .= "\n"; $array['email_templates'][$x]['template_body'] .= "\n"; $array['email_templates'][$x]['template_type'] = "html"; diff --git a/app/fax/app_languages.php b/app/fax/app_languages.php index 1932ad8beb..ff02f7f94b 100644 --- a/app/fax/app_languages.php +++ b/app/fax/app_languages.php @@ -5096,4 +5096,56 @@ $text['fax-active_status_fail']['zh-cn'] = "失败"; $text['fax-active_status_fail']['ja-jp'] = "失敗"; $text['fax-active_status_fail']['ko-kr'] = "실패하다"; -?> +$text['option-attachment']['en-us'] = "Attachment"; +$text['option-attachment']['en-gb'] = "Attachment"; +$text['option-attachment']['ar-eg'] = "مرفق"; +$text['option-attachment']['de-at'] = "Anhang"; +$text['option-attachment']['de-ch'] = "Anhang"; +$text['option-attachment']['de-de'] = "Anhang"; +$text['option-attachment']['el-gr'] = "Επισύναψη"; +$text['option-attachment']['es-cl'] = "Adjunto"; +$text['option-attachment']['es-mx'] = "Adjunto"; +$text['option-attachment']['fr-ca'] = "Pièce Jointe"; +$text['option-attachment']['fr-fr'] = "Pièce Jointe"; +$text['option-attachment']['he-il'] = "הִתקַשְׁרוּת"; +$text['option-attachment']['it-it'] = "Attaccamento"; +$text['option-attachment']['nl-nl'] = "Toevoeging"; +$text['option-attachment']['pl-pl'] = "Załącznik"; +$text['option-attachment']['pt-br'] = "Anexo"; +$text['option-attachment']['pt-pt'] = "Anexo"; +$text['option-attachment']['ro-ro'] = "Atașament"; +$text['option-attachment']['ru-ru'] = "Вложение"; +$text['option-attachment']['sv-se'] = "Anknytning"; +$text['option-attachment']['uk-ua'] = "вкладення"; +$text['option-attachment']['tr-tr'] = "EK"; +$text['option-attachment']['zh-cn'] = "依恋"; +$text['option-attachment']['ja-jp'] = "付属品"; +$text['option-attachment']['ko-kr'] = "부착"; + +$text['option-download_link']['en-us'] = "Download Link (Login Required)"; +$text['option-download_link']['en-gb'] = "Download Link (Login Required)"; +$text['option-download_link']['ar-eg'] = "رابط التحميل (يتطلب تسجيل الدخول)"; +$text['option-download_link']['de-at'] = "Download-Link (Anmeldung erforderlich)"; +$text['option-download_link']['de-ch'] = "Download-Link (Anmeldung erforderlich)"; +$text['option-download_link']['de-de'] = "Download-Link (Anmeldung erforderlich)"; +$text['option-download_link']['el-gr'] = "Σύνδεσμος λήψης (Απαιτείται σύνδεση)"; +$text['option-download_link']['es-cl'] = "Enlace de descarga (se requiere iniciar sesión)"; +$text['option-download_link']['es-mx'] = "Enlace de descarga (se requiere iniciar sesión)"; +$text['option-download_link']['fr-ca'] = "Lien de téléchargement (connexion requise)"; +$text['option-download_link']['fr-fr'] = "Lien de téléchargement (connexion requise)"; +$text['option-download_link']['he-il'] = "קישור להורדה (נדרשת כניסה)"; +$text['option-download_link']['it-it'] = "Link per il download (richiesto login)"; +$text['option-download_link']['nl-nl'] = "Downloadlink (inloggen vereist)"; +$text['option-download_link']['pl-pl'] = "Link do pobrania (wymagane zalogowanie)"; +$text['option-download_link']['pt-br'] = "Link para download (é necessário fazer login)"; +$text['option-download_link']['pt-pt'] = "Link para download (login necessário)"; +$text['option-download_link']['ro-ro'] = "Link de descărcare (autentificare obligatorie)"; +$text['option-download_link']['ru-ru'] = "Ссылка для скачивания (требуется вход в систему)"; +$text['option-download_link']['sv-se'] = "Nedladdningslänk (inloggning krävs)"; +$text['option-download_link']['uk-ua'] = "Посилання для завантаження (потрібно ввійти)"; +$text['option-download_link']['tr-tr'] = "İndirme Bağlantısı (Giriş Gereklidir)"; +$text['option-download_link']['zh-cn'] = "下载链接(需要登录)"; +$text['option-download_link']['ja-jp'] = "ダウンロードリンク(ログインが必要です)"; +$text['option-download_link']['ko-kr'] = "다운로드 링크 (로그인 필요)"; + +?> \ No newline at end of file diff --git a/app/fax/fax_edit.php b/app/fax/fax_edit.php index 31f6774c66..8194b7883b 100644 --- a/app/fax/fax_edit.php +++ b/app/fax/fax_edit.php @@ -119,6 +119,7 @@ $fax_destination_number = $_POST["fax_destination_number"]; $fax_prefix = $_POST["fax_prefix"]; $fax_email = implode(',',array_filter($_POST["fax_email"] ?? [])); + $fax_file = $_POST["fax_file"]; $fax_email_connection_type = $_POST["fax_email_connection_type"]; $fax_email_connection_host = $_POST["fax_email_connection_host"]; $fax_email_connection_port = $_POST["fax_email_connection_port"]; @@ -332,6 +333,7 @@ $array['fax'][0]['fax_name'] = $fax_name; if (permission_exists('fax_email')) { $array['fax'][0]['fax_email'] = $fax_email; + $array['fax'][0]['fax_file'] = $fax_file; } if (permission_exists('fax_caller_id_name')) { $array['fax'][0]['fax_caller_id_name'] = $fax_caller_id_name; @@ -426,6 +428,7 @@ $fax_prefix = $row["fax_prefix"]; $fax_name = $row["fax_name"]; $fax_email = $row["fax_email"]; + $fax_file = $row["fax_file"]; $fax_caller_id_name = $row["fax_caller_id_name"]; $fax_caller_id_number = $row["fax_caller_id_number"]; $fax_toll_allow = $row["fax_toll_allow"]; @@ -602,7 +605,7 @@ echo "\n"; echo "\n"; $x = 0; - foreach($fax_emails as $email) { + foreach ($fax_emails as $email) { echo "\n"; echo "\n"; echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; } if (permission_exists('fax_caller_id_name')) { diff --git a/app/fax/fax_files.php b/app/fax/fax_files.php index 9505177a22..71a1551eed 100644 --- a/app/fax/fax_files.php +++ b/app/fax/fax_files.php @@ -131,7 +131,7 @@ } //download the fax - if (isset($fax_dir) && !empty($_GET['a']) && $_GET['a'] == "download") { + if (isset($fax_dir) && !empty($_GET['a']) && ($_GET['a'] == "download" || $_GET['a'] == 'download_link')) { //sanitize the values that are used in the file name and path $fax_extension = preg_replace('/[^0-9]/', '', $_GET['ext']); @@ -158,6 +158,7 @@ $fax->order_by = $_GET['order_by'] ?? ''; $fax->order = $_GET['order'] ?? ''; $fax->box = $_GET['box'] ?? ''; + $fax->download = $_GET['a'] == 'download_link' ? true : false; $fax->fax_file_toggle($fax_files); unset($fax, $fax_files); } diff --git a/app/fax/resources/classes/fax.php b/app/fax/resources/classes/fax.php index dcb05521b4..0096bcfb15 100644 --- a/app/fax/resources/classes/fax.php +++ b/app/fax/resources/classes/fax.php @@ -42,6 +42,7 @@ if (!class_exists('fax')) { public $box; public $order_by; public $order; + public $download; /** * declare private variables @@ -668,11 +669,13 @@ if (!class_exists('fax')) { $text = $language->get(); //validate the token - $token = new token; - if (!$token->validate($_SERVER['PHP_SELF'])) { - message::add($text['message-invalid_token'],'negative'); - header('Location: fax_files.php?order_by='.urlencode($this->order_by).'&order='.urlencode($this->order).'&id='.urlencode($this->fax_uuid).'&box='.urlencode($this->box)); - exit; + if (empty($this->download) || $this->download == false) { + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: fax_files.php?order_by='.urlencode($this->order_by).'&order='.urlencode($this->order).'&id='.urlencode($this->fax_uuid).'&box='.urlencode($this->box)); + exit; + } } //toggle multiple records diff --git a/app/switch/resources/scripts/app/fax/resources/scripts/hangup_rx.lua b/app/switch/resources/scripts/app/fax/resources/scripts/hangup_rx.lua index b2f55f9d5b..d4cce11e28 100644 --- a/app/switch/resources/scripts/app/fax/resources/scripts/hangup_rx.lua +++ b/app/switch/resources/scripts/app/fax/resources/scripts/hangup_rx.lua @@ -214,28 +214,6 @@ fax_file_name = array[count(array)]; end ---fax to email - cmd = quote(shell_esc(php_dir).."/"..shell_esc(php_bin)).." "..quote(shell_esc(document_root).."/secure/fax_to_email.php").." "; - cmd = cmd .. "email="..quote(shell_esc(fax_email)).." "; - cmd = cmd .. "extension="..quote(shell_esc(fax_extension)).." "; - cmd = cmd .. "name="..quote(shell_esc(fax_file)).." "; - cmd = cmd .. "messages=" .. quote("result:"..shell_esc(fax_result_text).." sender:"..shell_esc(fax_remote_station_id).." pages:"..shell_esc(fax_document_total_pages)).." "; - cmd = cmd .. "domain="..quote(shell_esc(domain_name)).." "; - cmd = cmd .. "caller_id_name=" .. quote(shell_esc(caller_id_name) or '') .. " "; - cmd = cmd .. "caller_id_number=" .. quote(shell_esc(caller_id_number) or '') .. " "; - if #fax_forward_number > 0 then - cmd = cmd .. "fax_relay=true "; - else - cmd = cmd .. "fax_relay=false "; - end - if #fax_prefix > 0 then - cmd = cmd .. "fax_prefix=true "; - else - cmd = cmd .. "fax_prefix=false "; - end - freeswitch.consoleLog("notice", "[fax] command: " .. cmd .. "\n"); - os.execute(cmd); - --add to fax logs sql = "insert into v_fax_logs "; sql = sql .. "("; @@ -421,6 +399,29 @@ end end +--fax to email + cmd = quote(shell_esc(php_dir).."/"..shell_esc(php_bin)).." "..quote(shell_esc(document_root).."/secure/fax_to_email.php").." "; + cmd = cmd .. "email="..quote(shell_esc(fax_email)).." "; + cmd = cmd .. "extension="..quote(shell_esc(fax_extension)).." "; + cmd = cmd .. "name="..quote(shell_esc(fax_file)).." "; + cmd = cmd .. "messages=" .. quote("Result: "..shell_esc(fax_result_text)..", Sender: "..shell_esc(fax_remote_station_id)..", Pages:"..shell_esc(fax_document_total_pages)).." "; + cmd = cmd .. "domain="..quote(shell_esc(domain_name)).." "; + cmd = cmd .. "caller_id_name=" .. quote(shell_esc(caller_id_name) or '') .. " "; + cmd = cmd .. "caller_id_number=" .. quote(shell_esc(caller_id_number) or '') .. " "; + cmd = cmd .. "fax_file_uuid=" .. quote(shell_esc(uuid)) .. " "; + if #fax_forward_number > 0 then + cmd = cmd .. "fax_relay=true "; + else + cmd = cmd .. "fax_relay=false "; + end + if #fax_prefix > 0 then + cmd = cmd .. "fax_prefix=true "; + else + cmd = cmd .. "fax_prefix=false "; + end + freeswitch.consoleLog("notice", "[fax] command: " .. cmd .. "\n"); + os.execute(cmd); + --add to the fax queue when the fax_forward_number is set if (fax_forward_number ~= nil) then sql = "insert into v_fax_queue "; diff --git a/secure/fax_to_email.php b/secure/fax_to_email.php index 4775e73d3a..185459126b 100644 --- a/secure/fax_to_email.php +++ b/secure/fax_to_email.php @@ -270,6 +270,7 @@ if (!function_exists('fax_split_dtmf')) { case 'fax_extension': case 'debug_level': case 'config_file': + case 'fax_file_uuid': //tansform the name of the key into the name of the variable using $$ $$key = $value; break; @@ -323,7 +324,7 @@ if (!function_exists('fax_split_dtmf')) { //ensure we have a domain_uuid if (empty($domain_uuid)) { exit("Domain '$domain_name' not found\n"); -} + } //ensure we have a fax extension if (empty($fax_extension)) { @@ -346,6 +347,7 @@ if (!function_exists('fax_split_dtmf')) { $row = $database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { $fax_email = $row["fax_email"]; + $fax_email_file = $row["fax_file"]; $fax_uuid = $row["fax_uuid"]; $fax_accountcode = $row["fax_accountcode"]; $fax_prefix = $row["fax_prefix"]; @@ -451,7 +453,7 @@ if (!function_exists('fax_split_dtmf')) { } //get the email template from the database - if (!empty($fax_email) && !empty($domain_uuid)) { + if (!empty($domain_uuid)) { $sql = "select template_subject, template_body from v_email_templates "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and template_language = :template_language "; @@ -470,37 +472,40 @@ if (!function_exists('fax_split_dtmf')) { $email_body = $row['template_body']; } unset($sql, $parameters); - } - //replace variables in email subject - $email_subject = str_replace('${domain_name}', $domain_name, $email_subject); - $email_subject = str_replace('${fax_file_name}', $fax_file_name, $email_subject); - $email_subject = str_replace('${fax_extension}', $fax_extension, $email_subject); - $email_subject = str_replace('${fax_messages}', $fax_messages, $email_subject); - $email_subject = str_replace('${fax_file_warning}', $fax_file_warning, $email_subject); - $email_subject = str_replace('${fax_subject_tag}', $fax_email_inbound_subject_tag, $email_subject); + //replace variables in email subject + $email_subject = str_replace('${domain_name}', $domain_name, $email_subject); + $email_subject = str_replace('${fax_file_name}', $fax_file_name, $email_subject); + $email_subject = str_replace('${fax_extension}', $fax_extension, $email_subject); + $email_subject = str_replace('${fax_messages}', $fax_messages, $email_subject); + $email_subject = str_replace('${fax_file_warning}', $fax_file_warning, $email_subject); + $email_subject = str_replace('${fax_subject_tag}', $fax_email_inbound_subject_tag, $email_subject); - //replace variables in email body - $email_body = str_replace('${domain_name}', $domain_name, $email_body); - $email_body = str_replace('${fax_file_name}', $fax_file_name, $email_body); - $email_body = str_replace('${fax_extension}', $fax_extension, $email_body); - $email_body = str_replace('${fax_messages}', $fax_messages, $email_body); - $email_body = str_replace('${fax_file_warning}', $fax_file_warning, $email_body); - $email_body = str_replace('${fax_subject_tag}', $fax_email_inbound_subject_tag, $email_body); + //replace variables in email body + $email_body = str_replace('${domain_name}', $domain_name, $email_body); + $email_body = str_replace('${fax_file_name}', $fax_file_name, $email_body); + $email_body = str_replace('${fax_extension}', $fax_extension, $email_body); + $email_body = str_replace('${fax_messages}', $fax_messages, $email_body); + $email_body = str_replace('${fax_file_warning}', $fax_file_warning, $email_body); + $email_body = str_replace('${fax_subject_tag}', $fax_email_inbound_subject_tag, $email_body); + if ($fax_email_file == 'link') { + $email_body = str_replace('${fax_file_message}', "".($text['label-fax_download'] ?? 'Download Fax')."", $email_body); + } + else { + $email_body = str_replace('${fax_file_message}', ($text['label-fax_attached'] ?? 'Fax Attached'), $email_body); + } - //debug info - //echo "
\n"; - //echo "email_address ".$fax_email."
\n"; - //echo "email_subject ".$email_subject."
\n"; - //echo "email_body ".$email_body."
\n"; - //echo "
\n"; + //debug info + //echo "
\n"; + //echo "email_address ".$fax_email."
\n"; + //echo "email_subject ".$email_subject."
\n"; + //echo "email_body ".$email_body."
\n"; + //echo "
\n"; - //send the email - if (isset($fax_email) && !empty($fax_email)) { //add the attachment - if (!empty($fax_file_name)) { + if (!empty($fax_file_name) && $fax_email_file != 'link') { $email_attachments[0]['type'] = 'file'; - if ($pdf_file && file_exists($pdf_file)) { + if (!empty($pdf_file) && file_exists($pdf_file)) { $email_attachments[0]['name'] = $fax_file_name.'.pdf'; $email_attachments[0]['value'] = $pdf_file; } @@ -510,14 +515,16 @@ if (!function_exists('fax_split_dtmf')) { } } - //$email_response = send_email($email_address, $email_subject, $email_body); + //send the email $email = new email; $email->recipients = $fax_email; $email->subject = $email_subject; $email->body = $email_body; $email->from_address = $email_from_address; $email->from_name = $email_from_name; - $email->attachments = $email_attachments; + if ($fax_email_file != 'link') { + $email->attachments = $email_attachments; + } //$email->debug_level = 3; $response = $mail->error; $sent = $email->send();
\n"; echo " \n"; @@ -618,6 +621,20 @@ echo " ".$text['description-email']."\n"; echo "
\n"; + echo " ".($text['label-email_fax_file'] ?? 'Fax File')."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo ($text['description-email_fax_file'] ?? 'Select a fax file option.')."\n"; + echo "