4Dem_Integration_community - Version 1.0.0

Version Notes

First release

Download this release

Release Info

Developer 4Marketing.it
Extension 4Dem_Integration_community
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/FourMarketing/FourDem/Block/Adminhtml/System/Config/Form/Field/Mapfields.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * System configuration form field renderer for mapping MergeVars fields with Magento
5
+ * attributes.
6
+ *
7
+ * @category FourMarketing
8
+ * @package FourMarketing_FourDem
9
+ * @author FourMarketing Team <devandtrade@devandtrade.it>
10
+ */
11
+ class FourMarketing_FourDem_Block_Adminhtml_System_Config_Form_Field_Mapfields extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
12
+ {
13
+
14
+ public function __construct()
15
+ {
16
+
17
+ $this->addColumn('magento', array(
18
+ 'label' => Mage::helper('fourdem')->__('Magento'),
19
+ 'style' => 'width:120px',
20
+ ));
21
+ $this->addColumn('fourdem', array(
22
+ 'label' => Mage::helper('fourdem')->__('4Marketing'),
23
+ 'style' => 'width:120px',
24
+ ));
25
+ $this->_addAfter = false;
26
+ $this->_addButtonLabel = Mage::helper('fourdem')->__('Aggiungi Campo');
27
+ parent::__construct();
28
+ }
29
+ }
app/code/community/FourMarketing/FourDem/Block/Adminhtml/Users.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class FourMarketing_FourDem_Block_Adminhtml_Users extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_blockGroup = 'fourmarketing_fourdem';
7
+ $this->_controller = 'adminhtml_users';
8
+ $this->_headerText = $this->__('Clienti Sincronizzati');
9
+
10
+ $this->_addButton('button_synchronize', array(
11
+ 'label' => Mage::helper('fourdem')->__('Sincronizza Magento/4Dem'),
12
+ 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/synchronize') .'\')',
13
+ 'class' => 'remove',
14
+ ));
15
+
16
+ parent::__construct();
17
+ $this->_removeButton('add');
18
+ }
19
+
20
+ public function getHeaderCssClass()
21
+ {
22
+ return 'icon-head head-newsletter-list';
23
+ }
24
+ }
app/code/community/FourMarketing/FourDem/Block/Adminhtml/Users/Grid.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class FourMarketing_FourDem_Block_Adminhtml_Users_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+
8
+ $this->setDefaultSort('id_fourdem');
9
+ $this->setId('fourmarketing_fourdem_users_grid');
10
+ $this->setDefaultDir('desc');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _getCollectionClass()
15
+ {
16
+ return 'fourmarketing_fourdem/users_collection';
17
+ }
18
+
19
+ protected function _prepareCollection()
20
+ {
21
+ // Get and set our collection for the grid
22
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
23
+ $this->setCollection($collection);
24
+
25
+ return parent::_prepareCollection();
26
+ }
27
+
28
+ protected function _prepareColumns()
29
+ {
30
+ $this->addColumn('id_fourdem',
31
+ array(
32
+ 'header'=> $this->__('ID 4MARKETING'),
33
+ 'align' =>'right',
34
+ 'width' => '50px',
35
+ 'index' => 'id_fourdem'
36
+ )
37
+ );
38
+
39
+ $this->addColumn('firstname',
40
+ array(
41
+ 'header'=> $this->__('Nome Cliente'),
42
+ 'index' => 'firstname'
43
+ )
44
+ );
45
+
46
+ $this->addColumn('lastname',
47
+ array(
48
+ 'header'=> $this->__('Cognome Cliente'),
49
+ 'index' => 'lastname'
50
+ )
51
+ );
52
+
53
+ $this->addColumn('email_address',
54
+ array(
55
+ 'header'=> $this->__('Email Cliente'),
56
+ 'index' => 'email_address'
57
+ )
58
+ );
59
+
60
+ $this->addColumn('own_list',
61
+ array(
62
+ 'header' => $this->__('Lista di Appartenenza'),
63
+ 'index' => 'own_list'
64
+ )
65
+ );
66
+
67
+ $this->addColumn('action',
68
+ array(
69
+ 'header' => Mage::helper('catalog')->__('Disiscrizione Newsletter'),
70
+ 'width' => '50px',
71
+ 'type' => 'action',
72
+ 'getter' => 'getId',
73
+ 'actions' => array(
74
+ array(
75
+ 'caption' => Mage::helper('catalog')->__('Disiscrivi Utente'),
76
+ 'confirm' => $this->__('Sei sicuro di voler disiscrivere il cliente dalla lista?'),
77
+ 'url' => array(
78
+ 'base' => '*/*/delete'
79
+ ),
80
+ 'field' => 'id'
81
+ )
82
+ ),
83
+ 'filter' => false,
84
+ 'sortable' => false,
85
+ 'index' => 'stores',
86
+ ));
87
+
88
+ return parent::_prepareColumns();
89
+ }
90
+ }
app/code/community/FourMarketing/FourDem/Helper/Data.php ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Helper - Wrap Connection To 4Marketing
5
+ *
6
+ * @category FourMarketing
7
+ * @package FourMarketing_FourDem
8
+ * @author FourMarketing Team <devandtrade@devandtrade.it>
9
+ */
10
+ class FourMarketing_FourDem_Helper_Data extends Mage_Core_Helper_Abstract
11
+ {
12
+ public $consoleUrl = '';
13
+ public $urlConnectionAPI = "?Command=%s&ResponseFormat=JSON";
14
+ public $sessionID = '';
15
+ public static $singleAlert = 1;
16
+ public static $singleAlertSuccess = 1;
17
+
18
+ public function __construct()
19
+ {
20
+ $this->consoleUrl = Mage::getStoreConfig('fourdem/system_access/url_console');
21
+
22
+ $params = array(
23
+ 'username' => '&Username='.Mage::getStoreConfig('fourdem/system_access/username'),
24
+ 'password' => '&Password='.Mage::getStoreConfig('fourdem/system_access/password')
25
+ );
26
+
27
+ $resultJSON = $this->_getRequestApi('User.Login', $params);
28
+
29
+ if($resultJSON->Success)
30
+ {
31
+ $this->sessionID = $resultJSON->SessionID;
32
+ }
33
+
34
+ return;
35
+ }
36
+
37
+ private function _getRequestApi($method, array $params, $printUrl = false)
38
+ {
39
+ $consoleUrl = $this->consoleUrl.$this->urlConnectionAPI;
40
+ $urlRequest = sprintf($consoleUrl, $method);
41
+
42
+ foreach($params as $param)
43
+ {
44
+ $urlRequest .= $param;
45
+ }
46
+
47
+ if($printUrl)
48
+ {
49
+ print_r('<strong>'.$urlRequest.'</strong>'); die();
50
+ }
51
+
52
+ $curl = new Varien_Http_Adapter_Curl();
53
+ $curl->setConfig(array('timeout' => 15));
54
+ $curl->write(Zend_Http_Client::GET, $urlRequest, '1.0');
55
+ preg_match('/\{.*\}/i', $curl->read(), $jsonObj);
56
+
57
+ return json_decode(array_pop($jsonObj));
58
+ }
59
+
60
+ public function getListInformation($listID)
61
+ {
62
+ $method = 'List.Get';
63
+ $params = array(
64
+ 'sessionID' => '&SessionID='.$this->sessionID,
65
+ 'listID' => '&ListID='.$listID
66
+ );
67
+
68
+ return $this->_getRequestApi($method, $params);
69
+ }
70
+
71
+ public function getLists()
72
+ {
73
+ $method = 'Lists.Get';
74
+ $params = array(
75
+ 'sessionID' => '&SessionID='.$this->sessionID,
76
+ 'orderField' => '&OrderField=Name',
77
+ 'orderType' => '&OrderType=ASC'
78
+ );
79
+
80
+ return $this->_getRequestApi($method, $params);
81
+ }
82
+
83
+ public function getCustomFields($listID)
84
+ {
85
+ $method = "CustomFields.Get";
86
+ $params = array(
87
+ 'sessionID' => '&SessionID='.$this->sessionID,
88
+ 'orderField' => '&OrderField=FieldName',
89
+ 'orderType' => '&OrderType=ASC',
90
+ 'subscriberListID' => '&SubscriberListID='.$listID
91
+ );
92
+
93
+ return $this->_getRequestApi($method, $params);
94
+ }
95
+
96
+ public function newSubscriber($listID, $email, $ipAddress, $customFields = array(), $singleAlert = false, $isMessageSuppressed = false)
97
+ {
98
+ $method = 'Subscriber.Subscribe';
99
+ $params = array(
100
+ 'sessionID' => '&SessionID='.$this->sessionID,
101
+ 'listID' => '&ListID='.$listID,
102
+ 'emailAddress' => '&EmailAddress='.$email,
103
+ 'ipAddress' => '&IPAddress='.$ipAddress
104
+ );
105
+
106
+ if(!empty($customFields))
107
+ {
108
+ foreach($customFields as $key => $field)
109
+ {
110
+ $params[$key] = str_replace(" ", "%20", $field);
111
+ }
112
+ }
113
+
114
+ $fourObject = $this->_getRequestApi($method, $params);
115
+ $newSubscriber = $fourObject->Subscriber;
116
+
117
+ if(!empty($newSubscriber->SubscriberID))
118
+ {
119
+ if(self::$singleAlertSuccess && $singleAlert==true)
120
+ {
121
+ if(self::$singleAlertSuccess==1)
122
+ {
123
+ if(!$isMessageSuppressed)
124
+ {
125
+ self::$singleAlertSuccess++;
126
+ $message = $this->__('Iscrizione alla newsletter avvenuta con successo!');
127
+ Mage::getSingleton('core/session')->addSuccess($message);
128
+ }
129
+ }
130
+ }
131
+ }
132
+ elseif($singleAlert)
133
+ {
134
+ if(self::$singleAlert==1)
135
+ {
136
+ if(!$isMessageSuppressed)
137
+ {
138
+ self::$singleAlert++;
139
+ $message = $this->__("Alcuni indirizzi era già presenti nella lista di destinazione.");
140
+ Mage::getSingleton('core/session')->addError($message);
141
+ }
142
+ }
143
+ }
144
+ else
145
+ {
146
+ if(!$isMessageSuppressed)
147
+ {
148
+ $message = $this->__("Indirizzo email $email già presente nella lista!");
149
+ Mage::getSingleton('core/session')->addError($message);
150
+ }
151
+ }
152
+ }
153
+
154
+ public function updateSubscriber($emailAddress, $newEmailAddress, $listID, $customFields, $isMessageSuppressed = false)
155
+ {
156
+ $fourObject = $this->getAllSubscribers($listID, $emailAddress);
157
+ //echo '<pre>'; print_r($fourObject); echo '</pre>'; die();
158
+
159
+ try
160
+ {
161
+ if($fourObject->TotalSubscribers)
162
+ {
163
+ $method = "Subscriber.Update";
164
+ $subscriberObject = array_pop($fourObject->Subscribers);
165
+
166
+ $params = array(
167
+ 'sessionID' => "&SessionID=".$this->sessionID,
168
+ 'subscriberID' => "&SubscriberID=".$subscriberObject->SubscriberID,
169
+ 'subscriberListID' => "&SubscriberListID=".$listID,
170
+ 'emailAddress' => "&EmailAddress=".$newEmailAddress,
171
+ );
172
+
173
+ if(!empty($customFields))
174
+ {
175
+ foreach($customFields as $key => $field)
176
+ {
177
+ $params[$key] = str_replace(" ", "%20", $field);
178
+ }
179
+ }
180
+
181
+ $params['access'] = "&Access=admin";
182
+ //echo '<pre>'; print_r($params); echo '</pre>'; die();
183
+ $fourObject = $this->_getRequestApi($method, $params);
184
+
185
+ if($fourObject->Success)
186
+ {
187
+ if(!$isMessageSuppressed)
188
+ {
189
+ $message = $this->__('Aggiornamento Newsletter: I Tuoi Dati Sono Stati Aggiornati Con Successo!');
190
+ Mage::getSingleton('core/session')->addSuccess($message);
191
+ }
192
+ }
193
+ }
194
+ }
195
+ catch(Exception $e)
196
+ {
197
+ $message = $this->__($e->getMessage());
198
+ Mage::getSingleton('core/session')->addError($message);
199
+ }
200
+
201
+ return;
202
+ }
203
+
204
+ public function unsubscribeSubscriber($listID, $idSubscriber, $emailAddress)
205
+ {
206
+ $method = "Subscriber.Unsubscribe";
207
+ $params = array(
208
+ 'sessionID' => '&SessionID='.$this->sessionID,
209
+ 'subscriberListID' => '&ListID='.$listID,
210
+ 'subscribers' => '&SubscriberID='.$idSubscriber,
211
+ 'emailAddress' => '&EmailAddress='.$emailAddress
212
+ );
213
+
214
+ return $this->_getRequestApi($method, $params);
215
+ }
216
+
217
+ public function getAllSubscribers($listID, $emailAddress = NULL)
218
+ {
219
+ $method = "Subscribers.Get";
220
+ $params = array(
221
+ 'sessionID' => "&SessionID=".$this->sessionID,
222
+ 'orderField' => "&OrderField=EmailAddress",
223
+ 'orderType' => "&OrderType=DESC",
224
+ 'recordsFrom' => "&RecordsFrom=0",
225
+ //'recordPerRequest' => "&RecordsPerRequest=1",
226
+ 'searchField' => "&SearchField=EmailAddress",
227
+ 'subscriberSegment' => "&SubscriberSegment=Active",
228
+ 'subscriberListID' => "&SubscriberListID=".$listID,
229
+ );
230
+
231
+ if($emailAddress!=NULL)
232
+ {
233
+ $params['searchKeyword'] = "&SearchKeyword=".$emailAddress;
234
+ }
235
+
236
+ return $this->_getRequestApi($method, $params);
237
+ }
238
+
239
+ public function getAboutSubscriber($emailAddress, $listID)
240
+ {
241
+ $method = "Subscribers.Get";
242
+ $params = array(
243
+ 'sessionID' => "&SessionID=".$this->sessionID,
244
+ 'orderField' => "&OrderField=EmailAddress",
245
+ 'orderType' => "&OrderType=DESC",
246
+ 'recordsFrom' => "&RecordsFrom=0",
247
+ 'recordPerRequest' => "&RecordsPerRequest=1",
248
+ 'searchKeyword' => "&SearchKeyword=".$emailAddress,
249
+ 'searchField' => "&SearchField=EmailAddress",
250
+ 'subscriberSegment' => "&SubscriberSegment=Active",
251
+ 'subscriberListID' => "&SubscriberListID=".$listID,
252
+ );
253
+
254
+ return $this->_getRequestApi($method, $params);
255
+ }
256
+ }
app/code/community/FourMarketing/FourDem/Model/Adminhtml/System/Source/Fields.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class FourMarketing_FourDem_Model_Adminhtml_System_Source_Fields
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ $customerListID = Mage::getStoreConfig('fourdem/system_access/customer_list');
7
+ $newsletterListID = Mage::getStoreConfig('fourdem/system_access/newsletter_list');
8
+
9
+ if(!empty($customerListID))
10
+ {
11
+ $listID = $customerListID;
12
+ }
13
+ else
14
+ {
15
+ $listID = $newsletterListID;
16
+ }
17
+
18
+ $customFields = Mage::helper('fourdem')->getCustomFields($listID)->CustomFields;
19
+
20
+ if(!empty($customFields))
21
+ {
22
+ $options[] = array(
23
+ 'value' => '',
24
+ 'label' => '-- Nessun Campo --',
25
+ );
26
+
27
+ foreach($customFields as $field)
28
+ {
29
+ $options[] = array(
30
+ 'value' => $field->CustomFieldID,
31
+ 'label' => $field->FieldName,
32
+ );
33
+ }
34
+ }
35
+
36
+ return $options;
37
+ }
38
+ }
app/code/community/FourMarketing/FourDem/Model/Mysql4/Users.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class FourMarketing_FourDem_Model_Mysql4_Users extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('fourmarketing_fourdem/users', 'id_fourdem');
7
+ }
8
+ }
app/code/community/FourMarketing/FourDem/Model/Mysql4/Users/Collection.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class FourMarketing_FourDem_Model_Mysql4_Users_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('fourmarketing_fourdem/users');
7
+ }
8
+ }
app/code/community/FourMarketing/FourDem/Model/Observer.php ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Events Observer Model
5
+ *
6
+ * @category FourMarketing
7
+ * @package FourMarketing_FourDem
8
+ * @author FourMarketing Team <devandtrade@devandtrade.it>
9
+ */
10
+ class FourMarketing_FourDem_Model_Observer
11
+ {
12
+ /**
13
+ * Controllo Credenziali inserite dall'utente dal pannello di configurazione
14
+ * @author Raffaele Capasso
15
+ * @version 1.0
16
+ * @copyright Dev And Trade
17
+ */
18
+ public function check4demConfiguration()
19
+ {
20
+ try
21
+ {
22
+ $isEnabled = Mage::getStoreConfig('fourdem/system_access/active');
23
+
24
+ if($isEnabled)
25
+ {
26
+ if(empty(Mage::helper('fourdem')->sessionID))
27
+ {
28
+ throw new Exception('Nome Utente o Password Errati! Controlla le tue credenziali di accesso.');
29
+ }
30
+ }
31
+
32
+ return;
33
+ }
34
+ catch(Exception $e)
35
+ {
36
+ Mage::getSingleton('core/session')->addError($e->getMessage());
37
+ return;
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Iscrivo il cliente nella lista "Clienti" durante la registrazione.
43
+ * @author Raffaele Capasso
44
+ * @version 1.0
45
+ * @copyright Dev And Trade
46
+ */
47
+ public function subscribeCustomer(Varien_Event_Observer $observer)
48
+ {
49
+ $customer = $observer->getCustomer();
50
+ $listID = Mage::getStoreConfig('fourdem/system_access/customer_list');
51
+ $mapFields = Mage::getStoreConfig('fourdem/fourdem_mapping');
52
+ $email = $customer->getEmail();
53
+ $ipAddress = $_SERVER['REMOTE_ADDR'];
54
+ $customFields = array();
55
+
56
+ foreach($mapFields as $label => $customFieldID)
57
+ {
58
+ if(!empty($customFieldID))
59
+ {
60
+ $customerValueField = $customer->getData($label);
61
+
62
+ if(!empty($customerValueField))
63
+ {
64
+ $key = 'CustomField'.$customFieldID;
65
+ $customFields[$key] = '&CustomField'.$customFieldID.'='.$customerValueField;
66
+ }
67
+ }
68
+ }
69
+
70
+ Mage::helper('fourdem')->newSubscriber($listID, $email, $ipAddress, $customFields, true, true);
71
+ return;
72
+ }
73
+
74
+ public function collectionDataMapping(Varien_Event_Observer $observer)
75
+ {
76
+ $mapFields = Mage::getStoreConfig('fourdem/fourdem_mapping');
77
+ $customFields = array();
78
+ $listID = Mage::getStoreConfig('fourdem/system_access/customer_list');
79
+ $defaultBillingAddress = $observer->getCustomerAddress()->getData();
80
+ $emailCustomer = Mage::getModel('customer/customer')->load($defaultBillingAddress['parent_id'])->getEmail();
81
+
82
+ foreach($mapFields as $label => $customFieldID)
83
+ {
84
+ if(!empty($customFieldID))
85
+ {
86
+ $billingValueField = $defaultBillingAddress[$label];
87
+ $key = 'Fields'.$customFieldID;
88
+ $customFields[$key] = '&Fields[CustomField'.$customFieldID.']='.$billingValueField;
89
+ }
90
+ }
91
+
92
+ //echo '<pre>'; print_r($customFields); echo '</pre>'; die();
93
+ Mage::helper('fourdem')->updateSubscriber($emailCustomer, $emailCustomer, $listID, $customFields, true);
94
+ return;
95
+ }
96
+
97
+ /**
98
+ * Cambio le impostazioni date dall'utente inserite nella fase di registrazione.
99
+ * @author Raffaele Capasso
100
+ * @version 1.0
101
+ * @copyright Dev And Trade
102
+ */
103
+ public function changeSubscribeEmail(Varien_Event_Observer $observer)
104
+ {
105
+ $mapFields = Mage::getStoreConfig('fourdem/fourdem_mapping');
106
+ $customFields = array();
107
+ $oldDataCustomer = $observer->getCustomer()->getOrigData();
108
+ $newDataCustomer = $observer->getCustomer()->getData();
109
+
110
+ $listID = Mage::getStoreConfig('fourdem/system_access/customer_list');
111
+ $oldEmailCustomer = $oldDataCustomer['email'];
112
+ $newEmailCustomer = $newDataCustomer['email'];
113
+ $customerModel = Mage::getModel('customer/customer')->load($newDataCustomer['entity_id']);
114
+
115
+ if(empty($oldEmailCustomer))
116
+ {
117
+ $oldEmailCustomer = $newEmailCustomer;
118
+ }
119
+
120
+ foreach($mapFields as $label => $customFieldID)
121
+ {
122
+ if(!empty($customFieldID))
123
+ {
124
+ $billingValueField = $customerModel->getData($label);
125
+
126
+ if(!empty($billingValueField))
127
+ {
128
+ $key = 'Fields'.$customFieldID;
129
+ $customFields[$key] = '&Fields[CustomField'.$customFieldID.']='.$billingValueField;
130
+ }
131
+ else
132
+ {
133
+ if(is_object($customerModel->getDefaultBillingAddress()))
134
+ {
135
+ $billingDefaultAddress = $customerModel->getDefaultBillingAddress()->getData();
136
+ $billingValueField = $billingDefaultAddress[$label];
137
+ $key = 'Fields'.$customFieldID;
138
+ $customFields[$key] = '&Fields[CustomField'.$customFieldID.']='.$billingValueField;
139
+ }
140
+ }
141
+ }
142
+ }
143
+
144
+ if(isset($newDataCustomer['is_subscribed']) && !$newDataCustomer['is_subscribed'])
145
+ {
146
+ // Se l'utente disabilita la newsletter lo disiscrivo da 4Marketing.it..
147
+ $resource = Mage::getSingleton('core/resource')->getConnection('core_write');
148
+ $email = $newDataCustomer['email'];
149
+ $user = $resource->query("SELECT * FROM fourmarketing_fourdem_users WHERE email_address = '".$email."'");
150
+ $userRow = array_pop($user);
151
+ $idUser = $userRow['id_fourdem'];
152
+
153
+ Mage::helper('fourdem')->unsubscribeSubscriber($listID, $idUser, $email, true);
154
+ return;
155
+ }
156
+ elseif(isset($newDataCustomer['is_subscribed']) && $newDataCustomer['is_subscribed'])
157
+ {
158
+ // Se l'utente abilita la newsletter lo iscrivo nella lista 4Marketing.it impostata dall'utente.
159
+ $email = $newDataCustomer['email'];
160
+ $ipAddress = $_SERVER['REMOTE_ADDR'];
161
+
162
+ Mage::helper('fourdem')->newSubscriber($listID, $email, $ipAddress, $customFields, true, true);
163
+ return;
164
+ }
165
+
166
+ Mage::helper('fourdem')->updateSubscriber($oldEmailCustomer, $newEmailCustomer, $listID, $customFields, true);
167
+ return;
168
+ }
169
+
170
+ /**
171
+ * Quando il cliente effettua un'acquisto viene iscritto alla lista "Clienti" presente su 4Marketing.
172
+ * @author Raffaele Capasso
173
+ * @version 1.0
174
+ * @copyright Dev And Trade
175
+ */
176
+ public function subscribeCustomerAfterCheckout(Varien_Event_Observer $observer)
177
+ {
178
+ $mapFields = Mage::getStoreConfig('fourdem/fourdem_mapping');
179
+ $listID = Mage::getStoreConfig('fourdem/system_access/customer_list');
180
+ $customerQuote = $observer->getEvent()->getQuote()->getData();
181
+ $billingInformation = $observer->getEvent()->getQuote()->getBillingAddress()->getData();
182
+ $customFields = array();
183
+
184
+ if($customerQuote['checkout_method'] === 'guest')
185
+ {
186
+ $email = $customerQuote['customer_email'];
187
+ $ipAddress = $_SERVER['REMOTE_ADDR'];
188
+ $isMessageSuppressed = true;
189
+ $isCustomerRegistered = Mage::getModel('customer/customer')->setWebsiteId(1)->loadByEmail($email)->getId();
190
+
191
+ if($isCustomerRegistered)
192
+ {
193
+ foreach($mapFields as $label => $customFieldID)
194
+ {
195
+ if(!empty($customFieldID))
196
+ {
197
+ $billingValueField = $billingInformation[$label];
198
+ $key = 'Fields'.$customFieldID;
199
+ $customFields[$key] = '&Fields[CustomField'.$customFieldID.']='.$billingValueField;
200
+ }
201
+ }
202
+
203
+ Mage::helper('fourdem')->updateSubscriber($email, $email, $listID, $customFields);
204
+ return;
205
+ }
206
+ else
207
+ {
208
+ foreach($mapFields as $label => $customFieldID)
209
+ {
210
+ if(!empty($customFieldID))
211
+ {
212
+ $billingValueField = $billingInformation[$label];
213
+
214
+ if(!empty($billingValueField))
215
+ {
216
+ $key = 'CustomField'.$customFieldID;
217
+ $customFields[$key] = '&CustomField'.$customFieldID.'='.$billingValueField;
218
+ }
219
+ }
220
+ }
221
+
222
+ Mage::helper('fourdem')->newSubscriber($listID, $email, $ipAddress, $customFields, false, $isMessageSuppressed);
223
+ return;
224
+ }
225
+ }
226
+ else
227
+ {
228
+ $customerOrder = $observer->getEvent()->getOrder();
229
+ $customer = $customerOrder->getCustomer();
230
+ //echo '<pre>'; print_r($customer->getData()); echo '</pre>'; die();
231
+ $customerModel = Mage::getModel('customer/customer')->load($customer->getData('entity_id'));
232
+ $billingAddress = $customerOrder->getBillingAddress();
233
+ $email = $customerOrder->getCustomer()->getEmail();
234
+ $isCustomerRegistered = Mage::getModel('customer/customer')->setWebsiteId(1)->loadByEmail($email)->getId();
235
+ $ipAddress = $_SERVER['REMOTE_ADDR'];
236
+
237
+ if($isCustomerRegistered)
238
+ {
239
+ foreach($mapFields as $label => $customFieldID)
240
+ {
241
+ if(!empty($customFieldID) && $label!='billing_address')
242
+ {
243
+ $billingValueField = $billingAddress->getData($label);
244
+ $key = 'Fields'.$customFieldID;
245
+ $customFields[$key] = '&Fields[CustomField'.$customFieldID.']='.$billingValueField;
246
+ }
247
+ }
248
+
249
+ //echo '<pre>'; print_r($customFields); echo '</pre>'; die();
250
+ Mage::helper('fourdem')->updateSubscriber($email, $email, $listID, $customFields, true);
251
+ return;
252
+ }
253
+ else
254
+ {
255
+ foreach($mapFields as $label => $customFieldID)
256
+ {
257
+ if(!empty($customFieldID))
258
+ {
259
+ $billingValueField = $billingAddress->getData($label);
260
+
261
+ if(!empty($billingValueField))
262
+ {
263
+ $key = 'CustomField'.$customFieldID;
264
+ $customFields[$key] = '&CustomField'.$customFieldID.'='.$billingValueField;
265
+ }
266
+ else
267
+ {
268
+ $key = 'CustomField'.$customFieldID;
269
+ $customerValueField = $customerModel->getData($label);
270
+ $customFields[$key] = '&CustomField'.$customFieldID.'='.$customerValueField;
271
+ }
272
+ }
273
+ }
274
+
275
+ Mage::helper('fourdem')->newSubscriber($listID, $email, $ipAddress, $customFields);
276
+ return;
277
+ }
278
+ }
279
+ }
280
+ }
app/code/community/FourMarketing/FourDem/Model/System/Config/Source/List.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * 4Marketing lists source file
5
+ *
6
+ * @category FourMarketing
7
+ * @package FourMarketing_FourDem
8
+ * @author FourMarketing Team <devandtrade@devandtrade.it>
9
+ */
10
+ class FourMarketing_FourDem_Model_System_Config_Source_List
11
+ {
12
+ protected $_lists = null;
13
+
14
+ public function __construct()
15
+ {
16
+ if(is_null($this->_lists) && !empty(Mage::helper('fourdem')->sessionID))
17
+ {
18
+ $this->_lists = Mage::helper('fourdem')->getLists();
19
+ }
20
+ }
21
+
22
+ public function toOptionArray()
23
+ {
24
+ $lists = array();
25
+ $listsByApi = $this->_lists->Lists;
26
+
27
+ foreach($listsByApi as $list)
28
+ {
29
+ $lists [] = array(
30
+ 'value' => $list->ListID,
31
+ 'label' => $list->Name . ' (' . $list->SubscriberCount . ' ' . Mage::helper('fourdem')->__('Membri') . ')'
32
+ );
33
+ }
34
+
35
+ return $lists;
36
+ }
37
+
38
+ }
app/code/community/FourMarketing/FourDem/Model/Users.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class FourMarketing_FourDem_Model_Users extends Mage_Core_Model_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('fourmarketing_fourdem/users');
7
+ }
8
+ }
app/code/community/FourMarketing/FourDem/controllers/SubscribersController.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class FourMarketing_FourDem_SubscribersController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function newAction()
5
+ {
6
+ $params = $this->getRequest()->getParams();
7
+ $email = $params['email'];
8
+ $ipAddress = $params['ip-address'];
9
+ $listID = Mage::getStoreConfig('fourdem/system_access/newsletter_list');
10
+
11
+ Mage::helper('fourdem')->newSubscriber($listID, $email, $ipAddress);
12
+ $this->_redirect('');
13
+ }
14
+ }
app/code/community/FourMarketing/FourDem/controllers/UsersController.php ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Magento Class For 4Marketing Magento ADMIN
4
+ */
5
+ class FourMarketing_FourDem_UsersController extends Mage_Adminhtml_Controller_Action
6
+ {
7
+ public function indexAction()
8
+ {
9
+ $this->_initAction()->renderLayout();
10
+ }
11
+
12
+ protected function _initAction()
13
+ {
14
+ $this->loadLayout()
15
+ ->_setActiveMenu('fourdem/fourmarketing_fourdem_users')
16
+ ->_title($this->__('Iscritti Newsletter'))->_title($this->__('4Marketing'));
17
+
18
+ return $this;
19
+ }
20
+
21
+ public function deleteAction()
22
+ {
23
+ $params = $this->getRequest()->getParams();
24
+ $idUser = $params['id'];
25
+ $user = Mage::getModel('fourmarketing_fourdem/users')->load($idUser);
26
+
27
+ preg_match_all("/\d+/", $user->getOwnList(), $matches);
28
+ $listID = $matches[0][0];
29
+ $email = $user->getData('email_address');
30
+
31
+ try
32
+ {
33
+ // Cancello l'utente da Magento e dalla tabella di riferimento..
34
+ $response = Mage::helper('fourdem')->unsubscribeSubscriber($listID, $idUser, $email);
35
+
36
+ if($response->Success)
37
+ {
38
+ $user->delete();
39
+
40
+ $message = $this->__("L'utente $email è stato cancellato con successo!");
41
+ Mage::getSingleton('core/session')->addSuccess($message);
42
+ $this->_redirectReferer();
43
+ }
44
+ else
45
+ {
46
+ throw new Exception("L'utente $email non è presente in 4Marketing. Può darsi che sia già stato cancellato.");
47
+ }
48
+ }
49
+ catch(Exception $e)
50
+ {
51
+ $message = $e->getMessage();
52
+ Mage::getSingleton('core/session')->addError($message);
53
+ $this->_redirectReferer();
54
+ }
55
+ }
56
+
57
+ public function synchronizeAction()
58
+ {
59
+ $start = microtime(true);
60
+ try
61
+ {
62
+ // Clean Magento Table..
63
+ $resource = Mage::getSingleton('core/resource');
64
+ $writeConnection = $resource->getConnection('core_write');
65
+ $writeConnection->query("TRUNCATE fourmarketing_fourdem_users");
66
+
67
+ $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
68
+ $customers = $collection->getData();
69
+
70
+ //echo '<pre>'; print_r($customers); echo '</pre>'; die();
71
+
72
+ $mapFields = Mage::getStoreConfig('fourdem/fourdem_mapping');
73
+ $customFields = array();
74
+ $customFieldsUpdate = array();
75
+
76
+ $customerListID = Mage::getStoreConfig('fourdem/system_access/customer_list');
77
+ $newsletterListID = Mage::getStoreConfig('fourdem/system_access/newsletter_list');
78
+
79
+ $customerList = Mage::helper('fourdem')->getListInformation($customerListID)->List->Name;
80
+ $newsletterList = Mage::helper('fourdem')->getListInformation($newsletterListID)->List->Name;
81
+
82
+ $customerSubscribers = Mage::helper('fourdem')->getAllSubscribers($customerListID)->Subscribers;
83
+ $newsletterSubscribers = Mage::helper('fourdem')->getAllSubscribers($newsletterListID)->Subscribers;
84
+
85
+ // Prima Fase: Importo i Clienti Magento nella "Lista Clienti" Di Destinazione..
86
+ foreach($customers as $customer)
87
+ {
88
+ $modelCustomer = Mage::getModel('customer/customer')->load($customer['entity_id']);
89
+ $addressCustomerModel = Mage::getModel('customer/address')->load($modelCustomer->getDefaultBilling());
90
+
91
+ foreach($mapFields as $label => $customFieldID)
92
+ {
93
+ if(!empty($customFieldID) && $label!='billing_address')
94
+ {
95
+ $customerValueField = $modelCustomer->getData($label);
96
+
97
+ if(!empty($customerValueField))
98
+ {
99
+ $key = 'CustomField'.$customFieldID;
100
+ $customFields[$key] = '&CustomField'.$customFieldID.'='.$customerValueField;
101
+
102
+ $keyUpdate = 'Fields'.$customFieldID;
103
+ $customFieldsUpdate[$keyUpdate] = '&Fields[CustomField'.$customFieldID.']='.$customerValueField;
104
+ }
105
+ else
106
+ {
107
+ $customerValueField = $addressCustomerModel->getData($label);
108
+ $key = 'CustomField'.$customFieldID;
109
+ $customFields[$key] = '&CustomField'.$customFieldID.'='.$customerValueField;
110
+
111
+ $keyUpdate = 'Fields'.$customFieldID;
112
+ $customFieldsUpdate[$keyUpdate] = '&Fields[CustomField'.$customFieldID.']='.$customerValueField;
113
+ }
114
+ }
115
+ }
116
+
117
+ //echo '<pre>'; print_r($modelCustomer->getData()); echo '</pre>'; die();
118
+ //echo '<pre>'; print_r($mapFields); echo '</pre>'; die();
119
+ //echo '<pre>'; print_r($customFields); echo '</pre>'; die();
120
+
121
+ $listID = $customerListID;
122
+ $singleAlert = true;
123
+ $isThereSubscribers = Mage::helper('fourdem')->getAboutSubscriber($customer['email'], $listID)->Subscribers;
124
+
125
+ // Se l'utente è presente nella lista, controllo se sia cancellato oppure no..
126
+ if($isThereSubscribers)
127
+ {
128
+ $customerConsoleResponse = array_pop($isThereSubscribers);
129
+ $customerStatusOnConsole = $customerConsoleResponse->SubscriptionStatus;
130
+
131
+ //echo '<pre>'; print_r(var_dump($customerStatusOnConsole)); echo '</pre>'; die();
132
+
133
+ if($customerStatusOnConsole === 'Unsubscribed')
134
+ {
135
+ Mage::helper('fourdem')->newSubscriber($listID, $customer['email'], $_SERVER['REMOTE_ADDR'], $customFields, $singleAlert, true);
136
+ }
137
+ elseif($customerStatusOnConsole === 'Subscribed')
138
+ {
139
+ Mage::helper('fourdem')->updateSubscriber($customer['email'], $customer['email'], $listID, $customFieldsUpdate, true);
140
+ }
141
+ }
142
+ else
143
+ {
144
+ // Se l'utente non esite nella lista di destinazione lo iscrivo..
145
+ Mage::helper('fourdem')->newSubscriber($listID, $customer['email'], $_SERVER['REMOTE_ADDR'], $customFields, $singleAlert);
146
+ }
147
+ }
148
+
149
+ // Seconda Fase: Importo Le Liste Nella Tabella di Riferimento in Magento..
150
+ if(!empty($customerListID))
151
+ {
152
+ foreach($customerSubscribers as $subscriber)
153
+ {
154
+
155
+ $info = get_object_vars($subscriber);
156
+ $firstname = $info['CustomField'.$mapFields['firstname']];
157
+ $lastname = $info['CustomField'.$mapFields['lastname']];
158
+
159
+ $insertStatement = "INSERT INTO fourmarketing_fourdem_users VALUES(
160
+ ".$subscriber->SubscriberID.",
161
+ '$firstname',
162
+ '$lastname',
163
+ '".$subscriber->EmailAddress."',
164
+ 'ID: $customerListID / Nome: $customerList')";
165
+ $writeConnection->query($insertStatement);
166
+ }
167
+ }
168
+ else
169
+ {
170
+ // Import Newsletter Users
171
+ foreach($newsletterSubscribers as $subscriber)
172
+ {
173
+ $info = get_object_vars($subscriber);
174
+ $firstname = $info['CustomField'.$mapFields['firstname']];
175
+ $lastname = $info['CustomField'.$mapFields['lastname']];
176
+
177
+ $insertStatement = "INSERT INTO fourmarketing_fourdem_users VALUES(
178
+ ".$subscriber->SubscriberID.",
179
+ '$firstname',
180
+ '$lastname',
181
+ '".$subscriber->EmailAddress."',
182
+ 'ID: $newsletterListID / Nome: $newsletterList')";
183
+ $writeConnection->query($insertStatement);
184
+ }
185
+ }
186
+
187
+ $time_taken = microtime(true) - $start;
188
+ $minSeconds = date("i:s", $time_taken);
189
+
190
+ $message = $this->__("Tabella Sincronizzata Con Successo! Tempo stimato: ".$minSeconds." secondi");
191
+ Mage::getSingleton('core/session')->addSuccess($message);
192
+
193
+ $this->_redirectReferer();
194
+ }
195
+ catch(Exception $e)
196
+ {
197
+ $message = $this->__($e->getMessage());
198
+ Mage::getSingleton('core/session')->addError($message);
199
+ }
200
+ }
201
+ }
app/code/community/FourMarketing/FourDem/etc/adminhtml.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <fourdem translate="title" module="fourdem">
5
+ <title>4Dem.it</title>
6
+ <sort_order>65</sort_order>
7
+ <children>
8
+ <iscritti>
9
+ <title>Sincronizzazione Clienti</title>
10
+ <sort_order>1</sort_order>
11
+ <action>adminhtml/users</action>
12
+ </iscritti>
13
+ </children>
14
+ <!--
15
+ <children>
16
+ <utenti>
17
+ <title>Gestione Utenti</title>
18
+ <sort_order>2</sort_order>
19
+ <action>adminhtml/iscritti/getutenti</action>
20
+ </utenti>
21
+ </children>
22
+ -->
23
+ </fourdem>
24
+ </menu>
25
+ <acl>
26
+ <resources>
27
+ <admin>
28
+ <children>
29
+ <system>
30
+ <children>
31
+ <config>
32
+ <children>
33
+ <fourdem>
34
+ <title>4Dem.it - Email Marketing</title>
35
+ </fourdem>
36
+ </children>
37
+ </config>
38
+ </children>
39
+ </system>
40
+ </children>
41
+ </admin>
42
+ </resources>
43
+ </acl>
44
+ </config>
app/code/community/FourMarketing/FourDem/etc/config.xml ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <FourMarketing_FourDem>
5
+ <version>0.1.0</version>
6
+ </FourMarketing_FourDem>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <fourmarketing_fourdem>
11
+ <class>FourMarketing_FourDem_Block</class>
12
+ </fourmarketing_fourdem>
13
+ </blocks>
14
+ <helpers>
15
+ <fourdem>
16
+ <class>FourMarketing_FourDem_Helper</class>
17
+ </fourdem>
18
+ </helpers>
19
+
20
+ <models>
21
+ <fourmarketing_fourdem>
22
+ <class>FourMarketing_FourDem_Model</class>
23
+ <resourceModel>fourmarketing_fourdem_mysql4</resourceModel>
24
+ </fourmarketing_fourdem>
25
+
26
+ <fourmarketing_fourdem_mysql4>
27
+ <class>FourMarketing_FourDem_Model_Mysql4</class>
28
+ <entities>
29
+ <users>
30
+ <table>fourmarketing_fourdem_users</table>
31
+ </users>
32
+ </entities>
33
+ </fourmarketing_fourdem_mysql4>
34
+ </models>
35
+
36
+ <resources>
37
+ <fourmarketing_fourdem_setup>
38
+ <setup>
39
+ <module>FourMarketing_FourDem</module>
40
+ </setup>
41
+ <connection>
42
+ <use>core_setup</use>
43
+ </connection>
44
+ </fourmarketing_fourdem_setup>
45
+ <fourmarketing_fourdem_write>
46
+ <connection>
47
+ <use>core_write</use>
48
+ </connection>
49
+ </fourmarketing_fourdem_write>
50
+ <fourmarketing_fourdem_read>
51
+ <connection>
52
+ <use>core_read</use>
53
+ </connection>
54
+ </fourmarketing_fourdem_read>
55
+ </resources>
56
+ <events>
57
+ <admin_system_config_changed_section_fourdem>
58
+ <observers>
59
+ <fourdem>
60
+ <type>singleton</type>
61
+ <class>FourMarketing_FourDem_Model_Observer</class>
62
+ <method>check4DemConfiguration</method>
63
+ </fourdem>
64
+ </observers>
65
+ </admin_system_config_changed_section_fourdem>
66
+ <customer_register_success>
67
+ <observers>
68
+ <fourdem>
69
+ <type>singleton</type>
70
+ <class>FourMarketing_FourDem_Model_Observer</class>
71
+ <method>subscribeCustomer</method>
72
+ </fourdem>
73
+ </observers>
74
+ </customer_register_success>
75
+ <customer_save_after>
76
+ <observers>
77
+ <fourdem>
78
+ <type>singleton</type>
79
+ <class>FourMarketing_FourDem_Model_Observer</class>
80
+ <method>changeSubscribeEmail</method>
81
+ </fourdem>
82
+ </observers>
83
+ </customer_save_after>
84
+ <customer_address_save_after>
85
+ <observers>
86
+ <fourdem>
87
+ <type>singleton</type>
88
+ <class>FourMarketing_FourDem_Model_Observer</class>
89
+ <method>collectionDataMapping</method>
90
+ </fourdem>
91
+ </observers>
92
+ </customer_address_save_after>
93
+ <checkout_submit_all_after>
94
+ <observers>
95
+ <fourdem>
96
+ <type>singleton</type>
97
+ <class>FourMarketing_FourDem_Model_Observer</class>
98
+ <method>subscribeCustomerAfterCheckout</method>
99
+ </fourdem>
100
+ </observers>
101
+ </checkout_submit_all_after>
102
+ </events>
103
+ </global>
104
+ <admin>
105
+ <routers>
106
+ <adminhtml>
107
+ <args>
108
+ <modules>
109
+ <FourMarketing_FourDem before="Mage_Adminhtml">FourMarketing_FourDem</FourMarketing_FourDem>
110
+ </modules>
111
+ </args>
112
+ </adminhtml>
113
+ </routers>
114
+ </admin>
115
+ <adminhtml>
116
+ <layout>
117
+ <updates>
118
+ <fourmarketing_fourdem>
119
+ <file>fourmarketing/fourdem.xml</file>
120
+ </fourmarketing_fourdem>
121
+ </updates>
122
+ </layout>
123
+ </adminhtml>
124
+ <frontend>
125
+ <routers>
126
+ <fourdem>
127
+ <use>standard</use>
128
+ <args>
129
+ <module>FourMarketing_FourDem</module>
130
+ <frontName>fourdem</frontName>
131
+ </args>
132
+ </fourdem>
133
+ </routers>
134
+ <layout>
135
+ <updates>
136
+ <fourdem>
137
+ <file>fourdem.xml</file>
138
+ </fourdem>
139
+ </updates>
140
+ </layout>
141
+ </frontend>
142
+ </config>
app/code/community/FourMarketing/FourDem/etc/system.xml ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <fourdem translate="label" module="fourdem">
5
+ <label><![CDATA[4Dem.it]]></label>
6
+ <sort_order>400</sort_order>
7
+ </fourdem>
8
+ </tabs>
9
+ <sections>
10
+ <fourdem translate="label" module="fourdem">
11
+ <label><![CDATA[Configurazione 4Dem.it]]></label>
12
+ <tab>fourdem</tab>
13
+ <sort_order>1000</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <groups>
18
+ <system_access translate="label" module="fourdem">
19
+ <label>Configurazione 4Dem.it Email Marketing</label>
20
+ <frontend_type>text</frontend_type>
21
+ <sort_order>1000</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <comment><![CDATA[
26
+ <div style="float:right;width:560px;">
27
+ <p>Attivando il modulo 4Dem.it potrai sincronizzare i tuoi clienti e prospect con la nostra piattaforma di email marketing.
28
+ Inserisci lo username e password che utilizzi per accedere alla console.</p>
29
+ <p style="margin-top:95px;">
30
+ Puoi scegliere se separare gli utenti registrati e chi si è solo iscritto alla newsletter in due liste separate, oppure inserirli tutti nella stessa lista.
31
+ Se decidi di separarli verrà attivato nel frontend di magento un widget di iscrizione alla newsletter che avrà valenza a se stante, quindi si potrà essere iscritti alla newsletter senza essere registrati a magento. In caso contrario solamente gli utenti registrati a magento verranno sincronizzati con la console 4Dem.it.
32
+ Ricorda che sulla console 4Dem.it puoi selezionare più di una lista per ogni campagna, la deduplica degli indirizzi è automatica!
33
+ </p>
34
+ <p style="margin-top:203px;">
35
+ Seleziona la lista di destinazione dall'elenco delle liste presenti sul tuo account 4Dem.it.
36
+ Se hai deciso di separare i clienti e gli iscritti alla newsletter ricordati che per la lista dedicata alla newsletter dovrai impostare il metodo di
37
+ conferma Double Opt-in ed impostare la mail di conferma iscrizione sulla console 4Dem.it in modo che l'iscrizione alla newsletter rispetti i termini di legge e netiquette.
38
+ </p>
39
+ </div>
40
+ ]]></comment>
41
+ <fields>
42
+ <active translate="label">
43
+ <label>Attivare il Modulo 4Dem.it?</label>
44
+ <frontend_type>select</frontend_type>
45
+ <source_model>adminhtml/system_config_source_yesno</source_model>
46
+ <sort_order>10</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>1</show_in_store>
50
+ </active>
51
+ <username translate="label comment">
52
+ <label>Username</label>
53
+ <comment><![CDATA[Inserire la username fornita da 4Dem.it.]]></comment>
54
+ <frontend_type>text</frontend_type>
55
+ <sort_order>20</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>1</show_in_store>
59
+ </username>
60
+ <password translate="label comment">
61
+ <label>Password</label>
62
+ <comment><![CDATA[Inserire la password fornita da 4Dem.it.]]></comment>
63
+ <frontend_type>password</frontend_type>
64
+ <sort_order>30</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ </password>
69
+ <url_console translate="label comment">
70
+ <label>Console URL</label>
71
+ <comment><![CDATA[Inserire l'indirizzo della console. Esempio: http://www.4dem.it/api.php]]></comment>
72
+ <frontend_type>text</frontend_type>
73
+ <sort_order>40</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ </url_console>
78
+ <select_list translate="label">
79
+ <label>Vuoi che gli iscritti alla newsletter e i clienti siano su 2 liste separate?</label>
80
+ <frontend_type>select</frontend_type>
81
+ <source_model>adminhtml/system_config_source_yesno</source_model>
82
+ <sort_order>50</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ </select_list>
87
+ <customer_list translate="label comment">
88
+ <label>Lista Clienti</label>
89
+ <comment><![CDATA[Lista dei Clienti che hanno effettuato almeno un acquisto.]]></comment>
90
+ <frontend_type>multiselect</frontend_type>
91
+ <source_model>fourmarketing_fourdem/system_config_source_list</source_model>
92
+ <sort_order>60</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>0</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ <!--<can_be_empty>1</can_be_empty>-->
97
+ </customer_list>
98
+ <newsletter_list translate="label comment">
99
+ <label>Iscritti alla Newsletter</label>
100
+ <comment><![CDATA[Lista degli iscritti alla newsletter.]]></comment>
101
+ <frontend_type>multiselect</frontend_type>
102
+ <source_model>fourmarketing_fourdem/system_config_source_list</source_model>
103
+ <sort_order>70</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>0</show_in_website>
106
+ <show_in_store>1</show_in_store>
107
+ <can_be_empty>1</can_be_empty>
108
+ <depends>
109
+ <select_list>1</select_list>
110
+ </depends>
111
+ </newsletter_list>
112
+ </fields>
113
+ </system_access>
114
+ <fourdem_mapping translate="label">
115
+ <label>4Dem.it Mappatura Campi</label>
116
+ <frontend_type>text</frontend_type>
117
+ <sort_order>2000</sort_order>
118
+ <show_in_default>1</show_in_default>
119
+ <show_in_website>1</show_in_website>
120
+ <show_in_store>1</show_in_store>
121
+ <comment><![CDATA[<p style="font-size:13px;"><strong style="margin-right:150px;">Magento</strong><strong>Console 4Dem.it</strong></p>
122
+ <div style="float:right;width:573px;">
123
+ In questo pannello puoi decidere di importare ulteriori informazioni sui tuoi clienti oltre all'indirizzo email.
124
+ Per sincronizzare i dati aggiuntivi entra nel tuo account sulla console 4Dem.it, seleziona la lista dedicata agli utenti registrati in magento e crea i campi personalizzati di cui hai bisogno. Per ogni dato che vuoi sincronizzare devi creare un campo personalizzato.
125
+ Quando crei il campo personalizzato imposta solamente il nome del campo e lascia tutti gli altri valori come proposti.
126
+ Una volta che i campi saranno disponibili potrai effettuare il mapping utilizzano questo menù dove potrai selezionare per ogni dato disponibile su magento, il campo personalizzato della console 4Dem.it in cui importarlo.
127
+ La mappatura campi non è obbligatoria, ma puà risultare molto utilie in quanto ti permetterà di personalizzare le email inserendo automaticamente i dati del destinatario, ad esempio Nome e Cognome
128
+ </div>]]></comment>
129
+ <fields>
130
+ <firstname translate="comment">
131
+ <label>Nome</label>
132
+ <frontend_type>select</frontend_type>
133
+ <sort_order>1</sort_order>
134
+ <show_in_default>1</show_in_default>
135
+ <show_in_website>1</show_in_website>
136
+ <show_in_store>1</show_in_store>
137
+ <source_model>fourmarketing_fourdem/adminhtml_system_source_fields</source_model>
138
+ </firstname>
139
+ <lastname translate="comment">
140
+ <label>Cognome</label>
141
+ <frontend_type>select</frontend_type>
142
+ <sort_order>2</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>1</show_in_store>
146
+ <source_model>fourmarketing_fourdem/adminhtml_system_source_fields</source_model>
147
+ </lastname>
148
+ <gender translate="comment">
149
+ <label>Genere</label>
150
+ <frontend_type>select</frontend_type>
151
+ <sort_order>3</sort_order>
152
+ <show_in_default>1</show_in_default>
153
+ <show_in_website>1</show_in_website>
154
+ <show_in_store>1</show_in_store>
155
+ <source_model>fourmarketing_fourdem/adminhtml_system_source_fields</source_model>
156
+ </gender>
157
+ <company translate="comment">
158
+ <label>Nome Azienda</label>
159
+ <frontend_type>select</frontend_type>
160
+ <sort_order>4</sort_order>
161
+ <show_in_default>1</show_in_default>
162
+ <show_in_website>1</show_in_website>
163
+ <show_in_store>1</show_in_store>
164
+ <source_model>fourmarketing_fourdem/adminhtml_system_source_fields</source_model>
165
+ </company>
166
+ <street translate="comment">
167
+ <label>Indirizzo</label>
168
+ <frontend_type>select</frontend_type>
169
+ <sort_order>5</sort_order>
170
+ <show_in_default>1</show_in_default>
171
+ <show_in_website>1</show_in_website>
172
+ <show_in_store>1</show_in_store>
173
+ <source_model>fourmarketing_fourdem/adminhtml_system_source_fields</source_model>
174
+ </street>
175
+ <city translate="comment">
176
+ <label>Città</label>
177
+ <frontend_type>select</frontend_type>
178
+ <sort_order>6</sort_order>
179
+ <show_in_default>1</show_in_default>
180
+ <show_in_website>1</show_in_website>
181
+ <show_in_store>1</show_in_store>
182
+ <source_model>fourmarketing_fourdem/adminhtml_system_source_fields</source_model>
183
+ </city>
184
+ <postcode translate="comment">
185
+ <label>CAP</label>
186
+ <frontend_type>select</frontend_type>
187
+ <sort_order>7</sort_order>
188
+ <show_in_default>1</show_in_default>
189
+ <show_in_website>1</show_in_website>
190
+ <show_in_store>1</show_in_store>
191
+ <source_model>fourmarketing_fourdem/adminhtml_system_source_fields</source_model>
192
+ </postcode>
193
+ <province translate="comment">
194
+ <label>Provincia</label>
195
+ <frontend_type>select</frontend_type>
196
+ <sort_order>8</sort_order>
197
+ <show_in_default>1</show_in_default>
198
+ <show_in_website>1</show_in_website>
199
+ <show_in_store>1</show_in_store>
200
+ <source_model>fourmarketing_fourdem/adminhtml_system_source_fields</source_model>
201
+ </province>
202
+ <region translate="comment">
203
+ <label>Regione</label>
204
+ <frontend_type>select</frontend_type>
205
+ <sort_order>9</sort_order>
206
+ <show_in_default>1</show_in_default>
207
+ <show_in_website>1</show_in_website>
208
+ <show_in_store>1</show_in_store>
209
+ <source_model>fourmarketing_fourdem/adminhtml_system_source_fields</source_model>
210
+ </region>
211
+ <country_id translate="comment">
212
+ <label>Nazione</label>
213
+ <frontend_type>select</frontend_type>
214
+ <sort_order>10</sort_order>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>1</show_in_website>
217
+ <show_in_store>1</show_in_store>
218
+ <source_model>fourmarketing_fourdem/adminhtml_system_source_fields</source_model>
219
+ </country_id>
220
+ <created_at translate="comment">
221
+ <label>Ultimo acquisto</label>
222
+ <frontend_type>select</frontend_type>
223
+ <sort_order>11</sort_order>
224
+ <show_in_default>1</show_in_default>
225
+ <show_in_website>1</show_in_website>
226
+ <show_in_store>1</show_in_store>
227
+ <source_model>fourmarketing_fourdem/adminhtml_system_source_fields</source_model>
228
+ </created_at>
229
+ </fields>
230
+ </fourdem_mapping>
231
+ <box_newsletter translate="label">
232
+ <label>Frontend Box Newsletter</label>
233
+ <frontend_type>text</frontend_type>
234
+ <sort_order>3000</sort_order>
235
+ <show_in_default>1</show_in_default>
236
+ <show_in_website>1</show_in_website>
237
+ <show_in_store>1</show_in_store>
238
+ <fields>
239
+ <title_box translate="label comment">
240
+ <label>Titolo Box Newsletter</label>
241
+ <frontend_type>text</frontend_type>
242
+ <sort_order>10</sort_order>
243
+ <show_in_default>1</show_in_default>
244
+ <show_in_website>1</show_in_website>
245
+ <show_in_store>1</show_in_store>
246
+ </title_box>
247
+ <text_box translate="label comment">
248
+ <label>Testo Box Newsletter</label>
249
+ <frontend_type>text</frontend_type>
250
+ <sort_order>20</sort_order>
251
+ <show_in_default>1</show_in_default>
252
+ <show_in_website>1</show_in_website>
253
+ <show_in_store>1</show_in_store>
254
+ </text_box>
255
+ </fields>
256
+ </box_newsletter>
257
+ </groups>
258
+ </fourdem>
259
+ </sections>
260
+ </config>
app/code/community/FourMarketing/FourDem/sql/fourmarketing_fourdem_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $installer Mage_Core_Model_Resource_Setup */
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $installer->run("
7
+ CREATE TABLE fourmarketing_fourdem_users(
8
+ id_fourdem int(11) NOT NULL,
9
+ firstname text NOT NULL,
10
+ lastname text NOT NULL,
11
+ email_address text NOT NULL,
12
+ own_list text NOT NULL
13
+ )
14
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;
15
+ ");
16
+
17
+ $installer->endSetup();
app/design/frontend/default/default/layout/fourdem.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <remove name="left.newsletter"/>
5
+ <reference name="right">
6
+ <block type="core/template" name="right.subscribe" template="fourdem/subscribe.phtml" before="-"/>
7
+ </reference>
8
+ </default>
9
+ <customer_account_create>
10
+ <reference name="customer_form_register">
11
+ <action method="setTemplate">
12
+ <template>fourdem/form/register-customer.phtml</template>
13
+ </action>
14
+ </reference>
15
+ </customer_account_create>
16
+ </layout>
app/design/frontend/default/default/template/fourdem/form/register-customer.phtml ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <?php
28
+ /**
29
+ * Create account form template
30
+ *
31
+ * @var $this Mage_Customer_Block_Form_Register
32
+ */
33
+ ?>
34
+ <div class="account-create">
35
+ <div class="page-title">
36
+ <h1><?php echo $this->__('Create an Account') ?></h1>
37
+ </div>
38
+ <?php echo $this->getChildHtml('form_fields_before')?>
39
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
40
+ <?php /* Extensions placeholder */ ?>
41
+ <?php echo $this->getChildHtml('customer.form.register.extra')?>
42
+ <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">
43
+ <div class="fieldset">
44
+ <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
45
+ <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
46
+ <h2 class="legend"><?php echo $this->__('Personal Information') ?></h2>
47
+ <ul class="form-list">
48
+ <li class="fields">
49
+ <?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?>
50
+ </li>
51
+ <li>
52
+ <label for="email_address" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
53
+ <div class="input-box">
54
+ <input type="text" name="email" id="email_address" value="<?php echo $this->escapeHtml($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
55
+ </div>
56
+ </li>
57
+ <?php //if ($this->isNewsletterEnabled()): ?>
58
+ <li class="control" style="visibility:hidden;">
59
+ <div class="input-box">
60
+ <input type="checkbox" name="is_subscribed" title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" id="is_subscribed" checked="checked" class="checkbox"/>
61
+ </div>
62
+ <label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
63
+ <?php /* Extensions placeholder */ ?>
64
+ <?php echo $this->getChildHtml('customer.form.register.newsletter')?>
65
+ </li>
66
+ <?php //endif; ?>
67
+ <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
68
+ <?php if ($_dob->isEnabled()): ?>
69
+ <li><?php echo $_dob->setDate($this->getFormData()->getDob())->toHtml() ?></li>
70
+ <?php endif ?>
71
+ <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
72
+ <?php if ($_taxvat->isEnabled()): ?>
73
+ <li><?php echo $_taxvat->setTaxvat($this->getFormData()->getTaxvat())->toHtml() ?></li>
74
+ <?php endif ?>
75
+ <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
76
+ <?php if ($_gender->isEnabled()): ?>
77
+ <li><?php echo $_gender->setGender($this->getFormData()->getGender())->toHtml() ?></li>
78
+ <?php endif ?>
79
+ </ul>
80
+ </div>
81
+ <?php if($this->getShowAddressFields()): ?>
82
+ <div class="fieldset">
83
+ <input type="hidden" name="create_address" value="1" />
84
+ <h2 class="legend"><?php echo $this->__('Address Information') ?></h2>
85
+ <ul class="form-list">
86
+ <li class="fields">
87
+ <div class="field">
88
+ <label for="company"><?php echo $this->__('Company') ?></label>
89
+ <div class="input-box">
90
+ <input type="text" name="company" id="company" value="<?php echo $this->escapeHtml($this->getFormData()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
91
+ </div>
92
+ </div>
93
+ <div class="field">
94
+ <label for="telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
95
+ <div class="input-box">
96
+ <input type="text" name="telephone" id="telephone" value="<?php echo $this->escapeHtml($this->getFormData()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" />
97
+ </div>
98
+ </div>
99
+ </li>
100
+ <?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
101
+ <li class="wide">
102
+ <label for="street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
103
+ <div class="input-box">
104
+ <input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet(1)) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="input-text <?php echo $_streetValidationClass ?>" />
105
+ </div>
106
+ </li>
107
+ <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
108
+ <?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
109
+ <li class="wide">
110
+ <div class="input-box">
111
+ <input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet($_i)) ?>" title="<?php echo $this->__('Street Address %s', $_i) ?>" id="street_<?php echo $_i ?>" class="input-text <?php echo $_streetValidationClass ?>" />
112
+ </div>
113
+ </li>
114
+ <?php endfor; ?>
115
+ <li class="fields">
116
+ <div class="field">
117
+ <label for="city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
118
+ <div class="input-box">
119
+ <input type="text" name="city" value="<?php echo $this->escapeHtml($this->getFormData()->getCity()) ?>" title="<?php echo $this->__('City') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="city" />
120
+ </div>
121
+ </div>
122
+ <div class="field">
123
+ <label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
124
+ <div class="input-box">
125
+ <select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
126
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
127
+ </select>
128
+ <script type="text/javascript">
129
+ //<![CDATA[
130
+ $('region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getRegionId() ?>");
131
+ //]]>
132
+ </script>
133
+ <input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
134
+ </div>
135
+ </div>
136
+ </li>
137
+ <li class="fields">
138
+ <div class="field">
139
+ <label for="zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
140
+ <div class="input-box">
141
+ <input type="text" name="postcode" value="<?php echo $this->escapeHtml($this->getFormData()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
142
+ </div>
143
+ </div>
144
+ <div class="field">
145
+ <label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
146
+ <div class="input-box">
147
+ <?php echo $this->getCountryHtmlSelect() ?>
148
+ </div>
149
+ </div>
150
+ </li>
151
+ </ul>
152
+ <input type="hidden" name="default_billing" value="1" />
153
+ <input type="hidden" name="default_shipping" value="1" />
154
+ </div>
155
+ <?php endif; ?>
156
+ <div class="fieldset">
157
+ <h2 class="legend"><?php echo $this->__('Login Information') ?></h2>
158
+ <ul class="form-list">
159
+ <li class="fields">
160
+ <div class="field">
161
+ <label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
162
+ <div class="input-box">
163
+ <input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" />
164
+ </div>
165
+ </div>
166
+ <div class="field">
167
+ <label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
168
+ <div class="input-box">
169
+ <input type="password" name="confirmation" title="<?php echo $this->__('Confirm Password') ?>" id="confirmation" class="input-text required-entry validate-cpassword" />
170
+ </div>
171
+ </div>
172
+ </li>
173
+ <?php echo $this->getChildHtml('form.additional.info'); ?>
174
+ </ul>
175
+ </div>
176
+ <div class="buttons-set">
177
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
178
+ <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>" class="back-link"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
179
+ <button type="submit" title="<?php echo $this->__('Submit') ?>" class="button"><span><span><?php echo $this->__('Submit') ?></span></span></button>
180
+ </div>
181
+ </form>
182
+ <script type="text/javascript">
183
+ //<![CDATA[
184
+ var dataForm = new VarienForm('form-validate', true);
185
+ <?php if($this->getShowAddressFields()): ?>
186
+ new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
187
+ <?php endif; ?>
188
+ //]]>
189
+ </script>
190
+ </div>
app/etc/modules/FourMarketing_FourDem.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <FourMarketing_FourDem>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </FourMarketing_FourDem>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>4Dem_Integration_community</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.4dem.it/disclaimer">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Integrate Magento Users and Newsletter Subscribers with 4Dem.it Email Marketing Platform</summary>
10
+ <description>This extension provide a one way synchronization of the magento users data with a list on the 4Dem.it email marketing platform.&#xD;
11
+ Every new user registered on Magento and subscribed to the newsletter is synced with a subscribers list in 4Dem.it.&#xD;
12
+ User data and subscription preferences are authomatically synced and managed.&#xD;
13
+ &#xD;
14
+ This extension also provide a new newsletter only registration in magento frontend. Each visitor that subscribe using the provided newsletter form is put inside a 4Dem.it subscribers list.</description>
15
+ <notes>First release</notes>
16
+ <authors><author><name>4Marketing.it</name><user>techsupport4mkt</user><email>ugo.reynaldi@4marketing.it</email></author></authors>
17
+ <date>2014-03-31</date>
18
+ <time>07:52:39</time>
19
+ <contents><target name="magecommunity"><dir name="FourMarketing"><dir name="FourDem"><dir><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Mapfields.php" hash="4976f6ae47bb04d95c94064c231b8409"/></dir></dir></dir></dir><dir name="Users"><file name="Grid.php" hash="b4a73c4a95c9a83d31d8629c3715a86e"/></dir><file name="Users.php" hash="77ef1e8ebeca9e263039f299c9bee6c5"/></dir></dir><dir name="Helper"><file name="Data.php" hash="7d430d2c7cbdcfc946dd2503b78b8b38"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Source"><file name="Fields.php" hash="4085a2528df1ffc5fce044948fada18f"/></dir></dir></dir><dir name="Mysql4"><dir name="Users"><file name="Collection.php" hash="1ec0d46b7bd77347426a2d4713aa1e1e"/></dir><file name="Users.php" hash="ed06aa878acbad0d1a40b0c5161d3f7c"/></dir><file name="Observer.php" hash="83ae622587e58712bf6f9f9a905f5094"/><dir name="System"><dir name="Config"><dir name="Source"><file name="List.php" hash="959117927bc862ddcb48585f6dcdf96a"/></dir></dir></dir><file name="Users.php" hash="add246d80d352d6537cf71f3ab45f5dd"/></dir><dir name="controllers"><file name="SubscribersController.php" hash="30ae20725949ff4d061738bab0d46b03"/><file name="UsersController.php" hash="d2d34d6b3fd25b78aab858623c0e14a6"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e79bd5ce8327e0e3add9ba8cf2edf6bb"/><file name="config.xml" hash="b9ca98f3533d6b71a095b4f330119a13"/><file name="system.xml" hash="8b268fdfa16c13da969a7c99598b3bdb"/></dir><dir name="sql"><dir name="fourmarketing_fourdem_setup"><file name="mysql4-install-0.1.0.php" hash="ccef0bfd0b49a6ced3889f42560f5ece"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="fourdem.xml" hash="4cdb947b36365d26b3e94b732cfbd35e"/></dir><dir name="template"><dir name="fourdem"><dir name="form"><file name="register-customer.phtml" hash="cbe26dfdb19ac6444d96ed1dc389ec51"/><file name="register-customer.phtml" hash="cbe26dfdb19ac6444d96ed1dc389ec51"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="FourMarketing_FourDem.xml" hash="708a31c59e03b1c719335822113a6908"/></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.3.0</min><max>5.4.2</max></php></required></dependencies>
22
+ </package>