Mage_Laposta_Connect - Version 1.0.12

Version Notes

- Formatting and additional logging
- Added registration for newsletter subscribe events
- Added subscribe/unsubscribe event handlers
- Fixed remove contact function
- Using native newsletter table instead of customer table for subscriber list
- Updated sync function to include anonymous newsletter subscriptions
- native subscriber id column added to laposta subscriber table

Download this release

Release Info

Developer Merten van Gerven
Extension Mage_Laposta_Connect
Version 1.0.12
Comparing to
See all releases


Code changes from version 1.0.11 to 1.0.12

app/code/community/Laposta/Connect/Helper/Laposta.php CHANGED
@@ -539,6 +539,12 @@ class Laposta_Connect_Helper_Laposta extends Mage_Core_Helper_Abstract
539
  return $this;
540
  }
541
 
 
 
 
 
 
 
542
  protected function log($method, $result = array())
543
  {
544
  Mage::helper('lapostaconnect')->log(
@@ -552,11 +558,18 @@ class Laposta_Connect_Helper_Laposta extends Mage_Core_Helper_Abstract
552
  /**
553
  * Remove a contact
554
  *
555
- * @param $listId
556
- * @param $memberId
 
 
557
  */
558
  public function removeContact($listId, $memberId)
559
  {
 
 
560
 
 
 
 
561
  }
562
  }
539
  return $this;
540
  }
541
 
542
+ /**
543
+ * Log stuff
544
+ *
545
+ * @param string $method
546
+ * @param array $result
547
+ */
548
  protected function log($method, $result = array())
549
  {
550
  Mage::helper('lapostaconnect')->log(
558
  /**
559
  * Remove a contact
560
  *
561
+ * @param string $listId
562
+ * @param string $memberId
563
+ *
564
+ * @return $this
565
  */
566
  public function removeContact($listId, $memberId)
567
  {
568
+ $member = new Laposta_Member($listId);
569
+ $result = $member->delete($memberId);
570
 
571
+ $this->log(__METHOD__, $result);
572
+
573
+ return $this;
574
  }
575
  }
app/code/community/Laposta/Connect/Helper/Subscribe.php CHANGED
@@ -4,27 +4,29 @@ class Laposta_Connect_Helper_Subscribe extends Mage_Core_Helper_Abstract
4
  {
5
  public function refreshSubscriberList($listId)
6
  {
7
- /** @var $customerCollection Mage_Customer_Model_Entity_Customer_Collection */
8
- $customerCollection = Mage::getModel('customer/customer')->getCollection();
9
 
10
  /** @var $subscriberCollection Laposta_Connect_Model_Mysql4_Subscriber_Collection */
11
  $subscriberCollection = Mage::getModel('lapostaconnect/subscriber')->getCollection();
12
 
13
- $subscribed = array_flip($subscriberCollection->getColumnValues('customer_id'));
 
14
 
15
- /** @var $customer Mage_Customer_Model_Entity_Customer */
16
- foreach ($customerCollection as $customer) {
17
- $customerId = $customer->getEntityId();
 
18
 
19
- if (isset($subscribed[$customerId])) {
20
  continue;
21
  }
22
 
23
  $subscriber = $subscriberCollection->getNewEmptyItem();
24
  $subscriber->setListId($listId);
25
  $subscriber->setCustomerId($customerId);
 
26
  $subscriber->setUpdatedTime($subscriberCollection->formatDate(time()));
27
-
28
  $subscriber->save();
29
  }
30
  }
4
  {
5
  public function refreshSubscriberList($listId)
6
  {
7
+ /** @var $subscriberCollection Mage_Newsletter_Model_Resource_Subscriber_Collection */
8
+ $nativeSubscriberCollection = Mage::getModel('newsletter/subscriber')->getCollection();
9
 
10
  /** @var $subscriberCollection Laposta_Connect_Model_Mysql4_Subscriber_Collection */
11
  $subscriberCollection = Mage::getModel('lapostaconnect/subscriber')->getCollection();
12
 
13
+ $subscriberIdList = array_flip($subscriberCollection->getColumnValues('newsletter_subscriber_id'));
14
+ $customerIdList = array_flip($subscriberCollection->getColumnValues('customer_id'));
15
 
16
+ /** @var $nativeSubscriber Mage_Newsletter_Model_Subscriber */
17
+ foreach ($nativeSubscriberCollection as $nativeSubscriber) {
18
+ $customerId = $nativeSubscriber->getCustomerId();
19
+ $nativeSubscriberId = $nativeSubscriber->getId();
20
 
21
+ if (isset($customerIdList[$customerId]) || isset($subscriberIdList[$nativeSubscriberId])) {
22
  continue;
23
  }
24
 
25
  $subscriber = $subscriberCollection->getNewEmptyItem();
26
  $subscriber->setListId($listId);
27
  $subscriber->setCustomerId($customerId);
28
+ $subscriber->setNewsletterSubscriberId($nativeSubscriberId);
29
  $subscriber->setUpdatedTime($subscriberCollection->formatDate(time()));
 
30
  $subscriber->save();
31
  }
32
  }
app/code/community/Laposta/Connect/Helper/Sync.php CHANGED
@@ -13,23 +13,23 @@ class Laposta_Connect_Helper_Sync extends Mage_Core_Helper_Abstract
13
  * )
14
  */
15
  protected $fieldConfigMap = array(
16
- 'dob' => array(
17
  'type' => Laposta_Connect_Helper_Laposta::FIELD_TYPE_DATE,
18
  ),
19
- 'gender' => array(
20
  'type' => Laposta_Connect_Helper_Laposta::FIELD_TYPE_SELECT_SINGLE,
21
  'options' => array('', 'Male', 'Female'),
22
  ),
23
- 'store_id' => array(
24
  'type' => Laposta_Connect_Helper_Laposta::FIELD_TYPE_NUMERIC,
25
  ),
26
- 'website_id' => array(
27
  'type' => Laposta_Connect_Helper_Laposta::FIELD_TYPE_NUMERIC,
28
  ),
29
- 'date_of_purchase' => array(
30
  'type' => Laposta_Connect_Helper_Laposta::FIELD_TYPE_DATE,
31
  ),
32
- 'group_id' => array(
33
  'type' => Laposta_Connect_Helper_Laposta::FIELD_TYPE_NUMERIC,
34
  ),
35
  );
@@ -63,6 +63,8 @@ class Laposta_Connect_Helper_Sync extends Mage_Core_Helper_Abstract
63
  */
64
  public function syncList(Laposta_Connect_Model_List $list)
65
  {
 
 
66
  if (Mage::helper('lapostaconnect')->config('active') !== '1') {
67
  return $this;
68
  }
@@ -276,6 +278,22 @@ class Laposta_Connect_Helper_Sync extends Mage_Core_Helper_Abstract
276
  return $result;
277
  }
278
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  /**
280
  * Synchronise the subscribers
281
  *
@@ -308,25 +326,40 @@ class Laposta_Connect_Helper_Sync extends Mage_Core_Helper_Abstract
308
  /** @var $fieldsHelper Laposta_Connect_Helper_Fields */
309
  $fieldsHelper = Mage::helper('lapostaconnect/Fields');
310
 
311
- /** @var $newsletterSubscribers Mage_Newsletter_Model_Mysql4_Subscriber_Collection */
312
- $newsletterSubscribers = Mage::getModel('newsletter/subscriber')->getCollection();
313
 
314
  /** @var $subscriber Laposta_Connect_Model_Subscriber */
315
  foreach ($subscribers as $subscriber) {
316
- $customerId = $subscriber->getCustomerId();
317
- $lapostaMemberId = $subscriber->getLapostaId();
318
- $lapostaListId = $listIdMap[$subscriber->getListId()];
 
 
 
 
 
 
319
 
320
- if (empty($customerId) && empty($lapostaMemberId)) {
321
- $subscriber->delete($subscriber);
 
 
 
 
322
 
323
  continue;
324
  }
325
 
326
- if (empty($customerId)) {
327
- $laposta->removeContact($lapostaListId, $lapostaMemberId);
328
- }
329
- else {
 
 
 
 
 
330
  /** @var $customer Mage_Customer_Model_Customer */
331
  $customer = Mage::getModel('customer/customer')->load($customerId);
332
  /** @var $customerHelper Laposta_Connect_Helper_Customer */
@@ -338,33 +371,20 @@ class Laposta_Connect_Helper_Sync extends Mage_Core_Helper_Abstract
338
  array_values($fields),
339
  array_values($customerHelper->resolve(array_keys($fields)))
340
  );
 
341
 
342
- $newsletter = $newsletterSubscribers->getItemByColumnValue('customer_id', $customerId);
343
- $subscribed = false;
344
-
345
- if ($newsletter instanceof Mage_Newsletter_Model_Subscriber) {
346
- $status = $newsletter->getData('subscriber_status');
347
- $statusWhiteList = array(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
348
-
349
- if (Mage::helper('lapostaconnect')->config('subscribe_unconfirmed') === '1') {
350
- $statusWhiteList[] = Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED;
351
- }
352
-
353
- $subscribed = in_array($status, $statusWhiteList) ? true : false;
354
- }
355
-
356
- if (empty($lapostaMemberId)) {
357
- $lapostaId = $laposta->addContact($lapostaListId, '', $customer->getEmail(), $data, $subscribed);
358
-
359
- $subscriber->setData('laposta_id', $lapostaId);
360
- }
361
- else {
362
- $laposta->updateContact($lapostaListId, $lapostaMemberId, '', $customer->getEmail(), $data, $subscribed);
363
- }
364
-
365
- $subscriber->setSyncTime($subscribers->formatDate(time()));
366
- $subscriber->save();
367
  }
 
 
 
 
 
 
368
  }
369
 
370
  foreach ($listIdMap as $lapostaListId) {
@@ -373,4 +393,18 @@ class Laposta_Connect_Helper_Sync extends Mage_Core_Helper_Abstract
373
 
374
  return $this;
375
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  }
13
  * )
14
  */
15
  protected $fieldConfigMap = array(
16
+ 'dob' => array(
17
  'type' => Laposta_Connect_Helper_Laposta::FIELD_TYPE_DATE,
18
  ),
19
+ 'gender' => array(
20
  'type' => Laposta_Connect_Helper_Laposta::FIELD_TYPE_SELECT_SINGLE,
21
  'options' => array('', 'Male', 'Female'),
22
  ),
23
+ 'store_id' => array(
24
  'type' => Laposta_Connect_Helper_Laposta::FIELD_TYPE_NUMERIC,
25
  ),
26
+ 'website_id' => array(
27
  'type' => Laposta_Connect_Helper_Laposta::FIELD_TYPE_NUMERIC,
28
  ),
29
+ 'date_of_purchase' => array(
30
  'type' => Laposta_Connect_Helper_Laposta::FIELD_TYPE_DATE,
31
  ),
32
+ 'group_id' => array(
33
  'type' => Laposta_Connect_Helper_Laposta::FIELD_TYPE_NUMERIC,
34
  ),
35
  );
63
  */
64
  public function syncList(Laposta_Connect_Model_List $list)
65
  {
66
+ $this->log(__METHOD__, "Starting to sync list: " . $list->getListName());
67
+
68
  if (Mage::helper('lapostaconnect')->config('active') !== '1') {
69
  return $this;
70
  }
278
  return $result;
279
  }
280
 
281
+ /**
282
+ * Resolve the list of status codes considered active
283
+ *
284
+ * @return array
285
+ */
286
+ protected function resolveSubscriberStatusWhiteList()
287
+ {
288
+ $statusWhiteList = array(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
289
+
290
+ if (Mage::helper('lapostaconnect')->config('subscribe_unconfirmed') === '1') {
291
+ $statusWhiteList[] = Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED;
292
+ }
293
+
294
+ return $statusWhiteList;
295
+ }
296
+
297
  /**
298
  * Synchronise the subscribers
299
  *
326
  /** @var $fieldsHelper Laposta_Connect_Helper_Fields */
327
  $fieldsHelper = Mage::helper('lapostaconnect/Fields');
328
 
329
+ /** @var $nativeSubscribers Mage_Newsletter_Model_Mysql4_Subscriber_Collection */
330
+ $nativeSubscribers = Mage::getModel('newsletter/subscriber')->getCollection();
331
 
332
  /** @var $subscriber Laposta_Connect_Model_Subscriber */
333
  foreach ($subscribers as $subscriber) {
334
+ $customerId = $subscriber->getCustomerId();
335
+ $lapostaMemberId = $subscriber->getLapostaId();
336
+ $nativeSubscriberId = $subscriber->getNewsletterSubscriberId();
337
+ $lapostaListId = $listIdMap[$subscriber->getListId()];
338
+ $nativeSubscriber = $nativeSubscribers->getItemById($nativeSubscriberId);
339
+
340
+ if (!$nativeSubscriber instanceof Mage_Newsletter_Model_Subscriber || $nativeSubscriber->isEmpty()) {
341
+ $nativeSubscriber = $nativeSubscribers->getItemByColumnValue('customer_id', $customerId);
342
+ }
343
 
344
+ if ((empty($customerId) && empty($nativeSubscriberId)) || !$nativeSubscriber instanceof Mage_Newsletter_Model_Subscriber || $nativeSubscriber->isEmpty()) {
345
+ if (!empty($lapostaMemberId)) {
346
+ $laposta->removeContact($lapostaListId, $lapostaMemberId);
347
+ }
348
+
349
+ $subscriber->delete();
350
 
351
  continue;
352
  }
353
 
354
+ /*
355
+ * Resolve the subscriber core data values
356
+ */
357
+
358
+ $email = $nativeSubscriber->getEmail();
359
+ $subscribed = in_array($nativeSubscriber->getData('subscriber_status'), $this->resolveSubscriberStatusWhiteList()) ? true : false;
360
+ $data = array();
361
+
362
+ if ($customerId != "0") {
363
  /** @var $customer Mage_Customer_Model_Customer */
364
  $customer = Mage::getModel('customer/customer')->load($customerId);
365
  /** @var $customerHelper Laposta_Connect_Helper_Customer */
371
  array_values($fields),
372
  array_values($customerHelper->resolve(array_keys($fields)))
373
  );
374
+ }
375
 
376
+ if (empty($lapostaMemberId)) {
377
+ $subscriber->setData(
378
+ 'laposta_id',
379
+ $laposta->addContact($lapostaListId, '', $email, $data, $subscribed)
380
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
  }
382
+ else {
383
+ $laposta->updateContact($lapostaListId, $lapostaMemberId, '', $email, $data, $subscribed);
384
+ }
385
+
386
+ $subscriber->setSyncTime($subscribers->formatDate(time()));
387
+ $subscriber->save();
388
  }
389
 
390
  foreach ($listIdMap as $lapostaListId) {
393
 
394
  return $this;
395
  }
396
+
397
+ protected function log($method, $message, $result = array())
398
+ {
399
+ $logData = array(
400
+ 'method' => $method,
401
+ 'message' => $message,
402
+ );
403
+
404
+ if (!empty($result)) {
405
+ $logData['result'] = $result;
406
+ }
407
+
408
+ Mage::helper('lapostaconnect')->log($logData);
409
+ }
410
  }
app/code/community/Laposta/Connect/Model/Observer.php CHANGED
@@ -29,7 +29,81 @@ class Laposta_Connect_Model_Observer
29
  $collection = Mage::getModel('lapostaconnect/subscriber')->getCollection();
30
  $subscriber = $collection->getItemByColumnValue('customer_id', $customer->getId());
31
 
32
- if (!$subscriber instanceof Laposta_Connect_Model_Subscriber) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  /** @var $lists Laposta_Connect_Model_Mysql4_List_Collection */
34
  $lists = Mage::getModel('lapostaconnect/list')->getCollection();
35
  /** @var $list Laposta_Connect_Model_List */
@@ -41,39 +115,57 @@ class Laposta_Connect_Model_Observer
41
 
42
  $subscriber = $collection->getNewEmptyItem();
43
  $subscriber->setListId($list->getListId());
44
- $subscriber->setCustomerId($customer->getEntityId());
45
- }
46
-
47
- if ($subscriber->getData('customer_id') != '') {
48
  $subscriber->setUpdatedTime($collection->formatDate(time()));
49
  $subscriber->save();
50
  }
