Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_mail
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_mail
Commits
92e9b02b
Commit
92e9b02b
authored
7 years ago
by
Torsten Oppermann
Browse files
Options
Downloads
Plain Diff
Merge branch 'new_version_4_0' into new_version_4_1
parents
ad2ae457
344597a4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
New version 4 1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Controller/QueueController.php
+2
-23
2 additions, 23 deletions
Classes/Controller/QueueController.php
Classes/Service/BackendService.php
+73
-1
73 additions, 1 deletion
Classes/Service/BackendService.php
with
75 additions
and
24 deletions
Classes/Controller/QueueController.php
+
2
−
23
View file @
92e9b02b
...
...
@@ -171,30 +171,10 @@ class QueueController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
* @throws \InvalidArgumentException
*/
public
function
exportAction
(
array
$filters
=
[])
{
$pageUid
=
(
int
)
GeneralUtility
::
_GP
(
'id'
);
$queue
=
$this
->
mailRepository
->
findAllEntries
(
$pageUid
,
0
,
$filters
);
$exportString
=
'Subject;Body;To;From;From Name;CC;BCC;Reply To;Extension;Template;Language'
.
LF
;
foreach
(
$queue
as
$item
)
{
$exportString
.
=
$item
[
'mail_subject'
]
.
','
;
if
(
strpos
(
$item
[
'mail_body'
],
','
)
!==
FALSE
||
strpos
(
$item
[
'mail_body'
],
'"'
)
!==
FALSE
||
strpos
(
$item
[
'mail_body'
],
"
\n
"
)
!==
FALSE
)
{
$item
[
'mail_body'
]
=
'"'
.
str_replace
(
'"'
,
'""'
,
$item
[
'mail_body'
])
.
'"'
;
}
$exportString
.
=
trim
(
preg_replace
(
'/\s\s+/'
,
' '
,
strip_tags
(
$item
[
'mail_body'
])
.
';'
));
$exportString
.
=
$item
[
'to_address'
]
.
';'
;
$exportString
.
=
$item
[
'from_address'
]
.
';'
;
$exportString
.
=
$item
[
'from_name'
]
.
';'
;
$exportString
.
=
$item
[
'cc_addresses'
]
.
';'
;
$exportString
.
=
$item
[
'bcc_addresses'
]
.
';'
;
$exportString
.
=
$item
[
'reply_to'
]
.
';'
;
$exportString
.
=
$item
[
'extension_key'
]
.
';'
;
$exportString
.
=
$item
[
'template_name'
]
.
';'
;
$exportString
.
=
$item
[
'language'
]
.
LF
;
}
$exportString
=
BackendService
::
getCsvFromQueue
(
$filters
);
header
(
'Content-Type: application/force-download'
);
header
(
'Content-Transfer-Encoding: Binary'
);
...
...
@@ -202,6 +182,5 @@ class QueueController extends ActionController {
header
(
'Content-Length: '
.
strlen
(
$exportString
));
echo
$exportString
;
exit
(
0
);
}
}
This diff is collapsed.
Click to expand it.
Classes/Service/BackendService.php
+
73
−
1
View file @
92e9b02b
...
...
@@ -27,6 +27,7 @@ namespace SGalinski\SgMail\Service;
***************************************************************/
use
SGalinski\SgMail\Domain\Model\Template
;
use
SGalinski\SgMail\Domain\Repository\MailRepository
;
use
SGalinski\SgMail\Domain\Repository\TemplateRepository
;
use
TYPO3\CMS\Backend\Template\Components\ButtonBar
;
use
TYPO3\CMS\Backend\Template\Components\DocHeaderComponent
;
...
...
@@ -35,7 +36,6 @@ use TYPO3\CMS\Core\Database\DatabaseConnection;
use
TYPO3\CMS\Core\Imaging\Icon
;
use
TYPO3\CMS\Core\Imaging\IconFactory
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
use
TYPO3\CMS\Extbase\Domain\Model\FrontendUser
;
use
TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
;
use
TYPO3\CMS\Extbase\Mvc\Request
;
use
TYPO3\CMS\Extbase\Object\ObjectManager
;
...
...
@@ -315,4 +315,76 @@ class BackendService {
return
$frontendUserRepository
->
findAll
()
->
toArray
();
}
/**
* Generate a csv string from the queues, respecting the given filters
*
* @param array $filters
* @return string
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
* @throws \InvalidArgumentException
*/
public
static
function
getCsvFromQueue
(
array
$filters
=
[])
{
$objectManager
=
GeneralUtility
::
makeInstance
(
ObjectManager
::
class
);
/** @var MailRepository $mailRepository */
$mailRepository
=
$objectManager
->
get
(
MailRepository
::
class
);
$pageUid
=
(
int
)
GeneralUtility
::
_GP
(
'id'
);
/** @var array $queue */
$queue
=
$mailRepository
->
findAllEntries
(
$pageUid
,
0
,
$filters
);
$totalQueueSize
=
count
(
$queue
);
$exportString
=
''
;
if
(
$totalQueueSize
&&
$queue
)
{
$ignoreFields
=
[
'uid'
,
'pid'
,
'tstamp'
,
'password'
,
'starttime'
,
'endtime'
,
'deleted'
,
'sent'
,
'priority'
,
'crdate'
,
'cruser_id'
,
'hidden'
];
$dateFields
=
[
'tstamp'
,
'starttime'
,
'endtime'
,
'crdate'
];
$export
=
[[]];
$first
=
TRUE
;
/** @var array $mail */
foreach
(
$queue
as
$mail
)
{
if
(
$first
)
{
$first
=
FALSE
;
foreach
(
$mail
as
$field
=>
$value
)
{
if
(
!
in_array
(
$field
,
$ignoreFields
,
TRUE
))
{
$label
=
isset
(
$GLOBALS
[
'TCA'
][
'tx_sgmail_domain_model_mail'
][
'columns'
][
$field
])
?
$GLOBALS
[
'TCA'
][
'fe_users'
][
'columns'
][
$field
][
'label'
]
:
''
;
if
(
strpos
(
$label
,
'LLL:'
)
===
0
)
{
$label
=
$GLOBALS
[
'LANG'
]
->
sL
(
$label
);
}
$export
[
0
][]
=
$label
?:
$field
;
}
}
}
}
$line
=
1
;
/** @var array $mail */
foreach
(
$queue
as
$mail
)
{
foreach
(
$mail
as
$field
=>
$value
)
{
if
(
!
in_array
(
$field
,
$ignoreFields
,
TRUE
))
{
if
(
in_array
(
$field
,
$dateFields
,
TRUE
))
{
$export
[
$line
][]
=
$value
?
date
(
'd.m.Y'
,
$value
)
:
''
;
}
else
{
$export
[
$line
][]
=
(
string
)
$value
;
}
}
}
$line
++
;
}
foreach
(
$export
as
$line
)
{
/** @var array $line */
$fields
=
[];
foreach
(
$line
as
$field
)
{
$fields
[]
=
'"'
.
$field
.
'"'
;
}
$exportString
.
=
implode
(
','
,
$fields
)
.
';'
.
LF
;
}
}
return
trim
(
preg_replace
(
'/\s\s+/'
,
' '
,
strip_tags
(
$exportString
)));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment