MailUp - Version 2.7.0

Version Notes


  • NEW: Specify default group for new subscribers to be added to

  • NEW: Segmenting customers:

    • You can choose a custom subscription message ID

    • Can chose all customers who have not opted-in



  • NEW: Connection check for url, username and password to make entering your details easier

  • Improvement: Shopping-cart abandonment fields cleared immediately after order

  • Improvement: Task and log lists now show most recent first

Download this release

Release Info

Developer MailUp
Extension MailUp
Version 2.7.0
Comparing to
See all releases


Code changes from version 2.6.1 to 2.7.0

Files changed (99) hide show
  1. app/code/local/MailUp/MailUpSync/.DS_Store +0 -0
  2. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Adminhtml/Log.php +1 -1
  3. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Adminhtml/Log/Grid.php +4 -1
  4. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Adminhtml/Mailup/Grid.php +6 -54
  5. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Adminhtml/Mailupbackend.php +1 -1
  6. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Adminhtml/Sync.php +1 -1
  7. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Adminhtml/Sync/Grid.php +4 -12
  8. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Adminhtml/System/Config/Form/Field/Timezone.php +1 -1
  9. app/code/local/MailUp/MailUpSync/Block/Adminhtml/System/Config/Form/Testbutton.php +35 -0
  10. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Checkout/Subscribe.php +1 -1
  11. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Filters.php +2 -2
  12. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Index.php +1 -1
  13. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Helper/Customer.php +1 -1
  14. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Helper/Data.php +219 -15
  15. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Helper/Order.php +1 -1
  16. app/code/local/MailUp/MailUpSync/Model/.DS_Store +0 -0
  17. app/code/local/MailUp/MailUpSync/Model/Adminhtml/.DS_Store +0 -0
  18. app/code/local/MailUp/MailUpSync/Model/Adminhtml/System/.DS_Store +0 -0
  19. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Adminhtml/System/Clone/Mappings/Custom.php +2 -2
  20. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Adminhtml/System/Source/Cron/Frequency.php +2 -2
  21. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Adminhtml/System/Source/Cron/Hours.php +1 -1
  22. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Adminhtml/System/Source/Fields.php +2 -2
  23. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Config.php +14 -2
  24. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Consoleurlvalidator.php +1 -1
  25. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Cron.php +16 -10
  26. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Job.php +9 -8
  27. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Log.php +1 -1
  28. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/MailUp.php +1 -1
  29. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/MailUpWsImport.php +14 -11
  30. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Mysql14/MailUp.php +1 -1
  31. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Mysql14/MailUp/Collection.php +1 -1
  32. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Mysql4/Job.php +1 -1
  33. app/code/local/{SevenLike/MailUp/Model/Mysql4/Sync → MailUp/MailUpSync/Model/Mysql4/Job}/Collection.php +2 -2
  34. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Mysql4/Log.php +1 -1
  35. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Mysql4/Log/Collection.php +1 -1
  36. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Mysql4/Sync.php +1 -1
  37. app/code/local/MailUp/MailUpSync/Model/Mysql4/Sync/Collection.php +11 -0
  38. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Observer.php +104 -41
  39. app/code/local/MailUp/MailUpSync/Model/Source/Groups.php +70 -0
  40. app/code/local/{SevenLike/MailUp/Model → MailUp/MailUpSync/Model/Source}/Lists.php +9 -9
  41. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Source/Store.php +1 -1
  42. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Subscriber.php +5 -5
  43. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Sync.php +5 -5
  44. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Webserviceusernamevalidator.php +1 -1
  45. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Ws.php +0 -0
  46. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Wssend.php +28 -7
  47. app/code/local/MailUp/MailUpSync/controllers/Adminhtml/ConfigurationController.php +85 -0
  48. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/controllers/Adminhtml/FieldsmappingController.php +1 -1
  49. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/controllers/Adminhtml/FilterController.php +19 -14
  50. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/controllers/Adminhtml/LogController.php +1 -1
  51. app/code/local/MailUp/MailUpSync/controllers/Adminhtml/MailupbackendController.php +65 -0
  52. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/controllers/Adminhtml/SyncController.php +1 -1
  53. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/controllers/Adminhtml/ViewdatatransferlogController.php +1 -1
  54. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/controllers/IndexController.php +2 -2
  55. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/controllers/TestController.php +4 -4
  56. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/controllers/WebhookController.php +1 -1
  57. app/code/local/MailUp/MailUpSync/data/mailup_setup/upgrade-2.6.1-2.7.0.php +14 -0
  58. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/etc/config.xml +44 -35
  59. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/etc/system.xml +54 -35
  60. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/sql/mailup_setup/mysql4-install-0.1.0.php +0 -0
  61. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/sql/mailup_setup/mysql4-install-2.3.0.php +0 -0
  62. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/sql/mailup_setup/mysql4-install-2.4.0.php +0 -0
  63. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/sql/mailup_setup/mysql4-upgrade-0.1.0-1.0.0.php +0 -0
  64. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/sql/mailup_setup/mysql4-upgrade-0.3.0-1.0.0.php +0 -0
  65. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/sql/mailup_setup/mysql4-upgrade-1.0.0-1.5.2.php +0 -0
  66. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/sql/mailup_setup/mysql4-upgrade-2.1.3-2.2.0.php +0 -0
  67. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/sql/mailup_setup/mysql4-upgrade-2.2.0-2.3.0.php +0 -0
  68. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/sql/mailup_setup/mysql4-upgrade-2.2.1-2.3.0.php +0 -0
  69. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/sql/mailup_setup/mysql4-upgrade-2.3.0-2.3.1.php +0 -0
  70. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/sql/mailup_setup/mysql4-upgrade-2.3.1-2.3.2.php +0 -0
  71. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/sql/mailup_setup/mysql4-upgrade-2.3.2-2.4.0.php +0 -0
  72. app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/sql/mailup_setup/mysql4-upgrade-2.4.0-2.4.1.php +0 -0
  73. app/code/local/MailUp/MailUpSync/sql/mailup_setup/mysql4-upgrade-2.6.1-2.7.0.php +16 -0
  74. app/code/local/SevenLike/MailUp/Model/Mysql4/Job/Collection.php +0 -11
  75. app/code/local/SevenLike/MailUp/controllers/Adminhtml/ConfigurationController.php +0 -15
  76. app/code/local/SevenLike/MailUp/controllers/Adminhtml/MailupbackendController.php +0 -220
  77. app/design/adminhtml/default/default/layout/mailup.xml +21 -11
  78. app/design/adminhtml/default/default/template/{sevenlike/mailup → mailup/mailupsync}/confirm.phtml +42 -3
  79. app/design/adminhtml/default/default/template/{sevenlike/mailup → mailup/mailupsync}/fieldsmapping.phtml +0 -0
  80. app/design/adminhtml/default/default/template/{sevenlike/mailup → mailup/mailupsync}/filter.phtml +9 -5
  81. app/design/adminhtml/default/default/template/mailup/mailupsync/sysconfigjavascript.phtml +17 -0
  82. app/design/adminhtml/default/default/template/{sevenlike/mailup → mailup/mailupsync}/viewdatatransferlog.phtml +0 -0
  83. app/design/frontend/base/default/layout/mailup.xml +0 -0
  84. app/design/frontend/base/default/template/mailup/customer/account/dashboard/info.phtml +1 -1
  85. app/design/frontend/base/default/template/mailup/index.phtml +0 -0
  86. app/design/frontend/base/default/template/mailup/subscribe.phtml +0 -0
  87. app/design/frontend/enterprise/default/layout/mailup.xml +0 -0
  88. app/design/frontend/enterprise/default/template/mailup/customer/account/dashboard/info.phtml +1 -1
  89. app/design/frontend/enterprise/default/template/mailup/subscribe.phtml +0 -0
  90. app/etc/modules/MailUp_MailUpSync.xml +1 -0
  91. app/etc/modules/SevenLike_MailUp.xml +0 -1
  92. app/locale/en_US/{SevenLike_MailUp.csv → MailUp_MailUpSync.csv} +5 -1
  93. app/locale/it_IT/{SevenLike_MailUp.csv → MailUp_MailUpSync.csv} +39 -1
  94. js/mailup/admin.js +39 -0
  95. package.xml +9 -5
  96. skin/adminhtml/default/default/images/MailUp_300_200_transparent_small.png +0 -0
  97. skin/adminhtml/default/default/{sevenlike/mailup → mailup/mailupsync}/images/MailUp_300_200_transparent_small.png +0 -0
  98. skin/adminhtml/default/default/{sevenlike/mailup → mailup/mailupsync}/images/titoli.png +0 -0
  99. skin/adminhtml/default/default/{sevenlike/mailup → mailup/mailupsync}/mailup.css +0 -0
