Commit 66a20e95 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Feature 4255: Attachments for email.

Manual.rst: sendMailToken 'f' changed from  'f' to 'F'.
Download.php, Linnk.php: TOKEN_FILE_DEPRECATED
Sendmail.php: broken, in the middle of work
parent 72046a82
......@@ -4724,7 +4724,7 @@ Column: _link
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |Mode |M:file|pdf|zip |M:file, M:pdf, M:zip |Mode. Used to specify type of download. One or more element sources needs to be configured. See `download`_. |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |File |f:<filename> |f:fileadmin/file.pdf |Element source for download mode file|pdf|zip. See `download`_. |
| | |File |F:<filename> |F:fileadmin/file.pdf |Element source for download mode file|pdf|zip. See `download`_. |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |Delete record | x[:a|r|c] |x, x:r, x:c |a: ajax (only QFQ internal used), r: report (default), c: close (current page, open last page) |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
......@@ -4793,7 +4793,7 @@ Link Examples
+-----------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
| SELECT "U:form=Person&r=123|x|t:Delete" as _link | <a href="typo3conf/ext/qfq/qfq/api/delete.php?s=badcaffee1234">Delete</a> |
+-----------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
| SELECT "s:1|d:full.pdf|M:pdf|U:id=det1&r=12|U:id=det2|f:cv.pdf| | <a href="typo3conf/ext/qfq/qfq/api/download.php?s=badcaffee1234">Download</a> |
| SELECT "s:1|d:full.pdf|M:pdf|U:id=det1&r=12|U:id=det2|F:cv.pdf| | <a href="typo3conf/ext/qfq/qfq/api/download.php?s=badcaffee1234">Download</a> |
| t:Download|a:Create complete PDF - please wait" as _link | |
+-----------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
......@@ -4911,7 +4911,7 @@ Parameter and (element) sources
* *element sources* - for `m:pdf` or `m:zip`, all of the following three element sources might be specified multiple times. Any combination and order of the three options are allowed.
* *file*: `f:<pathFilename>` - relative or absolute pathFilename offered for a) download (single), or to be concatenated
* *file*: `F:<pathFilename>` - relative or absolute pathFilename offered for a) download (single), or to be concatenated
in a PDF or ZIP.
* *urlParam*: `U:id=<t3 page>&<key 1>=<value 1>&<key 2>=<value 2>&...&<key n>=<value n>`.
......@@ -4942,22 +4942,22 @@ Parameter and (element) sources
Example `_link`: ::
# single `file`. Specifying a popup message window text is not necessary, cause a file directly accessed is fast.
SELECT "d:file.pdf|s|t:Download|f:fileadmin/pdf/test.pdf" AS _link
SELECT "d:file.pdf|s|t:Download|F:fileadmin/pdf/test.pdf" AS _link
# single `file`, with mode
SELECT "d:file.pdf|m:pdf|s|t:Download|f:fileadmin/pdf/test.pdf" AS _link
SELECT "d:file.pdf|m:pdf|s|t:Download|F:fileadmin/pdf/test.pdf" AS _link
# three sources: two pages and one file
SELECT "d:complete.pdf|s|t:Complete PDF|U:id=detail&r=1|U:id=detail2&r=1|f:fileadmin/pdf/test.pdf" AS _link
SELECT "d:complete.pdf|s|t:Complete PDF|U:id=detail&r=1|U:id=detail2&r=1|F:fileadmin/pdf/test.pdf" AS _link
# three sources: two pages and one file
SELECT "d:complete.pdf|s|t:Complete PDF|U:id=detail&r=1|U:id=detail2&r=1|f:fileadmin/pdf/test.pdf" AS _link
SELECT "d:complete.pdf|s|t:Complete PDF|U:id=detail&r=1|U:id=detail2&r=1|F:fileadmin/pdf/test.pdf" AS _link
# three sources: two pages and one file, parameter to wkhtml will be SIP encoded
SELECT "d:complete.pdf|s|t:Complete PDF|U:id=detail&r=1&_sip=1|U:id=detail2&r=1&_sip=1|f:fileadmin/pdf/test.pdf" AS _link
SELECT "d:complete.pdf|s|t:Complete PDF|U:id=detail&r=1&_sip=1|U:id=detail2&r=1&_sip=1|F:fileadmin/pdf/test.pdf" AS _link
# three sources: two pages and one file, the second page will be in landscape and pagesize A3
SELECT "d:complete.pdf|s|t:Complete PDF|U:id=detail&r=1|U:id=detail2&r=1&--orientation=Landscape&--page-size=A3|f:fileadmin/pdf/test.pdf" AS _link
SELECT "d:complete.pdf|s|t:Complete PDF|U:id=detail&r=1|U:id=detail2&r=1&--orientation=Landscape&--page-size=A3|F:fileadmin/pdf/test.pdf" AS _link
..
......@@ -4965,18 +4965,18 @@ Example `_pdf`, `_zip`: ::
# File 1: U:id=1&--orientation=Landscape&--page-size=A3
# File 2: U:id=form
# File 3: f:fileadmin/file.pdf
SELECT 't:PDF|a:Creating a new PDF|U:id=1&--orientation=Landscape&--page-size=A3|U:id=form|f:fileadmin/file.pdf' AS _pdf
# File 3: F:fileadmin/file.pdf
SELECT 't:PDF|a:Creating a new PDF|U:id=1&--orientation=Landscape&--page-size=A3|U:id=form|F:fileadmin/file.pdf' AS _pdf
# File 1: U:id=1
# File 2: u:http://www.example.com
# File 3: f:fileadmin/file.pdf
SELECT 't:PDF - 3 Files|a:Please be patient|U:id=1|u:http://www.example.com|f:fileadmin/file.pdf' AS _pdf
# File 3: F:fileadmin/file.pdf
SELECT 't:PDF - 3 Files|a:Please be patient|U:id=1|u:http://www.example.com|F:fileadmin/file.pdf' AS _pdf
# File 1: U:id=1
# File 2: U:id=form
# File 3: f:fileadmin/file.pdf
SELECT CONCAT('t:ZIP - 3 Pages|a:Please be patient|U:id=1|U:id=form|f:', p.pathFilename) AS _zip
# File 3: F:fileadmin/file.pdf
SELECT CONCAT('t:ZIP - 3 Pages|a:Please be patient|U:id=1|U:id=form|F:', p.pathFilename) AS _zip
..
......@@ -5245,7 +5245,7 @@ Easily create Email links.
Column: _sendmail
^^^^^^^^^^^^^^^^^
t:<TO:email[,email]>|f:<FROM:email>|s:<subject>|b:<body>|[F:<REPLY-TO:email>]|[a:<flag autosubmit: on /off>]|[g:<grid>]|[x:xId]|[c:<CC:email[,email]]>|[B:<BCC:email[,email]]|[y:xId2]|[z:xId3]>
t:<TO:email[,email]>|F:<FROM:email>|s:<subject>|b:<body>|[F:<REPLY-TO:email>]|[a:<flag autosubmit: on /off>]|[g:<grid>]|[x:xId]|[c:<CC:email[,email]]>|[B:<BCC:email[,email]]|[y:xId2]|[z:xId3]>
Send text emails. Every mail will be logged in the table `mailLog`.
......@@ -5254,8 +5254,8 @@ Send text emails. Every mail will be logged in the table `mailLog`.
::
SELECT "t:john@doe.com|f:jane@doe.com|s:Reminder tomorrow|b:Please dont miss the meeting tomorrow" AS _sendmail
SELECT "t:john@doe.com|f:jane@doe.com|s:Reminder tomorrow|b:Please dont miss the meeting tomorrow|A:off|g:1|x:2|y:3|z:4" AS _sendmail
SELECT "t:john@doe.com|F:jane@doe.com|s:Reminder tomorrow|b:Please dont miss the meeting tomorrow" AS _sendmail
SELECT "t:john@doe.com|F:jane@doe.com|s:Reminder tomorrow|b:Please dont miss the meeting tomorrow|A:off|g:1|x:2|y:3|z:4" AS _sendmail
..
......@@ -5296,7 +5296,7 @@ Send text emails. Every mail will be logged in the table `mailLog`.
::
10.sql = SELECT "t:john.doe@example.com|f:company@example.com|s:Latest News|b:The new version is now available." AS _sendmail
10.sql = SELECT "t:john.doe@example.com|F:company@example.com|s:Latest News|b:The new version is now available." AS _sendmail
..
......@@ -5307,7 +5307,7 @@ This will send an email with subject *Latest News* from company@example.com to j
::
10.sql = SELECT "t:customer1@example.com,Firstname Lastname <customer2@example.com>, Firstname Lastname <customer3@example.com>|
f:company@example.com|s:Latest News|b:The new version is now available.|r:sales@example.com|A:on|g:101|x:222|c:ceo@example.com|B:backup@example.com" AS _sendmail
F:company@example.com|s:Latest News|b:The new version is now available.|r:sales@example.com|A:on|g:101|x:222|c:ceo@example.com|B:backup@example.com" AS _sendmail
..
......@@ -5421,23 +5421,23 @@ Most of the other Link-Class attributes can be used to customize the link.
SELECT "[options]" AS _pdf, "[options]" AS _file, "[options]" AS _zip
with: [options] = [d:<exportFilename]|[U:<params>]|[u:<url>]|[f:file]|[t:<text>]|[a:<message>]|[o:<tooltip>]|[c:<class>]|[r:<render mode>]
with: [options] = [d:<exportFilename]|[U:<params>]|[u:<url>]|[F:file]|[t:<text>]|[a:<message>]|[o:<tooltip>]|[c:<class>]|[r:<render mode>]
* Parameter are position independent.
* *<params>*: see `download-parameter-files`_
* For column `_pdf` and `_zip`, the element sources `U:...`, `u:...`, `f:...` might repeated multiple times.
* For column `_pdf` and `_zip`, the element sources `U:...`, `u:...`, `F:...` might repeated multiple times.
* Example: ::
SELECT "f:fileadmin/test.pdf" as _pdf, "f:fileadmin/test.pdf" as _file, "f:fileadmin/test.pdf" as _zip
SELECT "F:fileadmin/test.pdf" as _pdf, "F:fileadmin/test.pdf" as _file, "F:fileadmin/test.pdf" as _zip
SELECT "U:id=export&r=1" as _pdf, "U:id=export&r=1" as _file, "U:id=export&r=1" as _zip
SELECT "t:Download PDF|f:fileadmin/test.pdf" as _pdf, "t:Download PDF|f:fileadmin/test.pdf" as _file, "t:Download ZIP|f:fileadmin/test.pdf" as _zip
SELECT "t:Download PDF|F:fileadmin/test.pdf" as _pdf, "t:Download PDF|F:fileadmin/test.pdf" as _file, "t:Download ZIP|F:fileadmin/test.pdf" as _zip
SELECT "t:Download PDF|U:id=export&r=1" as _pdf, "t:Download PDF|U:id=export&r=1" as _file, "t:Download ZIP|U:id=export&r=1" as _zip
SELECT "d:complete.pdf|t:Download PDF|f:fileadmin/test1.pdf|f:fileadmin/test2.pdf" as _pdf, "d:complete.zip|t:Download ZIP|f:fileadmin/test1.pdf|f:fileadmin/test2.pdf" as _zip
SELECT "d:complete.pdf|t:Download PDF|F:fileadmin/test1.pdf|F:fileadmin/test2.pdf" as _pdf, "d:complete.zip|t:Download ZIP|F:fileadmin/test1.pdf|F:fileadmin/test2.pdf" as _zip
SELECT "d:complete.pdf|t:Download PDF|f:fileadmin/test.pdf|U:id=export&r=1|u:www.w3c.org" AS _pdf
SELECT "d:complete.pdf|t:Download PDF|F:fileadmin/test.pdf|U:id=export&r=1|u:www.w3c.org" AS _pdf
.. _column_ppdf:
......
......@@ -1063,6 +1063,7 @@ const COLUMN_PATH_FILE_NAME = 'pathFileName';
const EXISTING_PATH_FILE_NAME = '_existingPathFileName';
//SENDMAIL
const SENDMAIL_IDX_ARRAY = -1;
const SENDMAIL_IDX_RECEIVER = 0;
const SENDMAIL_IDX_SENDER = 1;
const SENDMAIL_IDX_SUBJECT = 2;
......@@ -1089,12 +1090,20 @@ const SENDMAIL_TOKEN_GR_ID = 'g';
const SENDMAIL_TOKEN_X_ID = 'x';
const SENDMAIL_TOKEN_RECEIVER_CC = 'c';
const SENDMAIL_TOKEN_RECEIVER_BCC = 'B';
const SENDMAIL_TOKEN_ATTACHMENT = 'a';
const SENDMAIL_TOKEN_ATTACHMENT_FILE = 'F';
const SENDMAIL_TOKEN_ATTACHMENT_DEPRECATED = 'a';
const SENDMAIL_TOKEN_HEADER = 'h';
const SENDMAIL_TOKEN_X_ID2 = 'y';
const SENDMAIL_TOKEN_X_ID3 = 'z';
const SENDMAIL_TOKEN_SRC = 'S';
const SENDMAIL_TOKEN_COMBINE = 'C';
const SENDMAIL_TOKEN_DOWNLOAD_FILENAME = 'd';
const SENDMAIL_TOKEN_ATTACHMENT_URL = 'u';
const SENDMAIL_TOKEN_ATTACHMENT_URL_LOCAL = 'U';
const SENDMAIL_PREFIX_TMP_ATTACHMENT = '/tmp/qfq.attachment/';
// Report, BodyText
const TOKEN_SQL = 'sql';
const TOKEN_HEAD = 'head';
......@@ -1193,6 +1202,7 @@ const TOKEN_HELP = 'H';
const TOKEN_INFO = 'I';
const TOKEN_NEW = 'N';
const TOKEN_SHOW = 'S';
const TOKEN_SHOW = 'S';
const TOKEN_GLYPH = 'G';
const TOKEN_RENDER = 'r';
const TOKEN_TARGET = 'g';
......@@ -1202,7 +1212,8 @@ const TOKEN_ENCRYPTION = 'e';
const TOKEN_SIP = 's';
const TOKEN_URL_PARAM = 'U';
const TOKEN_RIGHT = 'R';
const TOKEN_FILE = 'f';
const TOKEN_FILE = 'F';
const TOKEN_FILE_DEPRECATED = 'f';
const TOKEN_DOWNLOAD_MODE = 'M';
const TOKEN_ACTION_DELETE = 'x';
......
......@@ -226,6 +226,7 @@ class Download {
break;
case TOKEN_FILE:
case TOKEN_FILE_DEPRECATED:
$filename = $value;
break;
default:
......
......@@ -161,6 +161,7 @@ class Link {
TOKEN_NEW => 'buildNew',
TOKEN_SHOW => 'buildShow',
TOKEN_FILE => 'buildFile',
TOKEN_FILE_DEPRECATED => 'buildFile',
TOKEN_GLYPH => 'buildGlyph',
TOKEN_BOOTSTRAP_BUTTON => 'buildBootstrapButton',
];
......@@ -195,6 +196,7 @@ class Link {
TOKEN_RIGHT => NAME_RIGHT,
TOKEN_ACTION_DELETE => NAME_ACTION_DELETE,
TOKEN_FILE => NAME_FILE,
TOKEN_FILE_DEPRECATED => NAME_FILE,
];
// Used to find double definitions.
......@@ -471,7 +473,7 @@ class Link {
$value = $this->checkValue($key, $value);
// Store value
if (isset($tokenGiven[TOKEN_DOWNLOAD]) && ($key == TOKEN_URL || $key == TOKEN_URL_PARAM || $key == TOKEN_FILE)) {
if (isset($tokenGiven[TOKEN_DOWNLOAD]) && ($key == TOKEN_URL || $key == TOKEN_URL_PARAM || $key == TOKEN_FILE || $key == TOKEN_FILE_DEPRECATED)) {
$vars[NAME_DOWNLOAD_ELEMENTS][] = $key . ':' . $value;
......@@ -729,7 +731,7 @@ class Link {
// Determine default.
if ($mode == '') {
if ($cnt == 1) {
$mode = (substr($vars[NAME_DOWNLOAD_ELEMENTS][0], 0, 1) == TOKEN_FILE) ? DOWNLOAD_MODE_FILE : DOWNLOAD_MODE_PDF;
$mode = (substr($vars[NAME_DOWNLOAD_ELEMENTS][0], 0, 1) == TOKEN_FILE_DEPRECATED) ? DOWNLOAD_MODE_FILE : DOWNLOAD_MODE_PDF;
} else {
$mode = DOWNLOAD_MODE_PDF;
}
......
......@@ -1261,7 +1261,15 @@ class Report {
return false;
}
private function sendmailConvertToken($data) {
/**
* Convert a token based sendmail string into a numerical index based array.
* Each attachment (single file or combined) is an array in the array.
*
* @param string $data E.g.: 't:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John ...'
* @return array
* @throws UserReportException
*/
public function sendmailConvertToken($data) {
$sendmailToken = [SENDMAIL_TOKEN_RECEIVER => SENDMAIL_IDX_RECEIVER,
SENDMAIL_TOKEN_SENDER => SENDMAIL_IDX_SENDER,
......@@ -1271,7 +1279,14 @@ class Report {
SENDMAIL_TOKEN_RECEIVER_CC => SENDMAIL_IDX_RECEIVER_CC,
SENDMAIL_TOKEN_RECEIVER_BCC => SENDMAIL_IDX_RECEIVER_BCC,
SENDMAIL_TOKEN_HEADER => SENDMAIL_IDX_HEADER,
SENDMAIL_TOKEN_ATTACHMENT => SENDMAIL_IDX_ATTACHMENT,
SENDMAIL_TOKEN_COMBINE => SENDMAIL_IDX_ARRAY,
SENDMAIL_TOKEN_DOWNLOAD_FILENAME => SENDMAIL_IDX_ARRAY,
SENDMAIL_TOKEN_ATTACHMENT_FILE => SENDMAIL_IDX_ATTACHMENT,
SENDMAIL_TOKEN_ATTACHMENT_DEPRECATED => SENDMAIL_IDX_ATTACHMENT,
SENDMAIL_TOKEN_ATTACHMENT_URL => SENDMAIL_IDX_ARRAY,
SENDMAIL_TOKEN_ATTACHMENT_URL_LOCAL => SENDMAIL_IDX_ARRAY,
SENDMAIL_TOKEN_FLAG_AUTO_SUBMIT => SENDMAIL_IDX_FLAG_AUTO_SUBMIT,
SENDMAIL_TOKEN_GR_ID => SENDMAIL_IDX_GR_ID,
SENDMAIL_TOKEN_X_ID => SENDMAIL_IDX_X_ID,
......@@ -1280,13 +1295,15 @@ class Report {
SENDMAIL_TOKEN_X_ID3 => SENDMAIL_IDX_X_ID3
];
// Token based string? No: just explode and all is fine. This is the deprecated fixed position setup
if (!isset($data[1]) || $data[1] != ':') {
return explode('|', $data);
}
$segments = explode('|', $data);
$arr = ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''];
$attachmentCombineOpen = false;
$attachment = array();
foreach ($segments AS $line) {
$piece = explode(':', $line, 2);
......@@ -1298,8 +1315,37 @@ class Report {
throw new UserReportException ("Unknown token in sendmail: $piece[0]", ERROR_UNKNOWN_TOKEN);
}
$idx = $sendmailToken[$piece[0]];
$arr[$idx] = empty($piece[1]) ? '' : $piece[1];
switch ($piece[0]) {
case SENDMAIL_TOKEN_COMBINE:
$attachmentCombineOpen = true;
if (!empty($attachment)) {
$arr[SENDMAIL_IDX_ATTACHMENT][] = $attachment;
$attachment = array();
}
break;
case SENDMAIL_TOKEN_ATTACHMENT_FILE:
case SENDMAIL_TOKEN_ATTACHMENT_URL:
case SENDMAIL_TOKEN_ATTACHMENT_URL_LOCAL:
case SENDMAIL_TOKEN_DOWNLOAD_FILENAME:
$val = empty($piece[1]) ? '' : $piece[1];
$attachment[] = [$piece[0] => $val];
break;
default:
$idx = $sendmailToken[$piece[0]];
$arr[$idx] = empty($piece[1]) ? '' : $piece[1];
break;
}
if (!empty($attachment) && !$attachmentCombineOpen) {
$arr[SENDMAIL_IDX_ATTACHMENT][] = $attachment;
$attachment = array();
}
}
if (!empty($attachment) && $attachmentCombineOpen) {
$arr[SENDMAIL_IDX_ATTACHMENT][] = $attachment;
}
return ($arr);
......
......@@ -32,6 +32,13 @@ class Sendmail {
* SENDMAIL_IDX_FLAG_AUTO_SUBMIT optional: 'on'|'off', default: 'on'
* SENDMAIL_IDX_GR_ID optional: integer
* SENDMAIL_IDX_X_ID optional: integer
* SENDMAIL_IDX_RECEIVER_CC optional: integer
* SENDMAIL_IDX_RECEIVER_BCC optional: integer
* SENDMAIL_IDX_ATTACHMENT optional: array, per attachment one sub array.
* SENDMAIL_IDX_HEADER optional: integer
* SENDMAIL_IDX_X_ID2 optional: integer
* SENDMAIL_IDX_X_ID3 optional: integer
* SENDMAIL_IDX_SRC optional: integer
*
* @param $mailConfig
*
......@@ -133,10 +140,12 @@ class Sendmail {
}
if (!empty($mailConfig[SENDMAIL_IDX_ATTACHMENT])) {
$pieces = explode(',', $mailConfig[SENDMAIL_IDX_ATTACHMENT]);
foreach ($pieces as $piece) {
$args[] = '-a ' . $piece;
}
// $pieces = explode(',', $mailConfig[SENDMAIL_IDX_ATTACHMENT]);
// foreach ($pieces as $piece) {
// $args[] = '-a ' . $piece;
// }
$attachments = $this->attachmentsBuild($mailConfig[SENDMAIL_IDX_ATTACHMENT]);
$args[] = implode('-a ', $attachments);
}
if (!empty($mailConfig[SENDMAIL_IDX_HEADER])) {
......@@ -156,6 +165,7 @@ class Sendmail {
$cmd = $sendEmail . ' ' . implode(' ', $args);
exec($cmd, $arr, $rc);
if ($rc != 0) {
// After first installation of QFQ extension, the PERL script is not executable: is this the case?
$perms = fileperms($sendEmail);
......@@ -169,6 +179,8 @@ class Sendmail {
throw new UserFormException("Error sendmail failed: " . $output, ERROR_SENDMAIL);
}
}
$this->attachmentsDelete($attachments);
}
/**
......@@ -237,4 +249,31 @@ class Sendmail {
$db->sql('INSERT INTO MailLog (`receiver`, `sender`, `subject`, `body`, `header`, `grId`, `xId`, `xId2`, `xId3`, `src`, `modified`, `created`) VALUES ( ?, ? , ? , ? ,?, ?, ? ,?, ?, ?, NOW(), NOW() )', ROW_REGULAR, $log);
}
/**
* Removes all temporary created files.
*
* @param array $attachments
*/
private function attachmentsDelete(array $attachments) {
$len = strlen(SENDMAIL_PREFIX_TMP_ATTACHMENT);
foreach ($attachments as $file) {
if (SENDMAIL_PREFIX_TMP_ATTACHMENT == substr($file, 0, $len)) {
unlink($file);
$dir = dirname($file);
rmdir($dir);
}
}
}
private function attachmentsBuild(array $attachments) {
$files = array();
foreach ($attachments as $attach) {
if (isset($attach[0] && count()) )
$files[] =
}
}
}
......@@ -1073,6 +1073,61 @@ EOF;
}
public function testSendmailConvertToken() {
// Minimal setup
$result = $this->report->sendmailConvertToken('');
$expect = [''];
$this->assertEquals($expect, $result);
// Simple 'fixed position' DEPRECATED - not sure if it's ok that the array is not fillled up to the maximum.
$result = $this->report->sendmailConvertToken('john@doe.com|jane@miller.com|Latest|Dear John');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John'];
$this->assertEquals($expect, $result);
// Simple 'token based'
$result = $this->report->sendmailConvertToken('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', '', '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// All (but attachment) 'token based'
$result = $this->report->sendmailConvertToken('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|r:reply@doe.com|A:on|g:123|x:234|c:july@doe.com,steve@doe.com|B:ceo@doe.com|h:Auto-Submit: fake|y:345|z:456|S:test.php');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', 'reply@doe.com', 'on', '123', '234', 'july@doe.com,steve@doe.com', 'ceo@doe.com', '', 'Auto-Submit: fake', '345', '456', 'test.php', '', ''];
$this->assertEquals($expect, $result);
// Single attachment 'token based'
$attach = [[['F' => 'fileadmin/test1.pdf']]];
$result = $this->report->sendmailConvertToken('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|F:fileadmin/test1.pdf');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// Three individual attachment 'token based'
// $attach = [ [ [ 'F' => 'fileadmin/test1.pdf' ], [ 'F' => 'fileadmin/test2.pdf' ], [ 'F' => 'fileadmin/test3.pdf' ] ] ] ;
$attach = [[['F' => 'fileadmin/test1.pdf']], [['F' => 'fileadmin/test2.pdf']], [['F' => 'fileadmin/test3.pdf']]];
$result = $this->report->sendmailConvertToken('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|F:fileadmin/test1.pdf|F:fileadmin/test2.pdf|F:fileadmin/test3.pdf');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// One individual attachment, one dual combined attachment
$attach = [[['F' => 'fileadmin/test1.pdf']], [['F' => 'fileadmin/test2.pdf'], ['F' => 'fileadmin/test3.pdf']]];
$result = $this->report->sendmailConvertToken('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|F:fileadmin/test1.pdf|C|F:fileadmin/test2.pdf|F:fileadmin/test3.pdf');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// One individual attachment, one quad combined attachment
$attach = [[['F' => 'fileadmin/test1.pdf']], [['F' => 'fileadmin/test2.pdf'], ['F' => 'fileadmin/test3.pdf'], ['u' => 'http://nzz.ch'], ['U' => 'export&a=100']]];
$result = $this->report->sendmailConvertToken('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|F:fileadmin/test1.pdf|C|F:fileadmin/test2.pdf|F:fileadmin/test3.pdf|u:http://nzz.ch|U:export&a=100');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
// Two quad combined attachmente
$attach = [[['d-' => 'output1.pdf'], ['F' => 'fileadmin/test11.pdf'], ['F' => 'fileadmin/test12.pdf'], ['u' => 'http://nzz.ch.1'], ['U' => 'export1&a=100']], [['d' => 'output2.pdf'], ['F' => 'fileadmin/test21.pdf'], ['F' => 'fileadmin/test22.pdf'], ['u' => 'http://nzz.ch.2'], ['U' => 'export2&a=100']]];
$result = $this->report->sendmailConvertToken('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|C|d:output1.pdf|F:fileadmin/test11.pdf|F:fileadmin/test12.pdf|u:http://nzz.ch.1|U:export1&a=100|C|d:output2.pdf|F:fileadmin/test21.pdf|F:fileadmin/test22.pdf|u:http://nzz.ch.2|U:export2&a=100');
$expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John', '', '', '', '', '', '', $attach, '', '', '', '', '', ''];
$this->assertEquals($expect, $result);
}
/**
*
*/
......@@ -1087,7 +1142,6 @@ EOF;
// TODO: implement
}
/**
* @throws Exception
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment