Daffodil_Advancenewsletter - Version 1.0.0.1

Version Notes

First Release

Download this release

Release Info

Developer Daffodil Software
Extension Daffodil_Advancenewsletter
Version 1.0.0.1
Comparing to
See all releases


Version 1.0.0.1

app/code/local/Daffodil/Advancenewsletter/Block/Grid.php ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml newsletter subscribers grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Daffodil_Advancenewsletter_Block_Grid extends Mage_Adminhtml_Block_Newsletter_Subscriber_Grid
35
+ {
36
+ /**
37
+ * Constructor
38
+ *
39
+ * Set main configuration of grid
40
+ */
41
+ public function __construct()
42
+ {
43
+ parent::__construct();
44
+ $this->setId('subscriberGrid');
45
+ $this->setUseAjax(true);
46
+ $this->setDefaultSort('subscriber_id', 'desc');
47
+ }
48
+
49
+ /**
50
+ * Prepare collection for grid
51
+ *
52
+ * @return Mage_Adminhtml_Block_Widget_Grid
53
+ */
54
+
55
+
56
+ protected function _prepareColumns()
57
+ {
58
+ $prefix= Mage::getStoreConfig('advancenewsletter/all_settings/prefix_show');
59
+ $firstname= Mage::getStoreConfig('advancenewsletter/all_settings/firstname_show');
60
+ $lastname= Mage::getStoreConfig('advancenewsletter/all_settings/lastname_show');
61
+ $company= Mage::getStoreConfig('advancenewsletter/all_settings/company_show');
62
+ $address= Mage::getStoreConfig('advancenewsletter/all_settings/address_show');
63
+ $city= Mage::getStoreConfig('advancenewsletter/all_settings/city_show');
64
+ $state= Mage::getStoreConfig('advancenewsletter/all_settings/state_show');
65
+ $country= Mage::getStoreConfig('advancenewsletter/all_settings/country_show');
66
+ $fax= Mage::getStoreConfig('advancenewsletter/all_settings/fax_show');
67
+ $phoneno= Mage::getStoreConfig('advancenewsletter/all_settings/phoneno_show');
68
+ $zipcode= Mage::getStoreConfig('advancenewsletter/all_settings/zipcode_show');
69
+ $this->addColumn('subscriber_id', array(
70
+ 'header' => Mage::helper('newsletter')->__('ID'),
71
+ 'index' => 'subscriber_id'
72
+ ));
73
+
74
+ if($prefix):
75
+ $this->addColumn('salutation', array(
76
+ 'header' => Mage::helper('newsletter')->__('Salutation'),
77
+ 'index' => 'salutation',
78
+ 'default' => '----'
79
+ ));
80
+ endif;
81
+
82
+ if(($firstname=="opt")||($firstname=="req")):
83
+ $this->addColumn('firstname', array(
84
+ 'header' => Mage::helper('newsletter')->__('First Name'),
85
+ 'index' => 'firstname',
86
+ 'default' => '----'
87
+ ));
88
+ endif;
89
+
90
+ if(($lastname=="opt")||($lastname=="req")):
91
+ $this->addColumn('lastname', array(
92
+ 'header' => Mage::helper('newsletter')->__('Last Name'),
93
+ 'index' => 'lastname',
94
+ 'default' => '----'
95
+ ));
96
+ endif;
97
+
98
+ if(($company=="opt")||($company=="req")):
99
+ $this->addColumn('company', array(
100
+ 'header' => Mage::helper('newsletter')->__('Company'),
101
+ 'index' => 'company',
102
+ 'default' => '----'
103
+ ));
104
+
105
+ endif;
106
+
107
+ if(($address=="opt")||($address=="req")):
108
+ $this->addColumn('address', array(
109
+ 'header' => Mage::helper('newsletter')->__('Address'),
110
+ 'index' => 'address',
111
+ 'default' => '----'
112
+ ));
113
+
114
+ endif;
115
+
116
+ if(($city=="opt")||($city=="req")):
117
+ $this->addColumn('city', array(
118
+ 'header' => Mage::helper('newsletter')->__('City'),
119
+ 'index' => 'city',
120
+ 'default' => '----'
121
+ ));
122
+ endif;
123
+
124
+ if(($state=="opt")||($state=="req")):
125
+ $this->addColumn('state', array(
126
+ 'header' => Mage::helper('newsletter')->__('State/Province'),
127
+ 'index' => 'state',
128
+ 'default' => '----'
129
+ ));
130
+ endif;
131
+
132
+ if (($country=="opt")||($country=="req")):
133
+ $this->addColumn('country_id', array(
134
+ 'header' => Mage::helper('newsletter')->__('Country ID'),
135
+ 'index' => 'country',
136
+ 'default' => '----'
137
+ ));
138
+ endif;
139
+
140
+ if(($fax=="opt")||($fax=="req")):
141
+ $this->addColumn('fax', array(
142
+ 'header' => Mage::helper('newsletter')->__('Fax'),
143
+ 'index' => 'fax',
144
+ 'default' => '----'
145
+ ));
146
+ endif;
147
+
148
+ if(($phoneno=="opt")||($phoneno=="req")):
149
+ $this->addColumn('phoneno', array(
150
+ 'header' => Mage::helper('newsletter')->__('Phone Number'),
151
+ 'index' => 'phoneno',
152
+ 'default' => '----'
153
+ ));
154
+ endif;
155
+
156
+ if(($zipcode=="opt")||($zipcode=="req")):
157
+ $this->addColumn('zipcode', array(
158
+ 'header' => Mage::helper('newsletter')->__('Zip/Postal Code'),
159
+ 'index' => 'zipcode',
160
+ 'default' => '----'
161
+ ));
162
+ endif;
163
+
164
+ $this->addColumn('email', array(
165
+ 'header' => Mage::helper('newsletter')->__('Email'),
166
+ 'index' => 'subscriber_email'
167
+ ));
168
+
169
+ $this->addColumn('type', array(
170
+ 'header' => Mage::helper('newsletter')->__('Type'),
171
+ 'index' => 'type',
172
+ 'type' => 'options',
173
+ 'options' => array(
174
+ 1 => Mage::helper('newsletter')->__('Guest'),
175
+ 2 => Mage::helper('newsletter')->__('Customer')
176
+ )
177
+ ));
178
+
179
+ $this->addColumn('status', array(
180
+ 'header' => Mage::helper('newsletter')->__('Status'),
181
+ 'index' => 'subscriber_status',
182
+ 'type' => 'options',
183
+ 'options' => array(
184
+ Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE => Mage::helper('newsletter')->__('Not Activated'),
185
+ Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED => Mage::helper('newsletter')->__('Subscribed'),
186
+ Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED => Mage::helper('newsletter')->__('Unsubscribed'),
187
+ Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED => Mage::helper('newsletter')->__('Unconfirmed'),
188
+ )
189
+ ));
190
+
191
+ $this->addColumn('website', array(
192
+ 'header' => Mage::helper('newsletter')->__('Website'),
193
+ 'index' => 'website_id',
194
+ 'type' => 'options',
195
+ 'options' => $this->_getWebsiteOptions()
196
+ ));
197
+
198
+ $this->addColumn('group', array(
199
+ 'header' => Mage::helper('newsletter')->__('Store'),
200
+ 'index' => 'group_id',
201
+ 'type' => 'options',
202
+ 'options' => $this->_getStoreGroupOptions()
203
+ ));
204
+
205
+ $this->addColumn('store', array(
206
+ 'header' => Mage::helper('newsletter')->__('Store View'),
207
+ 'index' => 'store_id',
208
+ 'type' => 'options',
209
+ 'options' => $this->_getStoreOptions()
210
+ ));
211
+
212
+ $this->addExportType('*/*/exportCsv', Mage::helper('customer')->__('CSV'));
213
+ $this->addExportType('*/*/exportXml', Mage::helper('customer')->__('Excel XML'));
214
+
215
+ }
216
+
217
+
218
+ }
app/code/local/Daffodil/Advancenewsletter/Helper/Data.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Daffodil Advance Newsletter
5
+ */
6
+ ?>
7
+ <?php
8
+ class Daffodil_Advancenewsletter_Helper_Data extends Mage_Core_Helper_Abstract
9
+ {
10
+
11
+ }
app/code/local/Daffodil/Advancenewsletter/Model/Resource/Mysql4/Setup.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Daffodil_Advancenewsletter_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup
3
+ {
4
+ }
5
+
6
+ ?>
app/code/local/Daffodil/Advancenewsletter/Model/Subscriber.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Newsletter
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Newsletter subscriber model for MySQL4
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Newsletter
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Daffodil_Advancenewsletter_Model_Subscriber extends Mage_Newsletter_Model_Mysql4_Subscriber
36
+ {
37
+ protected function _prepareSave(Mage_Newsletter_Model_Subscriber $subscriber)
38
+ {
39
+ $data = array();
40
+ $data['customer_id'] = $subscriber->getCustomerId();
41
+ $data['store_id'] = $subscriber->getStoreId()?$subscriber->getStoreId():0;
42
+ $data['subscriber_status'] = $subscriber->getStatus();
43
+ $data['subscriber_email'] = $subscriber->getEmail();
44
+ $data['subscriber_confirm_code'] = $subscriber->getCode();
45
+ $data['salutation']= $subscriber->getSalutation();
46
+ $data['firstname'] = $subscriber->getFirstname();
47
+ $data['lastname'] = $subscriber->getLastname();
48
+ $data['company']= $subscriber->getCompany();
49
+ $data['address']= $subscriber->getAddress();
50
+ $data['country_id']= $subscriber->getCountryId();
51
+ $data['city']= $subscriber->getCity();
52
+ $data['state']= $subscriber->getState();
53
+ $data['phoneno']= $subscriber->getPhoneno();
54
+ $data['fax']= $subscriber->getFax();
55
+ $data['zipcode']= $subscriber->getZipcode();
56
+
57
+ //ADD A NEW FIELD END
58
+ }
59
+ }
app/code/local/Daffodil/Advancenewsletter/controllers/SubscriberController.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Newsletter
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Newsletter subscribe controller
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Newsletter
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ require_once("Mage/Newsletter/controllers/SubscriberController.php");
35
+ class Daffodil_Advancenewsletter_SubscriberController extends Mage_Newsletter_SubscriberController
36
+ {
37
+ /**
38
+ * New subscription action
39
+ */
40
+ public function newAction()
41
+ {
42
+ if ($this->getRequest()->isPost() && $this->getRequest()->getPost('email')) {
43
+ $session = Mage::getSingleton('core/session');
44
+ $customerSession = Mage::getSingleton('customer/session');
45
+ $email = (string) $this->getRequest()->getPost('email');
46
+
47
+ try {
48
+ if (!Zend_Validate::is($email, 'EmailAddress')) {
49
+ Mage::throwException($this->__('Please enter a valid email address.'));
50
+ }
51
+
52
+ if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 &&
53
+ !$customerSession->isLoggedIn()) {
54
+ Mage::throwException($this->__('Sorry, but administrator denied subscription for guests. Please <a href="%s">register</a>.', Mage::helper('customer')->getRegisterUrl()));
55
+ }
56
+
57
+ $ownerId = Mage::getModel('customer/customer')
58
+ ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
59
+ ->loadByEmail($email)
60
+ ->getId();
61
+ if ($ownerId !== null && $ownerId != $customerSession->getId()) {
62
+ Mage::throwException($this->__('This email address is already assigned to another user.'));
63
+ }
64
+
65
+ $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
66
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
67
+ $session->addSuccess($this->__('Confirmation request has been sent.'));
68
+ }
69
+ else {
70
+ $session->addSuccess($this->__('Thank you for your subscription.'));
71
+ }
72
+
73
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
74
+ $subscriber->setSalutation((string) $this->getRequest()->getPost('salutation'));
75
+ $subscriber->setFirstname((string) $this->getRequest()->getPost('firstname'));
76
+ $subscriber->setLastname((string) $this->getRequest()->getPost('lastname'));
77
+ $subscriber->setCompany((string) $this->getRequest()->getPost('company'));
78
+ $subscriber->setAddress((string) $this->getRequest()->getPost('address'));
79
+ $subscriber->setCountry((string) $this->getRequest()->getPost('country_id'));
80
+ $subscriber->setCity((string) $this->getRequest()->getPost('city'));
81
+ $subscriber->setState((string) $this->getRequest()->getPost('hidden-name'));
82
+ $subscriber->setPhoneno((string) $this->getRequest()->getPost('phoneno'));
83
+ $subscriber->setFax((string) $this->getRequest()->getPost('fax'));
84
+ $subscriber->setZipcode((string) $this->getRequest()->getPost('zipcode'));
85
+ //don't forget to save the subscriber!
86
+ $subscriber->save();
87
+
88
+
89
+ }
90
+ catch (Mage_Core_Exception $e) {
91
+ $session->addException($e, $this->__('There was a problem with the subscription: %s', $e->getMessage()));
92
+ }
93
+ catch (Exception $e) {
94
+ $session->addException($e, $this->__('There was a problem with the subscription.'));
95
+ }
96
+ }
97
+ $this->_redirectReferer();
98
+ }
99
+
100
+ /**
101
+ * Subscription confirm action
102
+ */
103
+ public function confirmAction()
104
+ {
105
+ $id = (int) $this->getRequest()->getParam('id');
106
+ $code = (string) $this->getRequest()->getParam('code');
107
+
108
+ if ($id && $code) {
109
+ $subscriber = Mage::getModel('newsletter/subscriber')->load($id);
110
+ $session = Mage::getSingleton('core/session');
111
+
112
+ if($subscriber->getId() && $subscriber->getCode()) {
113
+ if($subscriber->confirm($code)) {
114
+ $session->addSuccess($this->__('Your subscription has been confirmed.'));
115
+ } else {
116
+ $session->addError($this->__('Invalid subscription confirmation code.'));
117
+ }
118
+ } else {
119
+ $session->addError($this->__('Invalid subscription ID.'));
120
+ }
121
+ }
122
+
123
+ $this->_redirectUrl(Mage::getBaseUrl());
124
+ }
125
+
126
+ /**
127
+ * Unsubscribe newsletter
128
+ */
129
+ public function unsubscribeAction()
130
+ {
131
+ $id = (int) $this->getRequest()->getParam('id');
132
+ $code = (string) $this->getRequest()->getParam('code');
133
+
134
+ if ($id && $code) {
135
+ $session = Mage::getSingleton('core/session');
136
+ try {
137
+ Mage::getModel('newsletter/subscriber')->load($id)
138
+ ->setCheckCode($code)
139
+ ->unsubscribe();
140
+ $session->addSuccess($this->__('You have been unsubscribed.'));
141
+ }
142
+ catch (Mage_Core_Exception $e) {
143
+ $session->addException($e, $e->getMessage());
144
+ }
145
+ catch (Exception $e) {
146
+ $session->addException($e, $this->__('There was a problem with the un-subscription.'));
147
+ }
148
+ }
149
+ $this->_redirectReferer();
150
+ }
151
+ }
app/code/local/Daffodil/Advancenewsletter/controllers/SubscriberController.php~ ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Newsletter
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Newsletter subscribe controller
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Newsletter
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ require_once("Mage/Newsletter/controllers/SubscriberController.php");
35
+ class Daffodil_Advancenewsletter_SubscriberController extends Mage_Newsletter_SubscriberController
36
+ {
37
+ /**
38
+ * New subscription action
39
+ */
40
+ public function newAction()
41
+ {
42
+ if ($this->getRequest()->isPost() && $this->getRequest()->getPost('email')) {
43
+ $session = Mage::getSingleton('core/session');
44
+ $customerSession = Mage::getSingleton('customer/session');
45
+ $email = (string) $this->getRequest()->getPost('email');
46
+
47
+ try {
48
+ if (!Zend_Validate::is($email, 'EmailAddress')) {
49
+ Mage::throwException($this->__('Please enter a valid email address.'));
50
+ }
51
+
52
+ if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 &&
53
+ !$customerSession->isLoggedIn()) {
54
+ Mage::throwException($this->__('Sorry, but administrator denied subscription for guests. Please <a href="%s">register</a>.', Mage::helper('customer')->getRegisterUrl()));
55
+ }
56
+
57
+ $ownerId = Mage::getModel('customer/customer')
58
+ ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
59
+ ->loadByEmail($email)
60
+ ->getId();
61
+ if ($ownerId !== null && $ownerId != $customerSession->getId()) {
62
+ Mage::throwException($this->__('This email address is already assigned to another user.'));
63
+ }
64
+
65
+ $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
66
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
67
+ $session->addSuccess($this->__('Confirmation request has been sent.'));
68
+ }
69
+ else {
70
+ $session->addSuccess($this->__('Thank you for your subscription.'));
71
+ }
72
+
73
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
74
+ $subscriber->setSalutation((string) $this->getRequest()->getPost('salutation'));
75
+ $subscriber->setFirstname((string) $this->getRequest()->getPost('firstname'));
76
+ $subscriber->setLastname((string) $this->getRequest()->getPost('lastname'));
77
+ $subscriber->setCompany((string) $this->getRequest()->getPost('company'));
78
+ $subscriber->setAddress((string) $this->getRequest()->getPost('address'));
79
+ $subscriber->setCountry((string) $this->getRequest()->getPost('country_id'));
80
+ $subscriber->setCity((string) $this->getRequest()->getPost('city'));
81
+ $subscriber->setState((string) $this->getRequest()->getPost('hidden-name'));
82
+ $subscriber->setPhoneno((string) $this->getRequest()->getPost('phoneno'));
83
+ $subscriber->setFax((string) $this->getRequest()->getPost('fax'));
84
+ $subscriber->setZipcode((string) $this->getRequest()->getPost('zipcode'));
85
+ //don't forget to save the subscriber!
86
+ $subscriber->save();
87
+
88
+
89
+ }
90
+ catch (Mage_Core_Exception $e) {
91
+ $session->addException($e, $this->__('There was a problem with the subscription: %s', $e->getMessage()));
92
+ }
93
+ catch (Exception $e) {
94
+ $session->addException($e, $this->__('There was a problem with the subscription.'));
95
+ }
96
+ }
97
+ $this->_redirectReferer();
98
+ }
99
+
100
+ /**
101
+ * Subscription confirm action
102
+ */
103
+ public function confirmAction()
104
+ {
105
+ $id = (int) $this->getRequest()->getParam('id');
106
+ $code = (string) $this->getRequest()->getParam('code');
107
+
108
+ if ($id && $code) {
109
+ $subscriber = Mage::getModel('newsletter/subscriber')->load($id);
110
+ $session = Mage::getSingleton('core/session');
111
+
112
+ if($subscriber->getId() && $subscriber->getCode()) {
113
+ if($subscriber->confirm($code)) {
114
+ $session->addSuccess($this->__('Your subscription has been confirmed.'));
115
+ } else {
116
+ $session->addError($this->__('Invalid subscription confirmation code.'));
117
+ }
118
+ } else {
119
+ $session->addError($this->__('Invalid subscription ID.'));
120
+ }
121
+ }
122
+
123
+ $this->_redirectUrl(Mage::getBaseUrl());
124
+ }
125
+
126
+ /**
127
+ * Unsubscribe newsletter
128
+ */
129
+ public function unsubscribeAction()
130
+ {
131
+ $id = (int) $this->getRequest()->getParam('id');
132
+ $code = (string) $this->getRequest()->getParam('code');
133
+
134
+ if ($id && $code) {
135
+ $session = Mage::getSingleton('core/session');
136
+ try {
137
+ Mage::getModel('newsletter/subscriber')->load($id)
138
+ ->setCheckCode($code)
139
+ ->unsubscribe();
140
+ $session->addSuccess($this->__('You have been unsubscribed.'));
141
+ }
142
+ catch (Mage_Core_Exception $e) {
143
+ $session->addException($e, $e->getMessage());
144
+ }
145
+ catch (Exception $e) {
146
+ $session->addException($e, $this->__('There was a problem with the un-subscription.'));
147
+ }
148
+ }
149
+ $this->_redirectReferer();
150
+ }
151
+ }
app/code/local/Daffodil/Advancenewsletter/etc/config.xml ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Daffodil_Advancenewsletter>
5
+ <version>0.1.0</version>
6
+ </Daffodil_Advancenewsletter>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <advancenewsletter>
11
+ <class>Daffodil_Advancenewsletter_Helper</class>
12
+ </advancenewsletter>
13
+ </helpers>
14
+ <blocks>
15
+ <adminhtml>
16
+ <rewrite>
17
+ <newsletter_subscriber_grid>Daffodil_Advancenewsletter_Block_Grid</newsletter_subscriber_grid>
18
+ </rewrite>
19
+ </adminhtml>
20
+ </blocks>
21
+ <models>
22
+ <newsletter>
23
+ <rewrite>
24
+ <mysql4_subscriber>Daffodil_Advancenewsletter_Model_Subscriber</mysql4_subscriber>
25
+ </rewrite>
26
+ </newsletter>
27
+ </models>
28
+ <resources>
29
+ <advancenewsletter_setup>
30
+ <setup>
31
+ <module>Daffodil_Advancenewsletter</module>
32
+ <class>Daffodil_Advancenewsletter_Model_Resource_Mysql4_Setup</class>
33
+ </setup>
34
+ <connection>
35
+ <use>core_setup</use>
36
+ </connection>
37
+ </advancenewsletter_setup>
38
+ </resources>
39
+ </global>
40
+ <frontend>
41
+ <routers>
42
+ <newsletter>
43
+ <args>
44
+ <modules>
45
+ <Daffodil_Advancenewsletter before="Mage_Newsletter">Daffodil_Advancenewsletter</Daffodil_Advancenewsletter>
46
+ </modules>
47
+ </args>
48
+ </newsletter>
49
+ <advancenewsletter>
50
+ <use>standard</use>
51
+ <args>
52
+ <module>Daffodil_Advancenewsletter</module>
53
+ <frontName>advancenewsletter</frontName>
54
+ </args>
55
+ </advancenewsletter>
56
+ </routers>
57
+ <layout>
58
+ <updates>
59
+ <advancenewsletter>
60
+ <file>advancenewsletter.xml</file>
61
+ </advancenewsletter>
62
+ </updates>
63
+ </layout>
64
+ </frontend>
65
+
66
+ <adminhtml>
67
+ <acl>
68
+ <resources>
69
+ <admin>
70
+ <children>
71
+ <system>
72
+ <children>
73
+ <config>
74
+ <children>
75
+ <advancenewsletter>
76
+ <title>Daffodil Advance Newsletter</title>
77
+ </advancenewsletter>
78
+ </children>
79
+ </config>
80
+ </children>
81
+ </system>
82
+ </children>
83
+ </admin>
84
+ </resources>
85
+ </acl>
86
+ </adminhtml>
87
+ <default>
88
+ <advancenewsletter>
89
+ <all_settings>
90
+ <enabled>1</enabled>
91
+ <prefix_show>1</prefix_show>
92
+ <firstname_show>opt</firstname_show>
93
+ <lastname_show>opt</lastname_show>
94
+ <confirmemail_show>1</confirmemail_show>
95
+ <company_show>opt</company_show>
96
+ <address_show>opt</address_show>
97
+ <city_show>opt</city_show>
98
+ <state_show>opt</state_show>
99
+ <country_show>opt</country_show>
100
+ <fax_show>opt</fax_show>
101
+ <phoneno_show>opt</phoneno_show>
102
+ <zipcode_show>opt</zipcode_show>
103
+ </all_settings>
104
+ </advancenewsletter>
105
+ </default>
106
+ </config>
app/code/local/Daffodil/Advancenewsletter/etc/config.xml~ ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Daffodil_Advancenewsletter>
5
+ <version>0.1.0</version>
6
+ </Daffodil_Advancenewsletter>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <advancenewsletter>
11
+ <class>Daffodil_Advancenewsletter_Helper</class>
12
+ </advancenewsletter>
13
+ </helpers>
14
+ <blocks>
15
+ <adminhtml>
16
+ <rewrite>
17
+ <newsletter_subscriber_grid>Daffodil_Advancenewsletter_Block_Grid</newsletter_subscriber_grid>
18
+ </rewrite>
19
+ </adminhtml>
20
+ </blocks>
21
+ <models>
22
+ <newsletter>
23
+ <rewrite>
24
+ <mysql4_subscriber>Daffodil_Advancenewsletter_Model_Subscriber</mysql4_subscriber>
25
+ </rewrite>
26
+ </newsletter>
27
+ </models>
28
+ <resources>
29
+ <advancenewsletter_setup>
30
+ <setup>
31
+ <module>Daffodil_Advancenewsletter</module>
32
+ <class>Daffodil_Advancenewsletter_Model_Resource_Mysql4_Setup</class>
33
+ </setup>
34
+ <connection>
35
+ <use>core_setup</use>
36
+ </connection>
37
+ </advancenewsletter_setup>
38
+ </resources>
39
+ </global>
40
+ <frontend>
41
+ <routers>
42
+ <newsletter>
43
+ <args>
44
+ <modules>
45
+ <Daffodil_Advancenewsletter before="Mage_Newsletter">Daffodil_Advancenewsletter</Daffodil_Advancenewsletter>
46
+ </modules>
47
+ </args>
48
+ </newsletter>
49
+ <advancenewsletter>
50
+ <use>standard</use>
51
+ <args>
52
+ <module>Daffodil_Advancenewsletter</module>
53
+ <frontName>advancenewsletter</frontName>
54
+ </args>
55
+ </advancenewsletter>
56
+ </routers>
57
+ <layout>
58
+ <updates>
59
+ <advancenewsletter>
60
+ <file>advancenewsletter.xml</file>
61
+ </advancenewsletter>
62
+ </updates>
63
+ </layout>
64
+ </frontend>
65
+
66
+ <adminhtml>
67
+ <acl>
68
+ <resources>
69
+ <admin>
70
+ <children>
71
+ <system>
72
+ <children>
73
+ <config>
74
+ <children>
75
+ <advancenewsletter>
76
+ <title>Daffodil Advance Newsletter</title>
77
+ </advancenewsletter>
78
+ </children>
79
+ </config>
80
+ </children>
81
+ </system>
82
+ </children>
83
+ </admin>
84
+ </resources>
85
+ </acl>
86
+ </adminhtml>
87
+ <default>
88
+ <advancenewsletter>
89
+ <all_settings>
90
+ <enabled>1</enabled>
91
+ <prefix_show>1</prefix_show>
92
+ <firstname_show>opt</firstname_show>
93
+ <lastname_show>opt</lastname_show>
94
+ <confirmemail_show>1</confirmemail_show>
95
+ <company_show>opt</company_show>
96
+ <address_show>opt</address_show>
97
+ <city_show>opt</city_show>
98
+ <state_show>opt</state_show>
99
+ <country_show>opt</country_show>
100
+ <fax_show>opt</fax_show>
101
+ <phoneno_show>opt</phoneno_show>
102
+ <zipcode_show>opt</zipcode_show>
103
+ </all_settings>
104
+ </advancenewsletter>
105
+ </default>
106
+ </config>
app/code/local/Daffodil/Advancenewsletter/etc/system.xml ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <daffodil translate="label" module="advancenewsletter">
5
+ <label>Daffodil Extension</label>
6
+ <sort_order>100</sort_order>
7
+ </daffodil>
8
+ </tabs>
9
+ <sections>
10
+ <advancenewsletter translate="label" module="advancenewsletter">
11
+ <tab>daffodil</tab>
12
+ <label>Daffodil Newsletter+ setting</label>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1000</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <all_settings translate="label">
20
+ <label>Newsletter+ settings</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>10</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>0</show_in_store>
26
+ <fields>
27
+ <enabled translate="label">
28
+ <label>Enable Newsletters</label>
29
+ <comment>Enable or Disable Advance Newsletter</comment>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>adminhtml/system_config_source_yesno</source_model>
32
+ <sort_order>1</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>0</show_in_store>
36
+ </enabled>
37
+ <prefix_show translate="label comment">
38
+ <label>Show Prefix</label>
39
+ <frontend_type>select</frontend_type>
40
+ <source_model>adminhtml/system_config_source_yesno</source_model>
41
+ <sort_order>2</sort_order>
42
+ <comment>The title that goes before name (Mr., Mrs., etc.)</comment>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>0</show_in_store>
46
+ </prefix_show>
47
+ <firstname_show translate="label comment">
48
+ <label>Show First Name</label>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
51
+ <sort_order>3</sort_order>
52
+ <comment>Show First name Field in Advance Newsletter</comment>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>0</show_in_store>
56
+ </firstname_show>
57
+ <lastname_show translate="label comment">
58
+ <label>Show Last Name</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
61
+ <sort_order>4</sort_order>
62
+ <comment>Show Last name Field in Advance Newsletter</comment>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>0</show_in_store>
66
+ </lastname_show>
67
+ <confirmemail_show translate="label comment">
68
+ <label>Confirm Email</label>
69
+ <frontend_type>select</frontend_type>
70
+ <source_model>adminhtml/system_config_source_yesno</source_model>
71
+ <sort_order>5</sort_order>
72
+ <comment>Show Confirm Email Field in Advance Newsletter</comment>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>0</show_in_store>
76
+ </confirmemail_show>
77
+ <company_show translate="label comment">
78
+ <label>Show Company</label>
79
+ <frontend_type>select</frontend_type>
80
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
81
+ <sort_order>6</sort_order>
82
+ <comment>Show Company Field in Advance Newsletter</comment>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>0</show_in_store>
86
+ </company_show>
87
+ <address_show translate="label comment">
88
+ <label>Show Address</label>
89
+ <frontend_type>select</frontend_type>
90
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
91
+ <sort_order>7</sort_order>
92
+ <comment>Show Address Field in Advance Newsletter</comment>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>0</show_in_store>
96
+ </address_show>
97
+ <city_show translate="label comment">
98
+ <label>Show City</label>
99
+ <frontend_type>select</frontend_type>
100
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
101
+ <sort_order>8</sort_order>
102
+ <comment>Show City Field in Advance Newsletter</comment>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>0</show_in_store>
106
+ </city_show>
107
+ <state_show translate="label comment">
108
+ <label>Show State/Province</label>
109
+ <frontend_type>select</frontend_type>
110
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
111
+ <sort_order>9</sort_order>
112
+ <comment>Show State/Province Field in Advance Newsletter</comment>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>0</show_in_store>
116
+ </state_show>
117
+ <country_show translate="label comment">
118
+ <label>Show Country</label>
119
+ <frontend_type>select</frontend_type>
120
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
121
+ <sort_order>10</sort_order>
122
+ <comment>Show Country Field in Advance Newsletter</comment>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>1</show_in_website>
125
+ <show_in_store>0</show_in_store>
126
+ </country_show>
127
+ <fax_show translate="label comment">
128
+ <label>Show Fax</label>
129
+ <frontend_type>select</frontend_type>
130
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
131
+ <sort_order>11</sort_order>
132
+ <comment>Show Fax Field in Advance Newsletter</comment>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>0</show_in_store>
136
+ </fax_show>
137
+ <phoneno_show translate="label comment">
138
+ <label>Show Phone number</label>
139
+ <frontend_type>select</frontend_type>
140
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
141
+ <sort_order>12</sort_order>
142
+ <comment>Show Phone Number Field in Advance Newsletter</comment>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>0</show_in_store>
146
+ </phoneno_show>
147
+ <zipcode_show translate="label comment">
148
+ <label>Show Zip/Postal Code</label>
149
+ <frontend_type>select</frontend_type>
150
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
151
+ <sort_order>13</sort_order>
152
+ <comment>Show Zip/Postal Code Field in Advance Newsletter</comment>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>0</show_in_store>
156
+ </zipcode_show>
157
+ </fields>
158
+ </all_settings>
159
+ </groups>
160
+ </advancenewsletter>
161
+ </sections>
162
+ </config>
app/code/local/Daffodil/Advancenewsletter/etc/system.xml~ ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <advancenewsletter translate="label" module="advancenewsletter">
5
+ <label>Daffodil Advance Newsletter</label>
6
+ <sort_order>100</sort_order>
7
+ </advancenewsletter>
8
+ </tabs>
9
+ <sections>
10
+ <advancenewsletter translate="label" module="advancenewsletter">
11
+ <tab>advancenewsletter</tab>
12
+ <label>Advance Newsletters setting</label>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1000</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <all_settings translate="label">
20
+ <label>Newsletters settings</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>10</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>0</show_in_store>
26
+ <fields>
27
+ <enabled translate="label">
28
+ <label>Enable Newsletters</label>
29
+ <comment>Enable or Disable Advance Newsletter</comment>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>adminhtml/system_config_source_yesno</source_model>
32
+ <sort_order>1</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>0</show_in_store>
36
+ </enabled>
37
+ <prefix_show translate="label comment">
38
+ <label>Show Prefix</label>
39
+ <frontend_type>select</frontend_type>
40
+ <source_model>adminhtml/system_config_source_yesno</source_model>
41
+ <sort_order>2</sort_order>
42
+ <comment>The title that goes before name (Mr., Mrs., etc.)</comment>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>0</show_in_store>
46
+ </prefix_show>
47
+ <firstname_show translate="label comment">
48
+ <label>Show First Name</label>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
51
+ <sort_order>3</sort_order>
52
+ <comment>Show First name Field in Advance Newsletter</comment>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>0</show_in_store>
56
+ </firstname_show>
57
+ <lastname_show translate="label comment">
58
+ <label>Show Last Name</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
61
+ <sort_order>4</sort_order>
62
+ <comment>Show Last name Field in Advance Newsletter</comment>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>0</show_in_store>
66
+ </lastname_show>
67
+ <confirmemail_show translate="label comment">
68
+ <label>Confirm Email</label>
69
+ <frontend_type>select</frontend_type>
70
+ <source_model>adminhtml/system_config_source_yesno</source_model>
71
+ <sort_order>5</sort_order>
72
+ <comment>Show Confirm Email Field in Advance Newsletter</comment>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>0</show_in_store>
76
+ </confirmemail_show>
77
+ <company_show translate="label comment">
78
+ <label>Show Company</label>
79
+ <frontend_type>select</frontend_type>
80
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
81
+ <sort_order>6</sort_order>
82
+ <comment>Show Company Field in Advance Newsletter</comment>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>0</show_in_store>
86
+ </company_show>
87
+ <address_show translate="label comment">
88
+ <label>Show Address</label>
89
+ <frontend_type>select</frontend_type>
90
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
91
+ <sort_order>7</sort_order>
92
+ <comment>Show Address Field in Advance Newsletter</comment>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>0</show_in_store>
96
+ </address_show>
97
+ <city_show translate="label comment">
98
+ <label>Show City</label>
99
+ <frontend_type>select</frontend_type>
100
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
101
+ <sort_order>8</sort_order>
102
+ <comment>Show City Field in Advance Newsletter</comment>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>0</show_in_store>
106
+ </city_show>
107
+ <state_show translate="label comment">
108
+ <label>Show State/Province</label>
109
+ <frontend_type>select</frontend_type>
110
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
111
+ <sort_order>9</sort_order>
112
+ <comment>Show State/Province Field in Advance Newsletter</comment>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>0</show_in_store>
116
+ </state_show>
117
+ <country_show translate="label comment">
118
+ <label>Show Country</label>
119
+ <frontend_type>select</frontend_type>
120
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
121
+ <sort_order>10</sort_order>
122
+ <comment>Show Country Field in Advance Newsletter</comment>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>1</show_in_website>
125
+ <show_in_store>0</show_in_store>
126
+ </country_show>
127
+ <fax_show translate="label comment">
128
+ <label>Show Fax</label>
129
+ <frontend_type>select</frontend_type>
130
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
131
+ <sort_order>11</sort_order>
132
+ <comment>Show Fax Field in Advance Newsletter</comment>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>0</show_in_store>
136
+ </fax_show>
137
+ <phoneno_show translate="label comment">
138
+ <label>Show Phone number</label>
139
+ <frontend_type>select</frontend_type>
140
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
141
+ <sort_order>12</sort_order>
142
+ <comment>Show Phone Number Field in Advance Newsletter</comment>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>0</show_in_store>
146
+ </phoneno_show>
147
+ <zipcode_show translate="label comment">
148
+ <label>Show Zip/Postal Code</label>
149
+ <frontend_type>select</frontend_type>
150
+ <source_model>adminhtml/system_config_source_nooptreq</source_model>
151
+ <sort_order>13</sort_order>
152
+ <comment>Show Zip/Postal Code Field in Advance Newsletter</comment>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>0</show_in_store>
156
+ </zipcode_show>
157
+ </fields>
158
+ </all_settings>
159
+ </groups>
160
+ </advancenewsletter>
161
+ </sections>
162
+ </config>
app/code/local/Daffodil/Advancenewsletter/sql/advancenewsletter_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Daffodil Advance Newsletter
5
+ */
6
+ ?>
7
+ <?php
8
+ $installer = $this;
9
+ $installer->startSetup();
10
+ $installer->run("
11
+ ALTER TABLE {$this->getTable('newsletter_subscriber')}
12
+ ADD ( `salutation` TEXT NULL,
13
+ `firstname` TEXT NULL,
14
+ `lastname` TEXT NULL,
15
+ `company` TEXT NULL,
16
+ `address` TEXT NULL,
17
+ `city` TEXT NULL,
18
+ `state` TEXT NULL,
19
+ `country` TEXT NULL,
20
+ `fax` TEXT NULL,
21
+ `phoneno` INT(20) NULL,
22
+ `zipcode` TEXT NULL
23
+ );
24
+ ");
25
+ $installer->endSetup();
26
+ ?>
app/design/frontend/default/default/layout/advancenewsletter.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addCss"><stylesheet>css/advancenewsletter.css</stylesheet></action>
6
+ <action method="addJs"><script>advancenewsletter/validation.js</script></action>
7
+ </reference>
8
+ <reference name="left.newsletter">
9
+ <action method="setTemplate" ifconfig="advancenewsletter/all_settings/enabled"><template>advancenewsletter/subscriber.phtml</template></action>
10
+ </reference>
11
+ </default>
12
+ </layout>
app/design/frontend/default/default/template/advancenewsletter/subscriber.phtml ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+
28
+ <?php $prefix= Mage::getStoreConfig('advancenewsletter/all_settings/prefix_show');
29
+ $firstname= Mage::getStoreConfig('advancenewsletter/all_settings/firstname_show');
30
+ $lastname= Mage::getStoreConfig('advancenewsletter/all_settings/lastname_show');
31
+ $confirmmail=Mage::getStoreConfig('advancenewsletter/all_settings/confirmemail_show');
32
+ $company= Mage::getStoreConfig('advancenewsletter/all_settings/company_show');
33
+ $address= Mage::getStoreConfig('advancenewsletter/all_settings/address_show');
34
+ $city= Mage::getStoreConfig('advancenewsletter/all_settings/city_show');
35
+ $state= Mage::getStoreConfig('advancenewsletter/all_settings/state_show');
36
+ $country= Mage::getStoreConfig('advancenewsletter/all_settings/country_show');
37
+ $fax= Mage::getStoreConfig('advancenewsletter/all_settings/fax_show');
38
+ $phoneno= Mage::getStoreConfig('advancenewsletter/all_settings/phoneno_show');
39
+ $zipcode= Mage::getStoreConfig('advancenewsletter/all_settings/zipcode_show');
40
+ $no_of_line= Mage::getStoreConfig('advancenewsletter/all_settings/lines_in_address_show');?>
41
+
42
+ <div class="block block-subscribe">
43
+ <div class="block-title">
44
+ <strong><span><?php echo $this->__('Newsletter') ?></span></strong>
45
+ </div>
46
+ <form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-validate-detail">
47
+ <div class="block-content">
48
+ <div class="advance-subscribe-header">
49
+ <label for="newsletter"><?php echo $this->__('Sign Up for Our Newsletter:') ?></label>
50
+ </div>
51
+ <div class="input-box">
52
+ <?php if($prefix): ?>
53
+ <label for="salutation"><?php echo $this->__('Prefix') ?></label>
54
+ <select name="salutation" id="prefix">
55
+ <option value="Mr">Mr</option>
56
+ <option value="Mrs">Mrs</option>
57
+ <option value="Ms">Ms</option>
58
+ </select>
59
+ <?php endif;?>
60
+ <?php if($firstname=="opt"):?>
61
+ <label for="firstname"><?php echo $this->__('First Name') ?></label>
62
+ <input type="text" name="firstname" id="advancenewsletter" title="<?php echo $this->__('First name') ?>" class="input-text" />
63
+ <?php elseif($firstname=="req"):?>
64
+ <label for="firstname"><em>*</em><?php echo $this->__('First Name') ?></label>
65
+ <input type="text" name="firstname" id="advancenewsletter" title="<?php echo $this->__('First name') ?>" class="input-text required-entry" />
66
+ <?php endif;?>
67
+ <?php if($lastname=="opt"):?>
68
+ <label for="lastname"><?php echo $this->__('Last Name') ?></label>
69
+ <input type="text" name="lastname" id="advancenewsletter" title="<?php echo $this->__('Last name') ?>" class="input-text" />
70
+ <?php elseif($lastname=="req"):?>
71
+ <label for="lastname"><em>*</em><?php echo $this->__('Last Name') ?></label>
72
+ <input type="text" name="lastname" id="advancenewsletter" title="<?php echo $this->__('Last name') ?>" class="input-text required-entry" />
73
+ <?php endif;?>
74
+ <label for="email"><em>*</em><?php echo $this->__('Email') ?></label>
75
+ <input type="text" name="email" id="advancenewsletter" title="<?php echo $this->__('Email Id') ?>" class="input-text required-entry validate-email" />
76
+ <?php if($confirmmail):?>
77
+ <label for="confirmemail"><em>*</em><?php echo $this->__('Confirm Email') ?></label>
78
+ <input type="text" name="email" id="advancenewsletter" title="<?php echo $this->__('Confirm Email Id') ?>" class="input-text required-entry validate-cemail" />
79
+ <?php endif;?>
80
+ <?php if($company=="opt"):?>
81
+ <label for="company"><?php echo $this->__('Company') ?></label>
82
+ <input type="text" name="company" id="advancenewsletter" title="<?php echo $this->__('Company') ?>" class="input-text" />
83
+ <?php elseif ($company=="req"):?>
84
+ <label for="company"><em>*</em><?php echo $this->__('Company') ?></label>
85
+ <input type="text" name="company" id="advancenewsletter" title="<?php echo $this->__('Company') ?>" class="input-text required-entry" />
86
+ <?php endif;?>
87
+ <?php if($address=="opt"):?>
88
+ <label for="address"><?php echo $this->__('Address') ?></label>
89
+ <input type="text" name="address" id="advancenewsletter" title="<?php echo $this->__('Address') ?>" class="input-text" />
90
+ <?php elseif($address=="req"):?>
91
+ <label for="address"><em>*</em><?php echo $this->__('Address') ?></label>
92
+ <input type="text" name="address" id="advancenewsletter" title="<?php echo $this->__('Address') ?>" class="input-text required-entry" />
93
+ <?php endif;?>
94
+ <?php if($city=="opt"): ?>
95
+ <label for="city"><?php echo $this->__('City') ?></label>
96
+ <input type="text" name="city" id="advancenewsletter" title="<?php echo $this->__('City') ?>" class="input-text" />
97
+ <?php elseif($city=="req"): ?>
98
+ <label for="city"><em>*</em><?php echo $this->__('City') ?></label>
99
+ <input type="text" name="city" id="advancenewsletter" title="<?php echo $this->__('City') ?>" class="input-text required-entry" />
100
+ <?php endif;?>
101
+ <?php if(($state=="opt")&&($country!="")):?>
102
+ <label for="state"><?php echo $this->__('State/Province') ?></label>
103
+ <select name="state-dropdown" id="region_id" onselect="setvalue();" title="<?php echo $this->__('State/Province') ?>" style="display:none;">
104
+ <option value=""><?php echo $this->__('Please select state/province') ?></option>
105
+ </select>
106
+ <script type="text/javascript">
107
+ //<![CDATA[
108
+ $('region_id').setAttribute('defaultValue', "<?php echo $this->getRegionId() ?>");
109
+ //]]>
110
+ jQuery.noConflict();
111
+ jQuery(document).ready(function(){
112
+ jQuery('#region_id').removeClass('validate-select');
113
+ jQuery('#region_id').removeClass('required-entry');
114
+ });
115
+ jQuery(document).ready(function(){
116
+ jQuery("#country").change(function() {
117
+ jQuery('#region_id').removeClass('validate-select');
118
+ jQuery('#region_id').removeClass('required-entry');
119
+ });
120
+ });
121
+ </script>
122
+ <input type="hidden" id="hidden-id" name="hidden-name" value="" />
123
+ <input type="text" id="region" name="state-text" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
124
+ <?php elseif(($state=="req")&&($country!="")):?>
125
+ <label for="state"><em>*</em><?php echo $this->__('State/Province') ?></label>
126
+ <select name="state-dropdown-req" id="region_id" title="<?php echo $this->__('State/Province') ?>" style="display:none;" class="validate-select">
127
+ <option value=""><?php echo $this->__('Please select state/province') ?></option>
128
+ </select>
129
+ <script type="text/javascript">
130
+ //<![CDATA[
131
+ $('region_id').setAttribute('defaultValue', "<?php echo $this->getRegionId() ?>");
132
+ //]]>
133
+
134
+ </script>
135
+ <input type="hidden" id="hidden-id" name="hidden-name" value="" />
136
+ <input type="text" id="region" name="state-text-req" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" style="display:none;" />
137
+ <script type="text/javascript">
138
+ jQuery.noConflict();
139
+ jQuery(document).ready(function(){
140
+ jQuery('#region').addClass('input-text');
141
+ jQuery('#region').addClass('required-entry');
142
+
143
+ });
144
+ jQuery(document).ready(function(){
145
+ jQuery("#country").change(function() {
146
+ jQuery('#region').addClass('input-text');
147
+ jQuery('#region').addClass('required-entry');
148
+ });
149
+ });
150
+ </script>
151
+ <?php elseif(($state=="opt")&&($country=="")):?>
152
+ <label for="state"><?php echo $this->__('State/Province') ?></label>
153
+
154
+ <input type="text" id="region" name="hidden-name" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" />
155
+ <?php elseif(($state=="req")&&($country=="")):?>
156
+ <label for="state"><em>*</em><?php echo $this->__('State/Province') ?></label>
157
+
158
+ <input type="text" id="region" name="hidden-name" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text required-entry" />
159
+ <?php endif;?>
160
+ <?php if ($country=="opt"): ?>
161
+ <label for="country"><?php echo $this->__('Country') ?></label>
162
+ <?php echo Mage::getBlockSingleton('directory/data')->getCountryHtmlSelect($this->getCountryId()) ?>
163
+ <script type="text/javascript">
164
+ jQuery(document).ready(function(){
165
+ jQuery("#country").change(function() {
166
+ jQuery('#country').removeClass('validate-select');
167
+ jQuery('#country').removeClass('required-entry');
168
+ });
169
+ });
170
+ </script>
171
+ <?php elseif($country=="req"):?>
172
+ <label for="country"><em>*</em><?php echo $this->__('Country') ?></label>
173
+ <?php echo Mage::getBlockSingleton('directory/data')->getCountryHtmlSelect($this->getCountryId()) ?>
174
+ <?php endif; ?>
175
+ <?php if($fax=="opt"):?>
176
+ <label for="fax"><?php echo $this->__('Fax') ?></label>
177
+ <input type="text" name="fax" id="advancenewsletter" title="<?php echo $this->__('Fax') ?>" class="input-text" />
178
+ <?php elseif($fax=="req"):?>
179
+ <label for="fax"><em>*</em><?php echo $this->__('Fax') ?></label>
180
+ <input type="text" name="fax" id="advancenewsletter" title="<?php echo $this->__('Fax') ?>" class="input-text required-entry" />
181
+ <?php endif;?>
182
+ <?php if($phoneno=="opt"):?>
183
+ <label for="phoneno"><?php echo $this->__('Phone Number') ?></label>
184
+ <input type="text" name="phoneno" id="advancenewsletter" title="<?php echo $this->__('Phone Number') ?>" class="input-text validate-number" />
185
+ <?php elseif($phoneno=="req"):?>
186
+ <label for="phoneno"><em>*</em><?php echo $this->__('Phone Number') ?></label>
187
+ <input type="text" name="phoneno" id="advancenewsletter" title="<?php echo $this->__('Phone Number') ?>" class="input-text required-entry validate-number" />
188
+ <?php endif;?>
189
+ <?php if($zipcode=="opt"):?>
190
+ <label for="zipcode"><?php echo $this->__('Zip/Postal Code') ?></label>
191
+ <input type="text" name="zipcode" id="advancenewsletter" title="<?php echo $this->__('Zip/Postal Code') ?>" class="input-text" />
192
+ <?php elseif($zipcode=="req"):?>
193
+ <label for="zipcode"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
194
+ <input type="text" name="zipcode" id="advancenewsletter" title="<?php echo $this->__('Zip/Postal Code') ?>" class="input-text required-entry" />
195
+ <?php endif;?>
196
+ </div>
197
+
198
+ <div class="advancenewsletter-actions">
199
+ <button type="submit" onclick="showtest()" title="<?php echo $this->__('Subscribe') ?>" class="button"><span><span><?php echo $this->__('Subscribe') ?></span></span></button>
200
+ </div>
201
+ </div>
202
+ </form>
203
+ <script type="text/javascript">
204
+ function showtest(){
205
+ jQuery.noConflict();
206
+
207
+ if(jQuery("#region_id").css('display') == 'none')
208
+ {
209
+ document.getElementById("hidden-id").value=document.getElementById("region").value;
210
+ }
211
+ else
212
+ {
213
+ document.getElementById("hidden-id").value=document.getElementById("region_id").value;
214
+ }
215
+ }
216
+ //<![CDATA[
217
+ var newsletterSubscriberFormDetail = new VarienForm('newsletter-validate-detail');
218
+ //]]>
219
+ new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
220
+ </script>
221
+ </div>
222
+
223
+
224
+
app/design/frontend/default/default/template/advancenewsletter/subscriber.phtml~ ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+
28
+ <?php $prefix= Mage::getStoreConfig('advancenewsletter/all_settings/prefix_show');
29
+ $firstname= Mage::getStoreConfig('advancenewsletter/all_settings/firstname_show');
30
+ $lastname= Mage::getStoreConfig('advancenewsletter/all_settings/lastname_show');
31
+ $confirmmail=Mage::getStoreConfig('advancenewsletter/all_settings/confirmemail_show');
32
+ $company= Mage::getStoreConfig('advancenewsletter/all_settings/company_show');
33
+ $address= Mage::getStoreConfig('advancenewsletter/all_settings/address_show');
34
+ $city= Mage::getStoreConfig('advancenewsletter/all_settings/city_show');
35
+ $state= Mage::getStoreConfig('advancenewsletter/all_settings/state_show');
36
+ $country= Mage::getStoreConfig('advancenewsletter/all_settings/country_show');
37
+ $fax= Mage::getStoreConfig('advancenewsletter/all_settings/fax_show');
38
+ $phoneno= Mage::getStoreConfig('advancenewsletter/all_settings/phoneno_show');
39
+ $zipcode= Mage::getStoreConfig('advancenewsletter/all_settings/zipcode_show');
40
+ $no_of_line= Mage::getStoreConfig('advancenewsletter/all_settings/lines_in_address_show');?>
41
+
42
+ <div class="block block-subscribe">
43
+ <div class="block-title">
44
+ <strong><span><?php echo $this->__('Newsletter') ?></span></strong>
45
+ </div>
46
+ <form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-validate-detail">
47
+ <div class="block-content">
48
+ <div class="advance-subscribe-header">
49
+ <label for="newsletter"><?php echo $this->__('Sign Up for Our Newsletter:') ?></label>
50
+ </div>
51
+ <div class="input-box">
52
+ <?php if($prefix): ?>
53
+ <label for="salutation"><?php echo $this->__('Prefix') ?></label>
54
+ <select name="salutation" id="prefix">
55
+ <option value="Mr">Mr</option>
56
+ <option value="Mrs">Mrs</option>
57
+ <option value="Ms">Ms</option>
58
+ </select>
59
+ <?php endif;?>
60
+ <?php if($firstname=="opt"):?>
61
+ <label for="firstname"><?php echo $this->__('First Name') ?></label>
62
+ <input type="text" name="firstname" id="advancenewsletter" title="<?php echo $this->__('First name') ?>" class="input-text" />
63
+ <?php elseif($firstname=="req"):?>
64
+ <label for="firstname"><em>*</em><?php echo $this->__('First Name') ?></label>
65
+ <input type="text" name="firstname" id="advancenewsletter" title="<?php echo $this->__('First name') ?>" class="input-text required-entry" />
66
+ <?php endif;?>
67
+ <?php if($lastname=="opt"):?>
68
+ <label for="lastname"><?php echo $this->__('Last Name') ?></label>
69
+ <input type="text" name="lastname" id="advancenewsletter" title="<?php echo $this->__('Last name') ?>" class="input-text" />
70
+ <?php elseif($lastname=="req"):?>
71
+ <label for="lastname"><em>*</em><?php echo $this->__('Last Name') ?></label>
72
+ <input type="text" name="lastname" id="advancenewsletter" title="<?php echo $this->__('Last name') ?>" class="input-text required-entry" />
73
+ <?php endif;?>
74
+ <label for="email"><em>*</em><?php echo $this->__('Email') ?></label>
75
+ <input type="text" name="email" id="advancenewsletter" title="<?php echo $this->__('Email Id') ?>" class="input-text required-entry validate-email" />
76
+ <?php if($confirmmail):?>
77
+ <label for="confirmemail"><em>*</em><?php echo $this->__('Confirm Email') ?></label>
78
+ <input type="text" name="email" id="advancenewsletter" title="<?php echo $this->__('Confirm Email Id') ?>" class="input-text required-entry validate-cemail" />
79
+ <?php endif;?>
80
+ <?php if($company=="opt"):?>
81
+ <label for="company"><?php echo $this->__('Company') ?></label>
82
+ <input type="text" name="company" id="advancenewsletter" title="<?php echo $this->__('Company') ?>" class="input-text" />
83
+ <?php elseif ($company=="req"):?>
84
+ <label for="company"><em>*</em><?php echo $this->__('Company') ?></label>
85
+ <input type="text" name="company" id="advancenewsletter" title="<?php echo $this->__('Company') ?>" class="input-text required-entry" />
86
+ <?php endif;?>
87
+ <?php if($address=="opt"):?>
88
+ <label for="address"><?php echo $this->__('Address') ?></label>
89
+ <input type="text" name="address" id="advancenewsletter" title="<?php echo $this->__('Address') ?>" class="input-text" />
90
+ <?php elseif($address=="req"):?>
91
+ <label for="address"><em>*</em><?php echo $this->__('Address') ?></label>
92
+ <input type="text" name="address" id="advancenewsletter" title="<?php echo $this->__('Address') ?>" class="input-text required-entry" />
93
+ <?php endif;?>
94
+ <?php if($city=="opt"): ?>
95
+ <label for="city"><?php echo $this->__('City') ?></label>
96
+ <input type="text" name="city" id="advancenewsletter" title="<?php echo $this->__('City') ?>" class="input-text" />
97
+ <?php elseif($city=="req"): ?>
98
+ <label for="city"><em>*</em><?php echo $this->__('City') ?></label>
99
+ <input type="text" name="city" id="advancenewsletter" title="<?php echo $this->__('City') ?>" class="input-text required-entry" />
100
+ <?php endif;?>
101
+ <?php if(($state=="opt")&&($country!="")):?>
102
+ <label for="state"><?php echo $this->__('State/Province') ?></label>
103
+ <select name="state-dropdown" id="region_id" onselect="setvalue();" title="<?php echo $this->__('State/Province') ?>" style="display:none;">
104
+ <option value=""><?php echo $this->__('Please select state/province') ?></option>
105
+ </select>
106
+ <script type="text/javascript">
107
+ //<![CDATA[
108
+ $('region_id').setAttribute('defaultValue', "<?php echo $this->getRegionId() ?>");
109
+ //]]>
110
+ jQuery.noConflict();
111
+ jQuery(document).ready(function(){
112
+ jQuery('#region_id').removeClass('validate-select');
113
+ jQuery('#region_id').removeClass('required-entry');
114
+ });
115
+ jQuery(document).ready(function(){
116
+ jQuery("#country").change(function() {
117
+ jQuery('#region_id').removeClass('validate-select');
118
+ jQuery('#region_id').removeClass('required-entry');
119
+ });
120
+ });
121
+ </script>
122
+ <input type="hidden" id="hidden-id" name="hidden-name" value="" />
123
+ <input type="text" id="region" name="state-text" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
124
+ <?php elseif(($state=="req")&&($country!="")):?>
125
+ <label for="state"><em>*</em><?php echo $this->__('State/Province') ?></label>
126
+ <select name="state-dropdown-req" id="region_id" title="<?php echo $this->__('State/Province') ?>" style="display:none;" class="validate-select">
127
+ <option value=""><?php echo $this->__('Please select state/province') ?></option>
128
+ </select>
129
+ <script type="text/javascript">
130
+ //<![CDATA[
131
+ $('region_id').setAttribute('defaultValue', "<?php echo $this->getRegionId() ?>");
132
+ //]]>
133
+
134
+ </script>
135
+ <input type="hidden" id="hidden-id" name="hidden-name" value="" />
136
+ <input type="text" id="region" name="state-text-req" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" style="display:none;" />
137
+ <script type="text/javascript">
138
+ jQuery.noConflict();
139
+ jQuery(document).ready(function(){
140
+ jQuery('#region').addClass('input-text');
141
+ jQuery('#region').addClass('required-entry');
142
+
143
+ });
144
+ jQuery(document).ready(function(){
145
+ jQuery("#country").change(function() {
146
+ jQuery('#region').addClass('input-text');
147
+ jQuery('#region').addClass('required-entry');
148
+ });
149
+ });
150
+ </script>
151
+ <?php elseif(($state=="opt")&&($country=="")):?>
152
+ <label for="state"><?php echo $this->__('State/Province') ?></label>
153
+
154
+ <input type="text" id="region" name="hidden-name" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" />
155
+ <?php elseif(($state=="req")&&($country=="")):?>
156
+ <label for="state"><em>*</em><?php echo $this->__('State/Province') ?></label>
157
+
158
+ <input type="text" id="region" name="hidden-name" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text required-entry" />
159
+ <?php endif;?>
160
+ <?php if ($country=="opt"): ?>
161
+ <label for="country"><?php echo $this->__('Country') ?></label>
162
+ <?php echo Mage::getBlockSingleton('directory/data')->getCountryHtmlSelect($this->getCountryId()) ?>
163
+ <script type="text/javascript">
164
+ jQuery(document).ready(function(){
165
+ jQuery("#country").change(function() {
166
+ jQuery('#country').removeClass('validate-select');
167
+ jQuery('#country').removeClass('required-entry');
168
+ });
169
+ });
170
+ </script>
171
+ <?php elseif($country=="req"):?>
172
+ <label for="country"><em>*</em><?php echo $this->__('Country') ?></label>
173
+ <?php echo Mage::getBlockSingleton('directory/data')->getCountryHtmlSelect($this->getCountryId()) ?>
174
+ <?php endif; ?>
175
+ <?php if($fax=="opt"):?>
176
+ <label for="fax"><?php echo $this->__('Fax') ?></label>
177
+ <input type="text" name="fax" id="advancenewsletter" title="<?php echo $this->__('Fax') ?>" class="input-text" />
178
+ <?php elseif($fax=="req"):?>
179
+ <label for="fax"><em>*</em><?php echo $this->__('Fax') ?></label>
180
+ <input type="text" name="fax" id="advancenewsletter" title="<?php echo $this->__('Fax') ?>" class="input-text required-entry" />
181
+ <?php endif;?>
182
+ <?php if($phoneno=="opt"):?>
183
+ <label for="phoneno"><?php echo $this->__('Phone Number') ?></label>
184
+ <input type="text" name="phoneno" id="advancenewsletter" title="<?php echo $this->__('Phone Number') ?>" class="input-text validate-number" />
185
+ <?php elseif($phoneno=="req"):?>
186
+ <label for="phoneno"><em>*</em><?php echo $this->__('Phone Number') ?></label>
187
+ <input type="text" name="phoneno" id="advancenewsletter" title="<?php echo $this->__('Phone Number') ?>" class="input-text required-entry validate-number" />
188
+ <?php endif;?>
189
+ <?php if($zipcode=="opt"):?>
190
+ <label for="zipcode"><?php echo $this->__('Zip/Postal Code') ?></label>
191
+ <input type="text" name="zipcode" id="advancenewsletter" title="<?php echo $this->__('Zip/Postal Code') ?>" class="input-text" />
192
+ <?php elseif($zipcode=="req"):?>
193
+ <label for="zipcode"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
194
+ <input type="text" name="zipcode" id="advancenewsletter" title="<?php echo $this->__('Zip/Postal Code') ?>" class="input-text required-entry" />
195
+ <?php endif;?>
196
+ </div>
197
+
198
+ <div class="advancenewsletter-actions">
199
+ <button type="submit" onclick="showtest()" title="<?php echo $this->__('Subscribe') ?>" class="button"><span><span><?php echo $this->__('Subscribe') ?></span></span></button>
200
+ </div>
201
+ </div>
202
+ </form>
203
+ <script type="text/javascript">
204
+ function showtest(){
205
+ jQuery.noConflict();
206
+
207
+ if(jQuery("#region_id").css('display') == 'none')
208
+ {
209
+ document.getElementById("hidden-id").value=document.getElementById("region").value;
210
+ }
211
+ else
212
+ {
213
+ document.getElementById("hidden-id").value=document.getElementById("region_id").value;
214
+ }
215
+ }
216
+ //<![CDATA[
217
+ var newsletterSubscriberFormDetail = new VarienForm('newsletter-validate-detail');
218
+ //]]>
219
+ new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
220
+ </script>
221
+ </div>
222
+
223
+
224
+
app/etc/modules/Daffodil_Advancenewsletter.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Daffodil_Advancenewsletter>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <version>0.1.0</version>
8
+ </Daffodil_Advancenewsletter>
9
+ </modules>
10
+ </config>
11
+
js/advancenewsletter/validation.js ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Validation.addAllThese([
2
+
3
+ ['validate-cemail', 'Please make sure your emails match.', function(v) {
4
+ var conf = $$('.validate-cemail')[0];
5
+ var pass = false;
6
+ if ($('email')) {
7
+ pass = $('email');
8
+ }
9
+ var emailElements = $$('.validate-email');
10
+ for (var i = 0; i < emailElements.size(); i++) {
11
+ var emailElement = emailElements[i];
12
+ if (emailElement.up('form').id == conf.up('form').id) {
13
+ pass = emailElement;
14
+ }
15
+ }
16
+ if ($$('.validate-admin-email').size()) {
17
+ pass = $$('.validate-admin-email')[0];
18
+ }
19
+ return (pass.value == conf.value);
20
+ }],
21
+ ]);
22
+
23
+
package.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Daffodil_Advancenewsletter</name>
4
+ <version>1.0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Customize Newsletter</summary>
10
+ <description>Newsletter+ extension is used to customize default newsletter. By default only Email field is present in newsletter subscription. But with the help of Newsletter+ extension you can extend fields. It includes following fields:-&#xD;
11
+ Prefix, First Name, Last Name, Email Id, Confirm Email Id, Company, Address, State, City, Country, Fax, Phone Number, Zip Code. &#xD;
12
+ &#xD;
13
+ You can easily enable or disable these fields from admin.&#xD;
14
+ If there is a need of required fields than u can select any field as required from admin.&#xD;
15
+ </description>
16
+ <notes>First Release</notes>
17
+ <authors><author><name>Daffodil Software</name><user>daffodilsw</user><email>ashish.mittal@daffodilsw.com</email></author></authors>
18
+ <date>2013-01-16</date>
19
+ <time>06:18:56</time>
20
+ <contents><target name="mageetc"><dir name="modules"><file name="Daffodil_Advancenewsletter.xml" hash="849322343df8002ca935fa7f4aa59cf5"/></dir></target><target name="magelocal"><dir name="Daffodil"><dir name="Advancenewsletter"><dir name="Block"><file name="Grid.php" hash="1fb32a88eb6251a7ee47ebcaa34d7894"/></dir><dir name="controllers"><file name="SubscriberController.php" hash="8a8b2630bc238e935b0f504e5ea0c6ae"/><file name="SubscriberController.php~" hash="3ec25e1a260057ac4efceeb9cd64dc92"/></dir><dir name="etc"><file name="config.xml" hash="d1564368ac5b35afe4be5b852831a7d8"/><file name="config.xml~" hash="f2aff9734e3c6852e3a58f668432a966"/><file name="system.xml" hash="f22d086e88c71a9eb33bebeef8ee5997"/><file name="system.xml~" hash="5dcf947ab6d3f8bf4fb6d644d98135ec"/></dir><dir name="Helper"><file name="Data.php" hash="fbe1d7a3219292fc3fa2d4c722478a88"/></dir><dir name="Model"><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="b1bb63824aa1c29e96768a7b809850b9"/></dir></dir><file name="Subscriber.php" hash="e618032bacb05cfa4c4bc427cd674292"/></dir><dir name="sql"><dir name="advancenewsletter_setup"><file name="mysql4-install-0.1.0.php" hash="c60aa393762ab74da773801c243f4444"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="advancenewsletter.xml" hash="df992051b104beb061e6cea8d8862065"/></dir><dir name="template"><dir name="advancenewsletter"><file name="subscriber.phtml" hash="32db3c768d185d9dc9fdabc83f76df50"/><file name="subscriber.phtml~" hash="bc9d455980adf25ea03966ab763ad054"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><file name="advancenewsletter.css" hash="f559bf0c04edea7de0b05f650d80acc5"/></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="advancenewsletter"><file name="validation.js" hash="61fd0f0e1041fd92798a61a33bcd36d4"/></dir></dir></target></contents>
21
+ <compatible/>
22
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
23
+ </package>
skin/frontend/default/default/css/advancenewsletter.css ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #region_id
2
+ {
3
+ width: 172px;
4
+ margin-bottom: 5px;
5
+ }
6
+ #country
7
+ {
8
+ width: 172px;
9
+ margin-bottom: 5px;
10
+ }
11
+ #advancenewsletter
12
+ {
13
+ display: block;
14
+ margin-bottom: 5px;
15
+ width: 163px;
16
+ }
17
+ .advance-subscribe-header
18
+ {
19
+ font-size: 13px;
20
+ margin-bottom: 13px;
21
+ }
22
+ .advancenewsletter-actions
23
+ {
24
+ margin: 18px 0 10px;
25
+ text-align: center;
26
+ }
27
+ #prefix
28
+ {
29
+ width: 172px;
30
+ margin-bottom: 5px;
31
+ display: block;
32
+ }
33
+ .input-box em
34
+ {
35
+ color: red;
36
+ margin: 0 3px;
37
+ }