@@ -28,6 +28,8 @@ protected function _prepareForm()
2828 $ data = Mage::registry ('tm_email_gateway_transport_data ' )->getData ();
2929 }
3030
31+ $ isNew = !isset ($ data ['id ' ]);
32+
3133 $ fieldset = $ form ->addFieldset (
3234 'gateway_general_form ' ,
3335 array ('legend ' => Mage::helper ('tm_email ' )->__ ('Email Transport Details ' ))
@@ -67,13 +69,106 @@ protected function _prepareForm()
6769 )
6870 ),
6971 ));
70- $ fieldset ->addField ('type ' , 'select ' , array (
72+
73+ $ el = $ fieldset ->addField ('type ' , 'select ' , array (
7174 'label ' => Mage::helper ('tm_email ' )->__ ('Type ' ),
7275 'name ' => 'type ' ,
7376 'required ' => true ,
74- 'values ' => TM_Email_Model_System_Config_Source_Gateway_Transport_Provider::toOptionArray ()
77+ 'values ' => TM_Email_Model_System_Config_Source_Gateway_Transport_Provider::toOptionArray (),
78+ 'onchange ' => $ isNew ? 'fillDefaultProviderData(this) ' : 'return false '
7579 ));
7680
81+ if ($ isNew ) {
82+ $ conf = array (
83+ TM_Email_Model_Gateway_Transport::TYPE_AOL => array (
84+ 'host ' => 'smtp.aol.com ' ,
85+ 'port ' => 587 ,
86+ 'secure ' => TM_Email_Model_Gateway_Transport::SECURE_NONE ,
87+ 'auth ' => TM_Email_Model_Gateway_Transport::AUTH_LOGIN
88+ ),
89+ TM_Email_Model_Gateway_Transport::TYPE_COMCAST => array (
90+ 'host ' => 'smtp.comcast.net ' ,
91+ 'port ' => 587 ,
92+ 'secure ' => TM_Email_Model_Gateway_Transport::SECURE_NONE ,
93+ 'auth ' => TM_Email_Model_Gateway_Transport::AUTH_LOGIN
94+ ),
95+ TM_Email_Model_Gateway_Transport::TYPE_GMX => array (
96+ 'host ' => 'mail.gmx.net ' ,
97+ 'port ' => 587 ,
98+ 'secure ' => TM_Email_Model_Gateway_Transport::SECURE_TLS ,
99+ 'auth ' => TM_Email_Model_Gateway_Transport::AUTH_LOGIN
100+ ),
101+ TM_Email_Model_Gateway_Transport::TYPE_GMAIL => array (
102+ 'host ' => 'smtp.gmail.com ' ,
103+ 'port ' => 465 ,
104+ 'secure ' => TM_Email_Model_Gateway_Transport::SECURE_SSL ,
105+ 'auth ' => TM_Email_Model_Gateway_Transport::AUTH_LOGIN
106+ ),
107+ TM_Email_Model_Gateway_Transport::TYPE_HOTMAIL => array (
108+ 'host ' => 'smtp.live.com ' ,
109+ 'port ' => 465 ,
110+ 'secure ' => TM_Email_Model_Gateway_Transport::SECURE_SSL ,
111+ 'auth ' => TM_Email_Model_Gateway_Transport::AUTH_LOGIN
112+ ),
113+ TM_Email_Model_Gateway_Transport::TYPE_MAILCOM => array (
114+ 'host ' => 'smtp.mail.com ' ,
115+ 'port ' => 465 ,
116+ 'secure ' => TM_Email_Model_Gateway_Transport::SECURE_SSL ,
117+ 'auth ' => TM_Email_Model_Gateway_Transport::AUTH_LOGIN
118+ ),
119+ TM_Email_Model_Gateway_Transport::TYPE_O2 => array (
120+ 'host ' => 'smtp.o2.ie ' ,
121+ 'port ' => 25 ,
122+ 'secure ' => TM_Email_Model_Gateway_Transport::SECURE_NONE ,
123+ 'auth ' => TM_Email_Model_Gateway_Transport::AUTH_LOGIN
124+ ),
125+ TM_Email_Model_Gateway_Transport::TYPE_OFFICE365 => array (
126+ 'host ' => 'smtp.office365.com ' ,
127+ 'port ' => 587 ,
128+ 'secure ' => TM_Email_Model_Gateway_Transport::SECURE_TLS ,
129+ 'auth ' => TM_Email_Model_Gateway_Transport::AUTH_LOGIN
130+ ),
131+ TM_Email_Model_Gateway_Transport::TYPE_ORANGE => array (
132+ 'host ' => 'smtp.orange.net ' ,
133+ 'port ' => 25 ,
134+ 'secure ' => TM_Email_Model_Gateway_Transport::SECURE_NONE ,
135+ 'auth ' => TM_Email_Model_Gateway_Transport::AUTH_LOGIN
136+ ),
137+ TM_Email_Model_Gateway_Transport::TYPE_OUTLOOK => array (
138+ 'host ' => 'smtp-mail.outlook.com ' ,
139+ 'port ' => 587 ,
140+ 'secure ' => TM_Email_Model_Gateway_Transport::SECURE_TLS ,
141+ 'auth ' => TM_Email_Model_Gateway_Transport::AUTH_LOGIN
142+ ),
143+ TM_Email_Model_Gateway_Transport::TYPE_YAHOO => array (
144+ 'host ' => 'smtp.mail.yahoo.com ' ,
145+ 'port ' => 465 ,
146+ 'secure ' => TM_Email_Model_Gateway_Transport::SECURE_SSL ,
147+ 'auth ' => TM_Email_Model_Gateway_Transport::AUTH_LOGIN
148+ ),
149+ TM_Email_Model_Gateway_Transport::TYPE_ZOHO => array (
150+ 'host ' => 'smtp.zoho.com ' ,
151+ 'port ' => 465 ,
152+ 'secure ' => TM_Email_Model_Gateway_Transport::SECURE_SSL ,
153+ 'auth ' => TM_Email_Model_Gateway_Transport::AUTH_LOGIN
154+ )
155+ );
156+ $ el ->setAfterElementHtml (
157+ "<script type= \"text/javascript \">
158+ function fillDefaultProviderData(element)
159+ {
160+ var type = element.value, dataset = " . json_encode ($ conf ) . ";
161+ if (dataset[type]) {
162+ \$H(dataset[type]).each(function(pair){
163+ $(pair.key).value = pair.value;
164+ });
165+ }
166+ }
167+ </script>
168+ " );
169+ }
170+
171+
77172 $ fieldset ->addField ('host ' , 'text ' , array (
78173 'label ' => Mage::helper ('tm_email ' )->__ ('Host ' ),
79174 'class ' => 'required-entry ' ,
@@ -141,4 +236,4 @@ protected function _prepareForm()
141236 $ this ->setForm ($ form );
142237 return parent ::_prepareForm ();
143238 }
144- }
239+ }
0 commit comments