Skip to content

Commit c167163

Browse files
committed
Improve email testing logic and reliability
1 parent 27a95c4 commit c167163

File tree

19 files changed

+140
-276
lines changed

19 files changed

+140
-276
lines changed

Block/Adminhtml/System/Config/Form/Composer/Version.php

Lines changed: 0 additions & 119 deletions
This file was deleted.

Block/Adminhtml/System/Config/Form/Module/Version.php

Lines changed: 0 additions & 74 deletions
This file was deleted.

Block/Adminhtml/System/Config/ValidateConfigButton.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Copyright © MagePal LLC. All rights reserved.
44
* See COPYING.txt for license details.
5-
* http://www.magepal.com | support@magepal.com
5+
* https://www.magepal.com | support@magepal.com
66
*/
77

88
namespace MagePal\CustomSmtp\Block\Adminhtml\System\Config;

Block/Adminhtml/ValidateConfig.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ValidateConfig extends Template
4343
/**
4444
* @var string
4545
*/
46-
protected $storeId;
46+
protected $storeId = null;
4747

4848
/**
4949
* @var string
@@ -165,18 +165,36 @@ public function loadDefaultConfig()
165165
$request = $this->getRequest();
166166
$formPostArray = (array) $request->getPost();
167167

168+
if ($request->getParam('website', false)) {
169+
$scopeCode = $request->getParam('website');
170+
$scopeType = ScopeInterface::SCOPE_WEBSITE;
171+
} else if ($request->getParam('store', false)) {
172+
$scopeCode = $request->getParam('store');
173+
$scopeType = ScopeInterface::SCOPE_STORE;
174+
} else {
175+
$scopeCode = null;
176+
$scopeType = ScopeInterface::SCOPE_STORE;
177+
}
178+
168179
$fields = array_keys($this->configFields);
169180
foreach ($fields as $field) {
170181
if (!array_key_exists($field, $formPostArray)) {
171-
$this->setConfig($field, $this->_dataHelper->getConfigValue($field), $this->getStoreId());
182+
$this->setConfig($field, $this->_dataHelper->getConfigValue($field, $scopeType, $scopeCode));
172183
} else {
173184
$this->setConfig($field, $request->getPost($field));
174185
}
175186
}
176187

188+
$this->loadObscuredData($scopeType, $scopeCode);
189+
190+
return $this;
191+
}
192+
193+
public function loadObscuredData($scopeType, $scopeCode)
194+
{
177195
//if password mask (6 stars)
178196
if ($this->getConfig('password') === '******') {
179-
$password = $this->_dataHelper->getConfigPassword($this->getStoreId());
197+
$password = $this->_dataHelper->getConfigPassword($scopeType, $scopeCode);
180198
$this->setConfig('password', $password);
181199
}
182200

@@ -189,13 +207,12 @@ public function loadDefaultConfig()
189207
protected function init()
190208
{
191209
$request = $this->getRequest();
192-
$this->setStoreId($request->getParam('store', null));
193210

194211
$this->loadDefaultConfig();
195212

196213
$this->toAddress = $this->getConfig('email') ? $this->getConfig('email') : $this->getConfig('username');
197214

198-
$this->fromAddress = trim($this->getConfig('from_email'));
215+
$this->fromAddress = trim((string) $this->getConfig('from_email'));
199216

200217
if (!$this->emailAddressValidator->isValid($this->fromAddress)) {
201218
$this->fromAddress = $this->toAddress;
@@ -299,6 +316,9 @@ protected function validateServerEmailSetting()
299316
return $result;
300317
}
301318

319+
/**
320+
* @return Smtp
321+
*/
302322
public function getMailTransportSmtp()
303323
{
304324
$username = $this->getConfig('username');

Controller/Adminhtml/Validateconfig/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Copyright © MagePal LLC. All rights reserved.
44
* See COPYING.txt for license details.
5-
* http://www.magepal.com | support@magepal.com
5+
* https://www.magepal.com | support@magepal.com
66
*/
77

88
namespace MagePal\CustomSmtp\Controller\Adminhtml\Validateconfig;

0 commit comments

Comments
 (0)