Skip to content

Commit

Permalink
Merge pull request #195 from kartolo/release/6.0.0
Browse files Browse the repository at this point in the history
[TASK] Release version 6.0.0
  • Loading branch information
kartolo authored Jul 6, 2020
2 parents 6fac00d + f1593d5 commit e412aa7
Show file tree
Hide file tree
Showing 122 changed files with 4,290 additions and 3,714 deletions.
5 changes: 5 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These are supported funding model platforms

#github: kartolo
patreon: kartolo
custom: ['https://www.paypal.me/kartolo', 'http://www.amazon.de/gp/registry/3NIXEA6OTWU84']
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,5 @@
*.swp
#
# Ignore by common IDEs used directories/files
nbproject
*.idea
*.project
.buildpath
.project
.settings
.TemporaryItems
.webprj
.idea
91 changes: 91 additions & 0 deletions Classes/Command/InvokeMailerEngineCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
namespace DirectMailTeam\DirectMail\Command;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

use DirectMailTeam\DirectMail\Dmailer;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Class InvokeMailerEngineCommand
*
* Starts sending the newsletter by invoking mailer engine via CLI
*
* Use TYPO3 CLI module dispatcher with `direct_mail:invokemailerengine`
*
* This class replaces the earlier version of EXT:direct_mail/cli/cli_direct_mail.php from Ivan Kartolo, (c) 2008
* Executes the earlier solely option named 'masssend' which has been dropped as optional argument
*
* @package TYPO3
* @subpackage tx_directmail
* @author 2019 J.Kummer
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 2
*/
class InvokeMailerEngineCommand extends Command
{

/**
* Configure the command by defining the name, options and arguments
*/
public function configure()
{
$this->setDescription('Invoke Mailer Engine of EXT:directmail');
$this->setHelp('Describe ...');
$this->setHelp('
Sends newsletters which are ready to send.
Depend on how many direct_mail newsletters are planned or left to get send out,
and the extension configuration for number of messages to be sent per cycle of the dmailer cron task,
this command will send the latest open newsletter queue,
like the recommended scheduler task or BE module for invoking maler engine will do.');
}

/**
* Executes the command for showing sys_log entries
*
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// Check if cronjob is already running:
if (@file_exists(Environment::getPublicPath() . '/typo3temp/tx_directmail_cron.lock')) {
// If the lock is not older than 1 day, skip index creation:
if (filemtime(Environment::getPublicPath() . '/typo3temp/tx_directmail_cron.lock') > (time() - (60 * 60 * 24))) {
die('TYPO3 Direct Mail Cron: Aborting, another process is already running!' . LF);
} else {
echo('TYPO3 Direct Mail Cron: A .lock file was found but it is older than 1 day! Processing mails ...' . LF);
}
}

$lockfile = Environment::getPublicPath() . '/typo3temp/tx_directmail_cron.lock';
touch($lockfile);
// Fixing filepermissions
GeneralUtility::fixPermissions($lockfile);

/**
* The direct_mail engine
* @var $htmlmail Dmailer
*/
$htmlmail = GeneralUtility::makeInstance(Dmailer::class);
$htmlmail->start();
$htmlmail->runcron();

unlink($lockfile);
}
}
59 changes: 42 additions & 17 deletions Classes/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* The TYPO3 project - inspiring people to share!
*/

use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MailUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;

Expand Down Expand Up @@ -71,23 +73,32 @@ public function insert_dMailer_boundaries($content, $conf = array())
$mmTable = 'sys_dmail_ttcontent_category_mm';
$whereClause = '';
$orderBy = $foreignTable . '.uid';
$res = $this->cObj->exec_mm_query_uidList(
$select,
$localTableUidList,
$mmTable,
$foreignTable,
$whereClause,
'',
$orderBy
);

if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
$categoryList .= $row['uid'] . ',';
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
$categoryList = rtrim($categoryList, ',');

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($foreignTable);
$statement = $queryBuilder
->select($select)
->from($foreignTable)
->from($mmTable)
->where(
$queryBuilder->expr()->eq(
$foreignTable . '.uid',
$mmTable . '.uid_foreign'
)
)
->andWhere(
$queryBuilder->expr()->in(
$mmTable . '.uid_local',
$localTableUidList
)
)
->orderBy($orderBy)
->execute();


while (($row = $statement->fetch())) {
$categoryList .= $row['uid'] . ',';
}
$categoryList = rtrim($categoryList, ',');
}
// wrap boundaries around content
$content = $this->cObj->wrap($categoryList, $this->boundaryStartWrap) . $content . $this->boundaryEnd;
Expand Down Expand Up @@ -142,7 +153,21 @@ public function insertSitemapBoundaries($content, array $conf)
$uid = $this->cObj->data['uid'];
$content = '';

$categories = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_dmail_ttcontent_category_mm', 'uid_local=' . (int)$uid, '', 'sorting');
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_dmail_ttcontent_category_mm');
$categories = $queryBuilder
->select('*')
->from('sys_dmail_ttcontent_category_mm')
->where(
$queryBuilder->expr()->eq(
'uid_local',
(int) $uid
)
)
->orderBy('sorting')
->execute()
->fetchAll();


if (count($categories) > 0) {
$categoryList = array();
foreach ($categories as $category) {
Expand Down
Loading

0 comments on commit e412aa7

Please sign in to comment.