@@ -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 ' );
0 commit comments