51
  }
52
 
53
  /**
54
- * Handle subscribe event
55
  *
56
  * @param Varien_Event_Observer $observer
57
- *
58
- * @return void
59
  */
60
- public function handleCustomerDelete(Varien_Event_Observer $observer)
61
  {
62
- $customer = $observer->getEvent()->getCustomer();
 
63
 
64
- if (!$customer instanceof Mage_Customer_Model_Customer) {
65
  return;
66
  }
67
 
 
68
  /** @var $collection Laposta_Connect_Model_Mysql4_Subscriber_Collection */
69
  $collection = Mage::getModel('lapostaconnect/subscriber')->getCollection();
70
- $subscriber = $collection->getItemsByColumnValue('customer_id', $customer->getEntityId());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  if (!$subscriber instanceof Laposta_Connect_Model_Subscriber || $subscriber->isEmpty()) {
73
  return;
74
  }
75
 
76
  $subscriber->setCustomerId('');
 
77
  $subscriber->setUpdatedTime($collection->formatDate(time()));
78
  $subscriber->save();
79
  }
29
  $collection = Mage::getModel('lapostaconnect/subscriber')->getCollection();
30
  $subscriber = $collection->getItemByColumnValue('customer_id', $customer->getId());
31
 
32
+ if (!$subscriber instanceof Laposta_Connect_Model_Subscriber || $subscriber->isEmpty()) {
33
+ /*
34
+ * Nothing to do.
35
+ */
36
+
37
+ return;
38
+ }
39
+
40
+ if ($subscriber->getData('customer_id') != '') {
41
+ $subscriber->setUpdatedTime($collection->formatDate(time()));
42
+ $subscriber->save();
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Handle subscribe event
48
+ *
49
+ * @param Varien_Event_Observer $observer
50
+ *
51
+ * @return void
52
+ */
53
+ public function handleCustomerDelete(Varien_Event_Observer $observer)
54
+ {
55
+ /*
56
+ * method is now obsolete.
57
+ *
58
+ * Subscriber removal is handle through newsletter_subscriber_delete_after event.
59
+ */
60
+ }
61
+
62
+ /**
63
+ * Handle subscribe event
64
+ *
65
+ * @param Varien_Event_Observer $observer
66
+ */
67
+ public function handleNewsletterSubscriberSave(Varien_Event_Observer $observer)
68
+ {
69
+ /** @var $nativeSubscriber Mage_Newsletter_Model_Subscriber */
70
+ $nativeSubscriber = $observer->getEvent()->getSubscriber();
71
+
72
+ if (!$nativeSubscriber instanceof Mage_Newsletter_Model_Subscriber) {
73
+ return;
74
+ }
75
+
76
+ /** @var $collection Laposta_Connect_Model_Mysql4_Subscriber_Collection */
77
+ $collection = Mage::getModel('lapostaconnect/subscriber')->getCollection();
78
+ $customerId = $nativeSubscriber->getCustomerId();
79
+
80
+ /*
81
+ * find laposta subscriber by subscriber id
82
+ */
83
+
84
+ /** @var $subscriber Laposta_Connect_Model_Subscriber */
85
+ $subscriber = $collection->getItemByColumnValue('newsletter_subscriber_id', $nativeSubscriber->getId());
86
+
87
+ /*
88
+ * if not found and customer id is not '0' it could be a legacy record
89
+ */
90
+
91
+ if ($customerId != "0" && (!$subscriber instanceof Laposta_Connect_Model_Subscriber || $subscriber->isEmpty())) {
92
+ $subscriber = $collection->getItemByColumnValue('customer_id', $customerId);
93
+
94
+ /*
95
+ * update entries stored without a newsletter_subscriber_id
96
+ */
97
+
98
+ $subscriber->setNewsletterSubscriberId($nativeSubscriber->getId());
99
+ $subscriber->save();
100
+ }
101
+
102
+ /*
103
+ * if subscriber still doesn't exist then it really doesn't exist yet.
104
+ */
105
+
106
+ if (!$subscriber instanceof Laposta_Connect_Model_Subscriber || $subscriber->isEmpty()) {
107
  /** @var $lists Laposta_Connect_Model_Mysql4_List_Collection */
108
  $lists = Mage::getModel('lapostaconnect/list')->getCollection();
109
  /** @var $list Laposta_Connect_Model_List */
115
 
116
  $subscriber = $collection->getNewEmptyItem();
117
  $subscriber->setListId($list->getListId());
118
+ $subscriber->setCustomerId($customerId);
119
+ $subscriber->setNewsletterSubscriberId($nativeSubscriber->getId());
 
 
120
  $subscriber->setUpdatedTime($collection->formatDate(time()));
121
  $subscriber->save();
122
  }
123
  }
124
 
125
  /**
126
+ * Handle subscriber delete event
127
  *
128
  * @param Varien_Event_Observer $observer
 
 
129
  */
130
+ public function handleNewsletterSubscriberDelete(Varien_Event_Observer $observer)
131
  {
132
+ /** @var $nativeSubscriber Mage_Newsletter_Model_Subscriber */
133
+ $nativeSubscriber = $observer->getEvent()->getSubscriber();
134
 
135
+ if (!$nativeSubscriber instanceof Mage_Newsletter_Model_Subscriber) {
136
  return;
137
  }
138
 
139
+
140
  /** @var $collection Laposta_Connect_Model_Mysql4_Subscriber_Collection */
141
  $collection = Mage::getModel('lapostaconnect/subscriber')->getCollection();
142
+ $customerId = $nativeSubscriber->getCustomerId();
143
+
144
+ /*
145
+ * find laposta subscriber by subscriber id
146
+ */
147
+
148
+ /** @var $subscriber Laposta_Connect_Model_Subscriber */
149
+ $subscriber = $collection->getItemByColumnValue('newsletter_subscriber_id', $nativeSubscriber->getId());
150
+
151
+ /*
152
+ * if not found and customer id is not '0' it could be a legacy record
153
+ */
154
+
155
+ if ($customerId != "0" && (!$subscriber instanceof Laposta_Connect_Model_Subscriber || $subscriber->isEmpty())) {
156
+ $subscriber = $collection->getItemByColumnValue('customer_id', $customerId);
157
+ }
158
+
159
+ /*
160
+ * if subscriber still doesn't exist then it really doesn't exist yet.
161
+ */
162
 
163
  if (!$subscriber instanceof Laposta_Connect_Model_Subscriber || $subscriber->isEmpty()) {
164
  return;
165
  }
166
 
167
  $subscriber->setCustomerId('');
168
+ $subscriber->setNewsletterSubscriberId('');
169
  $subscriber->setUpdatedTime($collection->formatDate(time()));
170
  $subscriber->save();
171
  }
app/code/community/Laposta/Connect/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Laposta_Connect>
5
- <version>1.0.10</version>
6
  </Laposta_Connect>
7
  </modules>
8
  <frontend>
@@ -39,6 +39,22 @@
39
  </lapostaconnect_customer_delete>
40
  </observers>
41
  </customer_delete_after>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  </events>
43
  </frontend>
44
  <global>
2
  <config>
3
  <modules>
4
  <Laposta_Connect>
5
+ <version>1.0.12</version>
6
  </Laposta_Connect>
7
  </modules>
8
  <frontend>
39
  </lapostaconnect_customer_delete>
40
  </observers>
41
  </customer_delete_after>
42
+ <newsletter_subscriber_save_after>
43
+ <observers>
44
+ <lapostaconnect_subscriber_save>
45
+ <class>lapostaconnect/observer</class>
46
+ <method>handleNewsletterSubscriberSave</method>
47
+ </lapostaconnect_subscriber_save>
48
+ </observers>
49
+ </newsletter_subscriber_save_after>
50
+ <newsletter_subscriber_delete_after>
51
+ <observers>
52
+ <lapostaconnect_subscriber_delete>
53
+ <class>lapostaconnect/observer</class>
54
+ <method>handleNewsletterSubscriberDelete</method>
55
+ </lapostaconnect_subscriber_delete>
56
+ </observers>
57
+ </newsletter_subscriber_delete_after>
58
  </events>
59
  </frontend>
60
  <global>
app/code/community/Laposta/Connect/sql/lapostaconnect_setup/mysql4-install-1.0.12.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run(
8
+ "
9
+ CREATE TABLE IF NOT EXISTS `laposta_subscriber` (
10
+ `subscriber_id` int(11) unsigned NOT NULL auto_increment,
11
+ `list_id` int(11) unsigned NOT NULL default 1,
12
+ `customer_id` varchar(255) NOT NULL default '',
13
+ `newsletter_subscriber_id` varchar(255) DEFAULT NULL,
14
+ `laposta_id` varchar(255) NOT NULL default '',
15
+ `updated_time` datetime NULL,
16
+ `sync_time` datetime NULL,
17
+ PRIMARY KEY (`subscriber_id`),
18
+ INDEX `list_id` (`list_id`),
19
+ INDEX `customer_id` (`customer_id`),
20
+ INDEX `laposta_id` (`laposta_id`),
21
+ INDEX `newsletter_subscriber_id` (`newsletter_subscriber_id`)
22
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
23
+ "
24
+ );
25
+
26
+ $installer->run(
27
+ "
28
+ CREATE TABLE IF NOT EXISTS `laposta_field` (
29
+ `field_id` int(11) unsigned NOT NULL auto_increment,
30
+ `list_id` int(11) unsigned NOT NULL default 1,
31
+ `field_name` varchar(255) NOT NULL default '',
32
+ `field_relation` varchar(255) NOT NULL default '',
33
+ `laposta_id` varchar(255) NOT NULL default '',
34
+ `laposta_tag` varchar(255) NOT NULL default '',
35
+ `updated_time` datetime NULL,
36
+ `sync_time` datetime NULL,
37
+ PRIMARY KEY (`field_id`),
38
+ INDEX `list_id` (`list_id`),
39
+ INDEX `laposta_id` (`laposta_id`)
40
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
41
+ "
42
+ );
43
+
44
+ $installer->run(
45
+ "
46
+ CREATE TABLE IF NOT EXISTS `laposta_list` (
47
+ `list_id` int(11) unsigned NOT NULL auto_increment,
48
+ `list_name` varchar(255) NOT NULL default '',
49
+ `laposta_id` varchar(255) NOT NULL default '',
50
+ `webhook_token` varchar(255) NOT NULL default '',
51
+ `updated_time` datetime NULL,
52
+ `sync_time` datetime NULL,
53
+ PRIMARY KEY (`list_id`),
54
+ INDEX `webhook_token` (`webhook_token`)
55
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
56
+ "
57
+ );
58
+
59
+ $installer->endSetup();
app/code/community/Laposta/Connect/sql/lapostaconnect_setup/mysql4-upgrade-1.0.11-1.0.12.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+ ALTER TABLE `laposta_subscriber` ADD COLUMN `newsletter_subscriber_id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `customer_id`
9
+ ");
10
+
11
+ $installer->run("
12
+ ALTER TABLE `laposta_subscriber` ADD INDEX `newsletter_subscriber_id` (`newsletter_subscriber_id`)
13
+ ");
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Laposta_Connect</name>
4
- <version>1.0.11</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -24,11 +24,18 @@
24
  &#xD;
25
  &lt;h2&gt;Questions&lt;/h2&gt;&#xD;
26
  &lt;p&gt;Please see the FAQ section for questions.&lt;/p&gt;</description>
27
- <notes>- Ignore laposta internal email field within Magento</notes>
 
 
 
 
 
 
 
28
  <authors><author><name>Merten van Gerven</name><user>mertenvg</user><email>merten@codeblanche.com</email></author></authors>
29
- <date>2014-08-14</date>
30
- <time>11:36:24</time>
31
- <contents><target name="magecommunity"><dir name="Laposta"><dir name="Connect"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Mapfields.php" hash="2c88b8a08121c09ba5748f631205a282"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Customer.php" hash="ef0a5dff85fd77de92a0fefe06fddc60"/><file name="Data.php" hash="8f9e28d0f28f9375385432d227ec1d06"/><file name="Fields.php" hash="51bc0aa26167219b038c04b3babb19af"/><file name="Laposta.php" hash="e3e752e09512b9a3317ead8a0ca68eba"/><file name="Subscribe.php" hash="f58bc248ee3b4d229b58de8b4efbccf3"/><file name="Sync.php" hash="bc3ce223ae2cd539938523b4d8632d72"/></dir><dir name="Model"><file name="Cron.php" hash="270a2289a1de1bc678dfc4e6264c095b"/><file name="Field.php" hash="42e1857bdb7d90b31be189e2921ac8fd"/><file name="List.php" hash="99f590a5e5ea3b1a14869c641f49eaed"/><dir name="Mysql4"><dir name="Field"><file name="Collection.php" hash="f8133202231937b1ec14d8cdc39903fe"/></dir><file name="Field.php" hash="c49743d6acd1d4ce2b69aadf22838839"/><dir name="List"><file name="Collection.php" hash="fcc556452fff91bb3e9f933c68fff630"/></dir><file name="List.php" hash="6fef1b36f5d3a5560f83bafe205be614"/><dir name="Subscriber"><file name="Collection.php" hash="05db928eb656f132e4fa16ac740ce3c5"/></dir><file name="Subscriber.php" hash="9f73d39e97d4a19f8d8ad3c19f83a699"/></dir><file name="Observer.php" hash="1f22b2201a11543b725bc76f133b803d"/><file name="Subscriber.php" hash="cba5176e53a7dcab9b9014190f13485d"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="LapostaController.php" hash="cc2a0d62caf63469258042e3b29616e4"/></dir><file name="IndexController.php" hash="7577e30abee9624d59901edb5cecd3e9"/><file name="SubscribeAllController.php" hash="160ac8e5229bb1003d7220116a9b06f7"/><file name="WebhookController.php" hash="0526b02b319fc31cd8c8a3e9789ba358"/></dir><dir name="etc"><file name="adminhtml.xml" hash="71f985837d4b79e3db94c529bfee1e47"/><file name="config.xml" hash="e0f0be6791cbcdb6bf2f129eaa02feb2"/><file name="system.xml" hash="6ee7d5de56541573f16a2caf94dc0418"/></dir><dir name="lib"><dir name="Laposta"><dir name="Laposta"><file name="Error.php" hash="46e746b650bbb5df1ec51f4c530d5f35"/><file name="Field.php" hash="99bc22f997692ff648cb660330552a94"/><file name="List.php" hash="f3b8a716c1d9fd11828f980445dd6d5b"/><file name="Login.php" hash="dc11941e5ca3a404005730843c74e8b3"/><file name="Member.php" hash="cae2b3f6b23ee44e9246a8d33d2ddd46"/><file name="Request.php" hash="66bc536b8b9ce443c3ae0917bdd472ed"/><file name="Resource.php" hash="c2ca77821136b798b526b5dc41659054"/><file name="Util.php" hash="d6760d2d5ddb6f4de6aff185fd432a91"/><file name="Webhook.php" hash="e06b2e711c348af1df425b7faaa5c33e"/></dir><file name="Laposta.php" hash="c99f38dcfef24df38a5a921360356381"/></dir></dir><dir name="sql"><dir name="lapostaconnect_setup"><file name="mysql4-install-1.0.0.php" hash="a1b0319b992b9effe6aa2712031e8701"/><file name="mysql4-upgrade-1.0.7-1.0.8.php" hash="a1b0319b992b9effe6aa2712031e8701"/></dir></dir></dir></dir></target><target name="magelocal"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="lapostaconnect.xml" hash=""/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Laposta_Connect.xml" hash="ab7675e19ea96d39c5980bee835f0e76"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Laposta_Connect.csv" hash="4f8f28790602cdd01633c0bb00f70585"/></dir></target></contents>
32
  <compatible/>
33
  <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
34
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Laposta_Connect</name>
4
+ <version>1.0.12</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
24
  &#xD;
25
  &lt;h2&gt;Questions&lt;/h2&gt;&#xD;
26
  &lt;p&gt;Please see the FAQ section for questions.&lt;/p&gt;</description>
27
+ <notes>- Formatting and additional logging&#xD;
28
+ - Added registration for newsletter subscribe events&#xD;
29
+ - Added subscribe/unsubscribe event handlers&#xD;
30
+ - Fixed remove contact function&#xD;
31
+ - Using native newsletter table instead of customer table for subscriber list&#xD;
32
+ - Updated sync function to include anonymous newsletter subscriptions&#xD;
33
+ - native subscriber id column added to laposta subscriber table&#xD;
34
+ </notes>
35
  <authors><author><name>Merten van Gerven</name><user>mertenvg</user><email>merten@codeblanche.com</email></author></authors>
36
+ <date>2014-09-25</date>
37
+ <time>14:28:19</time>
38
+ <contents><target name="magecommunity"><dir name="Laposta"><dir name="Connect"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Mapfields.php" hash="2c88b8a08121c09ba5748f631205a282"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Customer.php" hash="ef0a5dff85fd77de92a0fefe06fddc60"/><file name="Data.php" hash="8f9e28d0f28f9375385432d227ec1d06"/><file name="Fields.php" hash="51bc0aa26167219b038c04b3babb19af"/><file name="Laposta.php" hash="f763f69df1ecc0ace15706bf5b2581b5"/><file name="Subscribe.php" hash="55f128263acb89cd1d9ab7f36e0dec07"/><file name="Sync.php" hash="97dc4aa48a3b0712274a8bbaad80a6c6"/></dir><dir name="Model"><file name="Cron.php" hash="270a2289a1de1bc678dfc4e6264c095b"/><file name="Field.php" hash="42e1857bdb7d90b31be189e2921ac8fd"/><file name="List.php" hash="99f590a5e5ea3b1a14869c641f49eaed"/><dir name="Mysql4"><dir name="Field"><file name="Collection.php" hash="f8133202231937b1ec14d8cdc39903fe"/></dir><file name="Field.php" hash="c49743d6acd1d4ce2b69aadf22838839"/><dir name="List"><file name="Collection.php" hash="fcc556452fff91bb3e9f933c68fff630"/></dir><file name="List.php" hash="6fef1b36f5d3a5560f83bafe205be614"/><dir name="Subscriber"><file name="Collection.php" hash="05db928eb656f132e4fa16ac740ce3c5"/></dir><file name="Subscriber.php" hash="9f73d39e97d4a19f8d8ad3c19f83a699"/></dir><file name="Observer.php" hash="fc3f7b870742256be4dca3110e77205e"/><file name="Subscriber.php" hash="cba5176e53a7dcab9b9014190f13485d"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="LapostaController.php" hash="cc2a0d62caf63469258042e3b29616e4"/></dir><file name="IndexController.php" hash="7577e30abee9624d59901edb5cecd3e9"/><file name="SubscribeAllController.php" hash="160ac8e5229bb1003d7220116a9b06f7"/><file name="WebhookController.php" hash="0526b02b319fc31cd8c8a3e9789ba358"/></dir><dir name="etc"><file name="adminhtml.xml" hash="71f985837d4b79e3db94c529bfee1e47"/><file name="config.xml" hash="aed35c1696e3d1d8c0e83099a3c1be2f"/><file name="system.xml" hash="6ee7d5de56541573f16a2caf94dc0418"/></dir><dir name="lib"><dir name="Laposta"><dir name="Laposta"><file name="Error.php" hash="46e746b650bbb5df1ec51f4c530d5f35"/><file name="Field.php" hash="99bc22f997692ff648cb660330552a94"/><file name="List.php" hash="f3b8a716c1d9fd11828f980445dd6d5b"/><file name="Login.php" hash="dc11941e5ca3a404005730843c74e8b3"/><file name="Member.php" hash="cae2b3f6b23ee44e9246a8d33d2ddd46"/><file name="Request.php" hash="66bc536b8b9ce443c3ae0917bdd472ed"/><file name="Resource.php" hash="c2ca77821136b798b526b5dc41659054"/><file name="Util.php" hash="d6760d2d5ddb6f4de6aff185fd432a91"/><file name="Webhook.php" hash="e06b2e711c348af1df425b7faaa5c33e"/></dir><file name="Laposta.php" hash="c99f38dcfef24df38a5a921360356381"/></dir></dir><dir name="sql"><dir name="lapostaconnect_setup"><file name="mysql4-install-1.0.0.php" hash="a1b0319b992b9effe6aa2712031e8701"/><file name="mysql4-install-1.0.12.php" hash="aafda6f1342a9e5ca30c3a87886619f8"/><file name="mysql4-upgrade-1.0.11-1.0.12.php" hash="4cb4083f5bbc27dc719bd0a816a33476"/><file name="mysql4-upgrade-1.0.7-1.0.8.php" hash="a1b0319b992b9effe6aa2712031e8701"/></dir></dir></dir></dir></target><target name="magelocal"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="lapostaconnect.xml" hash=""/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Laposta_Connect.xml" hash="ab7675e19ea96d39c5980bee835f0e76"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Laposta_Connect.csv" hash="4f8f28790602cdd01633c0bb00f70585"/></dir></target></contents>
39
  <compatible/>
40
  <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
41
  </package>