SALESmanago - Version 1.5.1

Version Notes

SALESmanago Marketing Automation integration.

Download this release

Release Info

Developer Benhauer Sp. z o.o. Sp. K.
Extension SALESmanago
Version 1.5.1
Comparing to
See all releases


Version 1.5.1

Files changed (23) hide show
  1. CHANGELOG.md +64 -0
  2. app/code/community/SalesManago/Tracking/Block/Layer.php +82 -0
  3. app/code/community/SalesManago/Tracking/Helper/Data.php +366 -0
  4. app/code/community/SalesManago/Tracking/Model/Customersync.php +9 -0
  5. app/code/community/SalesManago/Tracking/Model/Observer.php +456 -0
  6. app/code/community/SalesManago/Tracking/Model/Resource/Customersync.php +7 -0
  7. app/code/community/SalesManago/Tracking/Model/Resource/Customersync/Collection.php +8 -0
  8. app/code/community/SalesManago/Tracking/Model/Resource/Setup.php +5 -0
  9. app/code/community/SalesManago/Tracking/controllers/CustomerController.php +242 -0
  10. app/code/community/SalesManago/Tracking/controllers/Newsletter/SubscriberController.php +85 -0
  11. app/code/community/SalesManago/Tracking/etc/config.xml +211 -0
  12. app/code/community/SalesManago/Tracking/etc/system.xml +117 -0
  13. app/code/community/SalesManago/Tracking/sql/tracking_setup/mysql4-install-0.0.4.php +39 -0
  14. app/design/frontend/base/default/layout/salesmanago.xml +10 -0
  15. app/design/frontend/base/default/template/salesmanago/tracking/tracking.phtml +28 -0
  16. app/design/frontend/default/default/layout/salesmanago.xml +10 -0
  17. app/design/frontend/default/default/template/salesmanago/tracking/tracking.phtml +28 -0
  18. app/etc/modules/SalesManago_Tracking.xml +9 -0
  19. app/locale/de_DE/Salesmanago_Tracking.csv +15 -0
  20. app/locale/es_ES/Salesmanago_Tracking.csv +15 -0
  21. app/locale/pl_PL/Salesmanago_Tracking.csv +15 -0
  22. app/locale/ru_RU/Salesmanago_Tracking.csv +15 -0
  23. package.xml +111 -0
