Mage_Laposta_Connect - Version 1.0.1

Version Notes

- Removed redundant newsletter menu item
- Added reset for synchronised entries when API key is changed

Download this release

Release Info

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


Code changes from version 1.0.0 to 1.0.1

app/code/community/Laposta/Connect/Model/Observer.php CHANGED
@@ -8,6 +8,8 @@
8
  */
9
  class Laposta_Connect_Model_Observer
10
  {
 
 
11
  /**
12
  * Handle subscribe event
13
  *
@@ -76,6 +78,19 @@ class Laposta_Connect_Model_Observer
76
  $subscriber->save();
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  /**
80
  * Handle subscribe event
81
  *
@@ -85,6 +100,15 @@ class Laposta_Connect_Model_Observer
85
  */
86
  public function handleSaveConfig(Varien_Event_Observer $observer)
87
  {
 
 
 
 
 
 
 
 
 
88
  $list = $this->handleSaveListConfig();
89
 
90
  if (!$list instanceof Laposta_Connect_Model_List) {
@@ -228,4 +252,62 @@ class Laposta_Connect_Model_Observer
228
 
229
  return $result;
230
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  }
8
  */
9
  class Laposta_Connect_Model_Observer
10
  {
11
+ private $currentApiKey = '';
12
+
13
  /**
14
  * Handle subscribe event
15
  *
78
  $subscriber->save();
79
  }
80
 
81
+ /**
82
+ * Handle config initialization event.
83
+ *
84
+ * @param Varien_Event_Observer $observer
85
+ */
86
+ public function handleInitConfig(Varien_Event_Observer $observer)
87
+ {
88
+ /*
89
+ * Record the current api key to detect changes
90
+ */
91
+ $this->currentApiKey = Mage::helper('lapostaconnect')->config('api_key');
92
+ }
93
+
94
  /**
95
  * Handle subscribe event
96
  *
100
  */
101
  public function handleSaveConfig(Varien_Event_Observer $observer)
102
  {
103
+ if (Mage::helper('lapostaconnect')->config('api_key') !== $this->currentApiKey) {
104
+ Mage::helper('lapostaconnect')->log('Laposta API key changed. Resetting all records.');
105
+
106
+ /*
107
+ * clear the laposta token and sync times
108
+ */
109
+ $this->resetSynchronised();
110
+ }
111
+
112
  $list = $this->handleSaveListConfig();
113
 
114
  if (!$list instanceof Laposta_Connect_Model_List) {
252
 
253
  return $result;
254
  }
255
+
256
+ /**
257
+ * Reset tokens and sync times of all lists, fields, and subscribers.
258
+ */
259
+ protected function resetSynchronised()
260
+ {
261
+ /*
262
+ * Lists
263
+ */
264
+
265
+ /** @var $lists Laposta_Connect_Model_Mysql4_List_Collection */
266
+ $lists = Mage::getModel('lapostaconnect/list')->getCollection();
267
+
268
+ /** @var $list Laposta_Connect_Model_List */
269
+ foreach ($lists as $list) {
270
+ $list->setLapostaId('');
271
+ $list->setWebhookToken('');
272
+ $list->setSyncTime(null);
273
+ }
274
+
275
+ $lists->save();
276
+
277
+ Mage::helper('lapostaconnect')->log('Lists reset OK.');
278
+
279
+ /*
280
+ * Fields
281
+ */
282
+
283
+ $fields = Mage::getModel('lapostaconnect/field')->getCollection();
284
+
285
+ /** @var $field Laposta_Connect_Model_Field */
286
+ foreach ($fields as $field) {
287
+ $field->setLapostaId('');
288
+ $field->setLapostaTag('');
289
+ $field->setSyncTime(null);
290
+ }
291
+
292
+ $fields->save();
293
+
294
+ Mage::helper('lapostaconnect')->log('Fields reset OK.');
295
+
296
+ /*
297
+ * Subscribers
298
+ */
299
+
300
+ /** @var $subscribers Laposta_Connect_Model_Mysql4_Subscriber_Collection */
301
+ $subscribers = Mage::getModel('lapostaconnect/subscriber')->getCollection();
302
+
303
+ /** @var $subscriber Laposta_Connect_Model_Subscriber */
304
+ foreach ($subscribers as $subscriber) {
305
+ $subscriber->setLapostaId('');
306
+ $subscriber->setSyncTime(null);
307
+ }
308
+
309
+ $subscribers->save();
310
+
311
+ Mage::helper('lapostaconnect')->log('Subscribers reset OK.');
312
+ }
313
  }
app/code/community/Laposta/Connect/etc/adminhtml.xml CHANGED
@@ -1,15 +1,5 @@
1
  <?xml version="1.0"?>
2
  <config>
3
- <menu>
4
- <newsletter>
5
- <children>
6
- <lapostaconnect translate="title" module="connect">
7
- <title>Laposta</title>
8
- <action>lapostaconnect/adminhtml_laposta</action>
9
- </lapostaconnect>
10
- </children>
11
- </newsletter>
12
- </menu>
13
  <acl>
14
  <resources>
15
  <all>
@@ -17,13 +7,6 @@
17
  </all>
18
  <admin>
19
  <children>
20
- <newsletter>
21
- <children>
22
- <lapostaconnect translate="title">
23
- <title>Laposta</title>
24
- </lapostaconnect>
25
- </children>
26
- </newsletter>
27
  <system>
28
  <children>
29
  <config>
1
  <?xml version="1.0"?>
2
  <config>
 
 
 
 
 
 
 
 
 
 
3
  <acl>
4
  <resources>
5
  <all>
7
  </all>
8
  <admin>
9
  <children>
 
 
 
 
 
 
 
10
  <system>
11
  <children>
12
  <config>
app/code/community/Laposta/Connect/etc/config.xml CHANGED
@@ -110,6 +110,14 @@
110
  </admin>
111
  <adminhtml>
112
  <events>
 
 
 
 
 
 
 
 
113
  <admin_system_config_changed_section_lapostaconnect>
114
  <observers>
115
  <laposta_save_config>
110
  </admin>
111
  <adminhtml>
112
  <events>
113
+ <adminhtml_init_system_config>
114
+ <observers>
115
+ <laposta_save_config>
116
+ <class>lapostaconnect/observer</class>
117
+ <method>handleInitConfig</method>
118
+ </laposta_save_config>
119
+ </observers>
120
+ </adminhtml_init_system_config>
121
  <admin_system_config_changed_section_lapostaconnect>
122
  <observers>
123
  <laposta_save_config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Laposta_Connect</name>
4
- <version>1.0.0</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,12 @@
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>First release of the Laposta plugin for Magento.</notes>
 
28
  <authors><author><name>Merten van Gerven</name><user>mertenvg</user><email>merten@codeblanche.com</email></author></authors>
29
- <date>2014-03-20</date>
30
- <time>12:33:00</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="8a54f573c56f8ce9e248506bb9514561"/><file name="Data.php" hash="8f9e28d0f28f9375385432d227ec1d06"/><file name="Fields.php" hash="51bc0aa26167219b038c04b3babb19af"/><file name="Laposta.php" hash="9085c0c80dcd314d402bfc960b8f861e"/><file name="Subscribe.php" hash="f58bc248ee3b4d229b58de8b4efbccf3"/><file name="Sync.php" hash="ad94bd49cf666fb99fa043bef1ba8bcf"/></dir><dir name="Model"><file name="Cron.php" hash="7a6a22b317282c049f5fa10a59622d58"/><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="72c09576c05ddb5cc0f0a05b0278b953"/><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="dbdb6706b908bffd29e5d69f97c6809f"/></dir><dir name="etc"><file name="adminhtml.xml" hash="d8ae83f3fe59f6806f11109bdb1b5cc8"/><file name="config.xml" hash="955fc3a1b19aab532d4ac39cbbad488f"/><file name="system.xml" hash="6ee7d5de56541573f16a2caf94dc0418"/></dir><dir name="sql"><dir name="connect_setup"><file name="mysql4-install-0.1.0.php" hash="96c1911d06392a5e9496829411102479"/></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.1</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>- Removed redundant newsletter menu item&#xD;
28
+ - Added reset for synchronised entries when API key is changed</notes>
29
  <authors><author><name>Merten van Gerven</name><user>mertenvg</user><email>merten@codeblanche.com</email></author></authors>
30
+ <date>2014-04-25</date>
31
+ <time>17:51:55</time>
32
+ <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="8a54f573c56f8ce9e248506bb9514561"/><file name="Data.php" hash="8f9e28d0f28f9375385432d227ec1d06"/><file name="Fields.php" hash="51bc0aa26167219b038c04b3babb19af"/><file name="Laposta.php" hash="9085c0c80dcd314d402bfc960b8f861e"/><file name="Subscribe.php" hash="f58bc248ee3b4d229b58de8b4efbccf3"/><file name="Sync.php" hash="ad94bd49cf666fb99fa043bef1ba8bcf"/></dir><dir name="Model"><file name="Cron.php" hash="7a6a22b317282c049f5fa10a59622d58"/><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="dbdb6706b908bffd29e5d69f97c6809f"/></dir><dir name="etc"><file name="adminhtml.xml" hash="71f985837d4b79e3db94c529bfee1e47"/><file name="config.xml" hash="325b71820df2ffd4b265810cb7c680f6"/><file name="system.xml" hash="6ee7d5de56541573f16a2caf94dc0418"/></dir><dir name="sql"><dir name="connect_setup"><file name="mysql4-install-0.1.0.php" hash="96c1911d06392a5e9496829411102479"/></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>
33
  <compatible/>
34
  <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
35
  </package>