From 440fa1a71c4ccc3383ced8f0bc3898a5b0139d61 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Tue, 30 May 2017 17:10:16 +0200 Subject: [PATCH] add mail blocker && mail redirect --- copy_this/modules/d3/d3dev/metadata.php | 39 +++++--- .../d3dev/modules/models/d3_dev_oxemail.php | 88 +++++++++++++++++++ .../d3/d3dev/views/admin/de/d3dev_lang.php | 8 ++ 3 files changed, 123 insertions(+), 12 deletions(-) diff --git a/copy_this/modules/d3/d3dev/metadata.php b/copy_this/modules/d3/d3dev/metadata.php index b54d207..5e5d347 100644 --- a/copy_this/modules/d3/d3dev/metadata.php +++ b/copy_this/modules/d3/d3dev/metadata.php @@ -27,22 +27,25 @@ $aModule = array( -->

Sicherheitshinweis

- '. + ''. + '
  • blockiert übers Framework versendete Mails oder leitet diese um
  • '. + '
    Jede dieser Optionen muss aus Sicherheitsgründen unter "Einstell." aktiviert werden. Weiterhin darf der Shop nicht im Produktivmodus betrieben werden.

    '. + '* Ordernummer an URL ergänzen, wenn bestimmte Bestellungen angezeigt werden sollen', 'en' => ''), // 'thumbnail' => 'picture.png', - 'version' => '0.1', + 'version' => '1.1', 'author' => 'D³ Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com', 'url' => 'http://www.oxidmodule.com/', @@ -82,6 +85,18 @@ $aModule = array( 'type' => 'bool', 'value' => 'false' ), + array( + 'group' => 'd3dev_mailblock', + 'name' => 'blD3DevBlockMails', + 'type' => 'bool', + 'value' => 'false' + ), + array( + 'group' => 'd3dev_mailblock', + 'name' => 'sD3DevRedirectMail', + 'type' => 'str', + 'value' => 'd3test1@shopmodule.com' + ), ), ); diff --git a/copy_this/modules/d3/d3dev/modules/models/d3_dev_oxemail.php b/copy_this/modules/d3/d3dev/modules/models/d3_dev_oxemail.php index 1c6a66f..924ad3f 100644 --- a/copy_this/modules/d3/d3dev/modules/models/d3_dev_oxemail.php +++ b/copy_this/modules/d3/d3dev/modules/models/d3_dev_oxemail.php @@ -143,4 +143,92 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent return $oSmarty->fetch($myConfig->getTemplatePath($sTpl, false)); } + + protected function _sendMail() + { + if (oxRegistry::getConfig()->getActiveShop()->oxshops__oxproductive->value) { + return parent::_sendMail(); + } + + $this->d3clearRecipients(); + $this->d3clearCC(); + $this->d3clearBCC(); + + if (count($this->getRecipient())) { + return parent::_sendMail(); + } + + return true; + } + + public function d3clearRecipients() + { + $aRecipients = array(); + if (is_array($this->_aRecipients) && count($this->_aRecipients)) { + foreach ($this->_aRecipients as $aRecInfo) { + if (($sNewRecipient = $this->getNewRecipient($aRecInfo[0])) + && $sNewRecipient != $aRecInfo[0] + ) { + $aRecInfo[1] = $aRecInfo[1]." (".$aRecInfo[0].")"; + $aRecInfo[0] = $sNewRecipient; + $aRecipients[] = $aRecInfo; + } elseif (($sNewRecipient = $this->getNewRecipient($aRecInfo[0]))) { + $aRecipients[] = $aRecInfo; + } + } + } + + $this->_aRecipients = $aRecipients; + } + + public function d3clearCC() + { + $aCc = array(); + if (is_array($this->cc) && count($this->cc)) { + foreach ($this->cc as $aRecInfo) { + if (($sNewRecipient = $this->getNewRecipient($aRecInfo[0])) + && $sNewRecipient != $aRecInfo[0] + ) { + $aRecInfo[1] = $aRecInfo[1]." (".$aRecInfo[0].")"; + $aRecInfo[0] = $sNewRecipient; + $aCc[] = $aRecInfo; + } elseif (($sNewRecipient = $this->getNewRecipient($aRecInfo[0]))) { + $aCc[] = $aRecInfo; + } + } + } + + $this->cc = $aCc; + } + + public function d3clearBCC() + { + $aCc = array(); + if (is_array($this->bcc) && count($this->bcc)) { + foreach ($this->bcc as $aRecInfo) { + if (($sNewRecipient = $this->getNewRecipient($aRecInfo[0])) + && $sNewRecipient != $aRecInfo[0] + ) { + $aRecInfo[1] = $aRecInfo[1]." (".$aRecInfo[0].")"; + $aRecInfo[0] = $sNewRecipient; + $aCc[] = $aRecInfo; + } elseif (($sNewRecipient = $this->getNewRecipient($aRecInfo[0]))) { + $aCc[] = $aRecInfo; + } + } + } + + $this->bcc = $aCc; + } + + public function getNewRecipient($sMailAddress) + { + if (oxRegistry::getConfig()->getConfigParam('blD3DevBlockMails')) { + return false; + } elseif (oxRegistry::getConfig()->getConfigParam('sD3DevRedirectMail')) { + return trim(oxRegistry::getConfig()->getConfigParam('sD3DevRedirectMail')); + } + + return $sMailAddress; + } } diff --git a/copy_this/modules/d3/d3dev/views/admin/de/d3dev_lang.php b/copy_this/modules/d3/d3dev/views/admin/de/d3dev_lang.php index 9b9cd23..7bc5f24 100644 --- a/copy_this/modules/d3/d3dev/views/admin/de/d3dev_lang.php +++ b/copy_this/modules/d3/d3dev/views/admin/de/d3dev_lang.php @@ -46,4 +46,12 @@ $aLang = array( 'jeweiligen Mails sind im Stamm-Tab aufgelistet.
    Für die Anzeige wird ohne Angabe der Bestellnummer die '. 'letzte vorliegende Bestellung geladen. Über den Parameter "d3ordernr=X" kann eine bestimmten Bestellung '. 'vorgegeben werden.', + + 'SHOP_MODULE_GROUP_d3dev_mailblock' => 'Mailversand', + 'SHOP_MODULE_blD3DevBlockMails' => 'Mails an beliebige Mailadressen werden nicht '. + 'versandt', + 'HELP_SHOP_MODULE_blD3DevBlockMails' => 'Der Mailversand wird komplett geblockt.', + 'SHOP_MODULE_sD3DevRedirectMail' => 'versendete Mails an diese Adresse umleiten', + 'HELP_SHOP_MODULE_sD3DevRedirectMail' => 'Wenn leer, erfolgt keine Umleitung. Ohne '. + 'zusätzliche Blockieroption werden die Mails dann an den original Empfänger gesendet.', );