app/code/local/MailUp/MailUpSync/.DS_Store ADDED
Binary file
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Adminhtml/Log.php RENAMED
@@ -2,7 +2,7 @@
2
/**
3
* Log.php
4
*/
5
- class SevenLike_MailUp_Block_Adminhtml_Log extends Mage_Adminhtml_Block_Widget_Grid_Container
6
{
7
public function __construct()
8
{
2
/**
3
* Log.php
4
*/
5
+ class MailUp_MailUpSync_Block_Adminhtml_Log extends Mage_Adminhtml_Block_Widget_Grid_Container
6
{
7
public function __construct()
8
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Adminhtml/Log/Grid.php RENAMED
@@ -2,7 +2,7 @@
2
/**
3
* Grid.php
4
*/
5
- class SevenLike_MailUp_Block_Adminhtml_Log_Grid extends Mage_Adminhtml_Block_Widget_Grid
6
{
7
/**
8
* Constructor
@@ -25,6 +25,9 @@ class SevenLike_MailUp_Block_Adminhtml_Log_Grid extends Mage_Adminhtml_Block_Wid
25
{
26
$collection = Mage::getModel('mailup/log')->getCollection();
27
$this->setCollection($collection);
28
29
//var_dump(Mage::getModel('mailup/job')->load(1));
30
2
/**
3
* Grid.php
4
*/
5
+ class MailUp_MailUpSync_Block_Adminhtml_Log_Grid extends Mage_Adminhtml_Block_Widget_Grid
6
{
7
/**
8
* Constructor
25
{
26
$collection = Mage::getModel('mailup/log')->getCollection();
27
$this->setCollection($collection);
28
+ // Set default sort to ID by highest to lowest (normally shows most recent first)
29
+ $this->setDefaultSort('id');
30
+ $this->setDefaultDir('desc');
31
32
//var_dump(Mage::getModel('mailup/job')->load(1));
33
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Adminhtml/Mailup/Grid.php RENAMED
@@ -2,7 +2,7 @@
2
/**
3
* Grid.php
4
*/
5
- class SevenLike_MailUp_Block_Adminhtml_MailUp_Grid extends Mage_Adminhtml_Block_Widget_Grid
6
{
7
/**
8
* Constructor
@@ -19,12 +19,15 @@ class SevenLike_MailUp_Block_Adminhtml_MailUp_Grid extends Mage_Adminhtml_Block_
19
/**
20
* Prepare Collection
21
*
22
- * @return
23
*/
24
protected function _prepareCollection()
25
{
26
$collection = Mage::getModel('mailup/job')->getCollection();
27
$this->setCollection($collection);
28
29
//var_dump(Mage::getModel('mailup/job')->load(1));
30
@@ -64,13 +67,6 @@ class SevenLike_MailUp_Block_Adminhtml_MailUp_Grid extends Mage_Adminhtml_Block_
64
'options' => Mage::getModel('mailup/source_store')->getSelectOptions(),
65
));
66
67
- /*$this->addColumn('store_id', array(
68
- 'header' => Mage::helper('mailup')->__('Store ID'),
69
- //'align' =>'right',
70
- 'width' => '80px',
71
- 'index' => 'store_id',
72
- ));*/
73
-
74
$this->addColumn('mailupgroupid', array(
75
'header' => Mage::helper('mailup')->__('Mailup Group ID'),
76
//'align' =>'right',
@@ -162,21 +158,6 @@ class SevenLike_MailUp_Block_Adminhtml_MailUp_Grid extends Mage_Adminhtml_Block_
162
//'gmtoffset' => true
163
));
164
165
- //
166
- //
167
- // $this->addColumn('status', array(
168
- // 'header' => Mage::helper('importer')->__('Status'),
169
- // 'align' => 'left',
170
- // 'width' => '80px',
171
- // 'index' => 'status',
172
- // 'type' => 'options',
173
- // 'options' => array(
174
- // 1 => 'Enabled',
175
- // 2 => 'Disabled',
176
- // ),
177
- // ));
178
- //
179
-
180
$this->addColumn('action',
181
array(
182
'header' => Mage::helper('mailup')->__('Action'),
@@ -189,16 +170,6 @@ class SevenLike_MailUp_Block_Adminhtml_MailUp_Grid extends Mage_Adminhtml_Block_
189
'url' => array('base'=> '*/*/runjob'),
190
'field' => 'id'
191
),
192
- array(
193
- 'caption' => Mage::helper('mailup')->__('StartProcess'),
194
- 'url' => array('base'=> '*/*/startProcess'),
195
- 'field' => 'id'
196
- ),
197
- array(
198
- 'caption' => Mage::helper('mailup')->__('GetProcessDetail'),
199
- 'url' => array('base'=> '*/*/getProcessDetail'),
200
- 'field' => 'id'
201
- ),
202
array(
203
'caption' => Mage::helper('mailup')->__('Delete'),
204
'url' => array('base'=> '*/*/delete'),
@@ -209,31 +180,13 @@ class SevenLike_MailUp_Block_Adminhtml_MailUp_Grid extends Mage_Adminhtml_Block_
209
'sortable' => false,
210
'index' => 'stores',
211
'is_system' => true,
212
));
213
214
215
return parent::_prepareColumns();
216
}
217
218
- // /**
219
- // * Prepare Mass Action
220
- // */
221
- // protected function _prepareMassaction()
222
- // {
223
- // $this->setMassactionIdField('id');
224
- // $this->getMassactionBlock()->setFormFieldName('importer');
225
- //
226
- // $this->getMassactionBlock()->addItem('delete', array(
227
- // 'label' => Mage::helper('importer')->__('Delete'),
228
- // 'url' => $this->getUrl('*/*/massDelete'),
229
- // 'confirm' => Mage::helper('importer')->__('Are you sure?')
230
- // ));
231
- //
232
- // $statuses = Mage::getSingleton('importer/import')->getOptionArray();
233
- // array_unshift($statuses, array('label'=>'', 'value'=>''));
234
- //
235
- // return $this;
236
- // }
237
238
/**
239
* Get row url - None editable
@@ -241,7 +194,6 @@ class SevenLike_MailUp_Block_Adminhtml_MailUp_Grid extends Mage_Adminhtml_Block_
241
public function getRowUrl($row)
242
{
243
return '';
244
- //return $this->getUrl('*/*/edit', array('id' => $row->getId()));
245
}
246
247
}
2
/**
3
* Grid.php
4
*/
5
+ class MailUp_MailUpSync_Block_Adminhtml_MailUp_Grid extends Mage_Adminhtml_Block_Widget_Grid
6
{
7
/**
8
* Constructor
19
/**
20
* Prepare Collection
21
*
22
+ * @return $this
23
*/
24
protected function _prepareCollection()
25
{
26
$collection = Mage::getModel('mailup/job')->getCollection();
27
$this->setCollection($collection);
28
+ // Set default sort to ID by highest to lowest (normally shows most recent first)
29
+ $this->setDefaultSort('id');
30
+ $this->setDefaultDir('desc');
31
32
//var_dump(Mage::getModel('mailup/job')->load(1));
33
67
'options' => Mage::getModel('mailup/source_store')->getSelectOptions(),
68
));
69
70
$this->addColumn('mailupgroupid', array(
71
'header' => Mage::helper('mailup')->__('Mailup Group ID'),
72
//'align' =>'right',
158
//'gmtoffset' => true
159
));
160
161
$this->addColumn('action',
162
array(
163
'header' => Mage::helper('mailup')->__('Action'),
170
'url' => array('base'=> '*/*/runjob'),
171
'field' => 'id'
172
),
173
array(
174
'caption' => Mage::helper('mailup')->__('Delete'),
175
'url' => array('base'=> '*/*/delete'),
180
'sortable' => false,
181
'index' => 'stores',
182
'is_system' => true,
183
+ 'comment' => 'Run a pending or queued job, or delete an existing job'
184
));
185
186
187
return parent::_prepareColumns();
188
}
189
190
191
/**
192
* Get row url - None editable
194
public function getRowUrl($row)
195
{
196
return '';
197
}
198
199
}
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Adminhtml/Mailupbackend.php RENAMED
@@ -2,7 +2,7 @@
2
/**
3
* Mailupbackend.php
4
*/
5
- class SevenLike_MailUp_Block_Adminhtml_Mailupbackend extends Mage_Adminhtml_Block_Widget_Grid_Container
6
{
7
public function __construct()
8
{
2
/**
3
* Mailupbackend.php
4
*/
5
+ class MailUp_MailUpSync_Block_Adminhtml_Mailupbackend extends Mage_Adminhtml_Block_Widget_Grid_Container
6
{
7
public function __construct()
8
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Adminhtml/Sync.php RENAMED
@@ -2,7 +2,7 @@
2
/**
3
* Sync.php
4
*/
5
- class SevenLike_MailUp_Block_Adminhtml_Sync extends Mage_Adminhtml_Block_Widget_Grid_Container
6
{
7
public function __construct()
8
{
2
/**
3
* Sync.php
4
*/
5
+ class MailUp_MailUpSync_Block_Adminhtml_Sync extends Mage_Adminhtml_Block_Widget_Grid_Container
6
{
7
public function __construct()
8
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Adminhtml/Sync/Grid.php RENAMED
@@ -2,7 +2,7 @@
2
/**
3
* Grid.php
4
*/
5
- class SevenLike_MailUp_Block_Adminhtml_Sync_Grid extends Mage_Adminhtml_Block_Widget_Grid
6
{
7
/**
8
* Constructor
@@ -25,8 +25,9 @@ class SevenLike_MailUp_Block_Adminhtml_Sync_Grid extends Mage_Adminhtml_Block_Wi
25
{
26
$collection = Mage::getModel('mailup/sync')->getCollection();
27
$this->setCollection($collection);
28
-
29
- //var_dump(Mage::getModel('mailup/job')->load(1));
30
31
return parent::_prepareCollection();
32
}
@@ -43,8 +44,6 @@ class SevenLike_MailUp_Block_Adminhtml_Sync_Grid extends Mage_Adminhtml_Block_Wi
43
'index' => 'id',
44
));
45
46
-
47
-
48
$this->addColumn('store_id', array(
49
'header' => Mage::helper('mailup')->__('Store'),
50
'align' => 'left',
@@ -54,13 +53,6 @@ class SevenLike_MailUp_Block_Adminhtml_Sync_Grid extends Mage_Adminhtml_Block_Wi
54
'options' => Mage::getModel('mailup/source_store')->getSelectOptions(),
55
));
56
57
- /*$this->addColumn('store_id', array(
58
- 'header' => Mage::helper('mailup')->__('Store ID'),
59
- //'align' =>'right',
60
- 'width' => '80px',
61
- 'index' => 'store_id',
62
- ));*/
63
-
64
$this->addColumn('customer_id', array(
65
'header' => Mage::helper('mailup')->__('Customer ID'),
66
//'align' =>'right',
2
/**
3
* Grid.php
4
*/
5
+ class MailUp_MailUpSync_Block_Adminhtml_Sync_Grid extends Mage_Adminhtml_Block_Widget_Grid
6
{
7
/**
8
* Constructor
25
{
26
$collection = Mage::getModel('mailup/sync')->getCollection();
27
$this->setCollection($collection);
28
+ // Set default sort to ID by highest to lowest (normally shows most recent first)
29
+ $this->setDefaultSort('id');
30
+ $this->setDefaultDir('desc');
31
32
return parent::_prepareCollection();
33
}
44
'index' => 'id',
45
));
46
47
$this->addColumn('store_id', array(
48
'header' => Mage::helper('mailup')->__('Store'),
49
'align' => 'left',
53
'options' => Mage::getModel('mailup/source_store')->getSelectOptions(),
54
));
55
56
$this->addColumn('customer_id', array(
57
'header' => Mage::helper('mailup')->__('Customer ID'),
58
//'align' =>'right',
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Adminhtml/System/Config/Form/Field/Timezone.php RENAMED
@@ -1,6 +1,6 @@
1
<?php
2
3
- class SevenLike_MailUp_Block_Adminhtml_System_Config_Form_Field_Timezone
4
extends Mage_Adminhtml_Block_System_Config_Form_Field
5
{
6
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
1
<?php
2
3
+ class MailUp_MailUpSync_Block_Adminhtml_System_Config_Form_Field_Timezone
4
extends Mage_Adminhtml_Block_System_Config_Form_Field
5
{
6
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
app/code/local/MailUp/MailUpSync/Block/Adminhtml/System/Config/Form/Testbutton.php ADDED
@@ -0,0 +1,35 @@
1
+ <?php
2
+
3
+ /**
4
+ * Self-test button for connection details in system configuration
5
+ */
6
+ class MailUp_MailUpSync_Block_Adminhtml_System_Config_Form_Testbutton
7
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
8
+ {
9
+ /**
10
+ * Return element html
11
+ *
12
+ * @param Varien_Data_Form_Element_Abstract $element
13
+ * @return string
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
16
+ {
17
+ return $this->_toHtml();
18
+ }
19
+
20
+ /**
21
+ * Generate button html
22
+ *
23
+ * @return string
24
+ */
25
+ protected function _toHtml()
26
+ {
27
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
28
+ ->setData(array(
29
+ 'id' => 'mailup_selftest_button',
30
+ 'label' => $this->helper('adminhtml')->__('Test Connection')
31
+ ));
32
+
33
+ return $button->toHtml();
34
+ }
35
+ }
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Checkout/Subscribe.php RENAMED
@@ -2,7 +2,7 @@
2
/**
3
* Subscribe.php
4
*/
5
- class SevenLike_MailUp_Block_Checkout_Subscribe extends Mage_Core_Block_Template
6
{
7
public function _toHtml()
8
{
2
/**
3
* Subscribe.php
4
*/
5
+ class MailUp_MailUpSync_Block_Checkout_Subscribe extends Mage_Core_Block_Template
6
{
7
public function _toHtml()
8
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Filters.php RENAMED
@@ -4,7 +4,7 @@
4
*
5
* Adminhtml block for the filters section
6
*/
7
- class SevenLike_MailUp_Block_Filters extends Mage_Core_Block_Template
8
{
9
public function _toHtml()
10
{
@@ -19,7 +19,7 @@ class SevenLike_MailUp_Block_Filters extends Mage_Core_Block_Template
19
protected function _getStoresArray()
20
{
21
$config = Mage::getModel('mailup/config');
22
- /* @var $config SevenLike_Mailup_Model_Config */
23
return $config->getStoreArray();
24
}
25
}
4
*
5
* Adminhtml block for the filters section
6
*/
7
+ class MailUp_MailUpSync_Block_Filters extends Mage_Core_Block_Template
8
{
9
public function _toHtml()
10
{
19
protected function _getStoresArray()
20
{
21
$config = Mage::getModel('mailup/config');
22
+ /* @var $config MailUp_MailUpSync_Model_Config */
23
return $config->getStoreArray();
24
}
25
}
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Block/Index.php RENAMED
@@ -2,7 +2,7 @@
2
/**
3
* Index.php
4
*/
5
- class SevenLike_MailUp_Block_Index extends Mage_Core_Block_Template
6
{
7
public function _toHtml()
8
{
2
/**
3
* Index.php
4
*/
5
+ class MailUp_MailUpSync_Block_Index extends Mage_Core_Block_Template
6
{
7
public function _toHtml()
8
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Helper/Customer.php RENAMED
@@ -2,7 +2,7 @@
2
/**
3
* Customer helper methods for MailUp
4
*/
5
- class SevenLike_MailUp_Helper_Customer extends Mage_Core_Helper_Abstract
6
{
7
/**
8
* Check whether customer attribute is on ignore list
2
/**
3
* Customer helper methods for MailUp
4
*/
5
+ class MailUp_MailUpSync_Helper_Customer extends Mage_Core_Helper_Abstract
6
{
7
/**
8
* Check whether customer attribute is on ignore list
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Helper/Data.php RENAMED
@@ -1,10 +1,14 @@
1
<?php
2
/**
3
* Data.php
4
*
5
* @todo get rid of these static methods!
6
*/
7
- class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
8
{
9
/**
10
* importType takes one of the following values, varying:
@@ -38,7 +42,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
38
public static function getCustomersData($customerCollection = null)
39
{
40
$config = Mage::getModel('mailup/config');
41
- /* @var $config SevenLike_Mailup_Model_Config */
42
43
if ($config->isLogEnabled()) {
44
$config->log('Getting customers data');
@@ -332,7 +336,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
332
public static function generateAndSendCustomers($mailupCustomerIds, $post = null, $storeId = NULL)
333
{
334
$config = Mage::getModel('mailup/config');
335
- /* @var $config SevenLike_Mailup_Model_Config */
336
337
$wsSend = new MailUpWsSend($storeId);
338
require_once dirname(__FILE__) . "/../Model/MailUpWsImport.php";
@@ -348,7 +352,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
348
349
$jobId = $post['id'];
350
$jobModel = Mage::getModel('mailup/job')->load($post['id']);
351
- /* @var $jobModel SevenLike_Mailup_Model_Job */
352
353
if ($accessKey === false) {
354
Mage::throwException('no access key returned');
@@ -378,6 +382,14 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
378
$groupId = $wsImport->CreaGruppo($newGroup);
379
}
380
381
$importProcessData = array(
382
"idList" => $idList,
383
"listGUID" => $listGUID,
@@ -391,7 +403,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
391
"asOptOut" => 0,
392
"forceOptIn" => 0, // Dangerous to use as this can over-write pending/un-subscribe statuses
393
"replaceGroups" => 0,
394
- "idConfirmNL" => 0
395
);
396
397
$xmlData = '';
@@ -410,15 +422,15 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
410
$importProcessData["xmlDoc"] = "<subscribers>$xmlData</subscribers>";
411
$xmlData = "";
412
$subscribers_counter = 0;
413
- /*if($config->isLogEnabled($storeId)) {
414
Mage::log('ImportProcessData');
415
Mage::log($importProcessData, 0);
416
- }*/
417
$processID = $wsImport->newImportProcess($importProcessData);
418
/**
419
* Failure
420
*/
421
- if($processID === FALSE | $processID < 0) {
422
if($config->isLogEnabled($storeId)) {
423
$config->dbLog(sprintf('newImportProcess [ERROR] [%d]', $processID), $jobId, $storeId);
424
}
@@ -447,7 +459,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
447
"asOptOut" => 0,
448
"forceOptIn" => 0, // Dangerous to use as this can over-write pending/un-subscribe statuses
449
"replaceGroups" => 0,
450
- "idConfirmNL" => 0
451
);
452
453
if ($config->isLogEnabled($storeId)) {
@@ -498,7 +510,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
498
protected static function _getCustomerXml($customerId, $fields_mapping, $storeId)
499
{
500
$config = Mage::getModel('mailup/config');
501
- /* @var $config SevenLike_Mailup_Model_Config */
502
$xmlData = '';
503
$mappedData = array();
504
$subscriber = self::getCustomersData(array($customerId));
@@ -623,7 +635,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
623
public function runJob($jobId)
624
{
625
$config = Mage::getModel('mailup/config');
626
- /* @var $config SevenLike_Mailup_Model_Config */
627
require_once dirname(__FILE__) . '/../Helper/Data.php';
628
$db_read = Mage::getSingleton('core/resource')->getConnection('core_read');
629
$db_write = Mage::getSingleton('core/resource')->getConnection('core_write');
@@ -633,7 +645,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
633
// reading customers (jobid == 0, their updates)
634
$customer_entity_table_name = Mage::getSingleton('core/resource')->getTableName('customer_entity');
635
$jobModel = Mage::getModel('mailup/job')->load($jobId);
636
- /* @var $jobModel SevenLike_MailUp_Model_Job */
637
638
if( ! $jobModel) {
639
throw new Mage_Exception('No Job Exists: ' . $jobId);
@@ -653,7 +665,13 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
653
$job["mailupGroupId"] = $job["mailupgroupid"];
654
$job["send_optin_email_to_new_subscribers"] = $job["send_optin"];
655
656
- $tmp = new SevenLike_MailUp_Model_Lists;
657
$tmp = $tmp->toOptionArray($storeId); // pass store id!
658
foreach ($tmp as $t) {
659
if ($t["value"] == $job['mailupIdList']) {
@@ -679,7 +697,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
679
/**
680
* Send the Data!
681
*/
682
- $returnCode = SevenLike_MailUp_Helper_Data::generateAndSendCustomers($customers, $job, $storeId);
683
/**
684
* Check return OK
685
*/
@@ -934,7 +952,7 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
934
* @param string
935
* @param string
936
*/
937
- public function scheduleTask($when, $type = 'sevenlike_mailup')
938
{
939
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
940
$write->insert(Mage::getSingleton('core/resource')->getTableName('cron_schedule'), array(
@@ -976,4 +994,190 @@ class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract
976
977
return $id;
978
}
979
}
1
<?php
2
+
3
+ require_once dirname(__DIR__) . "/Model/MailUpWsImport.php";
4
+ require_once dirname(__DIR__) . "/Model/Wssend.php";
5
+
6
/**
7
* Data.php
8
*
9
* @todo get rid of these static methods!
10
*/
11
+ class MailUp_MailUpSync_Helper_Data extends Mage_Core_Helper_Abstract
12
{
13
/**
14
* importType takes one of the following values, varying:
42
public static function getCustomersData($customerCollection = null)
43
{
44
$config = Mage::getModel('mailup/config');
45
+ /* @var $config MailUp_MailUpSync_Model_Config */
46
47
if ($config->isLogEnabled()) {
48
$config->log('Getting customers data');
336
public static function generateAndSendCustomers($mailupCustomerIds, $post = null, $storeId = NULL)
337
{
338
$config = Mage::getModel('mailup/config');
339
+ /* @var $config MailUp_MailUpSync_Model_Config */
340
341
$wsSend = new MailUpWsSend($storeId);
342
require_once dirname(__FILE__) . "/../Model/MailUpWsImport.php";
352
353
$jobId = $post['id'];
354
$jobModel = Mage::getModel('mailup/job')->load($post['id']);
355
+ /* @var $jobModel MailUp_MailUpSync_Model_Job */
356
357
if ($accessKey === false) {
358
Mage::throwException('no access key returned');
382
$groupId = $wsImport->CreaGruppo($newGroup);
383
}
384
385
+ // If message_id set, then pass this to define which message is sent to customers
386
+ if (isset($post['message_id']) && $post['message_id'] !== null) {
387
+ $idConfirmNL = $post['message_id'];
388
+ } else {
389
+ // Default to 0 (ignored)
390
+ $idConfirmNL = 0;
391
+ }
392
+
393
$importProcessData = array(
394
"idList" => $idList,
395
"listGUID" => $listGUID,
403
"asOptOut" => 0,
404
"forceOptIn" => 0, // Dangerous to use as this can over-write pending/un-subscribe statuses
405
"replaceGroups" => 0,
406
+ "idConfirmNL" => $idConfirmNL
407
);
408
409
$xmlData = '';
422
$importProcessData["xmlDoc"] = "<subscribers>$xmlData</subscribers>";
423
$xmlData = "";
424
$subscribers_counter = 0;
425
+ if ($config->isLogEnabled($storeId)) {
426
Mage::log('ImportProcessData');
427
Mage::log($importProcessData, 0);
428
+ }
429
$processID = $wsImport->newImportProcess($importProcessData);
430
/**
431
* Failure
432
*/
433
+ if($processID === FALSE || $processID < 0) {
434
if($config->isLogEnabled($storeId)) {
435
$config->dbLog(sprintf('newImportProcess [ERROR] [%d]', $processID), $jobId, $storeId);
436
}
459
"asOptOut" => 0,
460
"forceOptIn" => 0, // Dangerous to use as this can over-write pending/un-subscribe statuses
461
"replaceGroups" => 0,
462
+ "idConfirmNL" => $idConfirmNL
463
);
464
465
if ($config->isLogEnabled($storeId)) {
510
protected static function _getCustomerXml($customerId, $fields_mapping, $storeId)
511
{
512
$config = Mage::getModel('mailup/config');
513
+ /* @var $config MailUp_MailUpSync_Model_Config */
514
$xmlData = '';
515
$mappedData = array();
516
$subscriber = self::getCustomersData(array($customerId));
635
public function runJob($jobId)
636
{
637
$config = Mage::getModel('mailup/config');
638
+ /* @var $config MailUp_MailUpSync_Model_Config */
639
require_once dirname(__FILE__) . '/../Helper/Data.php';
640
$db_read = Mage::getSingleton('core/resource')->getConnection('core_read');
641
$db_write = Mage::getSingleton('core/resource')->getConnection('core_write');
645
// reading customers (jobid == 0, their updates)
646
$customer_entity_table_name = Mage::getSingleton('core/resource')->getTableName('customer_entity');
647
$jobModel = Mage::getModel('mailup/job')->load($jobId);
648
+ /* @var $jobModel MailUp_MailUpSync_Model_Job */
649
650
if( ! $jobModel) {
651
throw new Mage_Exception('No Job Exists: ' . $jobId);
665
$job["mailupGroupId"] = $job["mailupgroupid"];
666
$job["send_optin_email_to_new_subscribers"] = $job["send_optin"];
667
668
+ // If group is 0 and there is a default group, set group to this group
669
+ $defaultGroupId = Mage::getStoreConfig('mailup_newsletter/mailup/default_group');
670
+ if ($job["mailupGroupId"] == 0 && $defaultGroupId !== null) {
671
+ $job["mailupGroupId"] = $defaultGroupId;
672
+ }
673
+
674
+ $tmp = Mage::getSingleton('mailup/source_lists');
675
$tmp = $tmp->toOptionArray($storeId); // pass store id!
676
foreach ($tmp as $t) {
677
if ($t["value"] == $job['mailupIdList']) {
697
/**
698
* Send the Data!
699
*/
700
+ $returnCode = MailUp_MailUpSync_Helper_Data::generateAndSendCustomers($customers, $job, $storeId);
701
/**
702
* Check return OK
703
*/
952
* @param string
953
* @param string
954
*/
955
+ public function scheduleTask($when, $type = 'MailUp_MailUpSync')
956
{
957
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
958
$write->insert(Mage::getSingleton('core/resource')->getTableName('cron_schedule'), array(
994
995
return $id;
996
}
997
+
998
+ /**
999
+ * Get ListGuid (Alphanumeric code associated to a distribution list) for given list
1000
+ *
1001
+ * @param $listId
1002
+ * @return false|string
1003
+ */
1004
+ public function getListGuid($listId)
1005
+ {
1006
+ $wsImport = new MailUpWsImport();
1007
+ $xmlString = $wsImport->GetNlList();
1008
+ if (!$xmlString) return $this;
1009
+
1010
+ $xmlString = html_entity_decode($xmlString);
1011
+ $startLists = strpos($xmlString, '<Lists>');
1012
+ $endPos = strpos($xmlString, '</Lists>');
1013
+ $endLists = $endPos + strlen('</Lists>') - $startLists;
1014
+ $xmlLists = substr($xmlString, $startLists, $endLists);
1015
+ $xmlLists = str_replace("&", "&amp;", $xmlLists);
1016
+ $xml = simplexml_load_string($xmlLists);
1017
+
1018
+ $listGUID = false;
1019
+ foreach ($xml->List as $list) {
1020
+ if ($list['idList'] == $listId) {
1021
+ $listGUID = $list["listGUID"];
1022
+ break;
1023
+ }
1024
+ }
1025
+
1026
+ return $listGUID;
1027
+ }
1028
+
1029
+ /**
1030
+ * Clear the abandonment id, date etc. for customer with given email address
1031
+ *
1032
+ * @param $email
1033
+ */
1034
+ public function clearAbandonmentFields($email)
1035
+ {
1036
+ // Fields to be set
1037
+ $fields = array(
1038
+ 'campo22' => '0', // LatestAbandonedCartID
1039
+ 'campo21' => '0', // LatestAbandonedCartDate
1040
+ 'campo20' => '0' // LatestAbandonedCartTotal
1041
+ );
1042
+
1043
+ // Gather list parameters
1044
+ $console = Mage::getStoreConfig('mailup_newsletter/mailup/url_console');
1045
+ $listId = Mage::getStoreConfig('mailup_newsletter/mailup/list');
1046
+ $listGUID = $this->getListGuid($listId);
1047
+
1048
+ // Set endpoint of API
1049
+ $ws = "http://{$console}/frontend/XmlUpdSubscriber.aspx";
1050
+
1051
+ // Add parameters to request
1052
+ $ws .= "?ListGuid=" . rawurlencode($listGUID);
1053
+ $ws .= "&List=" . rawurlencode($listId);
1054
+ $ws .= "&Email=" . rawurlencode($email);
1055
+ $ws .= "&csvFldNames=" . join(';', array_keys($fields));
1056
+ $ws .= "&csvFldValues=" . join(';', array_values($fields));
1057
+
1058
+ // Make request
1059
+ try {
1060
+ if(Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
1061
+ Mage::log("Cancelling abandonment: $ws");
1062
+ }
1063
+ $result = @file_get_contents($ws);
1064
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
1065
+ Mage::log("Cancelling abandonment result: $result");
1066
+ }
1067
+ } catch (Exception $e) {
1068
+ Mage::logException($e);
1069
+ }
1070
+ }
1071
+
1072
+ /**
1073
+ * Test all MailUp Connection details
1074
+ *
1075
+ * @param $urlConsole
1076
+ * @param $usernameWs
1077
+ * @param $passwordWs
1078
+ * @param $storeId
1079
+ * @return array Return array of messages (success or errors)
1080
+ */
1081
+ public function testConnection($urlConsole, $usernameWs, $passwordWs, $storeId)
1082
+ {
1083
+ $messages = array();
1084
+
1085
+ // Run test for url console
1086
+ if ($this->_testConnectionConsole($urlConsole) === false) {
1087
+ $messages[] = array(
1088
+ 'message' => $this->__('Error in console URL'),
1089
+ 'type' => 'error'
1090
+ );
1091
+ }
1092
+ // Run test for username and password
1093
+ if ($this->_testConnectionUserPassword($usernameWs, $passwordWs, $storeId) === false) {
1094
+ $messages[] = array(
1095
+ 'message' => $this->__('Error in username / password'),
1096
+ 'type' => 'error'
1097
+ );
1098
+ }
1099
+
1100
+ if (empty($messages)) {
1101
+ $messages[] = array(
1102
+ 'message' => $this->__('Success! Connection established with MailUp with given details'),
1103
+ 'type' => 'success'
1104
+ );
1105
+ }
1106
+
1107
+ return $messages;
1108
+ }
1109
+
1110
+ /**
1111
+ * Test configuration for common issues
1112
+ *
1113
+ * @return array Return array of messages (warnings)
1114
+ */
1115
+ public function testConfig()
1116
+ {
1117
+ $messages = array();
1118
+
1119
+ // Mysql timeout
1120
+ $timeout = ini_get('mysql.connect_timeout');
1121
+ if ($timeout !== false && $timeout < 60) {
1122
+ $messages[] = array(
1123
+ 'message' => $this->__('Config warning: mysql.connect_timeout is %d which is a bit low. ' .
1124
+ 'This may cause intermittent issues when connecting with MailUp. ' .
1125
+ 'Please contact your Web host to discuss an increase in the timeout setting.', $timeout),
1126
+ 'type' => 'warning'
1127
+ );
1128
+ }
1129
+
1130
+ return $messages;
1131
+ }
1132
+
1133
+ /**
1134
+ * Test the URL console address by making an http call
1135
+ *
1136
+ * @param $urlConsole
1137
+ * @return bool
1138
+ */
1139
+ protected function _testConnectionConsole($urlConsole)
1140
+ {
1141
+ // Set endpoint of API
1142
+ $ws = "http://{$urlConsole}/frontend/Xmlchksubscriber.aspx";
1143
+
1144
+ // Add parameters to request
1145
+ $ws .= "?ListGuid=" . rawurlencode('e347gh87347gh374hg34');
1146
+ $ws .= "&List=" . rawurlencode(1);
1147
+ $ws .= "&Email=" . rawurlencode('logintest@test.com');
1148
+
1149
+ // Make request
1150
+ $result = '';
1151
+ try {
1152
+ if(Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
1153
+ Mage::log("Testing Connection - console: $ws");
1154
+ }
1155
+ $result = @file_get_contents($ws);
1156
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
1157
+ Mage::log("Testing Connection - console: $result");
1158
+ }
1159
+ } catch (Exception $e) {
1160
+ Mage::logException($e);
1161
+ }
1162
+
1163
+ // Test that request returns 1 (with an allowance for whitespace)
1164
+ return (preg_match('/^1\s*#x2F;', $result) == 1);
1165
+ }
1166
+
1167
+ /**
1168
+ * Test username and password by making a soap login request
1169
+ *
1170
+ * @param $usernameWs
1171
+ * @param $passwordWs
1172
+ * @param $storeId
1173
+ * @return boolean
1174
+ */
1175
+ protected function _testConnectionUserPassword($usernameWs, $passwordWs, $storeId)
1176
+ {
1177
+ $wssend = new MailUpWsSend($storeId);
1178
+
1179
+ $loginSuccess = $wssend->loginFromId($usernameWs, $passwordWs);
1180
+
1181
+ return ($loginSuccess !== false);
1182
+ }
1183
}
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Helper/Order.php RENAMED
@@ -2,7 +2,7 @@
2
/**
3
* Order helper methods for MailUp
4
*/
5
- class SevenLike_MailUp_Helper_Order extends Mage_Core_Helper_Abstract
6
{
7
/**
8
* Filter an order collection by status/state depending on MailUp config
2
/**
3
* Order helper methods for MailUp
4
*/
5
+ class MailUp_MailUpSync_Helper_Order extends Mage_Core_Helper_Abstract
6
{
7
/**
8
* Filter an order collection by status/state depending on MailUp config
app/code/local/MailUp/MailUpSync/Model/.DS_Store ADDED
Binary file
app/code/local/MailUp/MailUpSync/Model/Adminhtml/.DS_Store ADDED
Binary file
app/code/local/MailUp/MailUpSync/Model/Adminhtml/System/.DS_Store ADDED
Binary file
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Adminhtml/System/Clone/Mappings/Custom.php RENAMED
@@ -4,9 +4,9 @@
4
* Provide clone model that specifies custom customer attributes as prefixes to be
5
* cloned from single original field
6
*
7
- * Class SevenLike_MailUp_Model_Adminhtml_System_Clone_Mappings_Custom
8
*/
9
- class SevenLike_MailUp_Model_Adminhtml_System_Clone_Mappings_Custom
10
extends Mage_Core_Model_Config_Data
11
{
12
/**
4
* Provide clone model that specifies custom customer attributes as prefixes to be
5
* cloned from single original field
6
*
7
+ * Class MailUp_MailUpSync_Model_Adminhtml_System_Clone_Mappings_Custom
8
*/
9
+ class MailUp_MailUpSync_Model_Adminhtml_System_Clone_Mappings_Custom
10
extends Mage_Core_Model_Config_Data
11
{
12
/**
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Adminhtml/System/Source/Cron/Frequency.php RENAMED
@@ -1,6 +1,6 @@
1
<?php
2
3
- class SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency
4
{
5
const HOURLY = 0;
6
const EVERY_2_HOURS = 1;
@@ -10,7 +10,7 @@ class SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency
10
11
/**
12
* Get the frequency in hours given a frequency index such as
13
- * SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_2_HOURS
14
*
15
* @param int $frequencyIndex
16
* @return null|int
1
<?php
2
3
+ class MailUp_MailUpSync_Model_Adminhtml_System_Source_Cron_Frequency
4
{
5
const HOURLY = 0;
6
const EVERY_2_HOURS = 1;
10
11
/**
12
* Get the frequency in hours given a frequency index such as
13
+ * MailUp_MailUpSync_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_2_HOURS
14
*
15
* @param int $frequencyIndex
16
* @return null|int
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Adminhtml/System/Source/Cron/Hours.php RENAMED
@@ -1,6 +1,6 @@
1
<?php
2
3
- class SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Hours
4
{
5
/**
6
* Fetch options array
1
<?php
2
3
+ class MailUp_MailUpSync_Model_Adminhtml_System_Source_Cron_Hours
4
{
5
/**
6
* Fetch options array
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Adminhtml/System/Source/Fields.php RENAMED
@@ -1,7 +1,7 @@
1
<?php
2
3
/**
4
- * Class SevenLike_MailUp_Model_Adminhtml_System_Source_Fields
5
*
6
* Cached MailUp recipient fields fetched via API
7
*
@@ -9,7 +9,7 @@
9
* - Within one instantiation of magento, store options in the object
10
* - Magento's cache is used for up to 10 minutes to save hitting the API too often
11
*/
12
- class SevenLike_MailUp_Model_Adminhtml_System_Source_Fields
13
{
14
const CACHE_LIFETIME = 600; // 10 min
15
1
<?php
2
3
/**
4
+ * Class MailUp_MailUpSync_Model_Adminhtml_System_Source_Fields
5
*
6
* Cached MailUp recipient fields fetched via API
7
*
9
* - Within one instantiation of magento, store options in the object
10
* - Magento's cache is used for up to 10 minutes to save hitting the API too often
11
*/
12
+ class MailUp_MailUpSync_Model_Adminhtml_System_Source_Fields
13
{
14
const CACHE_LIFETIME = 600; // 10 min
15
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Config.php RENAMED
@@ -4,7 +4,7 @@
4
*
5
* Central config model
6
*/
7
- class SevenLike_MailUp_Model_Config
8
{
9
const XML_CONSOLE = 'mailup_newsletter/mailup/url_console';
10
const XML_LOG_ENABLE = 'mailup_newsletter/mailup/enable_log';
@@ -12,6 +12,7 @@ class SevenLike_MailUp_Model_Config
12
const XML_MAILUP_USERNAME = 'mailup_newsletter/mailup/username_ws';
13
const XML_MAILUP_PASSWORD = 'mailup_newsletter/mailup/password_ws';
14
const XML_MAILUP_LIST_ID = 'mailup_newsletter/mailup/list';
15
const XML_SUBSCRIBE_IN_CHECKOUT = 'mailup_newsletter/mailup/enable_subscribe_in_checkout';
16
const XML_REQ_SUBSCRIPTION_CONF = 'mailup_newsletter/mailup/require_subscription_confirmation';
17
const XML_CRON_FREQ = 'mailup_newsletter/mailup/mailup_cron_frequency';
@@ -111,7 +112,7 @@ class SevenLike_MailUp_Model_Config
111
}
112
113
$log = Mage::getModel('mailup/log');
114
- /* @var $log SevenLike_MailUp_Model_Log */
115
$log->setData(array(
116
'store_id' => $storeId,
117
'job_id' => $jobId,
@@ -183,6 +184,17 @@ class SevenLike_MailUp_Model_Config
183
{
184
return Mage::getStoreConfig(self::XML_MAILUP_LIST_ID, $storeId);
185
}
186
187
/**
188
* Get the username from Config
4
*
5
* Central config model
6
*/
7
+ class MailUp_MailUpSync_Model_Config
8
{
9
const XML_CONSOLE = 'mailup_newsletter/mailup/url_console';
10
const XML_LOG_ENABLE = 'mailup_newsletter/mailup/enable_log';
12
const XML_MAILUP_USERNAME = 'mailup_newsletter/mailup/username_ws';
13
const XML_MAILUP_PASSWORD = 'mailup_newsletter/mailup/password_ws';
14
const XML_MAILUP_LIST_ID = 'mailup_newsletter/mailup/list';
15
+ const XML_MAILUP_DEFAULT_GROUP_ID = 'mailup_newsletter/mailup/default_group';
16
const XML_SUBSCRIBE_IN_CHECKOUT = 'mailup_newsletter/mailup/enable_subscribe_in_checkout';
17
const XML_REQ_SUBSCRIPTION_CONF = 'mailup_newsletter/mailup/require_subscription_confirmation';
18
const XML_CRON_FREQ = 'mailup_newsletter/mailup/mailup_cron_frequency';
112
}
113
114
$log = Mage::getModel('mailup/log');
115
+ /* @var $log MailUp_MailUpSync_Model_Log */
116
$log->setData(array(
117
'store_id' => $storeId,
118
'job_id' => $jobId,
184
{
185
return Mage::getStoreConfig(self::XML_MAILUP_LIST_ID, $storeId);
186
}
187
+
188
+ /**
189
+ * Get the default Group ID
190
+ *
191
+ * @param int
192
+ * @return int
193
+ */
194
+ public function getMailupDefaultGroupId($storeId = NULL)
195
+ {
196
+ return Mage::getStoreConfig(self::XML_MAILUP_DEFAULT_GROUP_ID, $storeId);
197
+ }
198
199
/**
200
* Get the username from Config
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Consoleurlvalidator.php RENAMED
@@ -1,6 +1,6 @@
1
<?php
2
3
- class SevenLike_MailUp_Model_Consoleurlvalidator extends Mage_Core_Model_Config_Data
4
{
5
public function save()
6
{
1
<?php
2
3
+ class MailUp_MailUpSync_Model_Consoleurlvalidator extends Mage_Core_Model_Config_Data
4
{
5
public function save()
6
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Cron.php RENAMED
@@ -7,7 +7,7 @@
7
require_once dirname(__FILE__) . "/MailUpWsImport.php";
8
require_once dirname(__FILE__) . "/Wssend.php";
9
10
- class SevenLike_MailUp_Model_Cron
11
{
12
/**
13
* Run the Task
@@ -48,7 +48,7 @@ class SevenLike_MailUp_Model_Cron
48
* Now Handle Jobs we need to Sync, and all customers attached to each job
49
*/
50
foreach(Mage::getModel('mailup/job')->fetchQueuedJobsCollection() as $jobModel) {
51
- /* @var $jobModel SevenLike_MailUp_Model_Job */
52
$job = $jobModel->getData();
53
$stmt = $db_write->query(
54
"UPDATE {$jobsTableName}
@@ -62,8 +62,14 @@ class SevenLike_MailUp_Model_Cron
62
$job['mailupIdList'] = Mage::getStoreConfig('mailup_newsletter/mailup/list', $storeId);
63
$job["mailupGroupId"] = $job["mailupgroupid"];
64
$job["send_optin_email_to_new_subscribers"] = $job["send_optin"];
65
66
- $tmp = new SevenLike_MailUp_Model_Lists;
67
$tmp = $tmp->toOptionArray($storeId); // pass store id!
68
foreach ($tmp as $t) {
69
if ($t["value"] == $job['mailupIdList']) {
@@ -89,7 +95,7 @@ class SevenLike_MailUp_Model_Cron
89
/**
90
* Send the Data!
91
*/
92
- $returnCode = SevenLike_MailUp_Helper_Data::generateAndSendCustomers($customers, $job, $storeId);
93
/**
94
* Check return OK
95
*/
@@ -136,7 +142,7 @@ class SevenLike_MailUp_Model_Cron
136
{
137
// Only run Auto Sync Jobs
138
$job = Mage::getModel('mailup/job');
139
- /* @var $job SevenLike_MailUp_Model_Job */
140
141
foreach($job->fetchAutoSyncQueuedJobsCollection() as $job) {
142
@@ -151,7 +157,7 @@ class SevenLike_MailUp_Model_Cron
151
// Only run Auto Sync Jobs
152
153
$job = Mage::getModel('mailup/job');
154
- /* @var $job SevenLike_MailUp_Model_Job */
155
156
foreach($job->fetchManualSyncQueuedJobsCollection() as $job) {
157
@@ -164,9 +170,9 @@ class SevenLike_MailUp_Model_Cron
164
public function startNextJob()
165
{
166
$jobModel = Mage::getModel('mailup/job');
167
- /* @var $jobModel SevenLike_MailUp_Model_Job */
168
foreach($jobModel->fetchQueuedJobsCollection() as $job) {
169
- /* @var $job SevenLike_MailUp_Model_Job */
170
171
/**
172
* Try and Start it... if it fails, we can try the next one!
@@ -193,14 +199,14 @@ class SevenLike_MailUp_Model_Cron
193
}
194
195
/**
196
- * @var SevenLike_MailUp_Model_Config
197
*/
198
protected $_config;
199
200
/**
201
* Get the config
202
*
203
- * @reutrn SevenLike_MailUp_Model_Config
204
*/
205
protected function _config()
206
{
7
require_once dirname(__FILE__) . "/MailUpWsImport.php";
8
require_once dirname(__FILE__) . "/Wssend.php";
9
10
+ class MailUp_MailUpSync_Model_Cron
11
{
12
/**
13
* Run the Task
48
* Now Handle Jobs we need to Sync, and all customers attached to each job
49
*/
50
foreach(Mage::getModel('mailup/job')->fetchQueuedJobsCollection() as $jobModel) {
51
+ /* @var $jobModel MailUp_MailUpSync_Model_Job */
52
$job = $jobModel->getData();
53
$stmt = $db_write->query(
54
"UPDATE {$jobsTableName}
62
$job['mailupIdList'] = Mage::getStoreConfig('mailup_newsletter/mailup/list', $storeId);
63
$job["mailupGroupId"] = $job["mailupgroupid"];
64
$job["send_optin_email_to_new_subscribers"] = $job["send_optin"];
65
+
66
+ // If group is 0 and there is a default group, set group to this group
67
+ $defaultGroupId = Mage::getStoreConfig('mailup_newsletter/mailup/default_group');
68
+ if ($job["mailupGroupId"] == 0 && $defaultGroupId !== null) {
69
+ $job["mailupGroupId"] = $defaultGroupId;
70
+ }
71
72
+ $tmp = Mage::getSingleton('mailup/source_lists');
73
$tmp = $tmp->toOptionArray($storeId); // pass store id!
74
foreach ($tmp as $t) {
75
if ($t["value"] == $job['mailupIdList']) {
95
/**
96
* Send the Data!
97
*/
98
+ $returnCode = MailUp_MailUpSync_Helper_Data::generateAndSendCustomers($customers, $job, $storeId);
99
/**
100
* Check return OK
101
*/
142
{
143
// Only run Auto Sync Jobs
144
$job = Mage::getModel('mailup/job');
145
+ /* @var $job MailUp_MailUpSync_Model_Job */
146
147
foreach($job->fetchAutoSyncQueuedJobsCollection() as $job) {
148
157
// Only run Auto Sync Jobs
158
159
$job = Mage::getModel('mailup/job');
160
+ /* @var $job MailUp_MailUpSync_Model_Job */
161
162
foreach($job->fetchManualSyncQueuedJobsCollection() as $job) {
163
170
public function startNextJob()
171
{
172
$jobModel = Mage::getModel('mailup/job');
173
+ /* @var $jobModel MailUp_MailUpSync_Model_Job */
174
foreach($jobModel->fetchQueuedJobsCollection() as $job) {
175
+ /* @var $job MailUp_MailUpSync_Model_Job */
176
177
/**
178
* Try and Start it... if it fails, we can try the next one!
199
}
200
201
/**
202
+ * @var MailUp_MailUpSync_Model_Config
203
*/
204
protected $_config;
205
206
/**
207
* Get the config
208
*
209
+ * @reutrn MailUp_MailUpSync_Model_Config
210
*/
211
protected function _config()
212
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Job.php RENAMED
@@ -17,8 +17,9 @@
17
* @method void setQueueDatetime(string $dateTime) Set the Datetime the job was queued.
18
* @method void setStartDatetime(string $dateTime) Set when the job was started
19
* @method void setFinishDatetime(string $dateTime) Set when the job was finished / completed
20
*/
21
- class SevenLike_MailUp_Model_Job extends Mage_Core_Model_Abstract
22
{
23
const STATUS_FINISHED = 'finished';
24
const STATUS_QUEUED = 'queued';
@@ -54,7 +55,7 @@ class SevenLike_MailUp_Model_Job extends Mage_Core_Model_Abstract
54
/**
55
* Mark as finished
56
*
57
- * @return \SevenLike_MailUp_Model_Job
58
*/
59
public function finished()
60
{
@@ -67,7 +68,7 @@ class SevenLike_MailUp_Model_Job extends Mage_Core_Model_Abstract
67
/**
68
* Mark as Queued
69
*
70
- * @return \SevenLike_MailUp_Model_Job
71
*/
72
public function queue()
73
{
@@ -116,12 +117,12 @@ class SevenLike_MailUp_Model_Job extends Mage_Core_Model_Abstract
116
* Get a collection of jobs in the Queue
117
*
118
* @param int
119
- * @return SevenLike_MailUp_Model_Mysql4_Job_Collection
120
*/
121
public function fetchQueuedJobsCollection($type = NULL)
122
{
123
$collection = $this->getCollection();
124
- /* @var $collection SevenLike_MailUp_Model_Mysql4_Job_Collection */
125
$collection
126
->addFieldToSelect('*')
127
->addFieldToFilter('status', array('eq' => self::STATUS_QUEUED))
@@ -137,7 +138,7 @@ class SevenLike_MailUp_Model_Job extends Mage_Core_Model_Abstract
137
/**
138
* Get a collection of jobs in the Queue
139
*
140
- * @return SevenLike_MailUp_Model_Mysql4_Job_Collection
141
*/
142
public function fetchManualSyncQueuedJobsCollection()
143
{
@@ -147,7 +148,7 @@ class SevenLike_MailUp_Model_Job extends Mage_Core_Model_Abstract
147
/**
148
* Get a collection of jobs in the Queue
149
*
150
- * @return SevenLike_MailUp_Model_Mysql4_Job_Collection
151
*/
152
public function fetchAutoSyncQueuedJobsCollection()
153
{
@@ -162,7 +163,7 @@ class SevenLike_MailUp_Model_Job extends Mage_Core_Model_Abstract
162
public function getJobData()
163
{
164
$jobTasks = Mage::getModel('mailup/sync');
165
- /* @var $jobTasks SevenLike_MailUp_Model_Sync */
166
return $jobTasks->fetchByJobId($this->getId());
167
}
168
17
* @method void setQueueDatetime(string $dateTime) Set the Datetime the job was queued.
18
* @method void setStartDatetime(string $dateTime) Set when the job was started
19
* @method void setFinishDatetime(string $dateTime) Set when the job was finished / completed
20
+ * @method void setMethodId(int $methodId) Set a messageId to use for subscribed customers
21
*/
22
+ class MailUp_MailUpSync_Model_Job extends Mage_Core_Model_Abstract
23
{
24
const STATUS_FINISHED = 'finished';
25
const STATUS_QUEUED = 'queued';
55
/**
56
* Mark as finished
57
*
58
+ * @return \MailUp_MailUpSync_Model_Job
59
*/
60
public function finished()
61
{
68
/**
69
* Mark as Queued
70
*
71
+ * @return \MailUp_MailUpSync_Model_Job
72
*/
73
public function queue()
74
{
117
* Get a collection of jobs in the Queue
118
*
119
* @param int
120
+ * @return MailUp_MailUpSync_Model_Mysql4_Job_Collection
121
*/
122
public function fetchQueuedJobsCollection($type = NULL)
123
{
124
$collection = $this->getCollection();
125
+ /* @var $collection MailUp_MailUpSync_Model_Mysql4_Job_Collection */
126
$collection
127
->addFieldToSelect('*')
128
->addFieldToFilter('status', array('eq' => self::STATUS_QUEUED))
138
/**
139
* Get a collection of jobs in the Queue
140
*
141
+ * @return MailUp_MailUpSync_Model_Mysql4_Job_Collection
142
*/
143
public function fetchManualSyncQueuedJobsCollection()
144
{
148
/**
149
* Get a collection of jobs in the Queue
150
*
151
+ * @return MailUp_MailUpSync_Model_Mysql4_Job_Collection
152
*/
153
public function fetchAutoSyncQueuedJobsCollection()
154
{
163
public function getJobData()
164
{
165
$jobTasks = Mage::getModel('mailup/sync');
166
+ /* @var $jobTasks MailUp_MailUpSync_Model_Sync */
167
return $jobTasks->fetchByJobId($this->getId());
168
}
169
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Log.php RENAMED
@@ -2,7 +2,7 @@
2
/**
3
* Log.php
4
*/
5
- class SevenLike_MailUp_Model_Log extends Mage_Core_Model_Abstract
6
{
7
const TYPE_DEBUG = 'DEBUG';
8
const TYPE_API = 'API';
2
/**
3
* Log.php
4
*/
5
+ class MailUp_MailUpSync_Model_Log extends Mage_Core_Model_Abstract
6
{
7
const TYPE_DEBUG = 'DEBUG';
8
const TYPE_API = 'API';
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/MailUp.php RENAMED
@@ -1,6 +1,6 @@
1
<?php
2
3
- class SevenLike_MailUp_Model_MailUp extends Mage_Core_Model_Abstract
4
{
5
public function _construct()
6
{
1
<?php
2
3
+ class MailUp_MailUpSync_Model_MailUp extends Mage_Core_Model_Abstract
4
{
5
public function _construct()
6
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/MailUpWsImport.php RENAMED
@@ -58,7 +58,7 @@ class MailUpWsImport
58
*/
59
protected $domResult;
60
/**
61
- * @var SevenLike_Mailup_Model_Config
62
*/
63
protected $_config;
64
/**
@@ -74,7 +74,7 @@ class MailUpWsImport
74
$this->setStoreId($storeId);
75
76
$this->_config = $config = Mage::getModel('mailup/config');
77
- /* @var $config SevenLike_Mailup_Model_Config */
78
79
$urlConsole = Mage::getStoreConfig('mailup_newsletter/mailup/url_console', $this->storeId);
80
$WSDLUrl = 'http://'. $urlConsole .'/services/WSMailUpImport.asmx?WSDL';
@@ -534,23 +534,26 @@ class MailUpWsImport
534
'eq' => $storeId
535
));
536
}
537
- /*else {
538
- $customerCollection->addAttributeToFilter('store_id', array(
539
- 'eq' => Mage::app()->getDefaultStoreView()->getStoreId()
540
- ));
541
- }*/
542
$customerCollection = $customerCollection->getSelect()->query();
543
544
while ($row = $customerCollection->fetch()) {
545
$customersFiltered[] = $row;
546
}
547
548
- //se richiesto, seleziono solo quelli iscritti alla newsletter di Magento
549
if ($request->getRequest()->getParam('mailupSubscribed') > 0) {
550
$tempSubscribed = array();
551
foreach ($customersFiltered as $customer) {
552
$customerItem = Mage::getModel('customer/customer')->load($customer['entity_id']);
553
- if (Mage::getModel('newsletter/subscriber')->loadByCustomer($customerItem)->isSubscribed()) {
554
$tempSubscribed[] = $customer;
555
}
556
}
@@ -1085,7 +1088,7 @@ class MailUpWsImport
1085
public function getFieldsMapping($storeId = NULL)
1086
{
1087
$config = Mage::getModel('mailup/config');
1088
- /* @var $config SevenLike_Mailup_Model_Config */
1089
return $config->getFieldsMapping($storeId);
1090
}
1091
@@ -1114,7 +1117,7 @@ class MailUpWsImport
1114
/**
1115
* Get the config
1116
*
1117
- * @return SevenLike_Mailup_Model_Config
1118
*/
1119
protected function _config()
1120
{
58
*/
59
protected $domResult;
60
/**
61
+ * @var MailUp_MailUpSync_Model_Config
62
*/
63
protected $_config;
64
/**
74
$this->setStoreId($storeId);
75
76
$this->_config = $config = Mage::getModel('mailup/config');
77
+ /* @var $config MailUp_MailUpSync_Model_Config */
78
79
$urlConsole = Mage::getStoreConfig('mailup_newsletter/mailup/url_console', $this->storeId);
80
$WSDLUrl = 'http://'. $urlConsole .'/services/WSMailUpImport.asmx?WSDL';
534
'eq' => $storeId
535
));
536
}
537
$customerCollection = $customerCollection->getSelect()->query();
538
539
while ($row = $customerCollection->fetch()) {
540
$customersFiltered[] = $row;
541
}
542
543
+ // if required, select only those that are (or are not) subscribed in Magento
544
if ($request->getRequest()->getParam('mailupSubscribed') > 0) {
545
+ // Base status on option (1 -> must be subscribed. 2 -> must NOT be subscribed
546
+ if ($request->getRequest()->getParam('mailupSubscribed') == 1) {
547
+ $expectedStatus = true;
548
+ } else {
549
+ $expectedStatus = false;
550
+ }
551
+ // Filter list of customers by expected subscription status
552
$tempSubscribed = array();
553
foreach ($customersFiltered as $customer) {
554
$customerItem = Mage::getModel('customer/customer')->load($customer['entity_id']);
555
+ $subscriptionStatus = Mage::getModel('newsletter/subscriber')->loadByCustomer($customerItem)->isSubscribed();
556
+ if ($subscriptionStatus === $expectedStatus) {
557
$tempSubscribed[] = $customer;
558
}
559
}
1088
public function getFieldsMapping($storeId = NULL)
1089
{
1090
$config = Mage::getModel('mailup/config');
1091
+ /* @var $config MailUp_MailUpSync_Model_Config */
1092
return $config->getFieldsMapping($storeId);
1093
}
1094
1117
/**
1118
* Get the config
1119
*
1120
+ * @return MailUp_MailUpSync_Model_Config
1121
*/
1122
protected function _config()
1123
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Mysql14/MailUp.php RENAMED
@@ -1,6 +1,6 @@
1
<?php
2
3
- class SevenLike_MailUp_Model_Mysql4_MailUp extends Mage_Core_Model_Mysql4_Abstract
4
{
5
public function _construct()
6
{
1
<?php
2
3
+ class MailUp_MailUpSync_Model_Mysql4_MailUp extends Mage_Core_Model_Mysql4_Abstract
4
{
5
public function _construct()
6
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Mysql14/MailUp/Collection.php RENAMED
@@ -1,6 +1,6 @@
1
<?php
2
3
- class SevenLike_MailUp_Model_Mysql4_MailUp_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
{
5
public function _construct()
6
{
1
<?php
2
3
+ class MailUp_MailUpSync_Model_Mysql4_MailUp_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
{
5
public function _construct()
6
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Mysql4/Job.php RENAMED
@@ -2,7 +2,7 @@
2
/**
3
* Job.php
4
*/
5
- class SevenLike_MailUp_Model_Mysql4_Job extends Mage_Core_Model_Mysql4_Abstract
6
{
7
protected function _construct()
8
{
2
/**
3
* Job.php
4
*/
5
+ class MailUp_MailUpSync_Model_Mysql4_Job extends Mage_Core_Model_Mysql4_Abstract
6
{
7
protected function _construct()
8
{
app/code/local/{SevenLike/MailUp/Model/Mysql4/Sync → MailUp/MailUpSync/Model/Mysql4/Job}/Collection.php RENAMED
@@ -2,10 +2,10 @@
2
/**
3
* Collection.php
4
*/
5
- class SevenLike_MailUp_Model_Mysql4_Sync_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
6
{
7
public function _construct()
8
{
9
- $this->_init("mailup/sync");
10
}
11
}
2
/**
3
* Collection.php
4
*/
5
+ class MailUp_MailUpSync_Model_Mysql4_Job_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
6
{
7
public function _construct()
8
{
9
+ $this->_init("mailup/job");
10
}
11
}
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Mysql4/Log.php RENAMED
@@ -11,7 +11,7 @@
11
* @method int getJobId()
12
* @method void setJobId(int $jobId)
13
*/
14
- class SevenLike_MailUp_Model_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract
15
{
16
const TYPE_ERROR = 'ERROR';
17
const TYPE_DEBUG = 'DEBUG';
11
* @method int getJobId()
12
* @method void setJobId(int $jobId)
13
*/
14
+ class MailUp_MailUpSync_Model_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract
15
{
16
const TYPE_ERROR = 'ERROR';
17
const TYPE_DEBUG = 'DEBUG';
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Mysql4/Log/Collection.php RENAMED
@@ -2,7 +2,7 @@
2
/**
3
* Collection.php
4
*/
5
- class SevenLike_MailUp_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
6
{
7
public function _construct()
8
{
2
/**
3
* Collection.php
4
*/
5
+ class MailUp_MailUpSync_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
6
{
7
public function _construct()
8
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Mysql4/Sync.php RENAMED
@@ -2,7 +2,7 @@
2
/**
3
* Job.php
4
*/
5
- class SevenLike_MailUp_Model_Mysql4_Sync extends Mage_Core_Model_Mysql4_Abstract
6
{
7
protected function _construct()
8
{
2
/**
3
* Job.php
4
*/
5
+ class MailUp_MailUpSync_Model_Mysql4_Sync extends Mage_Core_Model_Mysql4_Abstract
6
{
7
protected function _construct()
8
{
app/code/local/MailUp/MailUpSync/Model/Mysql4/Sync/Collection.php ADDED
@@ -0,0 +1,11 @@
1
+ <?php
2
+ /**
3
+ * Collection.php
4
+ */
5
+ class MailUp_MailUpSync_Model_Mysql4_Sync_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
6
+ {
7
+ public function _construct()
8
+ {
9
+ $this->_init("mailup/sync");
10
+ }
11
+ }
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Observer.php RENAMED
@@ -1,13 +1,13 @@
1
<?php
2
3
require_once dirname(__FILE__) . "/MailUpWsImport.php";
4
- require_once dirname(__FILE__) . "/Wssend.php";
5
- class SevenLike_MailUp_Model_Observer
6
{
7
- const CRON_STRING_PATH = 'crontab/jobs/sevenlike_mailup/schedule/cron_expr';
8
9
/**
10
- * @var SevenLike_MailUp_Model_Config
11
*/
12
protected $_config;
13
@@ -22,6 +22,8 @@ class SevenLike_MailUp_Model_Observer
22
*/
23
public function saveSystemConfig($observer)
24
{
25
Mage::getModel('core/config_data')
26
->load(self::CRON_STRING_PATH, 'path')
27
->setValue($this->_getSchedule())
@@ -31,6 +33,44 @@ class SevenLike_MailUp_Model_Observer
31
Mage::app()->cleanCache();
32
33
$this->configCheck();
34
}
35
36
/**
@@ -44,13 +84,13 @@ class SevenLike_MailUp_Model_Observer
44
$data = Mage::app()->getRequest()->getPost('groups');
45
$frequency = !empty($data['mailup']['fields']['mailup_cron_frequency']['value'])?
46
$data['mailup']['fields']['mailup_cron_frequency']['value']:
47
- SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::HOURLY;
48
$offset = !empty($data['mailup']['fields']['mailup_cron_offset']['value'])?
49
$data['mailup']['fields']['mailup_cron_offset']['value']:
50
0;
51
52
// Get period between calls and calculate explicit hours using this and offset
53
- $period = SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::getPeriod($frequency);
54
if ($period === null) {
55
Mage::log("MailUp: Could not find cron frequency in valid list. Defaulted to hourly", Zend_Log::ERR);
56
$period = 1;
@@ -83,7 +123,7 @@ class SevenLike_MailUp_Model_Observer
83
* Observes: customer_customer_authenticated
84
*
85
* @param type $observer
86
- * @return \SevenLike_MailUp_Model_Observer
87
*/
88
public function leggiUtente($observer)
89
{
@@ -180,9 +220,9 @@ class SevenLike_MailUp_Model_Observer
180
*
181
* @see newsletter_subscriber_save_after
182
* @param $observer
183
- * @return \SevenLike_MailUp_Model_Observer
184
*/
185
- public function inviaUtente($observer)
186
{
187
$model = $observer->getEvent()->getDataObject();
188
@@ -229,27 +269,11 @@ class SevenLike_MailUp_Model_Observer
229
230
$console = Mage::getStoreConfig('mailup_newsletter/mailup/url_console');
231
$listId = Mage::getStoreConfig('mailup_newsletter/mailup/list');
232
$confirm = Mage::getStoreConfig('mailup_newsletter/mailup/require_subscription_confirmation');
233
234
try {
235
- $wsImport = new MailUpWsImport();
236
- $xmlString = $wsImport->GetNlList();
237
- if (!$xmlString) return $this;
238
-
239
- $xmlString = html_entity_decode($xmlString);
240
- $startLists = strpos($xmlString, '<Lists>');
241
- $endPos = strpos($xmlString, '</Lists>');
242
- $endLists = $endPos + strlen('</Lists>') - $startLists;
243
- $xmlLists = substr($xmlString, $startLists, $endLists);
244
- $xmlLists = str_replace("&", "&amp;", $xmlLists);
245
- $xml = simplexml_load_string($xmlLists);
246
-
247
- foreach ($xml->List as $list) {
248
- if ($list['idList'] == $listId) {
249
- $listGUID = $list["listGUID"];
250
- break;
251
- }
252
- }
253
if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) Mage::log("STATO ISCRIZIONE: $status");
254
if ($status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED ||
255
$status == Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED) {
@@ -263,6 +287,11 @@ class SevenLike_MailUp_Model_Observer
263
$ws .= "&Email=" . rawurlencode($model->getEmail());
264
$ws .= "&Confirm=" . rawurlencode($confirm);
265
266
try {
267
if(Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
268
Mage::log("mailup invio utente $ws");
@@ -314,16 +343,50 @@ class SevenLike_MailUp_Model_Observer
314
}
315
}
316
317
/**
318
* Subscribe the user, during checkout.
319
- *
320
- * @return void
321
*/
322
- public function subscribeDuringCheckout()
323
{
324
if (isset($_REQUEST["mailup_subscribe2"]) && $_REQUEST["mailup_subscribe2"]) {
325
- $order_id = Mage::getSingleton("checkout/session")->getLastRealOrderId();
326
- $order = Mage::getModel("sales/order")->loadByIncrementId($order_id);
327
try {
328
Mage::getModel("newsletter/subscriber")->subscribe($order->getCustomerEmail());
329
} catch (Exception $e) {}
@@ -407,7 +470,7 @@ class SevenLike_MailUp_Model_Observer
407
*
408
* @param int
409
* @param int
410
- * @return boolean
411
*/
412
private static function setCustomerForDataSync($customerId, $storeId = NULL)
413
{
@@ -424,11 +487,11 @@ class SevenLike_MailUp_Model_Observer
424
}
425
426
$helper = Mage::helper('mailup');
427
- /* @var $helper SevenLike_Mailup_Helper_Data */
428
$config = Mage::getModel('mailup/config');
429
- /* @var $config SevenLike_Mailup_Model_Config */
430
- $lists = Mage::getModel('mailup/lists');
431
- /* @var $lists SevenLike_MailUp_Model_Lists */
432
$listID = $config->getMailupListId($storeId);
433
$listGuid = $lists->getListGuid($listID, $storeId);
434
// If list is not available, then cancel sync
@@ -439,13 +502,13 @@ class SevenLike_MailUp_Model_Observer
439
return false;
440
}
441
$job = Mage::getModel('mailup/job');
442
- /* @var $job SevenLike_MailUp_Model_Job */
443
444
/**
445
* Only Sync if they are a subscriber!
446
*/
447
if ( ! $helper->isSubscriber($customerId, $storeId)) {
448
- return;
449
}
450
451
// Set options for those already subscribed (not pending and no opt-in)
@@ -472,7 +535,7 @@ class SevenLike_MailUp_Model_Observer
472
473
try {
474
$jobTask = Mage::getModel('mailup/sync');
475
- /** @var $jobTask SevenLike_MailUp_Model_Sync */
476
$jobTask->setData(array(
477
'store_id' => $storeId,
478
'customer_id' => $customerId,
@@ -504,7 +567,7 @@ class SevenLike_MailUp_Model_Observer
504
/**
505
* Get the config
506
*
507
- * @reutrn SevenLike_MailUp_Model_Config
508
*/
509
protected function _config()
510
{
1
<?php
2
3
require_once dirname(__FILE__) . "/MailUpWsImport.php";
4
+
5
+ class MailUp_MailUpSync_Model_Observer
6
{
7
+ const CRON_STRING_PATH = 'crontab/jobs/mailup_mailupsync/schedule/cron_expr';
8
9
/**
10
+ * @var MailUp_MailUpSync_Model_Config
11
*/
12
protected $_config;
13
22
*/
23
public function saveSystemConfig($observer)
24
{
25
+ Mage::getSingleton('adminhtml/session')->setMessages(Mage::getModel('core/message_collection'));
26
+
27
Mage::getModel('core/config_data')
28
->load(self::CRON_STRING_PATH, 'path')
29
->setValue($this->_getSchedule())
33
Mage::app()->cleanCache();
34
35
$this->configCheck();
36
+
37
+ // If there are errors in config, do not progress further as it may be testing old data
38
+ $currentMessages = Mage::getSingleton('adminhtml/session')->getMessages();
39
+ foreach ($currentMessages->getItems() as $msg) {
40
+ if ($msg->getType() != 'success') {
41
+ return;
42
+ }
43
+ }
44
+
45
+ $messages = array();
46
+
47
+ // Close connection to avoid mysql gone away errors
48
+ $res = Mage::getSingleton('core/resource');
49
+ $res->getConnection('core_write')->closeConnection();
50
+
51
+ // Test connection
52
+ $storeId = Mage::app()->getStore();
53
+ $urlConsole = Mage::getStoreConfig('mailup_newsletter/mailup/url_console');
54
+ $usernameWs = Mage::getStoreConfig('mailup_newsletter/mailup/username_ws');
55
+ $passwordWs = Mage::getStoreConfig('mailup_newsletter/mailup/password_ws');
56
+ $retConn = Mage::helper('mailup')->testConnection($urlConsole, $usernameWs, $passwordWs, $storeId);
57
+ $messages = array_merge($messages, $retConn);
58
+
59
+ // Config tests
60
+ $retConfig = Mage::helper('mailup')->testConfig();
61
+ $messages = array_merge($messages, $retConfig);
62
+
63
+ // Re-open connection to avoid mysql gone away errors
64
+ $res->getConnection('core_write')->getConnection();
65
+
66
+ // Add messages from test
67
+ if (count($messages) > 0) {
68
+ foreach ($messages as $msg) {
69
+ $msgObj = Mage::getSingleton('core/message')->$msg['type']($msg['message']);
70
+ Mage::getSingleton('adminhtml/session')->addMessage($msgObj);
71
+ }
72
+ }
73
+
74
}
75
76
/**
84
$data = Mage::app()->getRequest()->getPost('groups');
85
$frequency = !empty($data['mailup']['fields']['mailup_cron_frequency']['value'])?
86
$data['mailup']['fields']['mailup_cron_frequency']['value']:
87
+ MailUp_MailUpSync_Model_Adminhtml_System_Source_Cron_Frequency::HOURLY;
88
$offset = !empty($data['mailup']['fields']['mailup_cron_offset']['value'])?
89
$data['mailup']['fields']['mailup_cron_offset']['value']:
90
0;
91
92
// Get period between calls and calculate explicit hours using this and offset
93
+ $period = MailUp_MailUpSync_Model_Adminhtml_System_Source_Cron_Frequency::getPeriod($frequency);
94
if ($period === null) {
95
Mage::log("MailUp: Could not find cron frequency in valid list. Defaulted to hourly", Zend_Log::ERR);
96
$period = 1;
123
* Observes: customer_customer_authenticated
124
*
125
* @param type $observer
126
+ * @return \MailUp_MailUpSync_Model_Observer
127
*/
128
public function leggiUtente($observer)
129
{
220
*
221
* @see newsletter_subscriber_save_after
222
* @param $observer
223
+ * @return \MailUp_MailUpSync_Model_Observer
224
*/
225
+ public function sendUser($observer)
226
{
227
$model = $observer->getEvent()->getDataObject();
228
269
270
$console = Mage::getStoreConfig('mailup_newsletter/mailup/url_console');
271
$listId = Mage::getStoreConfig('mailup_newsletter/mailup/list');
272
+ $defaultGroupId = Mage::getStoreConfig('mailup_newsletter/mailup/default_group');
273
$confirm = Mage::getStoreConfig('mailup_newsletter/mailup/require_subscription_confirmation');
274
275
try {
276
+ $listGUID = Mage::helper('mailup')->getListGuid($listId);
277
if (Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) Mage::log("STATO ISCRIZIONE: $status");
278
if ($status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED ||
279
$status == Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED) {
287
$ws .= "&Email=" . rawurlencode($model->getEmail());
288
$ws .= "&Confirm=" . rawurlencode($confirm);
289
290
+ // If there is a default group defined, use it
291
+ if ($defaultGroupId !== null) {
292
+ $ws .= "&Group=" . rawurlencode($defaultGroupId);
293
+ }
294
+
295
try {
296
if(Mage::getStoreConfig('mailup_newsletter/mailup/enable_log')) {
297
Mage::log("mailup invio utente $ws");
343
}
344
}
345
346
+ /**
347
+ * Called on completion of an order (saved during one-page checkout)
348
+ * NOTE: If another checkout is used, this will not be called!
349
+ */
350
+ public function onCheckoutSaveOrder()
351
+ {
352
+ $order_id = Mage::getSingleton("checkout/session")->getLastRealOrderId();
353
+ $order = Mage::getModel("sales/order")->loadByIncrementId($order_id);
354
+
355
+ $this->clearAbandonment($order);
356
+ $this->subscribeDuringCheckout($order);
357
+ }
358
+
359
+ /**
360
+ * If customer already subscribed, or pending, then set abandoned cart details to null
361
+ *
362
+ * @param Mage_Sales_Model_Order $order
363
+ */
364
+ public function clearAbandonment($order)
365
+ {
366
+ // Get subscriber status
367
+ $email = $order->getCustomerEmail();
368
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
369
+ if ($subscriber === null) {
370
+ return;
371
+ }
372
+ $status = $subscriber->getStatus();
373
+
374
+ // Check status and make API request to clear abandonment fields
375
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED ||
376
+ $status == Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED) {
377
+ Mage::helper("mailup")->clearAbandonmentFields($email);
378
+ }
379
+ }
380
+
381
/**
382
* Subscribe the user, during checkout.
383
+ *
384
+ * @param Mage_Sales_Model_Order $order
385
*/
386
+ public function subscribeDuringCheckout($order)
387
{
388
+ // If subscription option chosen, then subscribe
389
if (isset($_REQUEST["mailup_subscribe2"]) && $_REQUEST["mailup_subscribe2"]) {
390
try {
391
Mage::getModel("newsletter/subscriber")->subscribe($order->getCustomerEmail());
392
} catch (Exception $e) {}
470
*
471
* @param int
472
* @param int
473
+ * @return boolean|null
474
*/
475
private static function setCustomerForDataSync($customerId, $storeId = NULL)
476
{
487
}
488
489
$helper = Mage::helper('mailup');
490
+ /* @var $helper MailUp_MailUpSync_Helper_Data */
491
$config = Mage::getModel('mailup/config');
492
+ /* @var $config MailUp_MailUpSync_Model_Config */
493
+ $lists = Mage::getSingleton('mailup/source_lists');
494
+ /* @var $lists MailUp_MailUpSync_Model_Source_Lists */
495
$listID = $config->getMailupListId($storeId);
496
$listGuid = $lists->getListGuid($listID, $storeId);
497
// If list is not available, then cancel sync
502
return false;
503
}
504
$job = Mage::getModel('mailup/job');
505
+ /* @var $job MailUp_MailUpSync_Model_Job */
506
507
/**
508
* Only Sync if they are a subscriber!
509
*/
510
if ( ! $helper->isSubscriber($customerId, $storeId)) {
511
+ return null;
512
}
513
514
// Set options for those already subscribed (not pending and no opt-in)
535
536
try {
537
$jobTask = Mage::getModel('mailup/sync');
538
+ /** @var $jobTask MailUp_MailUpSync_Model_Sync */
539
$jobTask->setData(array(
540
'store_id' => $storeId,
541
'customer_id' => $customerId,
567
/**
568
* Get the config
569
*
570
+ * @reutrn MailUp_MailUpSync_Model_Config
571
*/
572
protected function _config()
573
{
app/code/local/MailUp/MailUpSync/Model/Source/Groups.php ADDED
@@ -0,0 +1,70 @@
1
+ <?php
2
+ /**
3
+ * Groups
4
+ */
5
+
6
+ /**
7
+ * Source for groups per list
8
+ */
9
+ class MailUp_MailUpSync_Model_Source_Groups
10
+ {
11
+ /**
12
+ * @var array
13
+ */
14
+ protected $_cache = array();
15
+
16
+ /**
17
+ * Get groups as array of options
18
+ *
19
+ * @param int|null $storeId
20
+ * @param int|null $listId
21
+ * @return array
22
+ */
23
+ public function toOptionArray($storeId = null, $listId = null)
24
+ {
25
+ $websiteCode = Mage::app()->getRequest()->getParam('website');
26
+ $storeCode = Mage::app()->getRequest()->getParam('store');
27
+
28
+ // Get store
29
+ if (isset($storeId) && $storeId == false) {
30
+ $storeId = Mage::app()->getStore($storeCode)->getId();
31
+ } elseif ($websiteCode) {
32
+ $storeId = Mage::app()
33
+ ->getWebsite($websiteCode)
34
+ ->getDefaultGroup()
35
+ ->getDefaultStoreId();
36
+ } else {
37
+ $storeId = NULL;
38
+ }
39
+
40
+ // Get List ID
41
+ if ($listId === null) {
42
+ $listId = Mage::getStoreConfig('mailup_newsletter/mailup/list', $storeId);
43
+ }
44
+
45
+ // Create select
46
+ $selectLists = array();
47
+ $selectLists[0] = array('value' => '', 'label'=>'-- No groups available --');
48
+
49
+ // Only attempt to get groups if there is a list specified
50
+ if (Mage::getStoreConfig('mailup_newsletter/mailup/list', $storeId)) {
51
+ // Get groups from list source (which gets both)
52
+ $sourcelist = Mage::getModel('mailup/source_lists');
53
+ $groups = $sourcelist->getListGroups($listId, $storeId);
54
+
55
+ // Put groups into option array
56
+ if ($groups !== false) {
57
+ $selectLists[0] = array('value' => '0', 'label'=>'-- Select a group (if any) --');
58
+ foreach ($groups as $index => $groupName) {
59
+ $selectLists[] = array(
60
+ 'value' => $index,
61
+ 'label' => $groupName
62
+ );
63
+ }
64
+ }
65
+ }
66
+
67
+ return $selectLists;
68
+ }
69
+
70
+ }
app/code/local/{SevenLike/MailUp/Model → MailUp/MailUpSync/Model/Source}/Lists.php RENAMED
@@ -2,10 +2,10 @@
2
/**
3
* Lists.php
4
*/
5
- require_once dirname(__FILE__) . "/MailUpWsImport.php";
6
- require_once dirname(__FILE__) . "/Wssend.php";
7
8
- class SevenLike_MailUp_Model_Lists
9
{
10
/**
11
* @var array
@@ -54,7 +54,7 @@ class SevenLike_MailUp_Model_Lists
54
//$storeId = Mage::app()->getDefaultStoreView()->getStoreId();
55
}
56
57
- //genero la select per Magento
58
$selectLists = array();
59
60
if (Mage::getStoreConfig('mailup_newsletter/mailup/url_console', $storeId)
@@ -65,7 +65,7 @@ class SevenLike_MailUp_Model_Lists
65
$accessKey = $wsSend->loginFromId();
66
67
if ($accessKey !== false) {
68
- require_once dirname(__FILE__) . "/MailUpWsImport.php";
69
$wsImport = new MailUpWsImport($storeId);
70
71
$xmlString = $wsImport->GetNlList();
@@ -110,8 +110,8 @@ class SevenLike_MailUp_Model_Lists
110
}
111
112
/**
113
- *
114
* Get an array of list data, and its groups.
115
* @param $listId
116
* @param $storeId
117
* @return bool|array
@@ -165,7 +165,7 @@ class SevenLike_MailUp_Model_Lists
165
}
166
167
// Attempt to make call to get lists from API
168
- require_once dirname(__FILE__) . "/MailUpWsImport.php";
169
$wsImport = new MailUpWsImport($storeId);
170
$xmlString = $wsImport->GetNlList();
171
if (!$xmlString) {
@@ -244,14 +244,14 @@ class SevenLike_MailUp_Model_Lists
244
}
245
246
/**
247
- * @var SevenLike_MailUp_Model_Config
248
*/
249
protected $_config;
250
251
/**
252
* Get the config
253
*
254
- * @reutrn SevenLike_MailUp_Model_Config
255
*/
256
protected function _config()
257
{
2
/**
3
* Lists.php
4
*/
5
+ require_once dirname(__DIR__) . "/MailUpWsImport.php";
6
+ require_once dirname(__DIR__) . "/Wssend.php";
7
8
+ class MailUp_MailUpSync_Model_Source_Lists
9
{
10
/**
11
* @var array
54
//$storeId = Mage::app()->getDefaultStoreView()->getStoreId();
55
}
56
57
+ // Create select
58
$selectLists = array();
59
60
if (Mage::getStoreConfig('mailup_newsletter/mailup/url_console', $storeId)
65
$accessKey = $wsSend->loginFromId();
66
67
if ($accessKey !== false) {
68
+ require_once dirname(__DIR__) . "/MailUpWsImport.php";
69
$wsImport = new MailUpWsImport($storeId);
70
71
$xmlString = $wsImport->GetNlList();
110
}
111
112
/**
113
* Get an array of list data, and its groups.
114
+ *
115
* @param $listId
116
* @param $storeId
117
* @return bool|array
165
}
166
167
// Attempt to make call to get lists from API
168
+ require_once dirname(__DIR__) . "/MailUpWsImport.php";
169
$wsImport = new MailUpWsImport($storeId);
170
$xmlString = $wsImport->GetNlList();
171
if (!$xmlString) {
244
}
245
246
/**
247
+ * @var MailUp_MailUpSync_Model_Config
248
*/
249
protected $_config;
250
251
/**
252
* Get the config
253
*
254
+ * @reutrn MailUp_MailUpSync_Model_Config
255
*/
256
protected function _config()
257
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Source/Store.php RENAMED
@@ -4,7 +4,7 @@
4
*
5
* Central config model
6
*/
7
- class SevenLike_MailUp_Model_Source_Store
8
{
9
/**
10
* Options getter
4
*
5
* Central config model
6
*/
7
+ class MailUp_MailUpSync_Model_Source_Store
8
{
9
/**
10
* Options getter
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Subscriber.php RENAMED
@@ -4,14 +4,14 @@
4
*
5
* Override Magento subscriber to allow us to enable / disable the Notifications
6
*/
7
- class SevenLike_MailUp_Model_Subscriber extends Mage_Newsletter_Model_Subscriber
8
{
9
/**
10
* Send Success Email
11
*
12
* @override
13
* @todo make this per store scope!
14
- * @return SevenLike_MailUp_Model_Subscriber
15
*/
16
public function sendConfirmationSuccessEmail()
17
{
@@ -30,7 +30,7 @@ class SevenLike_MailUp_Model_Subscriber extends Mage_Newsletter_Model_Subscriber
30
*
31
* @override
32
* @todo make this per store scope!
33
- * @return SevenLike_MailUp_Model_Subscriber
34
*/
35
public function sendConfirmationRequestEmail()
36
{
@@ -48,7 +48,7 @@ class SevenLike_MailUp_Model_Subscriber extends Mage_Newsletter_Model_Subscriber
48
*
49
* @override
50
* @todo make this per store scope!
51
- * @return SevenLike_MailUp_Model_Subscriber
52
*/
53
public function sendUnsubscriptionEmail()
54
{
@@ -64,7 +64,7 @@ class SevenLike_MailUp_Model_Subscriber extends Mage_Newsletter_Model_Subscriber
64
/**
65
* Get the config
66
*
67
- * @return SevenLike_MailUp_Model_Config
68
*/
69
protected function _getConfig()
70
{
4
*
5
* Override Magento subscriber to allow us to enable / disable the Notifications
6
*/
7
+ class MailUp_MailUpSync_Model_Subscriber extends Mage_Newsletter_Model_Subscriber
8
{
9
/**
10
* Send Success Email
11
*
12
* @override
13
* @todo make this per store scope!
14
+ * @return MailUp_MailUpSync_Model_Subscriber
15
*/
16
public function sendConfirmationSuccessEmail()
17
{
30
*
31
* @override
32
* @todo make this per store scope!
33
+ * @return MailUp_MailUpSync_Model_Subscriber
34
*/
35
public function sendConfirmationRequestEmail()
36
{
48
*
49
* @override
50
* @todo make this per store scope!
51
+ * @return MailUp_MailUpSync_Model_Subscriber
52
*/
53
public function sendUnsubscriptionEmail()
54
{
64
/**
65
* Get the config
66
*
67
+ * @return MailUp_MailUpSync_Model_Config
68
*/
69
protected function _getConfig()
70
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Sync.php RENAMED
@@ -6,7 +6,7 @@
6
* @method int getCustomerId()
7
* @method int getJobId()
8
*/
9
- class SevenLike_MailUp_Model_Sync extends Mage_Core_Model_Abstract
10
{
11
/**
12
* Constructor
@@ -72,7 +72,7 @@ class SevenLike_MailUp_Model_Sync extends Mage_Core_Model_Abstract
72
/**
73
* Get a collection of items which need Synced
74
*
75
- * @return SevenLike_MailUp_Model_Mysql4_Sync_Collection
76
*/
77
public function getSyncItemsCollection()
78
{
@@ -87,7 +87,7 @@ class SevenLike_MailUp_Model_Sync extends Mage_Core_Model_Abstract
87
$customerEntityTable = Mage::getSingleton('core/resource')->getTableName('customer_entity');
88
//$customerEntityTable = $this->getTable('customer/entity');
89
$collection = $this->getCollection();
90
- /* @var $collection SevenLike_MailUp_Model_Mysql4_Sync_Collection */
91
92
$collection
93
->addFieldToSelect('*')
@@ -102,7 +102,7 @@ class SevenLike_MailUp_Model_Sync extends Mage_Core_Model_Abstract
102
/**
103
* Get Sync entries for a particular job.
104
*
105
- * @return SevenLike_MailUp_Model_Mysql4_Sync_Collection
106
*/
107
public function fetchByJobId($jobId)
108
{
@@ -116,7 +116,7 @@ class SevenLike_MailUp_Model_Sync extends Mage_Core_Model_Abstract
116
/**
117
* Get the job model.
118
*
119
- * @return SevenLike_Mailup_Model_Job
120
*/
121
public function getJob()
122
{
6
* @method int getCustomerId()
7
* @method int getJobId()
8
*/
9
+ class MailUp_MailUpSync_Model_Sync extends Mage_Core_Model_Abstract
10
{
11
/**
12
* Constructor
72
/**
73
* Get a collection of items which need Synced
74
*
75
+ * @return MailUp_MailUpSync_Model_Mysql4_Sync_Collection
76
*/
77
public function getSyncItemsCollection()
78
{
87
$customerEntityTable = Mage::getSingleton('core/resource')->getTableName('customer_entity');
88
//$customerEntityTable = $this->getTable('customer/entity');
89
$collection = $this->getCollection();
90
+ /* @var $collection MailUp_MailUpSync_Model_Mysql4_Sync_Collection */
91
92
$collection
93
->addFieldToSelect('*')
102
/**
103
* Get Sync entries for a particular job.
104
*
105
+ * @return MailUp_MailUpSync_Model_Mysql4_Sync_Collection
106
*/
107
public function fetchByJobId($jobId)
108
{
116
/**
117
* Get the job model.
118
*
119
+ * @return MailUp_MailUpSync_Model_Job
120
*/
121
public function getJob()
122
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Webserviceusernamevalidator.php RENAMED
@@ -1,6 +1,6 @@
1
<?php
2
3
- class SevenLike_MailUp_Model_Webserviceusernamevalidator extends Mage_Core_Model_Config_Data
4
{
5
public function save()
6
{
1
<?php
2
3
+ class MailUp_MailUpSync_Model_Webserviceusernamevalidator extends Mage_Core_Model_Config_Data
4
{
5
public function save()
6
{
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Ws.php RENAMED
File without changes
app/code/local/{SevenLike/MailUp → MailUp/MailUpSync}/Model/Wssend.php RENAMED
@@ -11,7 +11,7 @@ class MailUpWsSend
11
*/
12
protected $storeId;
13
/**
14
- * @var SevenLike_MailUp_Model_Config
15
*/
16
protected $_config;
17
@@ -73,15 +73,36 @@ class MailUpWsSend
73
}
74
75
/**
76
- * @return $accessKey | false
77
*/
78
- public function loginFromId()
79
{
80
try {
81
//login with webservice user
82
- $loginData = array ('user' => Mage::getStoreConfig('mailup_newsletter/mailup/username_ws', $this->storeId),
83
- 'pwd' => Mage::getStoreConfig('mailup_newsletter/mailup/password_ws', $this->storeId),
84
- 'consoleId' => substr(Mage::getStoreConfig('mailup_newsletter/mailup/username_ws', $this->storeId), 1));
85
86
$result = get_object_vars($this->soapClient->LoginFromId($loginData));
87
$xml = simplexml_load_string($result['LoginFromIdResult']);
@@ -395,7 +416,7 @@ class MailUpWsSend
395
/**
396
* Get the config
397
*
398
- * @reutrn SevenLike_MailUp_Model_Config
399
*/
400
protected function _config()
401
{
11
*/
12
protected $storeId;
13
/**
14
+ * @var MailUp_MailUpSync_Model_Config
15
*/
16
protected $_config;
17
73
}
74
75
/**
76
+ * Login, returning access key or false on failing to login
77
+ *
78
+ * @param null $user
79
+ * @param null $pwd
80
+ * @param null $consoleId
81
+ * @return false|string Access key or false
82
*/
83
+ public function loginFromId($user=null, $pwd=null, $consoleId=null)
84
+ {
85
+ // login with webservice user
86
+ $user = ($user !== null) ? $user : Mage::getStoreConfig('mailup_newsletter/mailup/username_ws', $this->storeId);
87
+ $pwd = ($pwd !== null) ? $pwd : Mage::getStoreConfig('mailup_newsletter/mailup/password_ws', $this->storeId);
88
+ $consoleId = ($consoleId !== null) ? $consoleId : substr($user, 1);
89
+
90
+ return $this->_loginFromId($user, $pwd, $consoleId);
91
+ }
92
+
93
+ /**
94
+ * Login, returning access key or false on failing to login
95
+ *
96
+ * @param null $user
97
+ * @param null $pwd
98
+ * @param null $consoleId
99
+ * @return string|false Access key or false
100
+ */
101
+ protected function _loginFromId($user, $pwd, $consoleId)
102
{
103
try {
104
//login with webservice user
105
+ $loginData = array ('user' => $user, 'pwd' => $pwd, 'consoleId' => $consoleId);
106
107
$result = get_object_vars($this->soapClient->LoginFromId($loginData));
108
$xml = simplexml_load_string($result['LoginFromIdResult']);
416
/**
417
* Get the config
418
*
419
+ * @reutrn MailUp_MailUpSync_Model_Config
420
*/
421
protected function _config()
422
{
app/code/local/MailUp/MailUpSync/controllers/Adminhtml/ConfigurationController.php ADDED
@@ -0,0 +1,85 @@