CHANGELOG.md ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Magento integration v1.5.1 (Released: 21.11.2016)
2
+ Changes:
3
+ - New monitoring code
4
+
5
+ --------------------------------------------------
6
+ Magento integration v1.5.0 (Released: 09.11.2016)
7
+ Added:
8
+ - Register tags,
9
+ - Newsletter tags,
10
+ - Purchase tags,
11
+ - New method to upsert Vendor platform and version to support account
12
+ - Translations, MultiLanguage: Polish, English, Spanish, German, Russian
13
+ - New other event: Wishlist,
14
+
15
+ Improvements:
16
+ - More details in events,
17
+
18
+ Fixed:
19
+ - Installation bug - creating directories instead files,
20
+ --------------------------------------------------
21
+ Magento integration v0.1.2.1 (Released: 04.04.2016)
22
+ -Fixes:
23
+ OptIn after anonymous client purchase
24
+ --------------------------------------------------
25
+ Magento integration v0.1.2 (Released: 16.02.2016)
26
+ Added:
27
+ - Register form with address fields - compatibility
28
+ BugFixes:
29
+ - Profile and address editing in Magento make changes in SalesManago,
30
+ - Registering by form with address fields,
31
+ - Synchronizing contact details in salesmanago,
32
+ --------------------------------------------------
33
+ Magento integration v0.1.1 (Released: 29.07.2015)
34
+ Added:
35
+ - Profile and address editing in Magento make changes in SalesManago
36
+ --------------------------------------------------
37
+ Magento integration v0.1.0 (Released: 24.07.2015)
38
+ Added:
39
+ - creating SMclient cookie after login and registering
40
+ --------------------------------------------------
41
+ Magento integration v0.0.8 (Released: 05.05.2015)
42
+ Added:
43
+ - cart events for unregistered users (with smclient cookie)
44
+ --------------------------------------------------
45
+ Magento integration v0.0.7 (Released: 12.03.2015)
46
+ Added:
47
+ - enable/disable module
48
+ - when newsletter requires confirm, contact is sent to sm as optout.
49
+ --------------------------------------------------
50
+ Magento integration v0.0.6 (Released: 20.01.2015)
51
+ Added:
52
+ - optin callback support
53
+ - birthday date is sent to SM
54
+ --------------------------------------------------
55
+ Magento integration v0.0.5 (Released: 21.11.2014)
56
+ Added:
57
+ - support subscription form
58
+ - admin subscription managment integrated with SM
59
+
60
+ Bugfixes:
61
+ - address, phone etc. not send to SM
62
+ - cookie not created after guest purchase
63
+ - tracking code not shown in newest magento
64
+ - bad price for CART event
app/code/community/SalesManago/Tracking/Block/Layer.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright (C) 2012 Clearspring Technologies, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ ?>
18
+ <?php
19
+
20
+ class SalesManago_Tracking_Block_Layer extends Mage_Core_Block_Template
21
+ {
22
+ protected function _construct()
23
+ {
24
+ parent::_construct();
25
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
26
+ if($active == 1) {
27
+ $this->setTemplate('salesmanago/tracking/tracking.phtml');
28
+ }
29
+ }
30
+
31
+ public function getClientId(){
32
+ return Mage::getStoreConfig('salesmanago_tracking/general/client_id');
33
+ }
34
+
35
+ public function getClientApiSecret(){
36
+ return Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
37
+ }
38
+
39
+ public function getClientEmail(){
40
+ return Mage::getStoreConfig('salesmanago_tracking/general/email');
41
+ }
42
+
43
+ public function getEndPoint(){
44
+ return Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
45
+ }
46
+
47
+ public function getAdditionalJs(){
48
+ return Mage::getStoreConfig('salesmanago_tracking/general/additional_js');
49
+ }
50
+
51
+ public function isActive(){
52
+ return Mage::getStoreConfig('salesmanago_tracking/general/active');
53
+ }
54
+
55
+
56
+ public function getTagsRegistration(){
57
+ $tags = Mage::getStoreConfig('salesmanago_tracking/general/tagsRegistration');
58
+ $tags = explode(',', $tags);
59
+ return $tags;
60
+ }
61
+
62
+ public function getTagsNewsletter(){
63
+ $tags = Mage::getStoreConfig('salesmanago_tracking/general/tagsNewsletter');
64
+ $tags = explode(',', $tags);
65
+ return $tags;
66
+ }
67
+
68
+ public function getTagsPurchase(){
69
+ $tags = Mage::getStoreConfig('salesmanago_tracking/general/tagsPurchase');
70
+ $tags = explode(',', $tags);
71
+ return $tags;
72
+ }
73
+
74
+ public function getClientSalesManagoId(){
75
+ if(Mage::getSingleton('customer/session')->isLoggedIn()) {
76
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
77
+ return $customerData->getSalesmanagoContactId();
78
+ }
79
+
80
+ return false;
81
+ }
82
+ }
app/code/community/SalesManago/Tracking/Helper/Data.php ADDED
@@ -0,0 +1,366 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class SalesManago_Tracking_Helper_Data extends Mage_Core_Helper_Abstract{
3
+
4
+ public function setSalesmanagoCustomerSyncStatus($data = array()){
5
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
6
+ if($active == 1) {
7
+ $customersyncModel = Mage::getModel('tracking/customersync');
8
+ $dateTime = new DateTime('NOW');
9
+
10
+ $insert_data = array(
11
+ 'email' => $data['customerEmail'],
12
+ 'hash' => sha1($data['customerEmail']),
13
+ 'status' => $data['status'],
14
+ 'action' => $data['action'],
15
+ 'counter' => 1,
16
+ 'created_time' => $dateTime->format('c')
17
+ );
18
+ if (isset($data['entity_id']) && !empty($data['entity_id'])) {
19
+ $insert_data['customer_id'] = $data['entity_id'];
20
+ }
21
+
22
+ if (isset($data['order_id']) && !empty($data['order_id'])) {
23
+ $insert_data['order_id'] = $data['order_id'];
24
+ }
25
+
26
+ $customersyncModel->setData($insert_data);
27
+
28
+ try {
29
+ $customersyncModel->save();
30
+ } catch (Exception $e) {
31
+ Mage::log($e->getMessage());
32
+ }
33
+ }
34
+ }
35
+
36
+ public function salesmanagoOrderSync($orderDetails){
37
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
38
+ if($active == 1) {
39
+ $clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
40
+ $apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
41
+ $ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
42
+ $endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
43
+ $registerTags = explode(",", Mage::getStoreConfig('salesmanago_tracking/general/tagsPurchase'));
44
+
45
+ $productsIdsList = array();
46
+ $productsNamesList = array();
47
+
48
+ $items = $orderDetails->getAllVisibleItems();
49
+ foreach ($items as $item) {
50
+ array_push($productsIdsList, $item->getProduct()->getId());
51
+ array_push($productsNamesList, $item->getProduct()->getName());
52
+ }
53
+
54
+ $customerEmail = $orderDetails->getCustomerEmail();
55
+ $grandTotal = $orderDetails->getBaseGrandTotal();
56
+ $incrementOrderId = $orderDetails->getIncrementId();
57
+ $customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($customerEmail)->getData();
58
+ $orderData = $orderDetails->getData();
59
+ $customerDetails = $orderDetails->getBillingAddress();
60
+
61
+ $data = array();
62
+ $data['name'] = $customerDetails->getFirstname() . ' ' . $customerDetails->getLastname();
63
+ $data['phone'] = $customerDetails->getTelephone();
64
+ $data['company'] = $customerDetails->getCompany();
65
+ $data['fax'] = $customerDetails->getFax();
66
+ $data['address']['streetAddress'] = implode($customerDetails->getStreet(), ' ');
67
+ $data['address']['zipCode'] = $customerDetails->getPostcode();
68
+ $data['address']['city'] = $customerDetails->getCity();
69
+ $data['address']['country'] = $customerDetails->getCountryId();
70
+ $data['customerEmail'] = $customerEmail;
71
+ $data['tags'] = $registerTags;
72
+
73
+ if (isset($orderData['customer_dob']) && !empty($orderData['customer_dob'])) {
74
+ $dataArray = date_parse($orderData['customer_dob']);
75
+ $month = ($dataArray['month'] < 10) ? "0" . $dataArray['month'] : $dataArray['month'];
76
+ $day = ($dataArray['day'] < 10) ? "0" . $dataArray['day'] : $dataArray['day'];
77
+ $year = $dataArray['year'];
78
+ $data['birthday'] = $year . $month . $day;
79
+ }
80
+
81
+
82
+ if (isset($customer['salesmanago_contact_id']) && !empty($customer['salesmanago_contact_id'])) {
83
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customerEmail);
84
+ $status = $subscriber->isSubscribed();
85
+ if ($status) $data['is_subscribed'] = true;
86
+ else $data['is_subscribed'] = false;
87
+ } else {
88
+ $data['is_subscribed'] = false; //after purchase
89
+ }
90
+
91
+
92
+ $r = $this->salesmanagoContactSync($data);
93
+ if ($r == false || (isset($r['success']) && $r['success'] == false)) {
94
+ $data['status'] = 0;
95
+ $data['action'] = 1; //rejestracja
96
+ }
97
+
98
+
99
+ if ($orderDetails->getCustomerIsGuest() && $r['success'] == true) {
100
+ $period = time() + 3650 * 86400;
101
+ $this->sm_create_cookie('smclient', $r['contactId'], $period);
102
+ }
103
+
104
+
105
+ $apiKey = md5(time() . $apiSecret);
106
+ $dateTime = new DateTime('NOW');
107
+
108
+ $data_to_json = array(
109
+ 'apiKey' => $apiKey,
110
+ 'clientId' => $clientId,
111
+ 'requestTime' => time(),
112
+ 'sha' => sha1($apiKey . $clientId . $apiSecret),
113
+ 'owner' => $ownerEmail,
114
+ 'email' => $customerEmail,
115
+ 'contactEvent' => array(
116
+ 'date' => $dateTime->format('c'),
117
+ 'products' => implode(',', $productsIdsList),
118
+ 'contactExtEventType' => 'PURCHASE',
119
+ 'value' => $grandTotal,
120
+ 'detail1' => implode(",", $productsNamesList),
121
+ 'externalId' => $incrementOrderId,
122
+ ),
123
+ );
124
+
125
+ $json = json_encode($data_to_json);
126
+ $result = $this->_doPostRequest('https://' . $endPoint . '/api/contact/addContactExtEvent', $json);
127
+ $r = json_decode($result, true);
128
+
129
+ return $r;
130
+ }
131
+ }
132
+
133
+ /*
134
+ * Upsert event execute when new user register, sign in and for new owner, which shopping without register
135
+ */
136
+ public function salesmanagoContactSync($data){
137
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
138
+ if($active == 1) {
139
+ $clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
140
+ $apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
141
+ $ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
142
+ $endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
143
+
144
+ $apiKey = md5(time() . $apiSecret);
145
+
146
+ $data_to_json = array(
147
+ 'apiKey' => $apiKey,
148
+ 'clientId' => $clientId,
149
+ 'requestTime' => time(),
150
+ 'sha' => sha1($apiKey . $clientId . $apiSecret),
151
+ 'contact' => array(
152
+ 'email' => $data['customerEmail'],
153
+ 'name' => $data['name'],
154
+ 'fax' => $data['fax'],
155
+ 'company' => $data['company'],
156
+ 'phone' => $data['telephone'],
157
+ 'address' => array(
158
+ 'streetAddress' => $data['street'],
159
+ 'zipCode' => $data['postcode'],
160
+ 'city' => $data['city'],
161
+ 'country' => $data['country'],
162
+ ),
163
+ ),
164
+ 'owner' => $ownerEmail,
165
+ 'async' => false,
166
+ 'tags' => $data['tags'],
167
+ );
168
+
169
+ if (!$data['is_subscribed']) {
170
+ $data_to_json['forceOptOut'] = true;
171
+ $data_to_json['forceOptIn'] = false;
172
+ } else {
173
+ $data_to_json['forceOptIn'] = true;
174
+ $data_to_json['forceOptOut'] = false;
175
+ }
176
+
177
+ if (isset($data['birthday'])) {
178
+ $data_to_json['birthday'] = $data['birthday'];
179
+ }
180
+
181
+ $json = json_encode($data_to_json);
182
+ $result = $this->_doPostRequest('https://' . $endPoint . '/api/contact/upsert', $json);
183
+
184
+ $r = json_decode($result, true);
185
+
186
+ return $r;
187
+ }
188
+ }
189
+
190
+ public function salesmanagoSubscriberSync(){
191
+
192
+ }
193
+
194
+ public function _setCustomerData($customer){
195
+ $data = array();
196
+ $subscription_status = 0;
197
+ foreach ($customer->getAddresses() as $address) {
198
+ $data = $address->toArray();
199
+ }
200
+
201
+ $data['customerEmail'] = $customer['email'];
202
+ $data['entity_id'] = $customer['entity_id'];
203
+
204
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer['email']);
205
+ $subscription_status = $subscriber->isSubscribed();
206
+
207
+ if(isset($customer['firstname']) && isset($customer['lastname']) && isset($customer['middlename'])){
208
+ $data['name'] = $customer['firstname'].' '.$data['middlename'].' '.$customer['lastname'];
209
+ } else {
210
+ $data['name'] = $customer['firstname'].' '.$customer['lastname'];
211
+ }
212
+
213
+ if(isset($customer['is_subscribed']) || $subscription_status == 1){
214
+ $data['is_subscribed'] = true;
215
+ }
216
+
217
+ if(isset($customer['dob'])){
218
+ $dataArray = date_parse($customer['dob']);
219
+ $month = ($dataArray['month'] < 10) ? "0".$dataArray['month'] : $dataArray['month'];
220
+ $day = ($dataArray['day'] < 10) ? "0".$dataArray['day'] : $dataArray['day'];
221
+ $year = $dataArray['year'];
222
+ $data['birthday'] = $year . $month . $day;
223
+ }
224
+
225
+ $data['country']=$data['country_id'].' '.$data['region'];
226
+
227
+ return $data;
228
+ }
229
+
230
+ public function _doPostRequest($url, $data) {
231
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
232
+ if($active == 1) {
233
+
234
+ $connection_timeout = Mage::getStoreConfig('salesmanago_tracking/general/connection_timeout');
235
+
236
+ $ch = curl_init($url);
237
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
238
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
239
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
240
+ if(isset($connection_timeout) && !empty($connection_timeout)){
241
+ curl_setopt($ch, CURLOPT_TIMEOUT_MS, $connection_timeout);
242
+ }
243
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data)));
244
+
245
+ $result = curl_exec($ch);
246
+
247
+ if(curl_errno($ch) > 0){
248
+ if(curl_errno($ch)==28){
249
+ Mage::log("TIMEOUT ERROR NO: " . curl_errno($ch));
250
+ } else{
251
+ Mage::log("ERROR NO: " . curl_errno($ch));
252
+ }
253
+ return false;
254
+ }
255
+
256
+ return $result;
257
+
258
+ }
259
+ else {
260
+
261
+ return false;
262
+
263
+ }
264
+ }
265
+ function sm_create_cookie($name, $value, $period){
266
+ $url = parse_url(Mage::getBaseUrl());
267
+ setcookie($name, $value, $period, '/', '.'.$this -> sm_get_domain($url['host']));
268
+
269
+ }
270
+ function sm_get_domain($domain, $debug = false){
271
+ $original = $domain = strtolower($domain);
272
+
273
+ if (filter_var($domain, FILTER_VALIDATE_IP)) { return $domain; }
274
+
275
+ $debug ? Mage::Log('<strong style="color:green">&raquo;</strong> Parsing: '.$original, null, 'get_domain.log') : false;
276
+
277
+ $arr = array_slice(array_filter(explode('.', $domain, 4), function($value){
278
+ return $value !== 'www';
279
+ }), 0); //rebuild array indexes
280
+
281
+ if (count($arr) > 2)
282
+ {
283
+ $count = count($arr);
284
+ $_sub = explode('.', $count === 4 ? $arr[3] : $arr[2]);
285
+
286
+ $debug ? Mage::Log(" (parts count: {$count})", null, 'get_domain.log') : false;
287
+
288
+ if (count($_sub) === 2) // two level TLD
289
+ {
290
+ $removed = array_shift($arr);
291
+ if ($count === 4) // got a subdomain acting as a domain
292
+ {
293
+ $removed = array_shift($arr);
294
+ }
295
+ $debug ? Mage::Log("<br>\n" . '[*] Two level TLD: <strong>' . join('.', $_sub) . '</strong> ', null, 'get_domain.log') : false;
296
+ }
297
+ elseif (count($_sub) === 1) // one level TLD
298
+ {
299
+ $removed = array_shift($arr); //remove the subdomain
300
+
301
+ if (strlen($_sub[0]) === 2 && $count === 3) // TLD domain must be 2 letters
302
+ {
303
+ array_unshift($arr, $removed);
304
+ }
305
+ else
306
+ {
307
+ // non country TLD according to IANA
308
+ $tlds = array(
309
+ 'aero',
310
+ 'arpa',
311
+ 'asia',
312
+ 'biz',
313
+ 'cat',
314
+ 'com',
315
+ 'coop',
316
+ 'edu',
317
+ 'gov',
318
+ 'info',
319
+ 'jobs',
320
+ 'mil',
321
+ 'mobi',
322
+ 'museum',
323
+ 'name',
324
+ 'net',
325
+ 'org',
326
+ 'post',
327
+ 'pro',
328
+ 'tel',
329
+ 'travel',
330
+ 'xxx',
331
+ );
332
+
333
+ if (count($arr) > 2 && in_array($_sub[0], $tlds) !== false) //special TLD don't have a country
334
+ {
335
+ array_shift($arr);
336
+ }
337
+ }
338
+ $debug ? Mage::Log("<br>\n" .'[*] One level TLD: <strong>'.join('.', $_sub).'</strong> ', null, 'get_domain.log') : false;
339
+ }
340
+ else // more than 3 levels, something is wrong
341
+ {
342
+ for ($i = count($_sub); $i > 1; $i--)
343
+ {
344
+ $removed = array_shift($arr);
345
+ }
346
+ $debug ? Mage::Log("<br>\n" . '[*] Three level TLD: <strong>' . join('.', $_sub) . '</strong> ', null, 'get_domain.log') : false;
347
+ }
348
+ }
349
+ elseif (count($arr) === 2)
350
+ {
351
+ $arr0 = array_shift($arr);
352
+
353
+ if (strpos(join('.', $arr), '.') === false
354
+ && in_array($arr[0], array('localhost','test','invalid')) === false) // not a reserved domain
355
+ {
356
+ $debug ? Mage::Log("<br>\n" .'Seems invalid domain: <strong>'.join('.', $arr).'</strong> re-adding: <strong>'.$arr0.'</strong> ', null, 'get_domain.log') : false;
357
+ // seems invalid domain, restore it
358
+ array_unshift($arr, $arr0);
359
+ }
360
+ }
361
+
362
+ $debug ? Mage::Log("<br>\n".'<strong style="color:gray">&laquo;</strong> Done parsing: <span style="color:red">' . $original . '</span> as <span style="color:blue">'. join('.', $arr) ."</span><br>\n", null, 'get_domain.log') : false;
363
+
364
+ return join('.', $arr);
365
+ }
366
+ }
app/code/community/SalesManago/Tracking/Model/Customersync.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class SalesManago_Tracking_Model_Customersync extends Mage_Core_Model_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('tracking/customersync');
8
+ }
9
+ }
app/code/community/SalesManago/Tracking/Model/Observer.php ADDED
@@ -0,0 +1,456 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class SalesManago_Tracking_Model_Observer
4
+ {
5
+
6
+ protected function _getHelper()
7
+ {
8
+ return Mage::helper('tracking');
9
+ }
10
+
11
+ public function customer_login($observer)
12
+ {
13
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
14
+ if ($active == 1) {
15
+ $customer = $observer->getCustomer();
16
+
17
+ if (!empty($customer)) {
18
+ if (!isset($customer['salesmanago_contact_id']) || empty($customer['salesmanago_contact_id'])) {
19
+ $data = $this->_getHelper()->_setCustomerData($customer);
20
+
21
+ $r = $this->_getHelper()->salesmanagoContactSync($data);
22
+
23
+ if ($r == false || (isset($r['success']) && $r['success'] == false)) {
24
+ $data['status'] = 0;
25
+ $data['action'] = 2; //logowanie
26
+ $this->_getHelper()->setSalesmanagoCustomerSyncStatus($data);
27
+ }
28
+
29
+ if (isset($r['contactId']) && !empty($r['contactId'])) {
30
+ try {
31
+ $observer->getCustomer()->setData('salesmanago_contact_id', $r['contactId'])->save();
32
+ } catch (Exception $e) {
33
+ Mage::log($e->getMessage());
34
+ }
35
+ }
36
+ }
37
+ }
38
+ }
39
+ if (!isset($_COOKIE['smclient']) || empty($_COOKIE['smclient'])) {
40
+ $period = time() + 36500 * 86400;
41
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
42
+ $contactId = $customerData->getSalesmanagoContactId();
43
+ $this->_getHelper()->sm_create_cookie('smclient', $contactId, $period);
44
+ }
45
+ }
46
+
47
+ public function customer_register_success($observer)
48
+ {
49
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
50
+ if ($active == 1) {
51
+ $customer = $observer->getCustomer();
52
+
53
+ if (!empty($customer) && is_array($customer->getData())) {
54
+ $data = $this->_getHelper()->_setCustomerData($customer);
55
+ $data['tags'] = explode(",", Mage::getStoreConfig('salesmanago_tracking/general/tagsRegistration'));
56
+
57
+ $r = $this->_getHelper()->salesmanagoContactSync($data);
58
+
59
+ if ($r == false || (isset($r['success']) && $r['success'] == false)) {
60
+ $data['status'] = 0;
61
+ $data['action'] = 1; //rejestracja
62
+ $this->_getHelper()->setSalesmanagoCustomerSyncStatus($data);
63
+ }
64
+
65
+ if (isset($r['contactId']) && !empty($r['contactId'])) {
66
+ try {
67
+ $observer->getCustomer()->setData('salesmanago_contact_id', $r['contactId'])->save();
68
+ } catch (Exception $e) {
69
+ Mage::log($e->getMessage());
70
+ }
71
+ }
72
+ }
73
+ }
74
+ if (!isset($_COOKIE['smclient']) || empty($_COOKIE['smclient'])) {
75
+ $period = time() + 36500 * 86400;
76
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
77
+ $contactId = $customerData->getSalesmanagoContactId();
78
+ $this->_getHelper()->sm_create_cookie('smclient', $contactId, $period);
79
+ }
80
+
81
+ }
82
+
83
+ /*
84
+ * Dodanie zdarzenia addContactExtEvent na podsumowaniu zam�wienia z typem PURCHASE
85
+ */
86
+ public function checkout_onepage_controller_success_action($observer)
87
+ {
88
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
89
+ if ($active == 1) {
90
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
91
+ $orderDetails = Mage::getModel('sales/order')->load($orderId);
92
+
93
+ $r = $this->_getHelper()->salesmanagoOrderSync($orderDetails);
94
+
95
+ if ($r == false || (isset($r['success']) && $r['success'] == false)) {
96
+ $data = array(
97
+ 'customerEmail' => $orderDetails->getCustomerEmail(),
98
+ 'entity_id' => $orderDetails->getCustomerId(),
99
+ 'order_id' => $orderDetails->getEntityId(),
100
+ 'status' => 0,
101
+ 'action' => 3, //zlozenie zamowienia: addContactExtEvent - PURCHASE
102
+ );
103
+ $this->_getHelper()->setSalesmanagoCustomerSyncStatus($data);
104
+ }
105
+
106
+ $eventId = Mage::getSingleton('core/session')->getEventId();
107
+ if (isset($eventId) && !empty($eventId)) {
108
+ Mage::getSingleton('core/session')->unsEventId();
109
+ }
110
+ }
111
+ }
112
+
113
+ /*
114
+ * Dodanie (oraz na biezaco modyfikowanie) zdarzenia w koszyku addContactExtEvent z typem CART
115
+ */
116
+ public function checkout_cart_save_after($observer)
117
+ {
118
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
119
+ if ($active == 1) {
120
+ $cartHelper = Mage::getModel('checkout/cart')->getQuote();
121
+ $productsIdsList = array();
122
+ $productsNamesList = array();
123
+
124
+ $items = $cartHelper->getAllItems();
125
+ foreach ($items as $item) {
126
+ array_push($productsIdsList, $item->getProduct()->getId());
127
+ array_push($productsNamesList, $item->getProduct()->getName());
128
+
129
+ }
130
+
131
+
132
+ $clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
133
+ $apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
134
+ $ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
135
+ $endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
136
+
137
+ $customerEmail = Mage::getSingleton('customer/session')->getCustomer()->getEmail();
138
+ $isLoggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
139
+ //if (!empty($customerEmail)) {
140
+ $apiKey = md5(time() . $apiSecret);
141
+ $dateTime = new DateTime('NOW');
142
+
143
+
144
+ $data_to_json = array(
145
+ 'apiKey' => $apiKey,
146
+ 'clientId' => $clientId,
147
+ 'requestTime' => time(),
148
+ 'sha' => sha1($apiKey . $clientId . $apiSecret),
149
+ 'owner' => $ownerEmail,
150
+ 'contactEvent' => array(
151
+ 'date' => $dateTime->format('c'),
152
+ 'contactExtEventType' => 'CART',
153
+ 'products' => implode(',', $productsIdsList),
154
+ 'value' => $cartHelper->getGrandTotal(),
155
+ 'detail1' => implode(",", $productsNamesList),
156
+ ),
157
+ );
158
+
159
+ $eventId = Mage::getSingleton('core/session')->getEventId();
160
+
161
+ if (isset($eventId) && !empty($eventId)) {
162
+ $data_to_json['contactEvent']['eventId'] = $eventId;
163
+ $json = json_encode($data_to_json);
164
+ $result = $this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/updateContactExtEvent', $json);
165
+ } else {
166
+ if ($isLoggedIn) {
167
+ $data_to_json['email'] = $customerEmail;
168
+ } else {
169
+ if (!empty($_COOKIE['smclient']))
170
+ $data_to_json['contactId'] = $_COOKIE['smclient'];
171
+ }
172
+
173
+ Mage::log(serialize($data_to_json), null, 'mylogfile.log');
174
+
175
+ $json = json_encode($data_to_json);
176
+ $result = $this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/addContactExtEvent', $json);
177
+ }
178
+
179
+ $r = json_decode($result, true);
180
+
181
+ if (!isset($eventId) && isset($r['eventId'])) {
182
+ Mage::getSingleton('core/session')->setEventId($r['eventId']);
183
+ }
184
+ //}
185
+ }
186
+ }
187
+
188
+ public function newsletter_subscriber_save_before($observer)
189
+ {
190
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
191
+ if ($active == 1) {
192
+ $request = Mage::app()->getRequest();
193
+ $moduleName = $request->getModuleName();
194
+ $controllerName = $request->getControllerName();
195
+ $actionName = $request->getActionName();
196
+
197
+ if (($moduleName == 'newsletter' && $controllerName == 'manage' && $actionName == 'save') ||
198
+ ($moduleName == 'newsletter' && $controllerName == 'subscribe' && $actionName == 'unsubscribe') ||
199
+ ($moduleName == 'newsletter' && $controllerName == 'subscriber' && $actionName == 'new') ||
200
+ ($moduleName == 'newsletter' && $controllerName == 'subscriber' && $actionName == 'unsubscribe') ||
201
+ ($moduleName == 'admin' && $controllerName == 'newsletter_subscriber' && $actionName == 'massUnsubscribe')
202
+ ) {
203
+
204
+ $isAdmin = false;
205
+ if ($moduleName == 'admin') $isAdmin = true;
206
+
207
+ $clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
208
+ $apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
209
+ $ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
210
+ $newsletterTags = Mage::getStoreConfig('salesmanago_tracking/general/tagsNewsletter');
211
+ $endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
212
+
213
+
214
+ $subscriber = $observer->getEvent()->getDataObject();
215
+ $data = $subscriber->getData();
216
+ $email = $data['subscriber_email'];
217
+ $statusChange = $subscriber->getIsStatusChanged();
218
+
219
+ $id = (int)Mage::app()->getFrontController()->getRequest()->getParam('id');
220
+ $code = (string)Mage::app()->getFrontController()->getRequest()->getParam('code');
221
+
222
+ $apiKey = md5(time() . $apiSecret);
223
+
224
+ $data_to_json = array(
225
+ 'apiKey' => $apiKey,
226
+ 'clientId' => $clientId,
227
+ 'requestTime' => time(),
228
+ 'contact' => array(
229
+ 'email' => $email,
230
+ 'state' => 'CUSTOMER',
231
+ ),
232
+ 'sha' => sha1($apiKey . $clientId . $apiSecret),
233
+ 'owner' => $ownerEmail,
234
+ );
235
+
236
+ if (!empty($newsletterTags)) {
237
+ $newsletterTags = explode(",", $newsletterTags);
238
+ if (is_array($newsletterTags) && count($newsletterTags) > 0) {
239
+ $newsletterTags = array_map('trim', $newsletterTags);
240
+
241
+ }
242
+ }
243
+
244
+ if ($data['subscriber_status'] == "1" && ($statusChange == true || ($id && $code) || $isAdmin)) {
245
+ $data_to_json['forceOptIn'] = true;
246
+ $data_to_json['tags'] = $newsletterTags;
247
+ } elseif ($data['subscriber_status'] == "3" && ($statusChange == true || ($id && $code) || $isAdmin)) {
248
+ $data_to_json['forceOptOut'] = true;
249
+ $data_to_json['removeTags'] = $newsletterTags;
250
+ } elseif ($actionName == 'massDelete') {
251
+ $data_to_json['forceOptOut'] = true;
252
+ $data_to_json['removeTags'] = $newsletterTags;
253
+ }
254
+
255
+ $json = json_encode($data_to_json);
256
+ $result = $this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/upsert', $json);
257
+
258
+ $r = json_decode($result, true);
259
+
260
+ if ($r == false || (isset($r['success']) && $r['success'] == false)) {
261
+ $data['customerEmail'] = $email;
262
+ $data['status'] = 0;
263
+ $data['action'] = 4; //zapis / wypis z newslettera
264
+ $this->_getHelper()->setSalesmanagoCustomerSyncStatus($data);
265
+ }
266
+
267
+ if ($moduleName == 'newsletter' && $controllerName == 'subscriber' && $actionName == 'new') {
268
+ $period = time() + 3650 * 86400;
269
+ $this->_getHelper()->sm_create_cookie('smclient', $r['contactId'], $period);
270
+ }
271
+
272
+ return $r;
273
+ }
274
+ }
275
+ }
276
+
277
+ public function newsletter_subscriber_delete_after($observer)
278
+ {
279
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
280
+ if ($active == 1) {
281
+ $request = Mage::app()->getRequest();
282
+ $moduleName = $request->getModuleName();
283
+ $controllerName = $request->getControllerName();
284
+ $actionName = $request->getActionName();
285
+
286
+ if (($moduleName == 'admin' && $controllerName == 'newsletter_subscriber' && $actionName == 'massDelete')) {
287
+
288
+ $clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
289
+ $apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
290
+ $ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
291
+ $tags = Mage::getStoreConfig('salesmanago_tracking/general/tags');
292
+ $endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
293
+
294
+ $subscriber = $observer->getEvent()->getDataObject();
295
+ $data = $subscriber->getData();
296
+ $email = $data['subscriber_email'];
297
+ $statusChange = $subscriber->getIsStatusChanged();
298
+
299
+ $apiKey = md5(time() . $apiSecret);
300
+
301
+ $data_to_json = array(
302
+ 'apiKey' => $apiKey,
303
+ 'clientId' => $clientId,
304
+ 'requestTime' => time(),
305
+ 'contact' => array(
306
+ 'email' => $email,
307
+ 'state' => 'CUSTOMER',
308
+ ),
309
+ 'sha' => sha1($apiKey . $clientId . $apiSecret),
310
+ 'owner' => $ownerEmail,
311
+ 'forceOptOut' => true,
312
+ );
313
+
314
+ $json = json_encode($data_to_json);
315
+ $result = $this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/upsert', $json);
316
+
317
+ $r = json_decode($result, true);
318
+
319
+ return $r;
320
+ }
321
+ }
322
+ }
323
+
324
+ public function customer_data_edit($observer)
325
+ {
326
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
327
+ if ($active == 1) {
328
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
329
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
330
+
331
+ if (isset($customer['salesmanago_contact_id']) && !empty($customer['salesmanago_contact_id'])) {
332
+
333
+ $clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
334
+ $apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
335
+ $ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
336
+ $endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
337
+ $apiKey = md5(time() . $apiSecret);
338
+ $contactId = $customer->getSalesmanagoContactId();
339
+
340
+ foreach ($customer->getAddresses() as $address) {
341
+ $data = $address->toArray();
342
+ }
343
+
344
+ $street = $address->getStreet(1) . ' ' . $address->getStreet(2);
345
+
346
+ if (isset($data['firstname']) && isset($data['lastname']) && isset($data['middlename'])) {
347
+ $data['name'] = $data['firstname'] . ' ' . $data['middlename'] . ' ' . $data['lastname'];
348
+ } else {
349
+ $data['name'] = $data['firstname'] . ' ' . $data['lastname'];
350
+ }
351
+
352
+ $data_to_json = array(
353
+ 'apiKey' => $apiKey,
354
+ 'clientId' => $clientId,
355
+ 'requestTime' => time(),
356
+ 'sha' => sha1($apiKey . $clientId . $apiSecret),
357
+ 'contactId' => $contactId,
358
+ 'contact' => array(
359
+ 'name' => $data['name'],
360
+ 'fax' => $data['fax'],
361
+ 'company' => $data['company'],
362
+ 'phone' => $data['telephone'],
363
+ 'address' => array(
364
+ 'streetAddress' => $street,
365
+ 'zipCode' => $data['postcode'],
366
+ 'city' => $data['city'],
367
+ 'country' => $data['country_id'],
368
+ ),
369
+ ),
370
+ 'owner' => $ownerEmail,
371
+ 'async' => false,
372
+ );
373
+
374
+ $json = json_encode($data_to_json);
375
+ $this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/update', $json);
376
+ }
377
+ }
378
+ }
379
+ }
380
+
381
+ public function adminSystemConfigChangedSectionSalesmanago_tracking($observer)
382
+ {
383
+ $clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
384
+ $apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
385
+ $ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
386
+ $endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
387
+ $apiKey = md5(time() . $apiSecret);
388
+ $version = Mage::getVersion();
389
+
390
+ $data_to_json = array(
391
+ 'apiKey' => $apiKey,
392
+ 'clientId' => $clientId,
393
+ 'requestTime' => time(),
394
+ 'sha' => sha1($apiKey . $clientId . $apiSecret),
395
+ 'owner' => $ownerEmail,
396
+ 'tags' => ["MAGENTO_1"],
397
+ 'properties' => array("platform"=>"Magento", "version"=>$version),
398
+ );
399
+
400
+ $json = json_encode($data_to_json);
401
+ $this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/upsertVendorToSupport', $json);
402
+ }
403
+
404
+ public function wishlist_event($observer)
405
+ {
406
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
407
+ if ($active == 1) {
408
+ $isLoggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
409
+ if ($isLoggedIn) {
410
+ $clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
411
+ $apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
412
+ $ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
413
+ $endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
414
+ $apiKey = md5(time() . $apiSecret);
415
+ $dateTime = new DateTime('NOW');
416
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
417
+ $product = $observer->getEvent()->getItems()[0]->getProduct();
418
+ $productId = $product->getId();
419
+ $productName = $product->getName();
420
+ $productValue = round($product->getPrice(), 2);
421
+
422
+
423
+ $data_to_json = array(
424
+ 'apiKey' => $apiKey,
425
+ 'clientId' => $clientId,
426
+ 'requestTime' => time(),
427
+ 'sha' => sha1($apiKey . $clientId . $apiSecret),
428
+ 'owner' => $ownerEmail,
429
+ 'contactEvent' => array(
430
+ 'date' => $dateTime->format('c'),
431
+ 'contactExtEventType' => 'OTHER',
432
+ 'products' => $productId,
433
+ 'value' => $productValue,
434
+ 'detail1' => $productName,
435
+ 'description' => 'WISHLIST',
436
+ ),
437
+ );
438
+
439
+
440
+ if ($isLoggedIn) {
441
+ $data_to_json['email'] = $customer->getEmail();
442
+ $json = json_encode($data_to_json);
443
+ } else {
444
+ if (!isset($_COOKIE['smclient']) || empty($_COOKIE['smclient'])){
445
+ $data_to_json['contactId'] = $_COOKIE['smclient'];
446
+ $json = json_encode($data_to_json);
447
+ }
448
+ }
449
+
450
+ if(!empty($json))
451
+ $this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/upsertVendorToSupport', $json);
452
+ }
453
+ }
454
+ }
455
+ }
456
+
app/code/community/SalesManago/Tracking/Model/Resource/Customersync.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ class SalesManago_Tracking_Model_Resource_Customersync extends Mage_Core_Model_Resource_Db_Abstract {
3
+
4
+ protected function _construct() {
5
+ $this->_init('tracking/customersync', 'customer_sync_id');
6
+ }
7
+ }
app/code/community/SalesManago/Tracking/Model/Resource/Customersync/Collection.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class SalesManago_Tracking_Model_Resource_Customersync_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('tracking/customersync');
7
+ }
8
+ }
app/code/community/SalesManago/Tracking/Model/Resource/Setup.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class SalesManago_Tracking_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
4
+ {
5
+ }
app/code/community/SalesManago/Tracking/controllers/CustomerController.php ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class SalesManago_Tracking_CustomerController extends Mage_Core_Controller_Front_Action{
3
+
4
+ protected function _getHelper(){
5
+ return Mage::helper('tracking');
6
+ }
7
+
8
+ public function exportAction(){
9
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
10
+ if($active == 1) {
11
+ $clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
12
+ $apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
13
+ $ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
14
+ $tags = Mage::getStoreConfig('salesmanago_tracking/general/tags');
15
+ $endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
16
+
17
+ $key = $this->getRequest()->getParam('key');
18
+
19
+ if (isset($key) && isset($apiSecret) && $key == sha1($apiSecret)) {
20
+
21
+ $apiKey = md5(time() . $apiSecret);
22
+
23
+ $data_to_json = array(
24
+ 'apiKey' => $apiKey,
25
+ 'clientId' => $clientId,
26
+ 'requestTime' => time(),
27
+ 'sha' => sha1($apiKey . $clientId . $apiSecret),
28
+
29
+ 'upsertDetails' => array(),
30
+ 'owner' => $ownerEmail,
31
+ );
32
+
33
+ $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
34
+
35
+ $i = 0;
36
+ foreach ($collection as $item) {
37
+ if (!isset($item['salesmanago_contact_id']) || empty($item['salesmanago_contact_id']) || $item['salesmanago_contact_id'] == 0) {
38
+ $status = Mage::getModel('newsletter/subscriber')->loadByEmail($item['email'])->isSubscribed();
39
+
40
+ if ($status) {
41
+ $data_to_json['upsertDetails'][$i]['forceOptIn'] = true;
42
+ } else {
43
+ $data_to_json['upsertDetails'][$i]['forceOptOut'] = true;
44
+ }
45
+ $data_to_json['upsertDetails'][$i]['contact']['email'] = $item['email'];
46
+ $data_to_json['upsertDetails'][$i]['contact']['name'] = $item['firstname'] . ' ' . $item['lastname'];
47
+
48
+ $i++;
49
+ }
50
+ }
51
+
52
+ $json = json_encode($data_to_json);
53
+ $result = $this->_do_post_request('https://' . $endPoint . '/api/contact/batchupsert', $json);
54
+
55
+ $r = json_decode($result, true);
56
+
57
+ $return = array();
58
+ if (isset($r['success']) && $r['success'] == true && isset($r['contactIds']) && is_array($r['contactIds'])) {
59
+ foreach ($r['contactIds'] as $key => $value) {
60
+ $customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($key);
61
+ try {
62
+ $return[$key]['msg'] = 'Successfully added';
63
+ $customer->setData('salesmanago_contact_id', $value)->save();
64
+ } catch (Exception $e) {
65
+ $return[$key]['msg'] = 'Upsert error';
66
+ Mage::log($e->getMessage());
67
+ }
68
+ }
69
+ } else {
70
+ $return['msg'] = 'BatchUpsert error';
71
+ }
72
+ return $return;
73
+ }
74
+ }
75
+ }
76
+
77
+ public function syncAction(){
78
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
79
+ if($active == 1) {
80
+ $key = $this->getRequest()->getParam('key');
81
+ $action = $this->getRequest()->getParam('action');
82
+
83
+ $clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
84
+ $apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
85
+ $ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
86
+ $tags = Mage::getStoreConfig('salesmanago_tracking/general/tags');
87
+ $endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
88
+
89
+ if (isset($key) && isset($apiSecret) && $key == sha1($apiSecret)) {
90
+ $model = Mage::getModel('tracking/customersync');
91
+ $collection = $model->getCollection()->addFieldToFilter('status', 0);
92
+ $dateTime = new DateTime('NOW');
93
+
94
+ foreach ($collection as $item) {
95
+ if (!isset($action) || !ctype_digit($action)) {
96
+ $action = $item->getAction();
97
+ }
98
+ $counter = $item->getCounter();
99
+
100
+ if ($counter < 5) {
101
+ switch ($action) {
102
+ case 1: //register
103
+ $customer = Mage::getModel('customer/customer')->load($item->getCustomerId())->getData();
104
+ $data = $this->_getHelper()->_setCustomerData($customer);
105
+
106
+ $r = $this->_getHelper()->salesmanagoContactSync($data);
107
+
108
+ if ($r == false || (isset($r['success']) && $r['success'] == false)) {
109
+ try {
110
+ $model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setId($item->getCustomerSyncId())->save();
111
+ } catch (Exception $e) {
112
+ Mage::log($e->getMessage());
113
+ }
114
+ } elseif (isset($r['success']) && $r['success'] == true) {
115
+ try {
116
+ $model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setStatus(1)->setId($item->getCustomerSyncId())->save();
117
+ } catch (Exception $e) {
118
+ Mage::log($e->getMessage());
119
+ }
120
+ }
121
+
122
+ break;
123
+ case 2: //login
124
+ $customer = Mage::getModel('customer/customer')->load($item->getCustomerId())->getData();
125
+
126
+ if (!isset($customer['salesmanago_contact_id']) || empty($customer['salesmanago_contact_id'])) {
127
+ $data = $this->_getHelper()->_setCustomerData($customer);
128
+
129
+ $r = $this->_getHelper()->salesmanagoContactSync($data);
130
+
131
+ if ($r == false || (isset($r['success']) && $r['success'] == false)) {
132
+ try {
133
+ $model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setId($item->getCustomerSyncId())->save();
134
+ } catch (Exception $e) {
135
+ Mage::log($e->getMessage());
136
+ }
137
+ } elseif (isset($r['success']) && $r['success'] == true) {
138
+ try {
139
+ $model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setStatus(1)->setId($item->getCustomerSyncId())->save();
140
+ } catch (Exception $e) {
141
+ Mage::log($e->getMessage());
142
+ }
143
+ }
144
+ }
145
+ break;
146
+ case 3: //order purchase
147
+ $orderId = $item->getOrderId();
148
+ $orderDetails = Mage::getModel('sales/order')->load($orderId);
149
+
150
+ $r = $this->_getHelper()->salesmanagoOrderSync($orderDetails);
151
+
152
+ if ($r == false || (isset($r['success']) && $r['success'] == false)) {
153
+ try {
154
+ $model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setId($item->getCustomerSyncId())->save();
155
+ } catch (Exception $e) {
156
+ Mage::log($e->getMessage());
157
+ }
158
+ } elseif (isset($r['success']) && $r['success'] == true) {
159
+ try {
160
+ $model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setStatus(1)->setId($item->getCustomerSyncId())->save();
161
+ } catch (Exception $e) {
162
+ Mage::log($e->getMessage());
163
+ }
164
+ }
165
+ break;
166
+ case 4: //newsletter subscribe / unsubscribe
167
+ $status = Mage::getModel('newsletter/subscriber')->loadByEmail($item->getEmail())->isSubscribed();
168
+
169
+ $apiKey = md5(time() . $apiSecret);
170
+
171
+ $data_to_json = array(
172
+ 'apiKey' => $apiKey,
173
+ 'clientId' => $clientId,
174
+ 'requestTime' => time(),
175
+ 'email' => $item->getEmail(),
176
+ 'sha' => sha1($apiKey . $clientId . $apiSecret),
177
+ 'owner' => $ownerEmail,
178
+ );
179
+
180
+ if ($status) {
181
+ $data_to_json['forceOptIn'] = true;
182
+ } else {
183
+ $data_to_json['forceOptOut'] = true;
184
+ }
185
+
186
+ $json = json_encode($data_to_json);
187
+ $result = $this->_do_post_request('https://' . $endPoint . '/api/contact/update', $json);
188
+
189
+ $r = json_decode($result, true);
190
+
191
+ if ($r == false || (isset($r['success']) && $r['success'] == false)) {
192
+ try {
193
+ $model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setId($item->getCustomerSyncId())->save();
194
+ } catch (Exception $e) {
195
+ Mage::log($e->getMessage());
196
+ }
197
+ } elseif (isset($r['success']) && $r['success'] == true) {
198
+ try {
199
+ $model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setStatus(1)->setId($item->getCustomerSyncId())->save();
200
+ } catch (Exception $e) {
201
+ Mage::log($e->getMessage());
202
+ }
203
+ }
204
+ break;
205
+ default:
206
+ break;
207
+ }
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
213
+
214
+ private function _do_post_request($url, $data) {
215
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
216
+ if($active == 1) {
217
+ $connection_timeout = Mage::getStoreConfig('salesmanago_tracking/general/connection_timeout');
218
+
219
+ $ch = curl_init($url);
220
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
221
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
222
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
223
+ if (isset($connection_timeout) && !empty($connection_timeout)) {
224
+ curl_setopt($ch, CURLOPT_TIMEOUT_MS, $connection_timeout);
225
+ }
226
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data)));
227
+
228
+ $result = curl_exec($ch);
229
+
230
+ if (curl_errno($ch) > 0) {
231
+ if (curl_errno($ch) == 28) {
232
+ Mage::log("TIMEOUT ERROR NO: " . curl_errno($ch));
233
+ } else {
234
+ Mage::log("ERROR NO: " . curl_errno($ch));
235
+ }
236
+ return false;
237
+ }
238
+
239
+ return $result;
240
+ }
241
+ }
242
+ }
app/code/community/SalesManago/Tracking/controllers/Newsletter/SubscriberController.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once "Mage/Newsletter/controllers/SubscriberController.php";
3
+
4
+ class SalesManago_Tracking_Newsletter_SubscriberController extends Mage_Newsletter_SubscriberController{
5
+
6
+
7
+ public function sm_newsletter_unsubscribeAction(){
8
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
9
+ if($active == 1) {
10
+ $email = $this->getRequest()->getParam('email');
11
+ $key = $this->getRequest()->getParam('key');
12
+ $result = array();
13
+
14
+ $apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
15
+ $sha1 = sha1($email . $apiSecret);
16
+
17
+ if (isset($email) && isset($key) && isset($sha1) && filter_var($email, FILTER_VALIDATE_EMAIL) && $key == $sha1) {
18
+ try {
19
+ $status = Mage::getModel('newsletter/subscriber')->loadByEmail($email)->isSubscribed();
20
+
21
+ if ($status) {
22
+ Mage::getModel('newsletter/subscriber')->loadByEmail($email)->unsubscribe();
23
+ $result['success'] = true;
24
+ $result['message'] = 'Email succesfully unsubscribed';
25
+
26
+ } else {
27
+ $result['success'] = false;
28
+ $result['message'] = 'Email already unsubscribed';
29
+ }
30
+ } catch (Mage_Core_Exception $e) {
31
+ $result['success'] = false;
32
+ $result['message'] = 'General error';
33
+ } catch (Exception $e) {
34
+ $result['success'] = false;
35
+ $result['message'] = 'General error';
36
+ }
37
+ } else {
38
+ $result['success'] = false;
39
+ $result['message'] = 'Validation failed';
40
+ }
41
+
42
+ $json = json_encode($result);
43
+ return $json;
44
+ }
45
+ }
46
+ public function sm_newsletter_subscribeAction(){
47
+ $active = Mage::getStoreConfig('salesmanago_tracking/general/active');
48
+ if($active == 1) {
49
+ $email = $this->getRequest()->getParam('email');
50
+ $key = $this->getRequest()->getParam('key');
51
+ $result = array();
52
+
53
+ $apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
54
+ $sha1 = sha1($email . $apiSecret);
55
+
56
+ if (isset($email) && isset($key) && isset($sha1) && filter_var($email, FILTER_VALIDATE_EMAIL) && $key == $sha1) {
57
+ try {
58
+ $status = Mage::getModel('newsletter/subscriber')->loadByEmail($email)->isSubscribed();
59
+
60
+ if (!$status) {
61
+ Mage::getModel('newsletter/subscriber')->subscribe($email);
62
+ $result['success'] = true;
63
+ $result['message'] = 'Email succesfully subscribed';
64
+
65
+ } else {
66
+ $result['success'] = false;
67
+ $result['message'] = 'Email already subscribed';
68
+ }
69
+ } catch (Mage_Core_Exception $e) {
70
+ $result['success'] = false;
71
+ $result['message'] = 'General error';
72
+ } catch (Exception $e) {
73
+ $result['success'] = false;
74
+ $result['message'] = 'General error';
75
+ }
76
+ } else {
77
+ $result['success'] = false;
78
+ $result['message'] = 'Validation failed';
79
+ }
80
+
81
+ $json = json_encode($result);
82
+ return $json;
83
+ }
84
+ }
85
+ }
app/code/community/SalesManago/Tracking/etc/config.xml ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <SalesManago_Tracking>
5
+ <version>1.5.1</version>
6
+ </SalesManago_Tracking>
7
+ </modules>
8
+
9
+ <global>
10
+ <models>
11
+ <tracking>
12
+ <class>SalesManago_Tracking_Model</class>
13
+ <resourceModel>tracking_resource</resourceModel>
14
+ </tracking>
15
+ <tracking_resource>
16
+ <class>SalesManago_Tracking_Model_Resource</class>
17
+ <entities>
18
+ <customersync>
19
+ <table>salesmanago_customer_sync</table>
20
+ </customersync>
21
+ </entities>
22
+ </tracking_resource>
23
+ </models>
24
+
25
+ <events>
26
+ <customer_login>
27
+ <observers>
28
+ <salesmanago_tracking_observer>
29
+ <type>singleton</type>
30
+ <class>SalesManago_Tracking_Model_Observer</class>
31
+ <method>customer_login</method>
32
+ </salesmanago_tracking_observer>
33
+ </observers>
34
+ </customer_login>
35
+ <customer_register_success>
36
+ <observers>
37
+ <salesmanago_tracking_observer>
38
+ <type>singleton</type>
39
+ <class>SalesManago_Tracking_Model_Observer</class>
40
+ <method>customer_register_success</method>
41
+ </salesmanago_tracking_observer>
42
+ </observers>
43
+ </customer_register_success>
44
+
45
+ <newsletter_subscriber_save_before>
46
+ <observers>
47
+ <salesmanago_tracking_observer>
48
+ <type>singleton</type>
49
+ <class>SalesManago_Tracking_Model_Observer</class>
50
+ <method>newsletter_subscriber_save_before</method>
51
+ </salesmanago_tracking_observer>
52
+ </observers>
53
+ </newsletter_subscriber_save_before>
54
+
55
+ <newsletter_subscriber_delete_after>
56
+ <observers>
57
+ <salesmanago_tracking_observer>
58
+ <type>singleton</type>
59
+ <class>SalesManago_Tracking_Model_Observer</class>
60
+ <method>newsletter_subscriber_delete_after</method>
61
+ </salesmanago_tracking_observer>
62
+ </observers>
63
+ </newsletter_subscriber_delete_after>
64
+
65
+ <checkout_onepage_controller_success_action>
66
+ <observers>
67
+ <salesmanago_tracking_observer>
68
+ <type>singleton</type>
69
+ <class>SalesManago_Tracking_Model_Observer</class>
70
+ <method>checkout_onepage_controller_success_action</method>
71
+ </salesmanago_tracking_observer>
72
+ </observers>
73
+ </checkout_onepage_controller_success_action>
74
+
75
+ <checkout_cart_save_after>
76
+ <observers>
77
+ <salesmanago_tracking_observer>
78
+ <type>singleton</type>
79
+ <class>SalesManago_Tracking_Model_Observer</class>
80
+ <method>checkout_cart_save_after</method>
81
+ </salesmanago_tracking_observer>
82
+ </observers>
83
+ </checkout_cart_save_after>
84
+
85
+ <customer_address_save_commit_after>
86
+ <observers>
87
+ <salesmanago_tracking_observer>
88
+ <type>singleton</type>
89
+ <class>SalesManago_Tracking_Model_Observer</class>
90
+ <method>customer_data_edit</method>
91
+ </salesmanago_tracking_observer>
92
+ </observers>
93
+ </customer_address_save_commit_after>
94
+ <admin_system_config_changed_section_salesmanago_tracking>
95
+ <observers>
96
+ <salesmanago_tracking_observer>
97
+ <type>singleton</type>
98
+ <class>SalesManago_Tracking_Model_Observer</class>
99
+ <method>adminSystemConfigChangedSectionSalesmanago_tracking</method>
100
+ </salesmanago_tracking_observer>
101
+ </observers>
102
+ </admin_system_config_changed_section_salesmanago_tracking>
103
+
104
+ <wishlist_product_add_after>
105
+ <observers>
106
+ <salesmanago_tracking_observer>
107
+ <type>singleton</type>
108
+ <class>SalesManago_Tracking_Model_Observer</class>
109
+ <method>wishlist_event</method>
110
+ </salesmanago_tracking_observer>
111
+ </observers>
112
+ </wishlist_product_add_after>
113
+ </events>
114
+
115
+ <helpers>
116
+ <tracking>
117
+ <class>SalesManago_Tracking_Helper</class>
118
+ </tracking>
119
+ </helpers>
120
+
121
+ <blocks>
122
+ <tracking>
123
+ <class>SalesManago_Tracking_Block</class>
124
+ </tracking>
125
+ </blocks>
126
+
127
+ <resources>
128
+ <tracking_setup>
129
+ <setup>
130
+ <module>SalesManago_Tracking</module>
131
+ <class>SalesManago_Tracking_Model_Resource_Setup</class>
132
+ </setup>
133
+ <connection>
134
+ <use>core_setup</use>
135
+ </connection>
136
+ </tracking_setup>
137
+ <tracking_write>
138
+ <connection>
139
+ <use>core_write</use>
140
+ </connection>
141
+ </tracking_write>
142
+ <tracking_read>
143
+ <connection>
144
+ <use>core_read</use>
145
+ </connection>
146
+ </tracking_read>
147
+ </resources>
148
+ </global>
149
+
150
+
151
+ <frontend>
152
+ <layout>
153
+ <updates>
154
+ <tracking>
155
+ <file>salesmanago.xml</file>
156
+ </tracking>
157
+ </updates>
158
+ </layout>
159
+
160
+ <routers>
161
+ <newsletter>
162
+ <args>
163
+ <modules>
164
+ <SalesManago_Tracking before="Mage_Newsletter">SalesManago_Tracking_Newsletter</SalesManago_Tracking>
165
+ </modules>
166
+ </args>
167
+ </newsletter>
168
+ <frontend>
169
+ <use>standard</use>
170
+ <args>
171
+ <module>SalesManago_Tracking</module>
172
+ <frontName>salesmanago</frontName>
173
+ </args>
174
+ </frontend>
175
+ </routers>
176
+ </frontend>
177
+ <adminhtml>
178
+ <translate>
179
+ <modules>
180
+ <SalesManago_Tracking>
181
+ <files>
182
+ <default>Salesmanago_Tracking.csv</default>
183
+ </files>
184
+ </SalesManago_Tracking>
185
+ </modules>
186
+ </translate>
187
+ <acl>
188
+ <resources>
189
+ <all>
190
+ <title>Allow Everything</title>
191
+ </all>
192
+ <admin>
193
+ <children>
194
+ <system>
195
+ <children>
196
+ <config>
197
+ <children>
198
+ <salesmanago_tracking translate="title" module="tracking">
199
+ <title>Sales Manago</title>
200
+ <sort_order>52</sort_order>
201
+ </salesmanago_tracking>
202
+ </children>
203
+ </config>
204
+ </children>
205
+ </system>
206
+ </children>
207
+ </admin>
208
+ </resources>
209
+ </acl>
210
+ </adminhtml>
211
+ </config>
app/code/community/SalesManago/Tracking/etc/system.xml ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <salesmanago translate="label" module="tracking">
5
+ <label>SalesManago</label>
6
+ <sort_order>100</sort_order>
7
+ </salesmanago>
8
+ </tabs>
9
+ <sections>
10
+ <salesmanago_tracking translate="label" module="tracking">
11
+ <label>Connector settings</label>
12
+ <tab>salesmanago</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>10</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
+ <general translate="label" module="tracking">
20
+ <label>Connector settings</label>
21
+ <sort_order>800</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
+ <expanded>1</expanded>
26
+ <fields>
27
+ <client_id translate="label">
28
+ <label>Client ID</label>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>10</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ </client_id>
35
+ <api_secret translate="label">
36
+ <label>API secret code</label>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>20</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </api_secret>
43
+ <email translate="label">
44
+ <label>Main owner E-mail</label>
45
+ <frontend_type>text</frontend_type>
46
+ <sort_order>30</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
+ </email>
51
+ <endpoint translate="label">
52
+ <label>End point address</label>
53
+ <frontend_type>text</frontend_type>
54
+ <sort_order>40</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </endpoint>
59
+ <tagsNewsletter translate="label">
60
+ <label>Newsletter subscription tags</label>
61
+ <frontend_type>text</frontend_type>
62
+ <sort_order>50</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ <comment>If you want to use more tags, separate them with a comma</comment>
67
+ </tagsNewsletter>
68
+ <tagsRegistration translate="label">
69
+ <label>Sign up tag</label>
70
+ <frontend_type>text</frontend_type>
71
+ <sort_order>51</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ <comment>If you want to use more tags, separate them with a comma</comment>
76
+ </tagsRegistration>
77
+ <tagsPurchase translate="label">
78
+ <label>Purchase tag</label>
79
+ <frontend_type>text</frontend_type>
80
+ <sort_order>60</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>1</show_in_store>
84
+ <comment>If you want to use more tags, separate them with a comma</comment>
85
+ </tagsPurchase>
86
+ <additional_js translate="label">
87
+ <label>Custom JS code</label>
88
+ <frontend_type>text</frontend_type>
89
+ <sort_order>80</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>1</show_in_store>
93
+ </additional_js>
94
+ <connection_timeout translate="label">
95
+ <label>Connection Timeout</label>
96
+ <frontend_type>text</frontend_type>
97
+ <sort_order>90</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>1</show_in_store>
101
+ <comment>Limit the maximum execution time in ms (optional)</comment>
102
+ </connection_timeout>
103
+ <active translate="label">
104
+ <label>Enabled</label>
105
+ <frontend_type>select</frontend_type>
106
+ <source_model>adminhtml/system_config_source_yesno</source_model>
107
+ <sort_order>1</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>1</show_in_website>
110
+ <show_in_store>1</show_in_store>
111
+ </active>
112
+ </fields>
113
+ </general>
114
+ </groups>
115
+ </salesmanago_tracking>
116
+ </sections>
117
+ </config>
app/code/community/SalesManago/Tracking/sql/tracking_setup/mysql4-install-0.0.4.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+ $installer->run("
7
+ DROP TABLE IF EXISTS {$installer->getTable('tracking/customersync')};
8
+ CREATE TABLE {$installer->getTable('tracking/customersync')} (
9
+ `customer_sync_id` int(11) unsigned NOT NULL auto_increment,
10
+ `email` varchar(255) NULL,
11
+ `customer_id` int(11) NULL,
12
+ `order_id` int(11) NULL,
13
+ `hash` varchar(40) NOT NULL default '0',
14
+ `status` smallint(3) NOT NULL default '0',
15
+ `action` smallint(3) NOT NULL default '0',
16
+ `counter` smallint(3) NOT NULL default '0',
17
+ `created_time` datetime NULL,
18
+ `update_time` datetime NULL,
19
+ PRIMARY KEY (`customer_sync_id`)
20
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
21
+ ");
22
+
23
+ $installer->addAttribute('customer', 'salesmanago_contact_id', array(
24
+ 'type' => 'varchar',
25
+ 'input' => 'text',
26
+ 'label' => 'SALESmanago Contact ID',
27
+ 'global' => 1,
28
+ 'visible' => 1,
29
+ 'required' => 0,
30
+ 'user_defined' => 1,
31
+ 'default' => '0',
32
+ 'visible_on_front' => 0
33
+ ));
34
+ Mage::getSingleton('eav/config')
35
+ ->getAttribute('customer', 'salesmanago_contact_id')
36
+ ->setData('used_in_forms', array('adminhtml_customer'))
37
+ ->save();
38
+
39
+ $installer->endSetup();
app/design/frontend/base/default/layout/salesmanago.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <block type="tracking/layer" name="salesmanago_tracking">
6
+ <action method="setTemplate"><template>salesmanago/tracking/tracking.phtml</template></action>
7
+ </block>
8
+ </reference>
9
+ </default>
10
+ </layout>
app/design/frontend/base/default/template/salesmanago/tracking/tracking.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $client_id = $this->getClientId();
3
+ $endpoint = $this->getEndPoint();
4
+ $client_salesmanago_id = $this->getClientSalesManagoId();
5
+ $additional_js = $this->getAdditionalJs();
6
+ $active = $this -> isActive();
7
+
8
+ if($active == 1 && !empty($client_id) && !empty($endpoint)){
9
+ $trackingScript = "<script type='text/javascript'>\n";
10
+ $trackingScript .= "\tvar _smid = '".$client_id."';\n";
11
+ if(isset($additional_js) && !empty($additional_js)){
12
+ $trackingScript .= "\t".$additional_js."\n";
13
+ }
14
+ if($client_salesmanago_id){
15
+ $trackingScript .= "\tvar _smclientid = '".$client_salesmanago_id."';\n";
16
+ }
17
+ $trackingScript .= "\t(function(w, r, a, sm, s ) {\n";
18
+ $trackingScript .= "\t\tw['SalesmanagoObject'] = r;\n";
19
+ $trackingScript .= "\t\tw[r] = w[r] || function () {( w[r].q = w[r].q || [] ).push(arguments)};\n";
20
+ $trackingScript .= "\t\tsm = document.createElement('script'); sm.type = 'text/javascript'; sm.async = true; sm.src = a;\n";
21
+ $trackingScript .= "\t\ts = document.getElementsByTagName('script')[0];\n";
22
+ $trackingScript .= "\t\ts.parentNode.insertBefore(sm, s);\n";
23
+ $trackingScript .= "\t\t})(window, 'sm', ('https:' == document.location.protocol ? 'https://' : 'http://') + '".$endpoint."/static/sm.js');\n";
24
+ $trackingScript .= "</script>\n";
25
+
26
+ echo $trackingScript;
27
+ }
28
+ ?>
app/design/frontend/default/default/layout/salesmanago.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <block type="tracking/layer" name="salesmanago_tracking">
6
+ <action method="setTemplate"><template>salesmanago/tracking/tracking.phtml</template></action>
7
+ </block>
8
+ </reference>
9
+ </default>
10
+ </layout>
app/design/frontend/default/default/template/salesmanago/tracking/tracking.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $client_id = $this->getClientId();
3
+ $endpoint = $this->getEndPoint();
4
+ $client_salesmanago_id = $this->getClientSalesManagoId();
5
+ $additional_js = $this->getAdditionalJs();
6
+ $active = $this -> isActive();
7
+
8
+ if($active == 1 && !empty($client_id) && !empty($endpoint)){
9
+ $trackingScript = "<script type='text/javascript'>\n";
10
+ $trackingScript .= "\tvar _smid = '".$client_id."';\n";
11
+ if(isset($additional_js) && !empty($additional_js)){
12
+ $trackingScript .= "\t".$additional_js."\n";
13
+ }
14
+ if($client_salesmanago_id){
15
+ $trackingScript .= "\tvar _smclientid = '".$client_salesmanago_id."';\n";
16
+ }
17
+ $trackingScript .= "\t(function(w, r, a, sm, s ) {\n";
18
+ $trackingScript .= "\t\tw['SalesmanagoObject'] = r;\n";
19
+ $trackingScript .= "\t\tw[r] = w[r] || function () {( w[r].q = w[r].q || [] ).push(arguments)};\n";
20
+ $trackingScript .= "\t\tsm = document.createElement('script'); sm.type = 'text/javascript'; sm.async = true; sm.src = a;\n";
21
+ $trackingScript .= "\t\ts = document.getElementsByTagName('script')[0];\n";
22
+ $trackingScript .= "\t\ts.parentNode.insertBefore(sm, s);\n";
23
+ $trackingScript .= "\t\t})(window, 'sm', ('https:' == document.location.protocol ? 'https://' : 'http://') + '".$endpoint."/static/sm.js');\n";
24
+ $trackingScript .= "</script>\n";
25
+
26
+ echo $trackingScript;
27
+ }
28
+ ?>
app/etc/modules/SalesManago_Tracking.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <SalesManago_Tracking>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </SalesManago_Tracking>
8
+ </modules>
9
+ </config>
app/locale/de_DE/Salesmanago_Tracking.csv ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Connector settings","Verbindungseinstellungen"
2
+ "SalesManago_Tracking::Enabled","Freigeschaltet"
3
+ "Yes","Ja"
4
+ "No","Nein"
5
+ "Client ID","Kundennummer"
6
+ "API secret code","API Geheimnis"
7
+ "Main owner E-mail","Main owner E-mail"
8
+ "End point address","Endpunkt adresse"
9
+ "Newsletter subscription tags","Newsletter abonnement tag"
10
+ "Sign up tag","Anmelde tag"
11
+ "Purchase tag","Kauf tag"
12
+ "Custom JS code","Angepaster JS code"
13
+ "Connection Timeout","Verbindungsfehler"
14
+ "If you want to use more tags, separate them with a comma","Wenn Sie mehr Label (tag) nutzen möchten, trennen Sie diese durch Kommas"
15
+ "Limit the maximum execution time in ms (optional)","Limieteren Sie die maximale Ausfürungszeit ms (fakultativ)"
app/locale/es_ES/Salesmanago_Tracking.csv ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Connector settings","Ajustes o configuración del conector"
2
+ "SalesManago_Tracking::Enabled","Habilitado"
3
+ "Yes","Sí"
4
+ "No","No"
5
+ "Client ID","ID del Cliente"
6
+ "API secret code","API secret code"
7
+ "Main owner E-mail","Main owner E-mail"
8
+ "End point address","End point address"
9
+ "Newsletter subscription tags","Etiqueta de suscripción a newsletter"
10
+ "Sign up tag","Etiqueta de suscripción"
11
+ "Purchase tag","Etiqueta de compra"
12
+ "Custom JS code","Código JS personalizado"
13
+ "Connection Timeout","El tiempo de conexión expiro"
14
+ "If you want to use more tags, separate them with a comma","Si necesitas usar mas etiquetas, Separarlas con comas"
15
+ "Limit the maximum execution time in ms (optional)","Limitar el tiempo máximo de ejecución en ms (opcional)"
app/locale/pl_PL/Salesmanago_Tracking.csv ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Connector settings","Ustawienia Wtyczki"
2
+ "SalesManago_Tracking::Enabled","Włączona"
3
+ "Yes","Tak"
4
+ "No","Nie"
5
+ "Client ID","ID klienta"
6
+ "API secret code","Kod Api secret"
7
+ "Main owner E-mail","E-mail właściciela"
8
+ "End point address","Endpoint"
9
+ "Newsletter subscription tags","Tagi newsletter"
10
+ "Sign up tag","Tagi rejestracji"
11
+ "Purchase tag","Tagi zakupu"
12
+ "Custom JS code","Dodatkowy fragment JS"
13
+ "Connection Timeout","Czas wykonywania skryptu"
14
+ "If you want to use more tags, separate them with a comma","Kolejne tagi wpisuj po przecinku"
15
+ "Limit the maximum execution time in ms (optional)","Maksymalny czas oczekiwania na wykonanie skryptu w milisekundach (opcjonalnie)"
app/locale/ru_RU/Salesmanago_Tracking.csv ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Connector settings","Настройка связки"
2
+ "SalesManago_Tracking::Enabled","Включен"
3
+ "Yes","да"
4
+ "No","Нет"
5
+ "Client ID","ИН клиента"
6
+ "API secret code","API secret code"
7
+ "Main owner E-mail","Емейл"
8
+ "End point address","End point address"
9
+ "Newsletter subscription tags","Тег подписки на рассылку"
10
+ "Sign up tag","Тег регестрации"
11
+ "Purchase tag","Тег покупки"
12
+ "Custom JS code","Пользовательский JS-код"
13
+ "Connection Timeout","Время ожидания подключения"
14
+ "If you want to use more tags, separate them with a comma","Если Вы хотите использовать несколько тегов, разделяйте их запятой"
15
+ "Limit the maximum execution time in ms (optional)","Лимит максимального времени выполнения в ms (дополнительно) "
package.xml ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>SALESmanago</name>
4
+ <version>1.5.1</version>
5
+ <stability>stable</stability>
6
+ <license>ASL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>SALESmanago Marketing Automation integration.</summary>
10
+ <description>SALESmanago Marketing Automation integration.</description>
11
+ <notes>SALESmanago Marketing Automation integration.</notes>
12
+ <authors><author><name>Benhauer Sp. z o.o. Sp. K.</name><user>SalesManago</user><email>info@salesmanago.pl</email></author></authors>
13
+ <date>2014-02-06</date>
14
+ <time>01:51:06</time>
15
+ <contents>
16
+ <target name="magecommunity">
17
+ <dir name="SalesManago">
18
+ <dir name="Tracking">
19
+ <dir name="Block">
20
+ <file name="Layer.php" hash="5564c2dfb2cd62ea3d2f9cba11722718"/>
21
+ </dir>
22
+ <dir name="Helper">
23
+ <file name="Data.php" hash="11f51fb7782d47b1d0245ac43fb5962c"/>
24
+ </dir>
25
+ <dir name="Model">
26
+ <file name="Customersync.php" hash="c2535f600d93d711fc67324bf786b576"/>
27
+ <file name="Observer.php" hash="9a75d0f9550f24d4ddcb795b31276d27"/>
28
+ <dir name="Resource">
29
+ <dir name="Customersync">
30
+ <file name="Collection.php" hash="660921ec631893a685e0cacd4b9d07ef"/>
31
+ </dir>
32
+ <file name="Customersync.php" hash="3f6789e8568fb496e65d23cd6b8c3794"/>
33
+ <file name="Setup.php" hash="f196f0e7972b723dfaeecaea7ea0a0ee"/>
34
+ </dir>
35
+ </dir>
36
+ <dir name="controllers">
37
+ <file name="CustomerController.php" hash="c0154d7e55d551e1e0c1e8bed796e32e"/>
38
+ <dir name="Newsletter">
39
+ <file name="SubscriberController.php" hash="e683bda792cd39c11c40ad77d3b1a18e"/>
40
+ </dir>
41
+ </dir>
42
+ <dir name="etc">
43
+ <file name="config.xml" hash="d12c4b7723ad2ff49ffca0b2ccdb3460"/>
44
+ <file name="system.xml" hash="b0db5f4d20cd98eef017b1da798e59cd"/>
45
+ </dir><dir name="sql">
46
+ <dir name="tracking_setup">
47
+ <file name="mysql4-install-0.0.4.php" hash="efbe2ef2e234e72f8cfb61b02cd79fd8"/>
48
+ </dir>
49
+ </dir>
50
+ </dir>
51
+ </dir>
52
+ </target>
53
+ <target name="mageetc">
54
+ <dir name="modules">
55
+ <file name="SalesManago_Tracking.xml" hash="14e6da8fc1550fd46dc56ceea822d648"/>
56
+ </dir>
57
+ </target>
58
+ <target name="magedesign">
59
+ <dir name="frontend">
60
+ <dir name="default">
61
+ <dir name="default">
62
+ <dir name="layout">
63
+ <file name="salesmanago.xml" hash="c8d48e529e20472913b844723b0513a6"/>
64
+ </dir>
65
+ <dir name="template">
66
+ <dir name="salesmanago">
67
+ <dir name="tracking">
68
+ <file name="tracking.phtml" hash="f39205215f98504187fbfd9e90d477fb"/>
69
+ </dir>
70
+ </dir>
71
+ </dir>
72
+ </dir>
73
+ </dir>
74
+ </dir>
75
+ </target>
76
+ <target name="magedesign">
77
+ <dir name="frontend">
78
+ <dir name="base">
79
+ <dir name="default">
80
+ <dir name="layout">
81
+ <file name="salesmanago.xml" hash="c8d48e529e20472913b844723b0513a6"/>
82
+ </dir>
83
+ <dir name="template">
84
+ <dir name="salesmanago">
85
+ <dir name="tracking">
86
+ <file name="tracking.phtml" hash="f39205215f98504187fbfd9e90d477fb"/>
87
+ </dir>
88
+ </dir>
89
+ </dir>
90
+ </dir>
91
+ </dir>
92
+ </dir>
93
+ </target>
94
+ <target name="magelocale">
95
+ <dir name="de_DE">
96
+ <file name="Salesmanago_Tracking.csv"/>
97
+ </dir>
98
+ <dir name="es_ES">
99
+ <file name="Salesmanago_Tracking.csv"/>
100
+ </dir>
101
+ <dir name="pl_PL">
102
+ <file name="Salesmanago_Tracking.csv"/>
103
+ </dir>
104
+ <dir name="ru_RU">
105
+ <file name="Salesmanago_Tracking.csv"/>
106
+ </dir>
107
+ </target>
108
+ </contents>
109
+ <compatible/>
110
+ <dependencies><required><php><min>5.2.0</min><max>7.2.0</max></php></required></dependencies>
111
+ </package>