diff --git a/Classes/Module/Dmail.php b/Classes/Module/Dmail.php index 8ee14d2fb..dc8088df6 100644 --- a/Classes/Module/Dmail.php +++ b/Classes/Module/Dmail.php @@ -1,4 +1,5 @@ - * @author Jan-Erik Revsbech - * @author Stanislas Rolland - * @author Ivan-Dharma Kartolo + * @author Kasper Skårhøj + * @author Jan-Erik Revsbech + * @author Stanislas Rolland + * @author Ivan-Dharma Kartolo * - * @package TYPO3 - * @subpackage tx_directmail + * @package TYPO3 + * @subpackage tx_directmail */ class Dmail extends BaseScriptClass { @@ -47,7 +49,7 @@ class Dmail extends BaseScriptClass public $TSconfPrefix = 'mod.web_modules.dmail.'; public $fieldList = 'uid,name,title,email,phone,www,address,company,city,zip,country,fax,module_sys_dmail_category,module_sys_dmail_html'; // Internal - public $params = array(); + public $params = []; public $perms_clause = ''; public $pageinfo = ''; public $sys_dmail_uid; @@ -59,13 +61,13 @@ class Dmail extends BaseScriptClass public $back; public $noView; public $mode; - public $implodedParams = array(); + public $implodedParams = []; // If set a valid user table is around public $userTable; public $sys_language_uid = 0; - public $error=''; - public $allowedTables = array('tt_address','fe_users'); + public $error = ''; + public $allowedTables = ['tt_address', 'fe_users']; public $MCONF; public $cshTable; public $formname = 'dmailform'; @@ -95,15 +97,15 @@ class Dmail extends BaseScriptClass */ public function __construct() { - $this->MCONF = array( - 'name' => $this->moduleName - ); + $this->MCONF = [ + 'name' => $this->moduleName, + ]; } /** * First initialization of global variables * - * @return void + * @return void */ public function init() { @@ -119,7 +121,7 @@ public function init() // get the config from pageTS $temp = BackendUtility::getModTSconfig($this->id, 'mod.web_modules.dmail'); if (!is_array($temp['properties'])) { - $temp['properties'] = array(); + $temp['properties'] = []; } $this->params = $temp['properties']; $this->implodedParams = DirectMailUtility::implodeTSParams($this->params); @@ -135,7 +137,14 @@ public function init() $parts = parse_url(GeneralUtility::getIndpEnv('TYPO3_SITE_URL')); if (BackendUtility::getDomainStartPage($parts['host'], $parts['path'])) { $temporaryPreUrl = BackendUtility::firstDomainRecord($rootLine); - $domain = BackendUtility::getRecordsByField('sys_domain', 'domainName', $temporaryPreUrl, ' AND hidden=0', '', 'sorting'); + $domain = BackendUtility::getRecordsByField( + 'sys_domain', + 'domainName', + $temporaryPreUrl, + ' AND hidden=0', + '', + 'sorting' + ); if (is_array($domain)) { reset($domain); $dom = current($domain); @@ -145,24 +154,31 @@ public function init() } } - $this->MOD_MENU['dmail_mode'] = BackendUtility::unsetMenuItems($this->params, $this->MOD_MENU['dmail_mode'], 'menu.dmail_mode'); + $this->MOD_MENU['dmail_mode'] = BackendUtility::unsetMenuItems( + $this->params, + $this->MOD_MENU['dmail_mode'], + 'menu.dmail_mode' + ); - // initialize backend user language + // initialize backend user language if ($this->getLanguageService()->lang && ExtensionManagementUtility::isLoaded('static_info_tables')) { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 'sys_language.uid', 'sys_language LEFT JOIN static_languages ON sys_language.static_lang_isocode=static_languages.uid', - 'static_languages.lg_typo3=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->getLanguageService()->lang, 'static_languages') . - BackendUtility::BEenableFields('sys_language') . - BackendUtility::deleteClause('sys_language') . - BackendUtility::deleteClause('static_languages') - ); + 'static_languages.lg_typo3=' . $GLOBALS['TYPO3_DB']->fullQuoteStr( + $this->getLanguageService()->lang, + 'static_languages' + ) . + BackendUtility::BEenableFields('sys_language') . + BackendUtility::deleteClause('sys_language') . + BackendUtility::deleteClause('static_languages') + ); while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) { $this->sys_language_uid = $row['uid']; } $GLOBALS['TYPO3_DB']->sql_free_result($res); } - // load contextual help + // load contextual help $this->cshTable = '_MOD_' . $this->MCONF['name']; if ($GLOBALS['BE_USER']->uc['edit_showFieldHelp']) { $this->getLanguageService()->loadSingleTableDescription($this->cshTable); @@ -172,7 +188,7 @@ public function init() /** * Prints out the module HTML * - * @return void + * @return void */ public function printContent() { @@ -190,7 +206,9 @@ public function printContent() public function mainAction(ServerRequestInterface $request, ResponseInterface $response) { $this->getLanguageService()->includeLLFile('EXT:direct_mail/Resources/Private/Language/locallang_mod2-6.xlf'); - $this->getLanguageService()->includeLLFile('EXT:direct_mail/Resources/Private/Language/locallang_csh_sysdmail.xlf'); + $this->getLanguageService()->includeLLFile( + 'EXT:direct_mail/Resources/Private/Language/locallang_csh_sysdmail.xlf' + ); $this->init(); @@ -204,7 +222,7 @@ public function mainAction(ServerRequestInterface $request, ResponseInterface $r /** * The main function. Set CSS and JS * - * @return void + * @return void */ public function main() { @@ -226,8 +244,15 @@ public function main() $this->doc->setModuleTemplate('EXT:direct_mail/Resources/Private/Templates/ModuleDirectMail.html'); $this->doc->form = '
'; - // Add CSS - $this->getPageRenderer()->addCssFile(ExtensionManagementUtility::extRelPath('direct_mail') . 'Resources/Public/StyleSheets/modules.css', 'stylesheet', 'all', '', false, false); + // Add CSS + $this->getPageRenderer()->addCssFile( + ExtensionManagementUtility::extRelPath('direct_mail') . 'Resources/Public/StyleSheets/modules.css', + 'stylesheet', + 'all', + '', + false, + false + ); // JavaScript if (GeneralUtility::inList('send_mail_final,send_mass', $this->CMD)) { @@ -237,11 +262,11 @@ public function main() $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/DateTimePicker'); // Define settings for Date Picker - $typo3Settings = array( + $typo3Settings = [ 'datePickerUSmode' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? 1 : 0, - 'dateFormat' => array('j-n-Y', 'G:i j-n-Y'), - 'dateFormatUS' => array('n-j-Y', 'G:i n-j-Y'), - ); + 'dateFormat' => ['j-n-Y', 'G:i j-n-Y'], + 'dateFormatUS' => ['n-j-Y', 'G:i n-j-Y'], + ]; $this->getPageRenderer()->addInlineSettingArray('', $typo3Settings); } @@ -306,28 +331,36 @@ function toggleDisplay(toggleId, e, countBox) { // '; - $this->doc->postCode=' + $this->doc->postCode = ' '; - $markers = array( - 'TITLE' => '', + $markers = [ + 'TITLE' => '', 'FLASHMESSAGES' => '', - 'CONTENT' => '', - 'WIZARDSTEPS' => '', - 'NAVIGATION' => '' - ); - - $docHeaderButtons = array( - 'PAGEPATH' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.php:labels.path') . ': ' . GeneralUtility::fixed_lgd_cs($this->pageinfo['_thePath'], 50), - 'SHORTCUT' => '' - ); - // shortcut icon + 'CONTENT' => '', + 'WIZARDSTEPS' => '', + 'NAVIGATION' => '', + ]; + + $docHeaderButtons = [ + 'PAGEPATH' => $this->getLanguageService()->sL( + 'LLL:EXT:lang/locallang_core.php:labels.path' + ) . ': ' . GeneralUtility::fixed_lgd_cs($this->pageinfo['_thePath'], 50), + 'SHORTCUT' => '', + ]; + // shortcut icon if ($BE_USER->mayMakeShortcut()) { - $docHeaderButtons['SHORTCUT'] = $this->doc->makeShortcutIcon('id', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name'], 1, 'btn btn-default btn-sm'); + $docHeaderButtons['SHORTCUT'] = $this->doc->makeShortcutIcon( + 'id', + implode(',', array_keys($this->MOD_MENU)), + $this->MCONF['name'], + 1, + 'btn btn-default btn-sm' + ); } $module = $this->pageinfo['module']; @@ -337,12 +370,13 @@ function toggleDisplay(toggleId, e, countBox) { // } if ($module == 'dmail') { // Render content: - // Direct mail module + // Direct mail module if (($this->pageinfo['doktype'] == 254) && ($this->pageinfo['module'] == 'dmail')) { $markers = $this->moduleContent(); } elseif ($this->id != 0) { /* @var $flashMessage FlashMessage */ - $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', + $flashMessage = GeneralUtility::makeInstance( + 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $this->getLanguageService()->getLL('dmail_noRegular'), $this->getLanguageService()->getLL('dmail_newsletters'), FlashMessage::WARNING @@ -352,7 +386,8 @@ function toggleDisplay(toggleId, e, countBox) { // } } else { /* @var $flashMessage FlashMessage */ - $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', + $flashMessage = GeneralUtility::makeInstance( + 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $this->getLanguageService()->getLL('select_folder'), $this->getLanguageService()->getLL('header_directmail'), FlashMessage::WARNING @@ -362,7 +397,7 @@ function toggleDisplay(toggleId, e, countBox) { // } $this->content = $this->doc->startPage($this->getLanguageService()->getLL('title')); - $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers, array()); + $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers, []); } else { // If no access or if ID == zero @@ -386,22 +421,22 @@ function toggleDisplay(toggleId, e, countBox) { // public function createDMail_quick(array $indata) { $theOutput = ""; - // Set default values: - $dmail = array(); - $dmail['sys_dmail']['NEW'] = array( - 'from_email' => $indata['senderEmail'], - 'from_name' => $indata['senderName'], - 'replyto_email' => $this->params['replyto_email'], - 'replyto_name' => $this->params['replyto_name'], + // Set default values: + $dmail = []; + $dmail['sys_dmail']['NEW'] = [ + 'from_email' => $indata['senderEmail'], + 'from_name' => $indata['senderName'], + 'replyto_email' => $this->params['replyto_email'], + 'replyto_name' => $this->params['replyto_name'], 'return_path' => $this->params['return_path'], - 'priority' => $this->params['priority'], - 'use_domain' => $this->params['use_domain'], - 'use_rdct' => $this->params['use_rdct'], - 'long_link_mode' => $this->params['long_link_mode'], - 'organisation' => $this->params['organisation'], - 'authcode_fieldList'=> $this->params['authcode_fieldList'], - 'plainParams' => '' - ); + 'priority' => $this->params['priority'], + 'use_domain' => $this->params['use_domain'], + 'use_rdct' => $this->params['use_rdct'] ?? 0, + 'long_link_mode' => $this->params['long_link_mode'] ?? 0, + 'organisation' => $this->params['organisation'], + 'authcode_fieldList' => $this->params['authcode_fieldList'], + 'plainParams' => '', + ]; // always plaintext $dmail['sys_dmail']['NEW']['sendOptions'] = 1; @@ -409,9 +444,9 @@ public function createDMail_quick(array $indata) $dmail['sys_dmail']['NEW']['subject'] = $indata['subject']; $dmail['sys_dmail']['NEW']['type'] = 1; $dmail['sys_dmail']['NEW']['pid'] = $this->pageinfo['uid']; - $dmail['sys_dmail']['NEW']['charset'] = isset($this->params['quick_mail_charset'])? $this->params['quick_mail_charset'] : 'utf-8'; + $dmail['sys_dmail']['NEW']['charset'] = isset($this->params['quick_mail_charset']) ? $this->params['quick_mail_charset'] : 'utf-8'; - // If params set, set default values: + // If params set, set default values: if (isset($this->params['includeMedia'])) { $dmail['sys_dmail']['NEW']['includeMedia'] = $this->params['includeMedia']; } @@ -425,9 +460,9 @@ public function createDMail_quick(array $indata) if ($dmail['sys_dmail']['NEW']['pid'] && $dmail['sys_dmail']['NEW']['sendOptions']) { /* @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */ - $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); + $tce = GeneralUtility::makeInstance(DataHandler::class); $tce->stripslashes_values = 0; - $tce->start($dmail, array()); + $tce->start($dmail, []); $tce->process_datamap(); $this->sys_dmail_uid = $tce->substNEWwithIDs['NEW']; @@ -435,8 +470,11 @@ public function createDMail_quick(array $indata) // link in the mail $message = '' . $indata['message'] . ''; if (trim($this->params['use_rdct'])) { - $message = DirectMailUtility::substUrlsInPlainText($message, $this->params['long_link_mode']?'all':'76', - DirectMailUtility::getUrlBase($this->params['use_domain'])); + $message = DirectMailUtility::substUrlsInPlainText( + $message, + $this->params['long_link_mode'] ? 'all' : '76', + DirectMailUtility::getUrlBase($this->params['use_domain']) + ); } if ($indata['breakLines']) { $message = wordwrap($message, 76, "\n"); @@ -478,7 +516,9 @@ public function compileQuickMail(array $row, $message) if (!$message || !$htmlmail->theParts['plain']['content']) { $errorMsg .= '
' . $this->getLanguageService()->getLL('dmail_no_plain_content') . ''; } elseif (!strstr(base64_decode($htmlmail->theParts['plain']['content']), '