doppler - Version 0.1.6

Version Notes

First stable release

Download this release

Release Info

Developer Diego Noya
Extension doppler
Version 0.1.6
Comparing to
See all releases


Version 0.1.6

Files changed (52) hide show
  1. app/code/local/MakingSense/Doppler/Block/Adminhtml/Defaultlist.php +24 -0
  2. app/code/local/MakingSense/Doppler/Block/Adminhtml/Defaultlist/Edit.php +30 -0
  3. app/code/local/MakingSense/Doppler/Block/Adminhtml/Defaultlist/Edit/Form.php +57 -0
  4. app/code/local/MakingSense/Doppler/Block/Adminhtml/Defaultlist/Grid.php +72 -0
  5. app/code/local/MakingSense/Doppler/Block/Adminhtml/Leadmap.php +23 -0
  6. app/code/local/MakingSense/Doppler/Block/Adminhtml/Leadmap/Edit.php +30 -0
  7. app/code/local/MakingSense/Doppler/Block/Adminhtml/Leadmap/Edit/Form.php +101 -0
  8. app/code/local/MakingSense/Doppler/Block/Adminhtml/Leadmap/Grid.php +81 -0
  9. app/code/local/MakingSense/Doppler/Block/Adminhtml/Lists.php +24 -0
  10. app/code/local/MakingSense/Doppler/Block/Adminhtml/Lists/Edit.php +30 -0
  11. app/code/local/MakingSense/Doppler/Block/Adminhtml/Lists/Edit/Form.php +92 -0
  12. app/code/local/MakingSense/Doppler/Block/Adminhtml/Lists/Grid.php +84 -0
  13. app/code/local/MakingSense/Doppler/Block/Adminhtml/Page/Menu.php +29 -0
  14. app/code/local/MakingSense/Doppler/Block/Adminhtml/Subscribers.php +25 -0
  15. app/code/local/MakingSense/Doppler/Block/Adminhtml/Subscribers/Edit.php +30 -0
  16. app/code/local/MakingSense/Doppler/Block/Adminhtml/Subscribers/Edit/Form.php +80 -0
  17. app/code/local/MakingSense/Doppler/Block/Adminhtml/Subscribers/Grid.php +198 -0
  18. app/code/local/MakingSense/Doppler/Block/Adminhtml/Subscribers/Grid/Massaction.php +20 -0
  19. app/code/local/MakingSense/Doppler/Block/Adminhtml/Subscribers/Grid/Renderer/Status.php +30 -0
  20. app/code/local/MakingSense/Doppler/Block/System/Config/Form/Fieldset/Connection/Test.php +46 -0
  21. app/code/local/MakingSense/Doppler/Helper/Data.php +1064 -0
  22. app/code/local/MakingSense/Doppler/Model/Defaultlist.php +10 -0
  23. app/code/local/MakingSense/Doppler/Model/Importtasks.php +10 -0
  24. app/code/local/MakingSense/Doppler/Model/Leadmap.php +11 -0
  25. app/code/local/MakingSense/Doppler/Model/Lists.php +11 -0
  26. app/code/local/MakingSense/Doppler/Model/Observer.php +76 -0
  27. app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Defaultlist.php +8 -0
  28. app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Defaultlist/Collection.php +5 -0
  29. app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Importtasks.php +10 -0
  30. app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Importtasks/Collection.php +10 -0
  31. app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Leadmap.php +8 -0
  32. app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Leadmap/Collection.php +5 -0
  33. app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Lists.php +10 -0
  34. app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Lists/Collection.php +5 -0
  35. app/code/local/MakingSense/Doppler/controllers/Adminhtml/DefaultlistController.php +230 -0
  36. app/code/local/MakingSense/Doppler/controllers/Adminhtml/LeadmapController.php +308 -0
  37. app/code/local/MakingSense/Doppler/controllers/Adminhtml/ListsController.php +492 -0
  38. app/code/local/MakingSense/Doppler/controllers/Adminhtml/SubscribersController.php +444 -0
  39. app/code/local/MakingSense/Doppler/etc/adminhtml.xml +50 -0
  40. app/code/local/MakingSense/Doppler/etc/config.xml +107 -0
  41. app/code/local/MakingSense/Doppler/etc/system.xml +55 -0
  42. app/code/local/MakingSense/Doppler/sql/makingsense_doppler_setup/mysql4-install-0.1.0.php +13 -0
  43. app/code/local/MakingSense/Doppler/sql/makingsense_doppler_setup/mysql4-upgrade-0.1.0-0.1.1.php +25 -0
  44. app/code/local/MakingSense/Doppler/sql/makingsense_doppler_setup/mysql4-upgrade-0.1.1-0.1.2.php +38 -0
  45. app/code/local/MakingSense/Doppler/sql/makingsense_doppler_setup/mysql4-upgrade-0.1.2-0.1.3.php +29 -0
  46. app/code/local/MakingSense/Doppler/sql/makingsense_doppler_setup/mysql4-upgrade-0.1.3-0.1.4.php +26 -0
  47. app/code/local/MakingSense/Doppler/sql/makingsense_doppler_setup/mysql4-upgrade-0.1.4-0.1.5.php +38 -0
  48. app/code/local/MakingSense/Doppler/sql/makingsense_doppler_setup/mysql4-upgrade-0.1.5-0.1.6.php +36 -0
  49. app/design/adminhtml/default/default/layout/makingsense_doppler.xml +15 -0
  50. app/etc/modules/MakingSense_Doppler.xml +13 -0
  51. app/locale/es_AR/MakingSense_Doppler.csv +86 -0
  52. package.xml +19 -0
app/code/local/MakingSense/Doppler/Block/Adminhtml/Defaultlist.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defaultlist grid container
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Defaultlist extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+ /**
12
+ * Set controller, block group and labels for title and top-right button
13
+ */
14
+ public function __construct ()
15
+ {
16
+ $this->_controller = 'adminhtml_defaultlist';
17
+ $this->_blockGroup = 'makingsense_doppler';
18
+ $this->_headerText = Mage::helper('makingsense_doppler')->__('Default Doppler List');
19
+ $this->_addButtonLabel = Mage::helper('makingsense_doppler')->__('Set Default List');
20
+
21
+ parent::__construct();
22
+ }
23
+
24
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Defaultlist/Edit.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defaultlist edit form container
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Defaultlist_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
10
+ {
11
+ /**
12
+ * Set block group and controller
13
+ */
14
+ public function __construct()
15
+ {
16
+ $this->_blockGroup = 'makingsense_doppler';
17
+ $this->_controller = 'adminhtml_defaultlist';
18
+
19
+ parent::__construct();
20
+ }
21
+
22
+ /**
23
+ * Set header text
24
+ */
25
+ public function getHeaderText()
26
+ {
27
+ return $this->__('Default List Configuration');
28
+ }
29
+
30
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Defaultlist/Edit/Form.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defaultlist edit form
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Defaultlist_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ /**
12
+ * Prepare form before rendering HTML
13
+ *
14
+ * @return MakingSense_Doppler_Block_Adminhtml_Lists_Edit_Form
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+
19
+ $model = Mage::registry('defaultlist_data');
20
+
21
+ $form = new Varien_Data_Form(array(
22
+ 'id' => 'edit_form',
23
+ 'action' => $this->getUrl("*/*/save", array('id' => $this->getRequest()->getParam('id'))),
24
+ 'method' => 'post'
25
+ ));
26
+
27
+ $fieldset = $form->addFieldset('defaultlist_form', array(
28
+ 'legend' => Mage::helper('makingsense_doppler')->__('Default List')
29
+ ));
30
+
31
+ $dopplerLists = Mage::helper('makingsense_doppler')->getDopplerLists();
32
+
33
+ $fieldset->addField('doppler_list_id', 'select', array(
34
+ 'label' => Mage::helper('makingsense_doppler')->__('Doppler List Name'),
35
+ 'class' => 'required-entry',
36
+ 'required' => true,
37
+ 'name' => 'doppler_list_id',
38
+ 'values' => $dopplerLists
39
+ ));
40
+
41
+ if ($model->getId())
42
+ {
43
+ $fieldset->addField('id', 'hidden', array(
44
+ 'name' => 'id',
45
+ ));
46
+ }
47
+
48
+ $form->setUseContainer(true);
49
+ $form->setValues($model->getData());
50
+ $this->setForm($form);
51
+
52
+ return parent::_prepareForm();
53
+
54
+ }
55
+
56
+
57
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Defaultlist/Grid.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defaultlist edit grid
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Defaultlist_Grid extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+ /**
12
+ * Set grid ID, default sort by and direction
13
+ */
14
+ public function __construct (){
15
+ parent::__construct();
16
+
17
+ $this->setId('makingsense_doppler_defaultlist_grid');
18
+ $this->setFilterVisibility(false);
19
+ $this->setHeadersVisibility(false);
20
+ $this->setPagerVisibility(false);
21
+ $this->setEmptyText($this->__('There is no default Doppler list.'));
22
+ $this->setSaveParametersInSession(true);
23
+ }
24
+
25
+ /**
26
+ * Set collection for grid
27
+ */
28
+ protected function _prepareCollection (){
29
+
30
+ $collection = Mage::getModel('makingsense_doppler/defaultlist')->getCollection();
31
+ $this->setCollection($collection);
32
+
33
+ return parent::_prepareCollection();
34
+ }
35
+
36
+ /**
37
+ * Set columns for grid
38
+ */
39
+ protected function _prepareColumns (){
40
+ $this->addColumn('listId', array(
41
+ 'header' => Mage::helper('makingsense_doppler')->__('List ID'),
42
+ 'index' => 'listId',
43
+ 'filter' => false,
44
+ 'width' => '90px'
45
+ ));
46
+ $this->addColumn('name', array(
47
+ 'header' => Mage::helper('makingsense_doppler')->__('List Name'),
48
+ 'filter' => false,
49
+ 'index' => 'name'
50
+ ));
51
+ $this->addColumn('list_status', array(
52
+ 'header' => Mage::helper('makingsense_doppler')->__('Status'),
53
+ 'index' => 'list_status',
54
+ 'filter' => false,
55
+ 'width' => '600px',
56
+ 'align' => 'center',
57
+ 'type' => 'options',
58
+ 'options' => array(
59
+ MakingSense_Doppler_Helper_Data::DOPPLER_LIST_STATUS_DELETED => $this->__('The list has been deleted and the new customers auto-import process has been disabled. Please choose a new list.'),
60
+ MakingSense_Doppler_Helper_Data::DOPPLER_LIST_STATUS_ENABLED => $this->__('New customers auto-import enabled')
61
+ )
62
+ ));
63
+ }
64
+
65
+ /**
66
+ * Set URL for table row
67
+ */
68
+ public function getRowUrl ($row){
69
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
70
+ }
71
+
72
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Leadmap.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Leadmap grid container
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Leadmap extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+ /**
12
+ * Set controller, block group and labels for title and top-right button
13
+ */
14
+ public function __construct()
15
+ {
16
+ $this->_controller = 'adminhtml_leadmap';
17
+ $this->_blockGroup = 'makingsense_doppler';
18
+ $this->_headerText = Mage::helper('makingsense_doppler')->__('Lead Mapping Manager');
19
+ $this->_addButtonLabel = Mage::helper('makingsense_doppler')->__('Add Field');
20
+
21
+ parent::__construct();
22
+ }
23
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Leadmap/Edit.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Leadmap edit form container
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Leadmap_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
10
+ {
11
+ /**
12
+ * Set block group and controller
13
+ */
14
+ public function __construct()
15
+ {
16
+ $this->_blockGroup = 'makingsense_doppler';
17
+ $this->_controller = 'adminhtml_leadmap';
18
+
19
+ parent::__construct();
20
+ }
21
+
22
+ /**
23
+ * Set header text
24
+ */
25
+ public function getHeaderText()
26
+ {
27
+ return $this->__('Leadmap');
28
+ }
29
+
30
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Leadmap/Edit/Form.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Leadmap edit form
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Leadmap_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ /**
12
+ * Prepare form before rendering HTML
13
+ *
14
+ * @return MakingSense_Doppler_Block_Adminhtml_Leadmap_Edit_Form
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+ $model = Mage::registry('leadmap_data');
19
+
20
+ if (Mage::helper('makingsense_doppler')->testAPIConnection() != '200')
21
+ {
22
+ return parent::_prepareForm();
23
+ }
24
+
25
+ $form = new Varien_Data_Form(array(
26
+ 'id' => 'edit_form',
27
+ 'action' => $this->getUrl("*/*/save", array('id' => $this->getRequest()->getParam('id'))),
28
+ 'method' => 'post'
29
+ ));
30
+
31
+ $fieldset = $form->addFieldset('leadmap_form', array(
32
+ 'legend' => Mage::helper('makingsense_doppler')->__('Leadmap information')
33
+ ));
34
+
35
+ $dopplerFields = Mage::helper('makingsense_doppler')->getDopplerFields();
36
+
37
+ $fieldset->addField('doppler_field_name', 'select', array(
38
+ 'label' => Mage::helper('makingsense_doppler')->__('Doppler Field Name'),
39
+ 'class' => 'required-entry',
40
+ 'required' => true,
41
+ 'name' => 'doppler_field_name',
42
+ 'values' => $dopplerFields
43
+ ));
44
+
45
+ $magentoAttributes = $this->getCustomerAttributes();
46
+
47
+ $fieldset->addField('magento_field_name', 'select', array(
48
+ 'label' => Mage::helper('makingsense_doppler')->__('Magento Field Name'),
49
+ 'class' => 'required-entry',
50
+ 'required' => true,
51
+ 'name' => 'magento_field_name',
52
+ 'values' => $magentoAttributes,
53
+ ));
54
+
55
+ if ($model->getId()){
56
+ $fieldset->addField('id', 'hidden', array(
57
+ 'name' => 'id',
58
+ ));
59
+ }
60
+
61
+ $form->setUseContainer(true);
62
+ $form->setValues($model->getData());
63
+ $this->setForm($form);
64
+
65
+ return parent::_prepareForm();
66
+ }
67
+
68
+ /**
69
+ * Get all available customer attributes
70
+ *
71
+ * @return array
72
+ */
73
+ public function getCustomerAttributes()
74
+ {
75
+ // Get customer attributes
76
+ $attributes = Mage::getModel('customer/customer')->getAttributes();
77
+ $result = array();
78
+ foreach ($attributes as $attribute) {
79
+ if (($label = $attribute->getName()))
80
+ {
81
+ $result[$label] = $label;
82
+ }
83
+ }
84
+
85
+ // Get customer address attributes
86
+ $customerAddressAttributes = Mage::getModel('customer/address')->getAttributes();
87
+ foreach ($customerAddressAttributes as $customerAddressAttribute) {
88
+ if (($label = $customerAddressAttribute->getName()))
89
+ {
90
+ $result[$label] = $label;
91
+ }
92
+ }
93
+
94
+ foreach ($result as $attributeCode)
95
+ {
96
+ Mage::helper('makingsense_doppler')->getAttributeDataType($attributeCode);
97
+ }
98
+
99
+ return $result;
100
+ }
101
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Leadmap/Grid.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Leadmap edit grid
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Leadmap_Grid extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+ /**
12
+ * Set grid ID, default sort by and direction
13
+ */
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+
18
+ $this->setId('makingsense_doppler_leadmap_grid');
19
+ $this->setDefaultSort('id');
20
+ $this->setDefaultDir('asc');
21
+ $this->setSaveParametersInSession(true);
22
+ }
23
+
24
+ /**
25
+ * Set collection for grid
26
+ */
27
+ protected function _prepareCollection()
28
+ {
29
+ $collection = Mage::getModel('makingsense_doppler/leadmap')->getCollection();
30
+ $this->setCollection($collection);
31
+
32
+ return parent::_prepareCollection();
33
+ }
34
+
35
+ /**
36
+ * Set columns for grid
37
+ */
38
+ protected function _prepareColumns()
39
+ {
40
+ $this->addColumn('id', array(
41
+ 'header' => Mage::helper('makingsense_doppler')->__('Mapping ID'),
42
+ 'index' => 'id',
43
+ 'align' => 'center',
44
+ 'width' => '60px',
45
+ 'filter' => false
46
+ ));
47
+ $this->addColumn('doppler_field_name', array(
48
+ 'header' => Mage::helper('makingsense_doppler')->__('Doppler Field Name'),
49
+ 'index' => 'doppler_field_name'
50
+ ));
51
+ $this->addColumn('magento_field_name', array(
52
+ 'header' => Mage::helper('makingsense_doppler')->__('Magento Field Name'),
53
+ 'index' => 'magento_field_name'
54
+ ));
55
+ }
56
+
57
+ /**
58
+ * Set mass actions for grid items
59
+ */
60
+ protected function _prepareMassaction()
61
+ {
62
+ $this->setMassactionIdField('id');
63
+ $this->getMassactionBlock()->setFormFieldName('leadmap');
64
+
65
+ $this->getMassactionBlock()->addItem('delete', array(
66
+ 'label' => Mage::helper('makingsense_doppler')->__('Delete'),
67
+ 'url' => $this->getUrl('*/*/massDelete'),
68
+ 'confirm' => Mage::helper('makingsense_doppler')->__('Are you sure?')
69
+ ));
70
+
71
+ return parent::_prepareMassaction();
72
+ }
73
+
74
+ /**
75
+ * Set URL for row click
76
+ */
77
+ public function getRowUrl($row)
78
+ {
79
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
80
+ }
81
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Lists.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Lists grid container
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Lists extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+ /**
12
+ * Set controller, block group and labels for title and top-right button
13
+ */
14
+ public function __construct ()
15
+ {
16
+ $this->_controller = 'adminhtml_lists';
17
+ $this->_blockGroup = 'makingsense_doppler';
18
+ $this->_headerText = Mage::helper('makingsense_doppler')->__('Doppler Lists');
19
+ $this->_addButtonLabel = Mage::helper('makingsense_doppler')->__('Add List');
20
+
21
+ parent::__construct();
22
+ }
23
+
24
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Lists/Edit.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Lists edit form container
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Lists_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
10
+ {
11
+ /**
12
+ * Set block group and controller
13
+ */
14
+ public function __construct()
15
+ {
16
+ $this->_blockGroup = 'makingsense_doppler';
17
+ $this->_controller = 'adminhtml_lists';
18
+
19
+ parent::__construct();
20
+ }
21
+
22
+ /**
23
+ * Set header text
24
+ */
25
+ public function getHeaderText()
26
+ {
27
+ return $this->__('Lists');
28
+ }
29
+
30
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Lists/Edit/Form.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Lists edit form
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Lists_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ /**
12
+ * Prepare form before rendering HTML
13
+ *
14
+ * @return MakingSense_Doppler_Block_Adminhtml_Lists_Edit_Form
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+
19
+ $model = Mage::registry('lists_data');
20
+
21
+ $form = new Varien_Data_Form(array(
22
+ 'id' => 'edit_form',
23
+ 'action' => $this->getUrl("*/*/save", array('id' => $this->getRequest()->getParam('id'))),
24
+ 'method' => 'post'
25
+ ));
26
+
27
+ $fieldset = $form->addFieldset('lists_form', array(
28
+ 'legend' => Mage::helper('makingsense_doppler')->__('List information')
29
+ ));
30
+
31
+ $fieldset->addField('name', 'text', array(
32
+ 'label' => Mage::helper('makingsense_doppler')->__('Name'),
33
+ 'class' => 'required-entry',
34
+ 'required' => true,
35
+ 'name' => 'name',
36
+ ));
37
+
38
+ $isDefaultList = Mage::helper('makingsense_doppler')->isDefaultList($this->getRequest()->getParam('id'));
39
+
40
+ $fieldset->addField('default_list', 'checkbox', array(
41
+ 'label' => Mage::helper('makingsense_doppler')->__('Default List'),
42
+ 'required' => false,
43
+ 'name' => 'default_list',
44
+ 'value' => $isDefaultList,
45
+ 'checked' => ($isDefaultList) ? 'checked' : '',
46
+ 'onclick' => 'this.value = this.checked ? 1 : 0;'
47
+ ));
48
+
49
+ if ($this->getRequest()->getParam('id'))
50
+ {
51
+ $fieldset->addField('list_id', 'text', array(
52
+ 'label' => Mage::helper('makingsense_doppler')->__('List ID'),
53
+ 'required' => false,
54
+ 'readonly' => true,
55
+ 'name' => 'list_id',
56
+ 'class' => 'non-editable'
57
+ ));
58
+
59
+ $fieldset->addField('creation_date', 'text', array(
60
+ 'label' => Mage::helper('makingsense_doppler')->__('Creation Date'),
61
+ 'required' => false,
62
+ 'readonly' => true,
63
+ 'name' => 'creation_date',
64
+ 'class' => 'non-editable'
65
+ ));
66
+
67
+ $fieldset->addField('subscribers_count', 'text', array(
68
+ 'label' => Mage::helper('makingsense_doppler')->__('Subscribers Count'),
69
+ 'required' => false,
70
+ 'readonly' => true,
71
+ 'name' => 'subscribers_count',
72
+ 'class' => 'non-editable'
73
+ ));
74
+
75
+ }
76
+
77
+ if ($model->getId())
78
+ {
79
+ $fieldset->addField('id', 'hidden', array(
80
+ 'name' => 'id',
81
+ ));
82
+ }
83
+
84
+ $form->setUseContainer(true);
85
+ $form->setValues($model->getData());
86
+ $this->setForm($form);
87
+
88
+ return parent::_prepareForm();
89
+
90
+ }
91
+
92
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Lists/Grid.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Lists edit grid
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Lists_Grid extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+
12
+ /**
13
+ * Set grid ID, default sort by and direction
14
+ */
15
+ public function __construct (){
16
+ parent::__construct();
17
+
18
+ $this->setId('makingsense_doppler_lists_grid');
19
+ $this->setDefaultSort('id');
20
+ $this->setDefaultDir('asc');
21
+ $this->setSaveParametersInSession(true);
22
+ }
23
+
24
+ /**
25
+ * Set collection for grid
26
+ */
27
+ protected function _prepareCollection (){
28
+
29
+ $collection = Mage::getModel('makingsense_doppler/lists')->getCollection();
30
+ $this->setCollection($collection);
31
+
32
+ return parent::_prepareCollection();
33
+ }
34
+
35
+ /**
36
+ * Set columns for grid
37
+ */
38
+ protected function _prepareColumns (){
39
+ $this->addColumn('list_id', array(
40
+ 'header' => Mage::helper('makingsense_doppler')->__('List ID'),
41
+ 'index' => 'list_id',
42
+ 'width' => '90px'
43
+ ));
44
+ $this->addColumn('name', array(
45
+ 'header' => Mage::helper('makingsense_doppler')->__('List Name'),
46
+ 'index' => 'name'
47
+ ));
48
+ $this->addColumn('creation_date', array(
49
+ 'header' => Mage::helper('makingsense_doppler')->__('Creation Date'),
50
+ 'index' => 'creation_date',
51
+ 'width' => '200px'
52
+ ));
53
+ $this->addColumn('subscribers_count', array(
54
+ 'header' => Mage::helper('makingsense_doppler')->__('Subscribers Count'),
55
+ 'index' => 'subscribers_count',
56
+ 'align' => 'center',
57
+ 'width' => '90px'
58
+ ));
59
+ }
60
+
61
+ /**
62
+ * Set mass actions for grid items
63
+ */
64
+ protected function _prepareMassaction (){
65
+ $this->setMassactionIdField('id');
66
+ $this->getMassactionBlock()->setFormFieldName('lists');
67
+
68
+ $this->getMassactionBlock()->addItem('delete', array(
69
+ 'label' => Mage::helper('makingsense_doppler')->__('Delete'),
70
+ 'url' => $this->getUrl('*/*/massDelete'),
71
+ 'confirm' => Mage::helper('makingsense_doppler')->__('Are you sure?')
72
+ ));
73
+
74
+ return parent::_prepareMassaction();
75
+ }
76
+
77
+ /**
78
+ * Set URL for table row
79
+ */
80
+ public function getRowUrl ($row){
81
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
82
+ }
83
+
84
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Page/Menu.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MakingSense_Doppler_Block_Adminhtml_Page_Menu extends Mage_Adminhtml_Block_Page_Menu {
3
+
4
+ /**
5
+ * Initialize template and cache settings
6
+ *
7
+ */
8
+ protected function _construct()
9
+ {
10
+ parent::_construct();
11
+
12
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
13
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
14
+
15
+ if($usernameValue != '' && $apiKeyValue != '') {
16
+ if($usernameValue != '' && $apiKeyValue != '')
17
+ {
18
+ $status = Mage::helper('makingsense_doppler')->testAPIConnection();
19
+ $this->setActiveDopplerApi($status);
20
+ }
21
+ } else {
22
+ $this->setActiveDopplerApi(false);
23
+ }
24
+
25
+ $defaultListEnabled = Mage::helper('makingsense_doppler')->isDefaultListEnabled();
26
+ $this->setDefaultListEnabled($defaultListEnabled);
27
+ }
28
+
29
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Subscribers.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Subscribers grid container
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Subscribers extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+ /**
12
+ * Set controller, block group and labels for title and remove top-right button from grid
13
+ */
14
+ public function __construct ()
15
+ {
16
+ $this->_controller = 'adminhtml_subscribers';
17
+ $this->_blockGroup = 'makingsense_doppler';
18
+ $this->_headerText = Mage::helper('makingsense_doppler')->__('Doppler Subscribers');
19
+ parent::__construct();
20
+
21
+ // Remove add button from this grid
22
+ $this->_removeButton('add');
23
+ }
24
+
25
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Subscribers/Edit.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Subscribers edit form container
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Subscribers_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
10
+ {
11
+ /**
12
+ * Set block group and controller
13
+ */
14
+ public function __construct()
15
+ {
16
+ $this->_blockGroup = 'makingsense_doppler';
17
+ $this->_controller = 'adminhtml_subscribers';
18
+
19
+ parent::__construct();
20
+ }
21
+
22
+ /**
23
+ * Set header text
24
+ */
25
+ public function getHeaderText()
26
+ {
27
+ return $this->__('Export Customers');
28
+ }
29
+
30
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Subscribers/Edit/Form.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Subscribers edit form
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Subscribers_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+
12
+ /**
13
+ * Prepare form before rendering HTML
14
+ *
15
+ * @return MakingSense_Doppler_Block_Adminhtml_Subscribers_Edit_Form
16
+ */
17
+ protected function _prepareForm()
18
+ {
19
+ $model = Mage::registry('subscribers_data');
20
+
21
+ if (Mage::helper('makingsense_doppler')->testAPIConnection() != '200')
22
+ {
23
+ return parent::_prepareForm();
24
+ }
25
+
26
+ $form = new Varien_Data_Form(array(
27
+ 'id' => 'edit_form',
28
+ 'action' => $this->getUrl("*/*/save", array('id' => $this->getRequest()->getParam('id'))),
29
+ 'method' => 'post'
30
+ ));
31
+
32
+ $fieldset = $form->addFieldset('subscribers_form', array(
33
+ 'legend' => Mage::helper('makingsense_doppler')->__('Export customer to list')
34
+ ));
35
+
36
+ if ($model->getId()){
37
+ $fieldset->addField('firstname', 'text', array(
38
+ 'label' => Mage::helper('makingsense_doppler')->__('First Name'),
39
+ 'required' => false,
40
+ 'readonly' => true,
41
+ 'name' => 'firstname',
42
+ 'class' => 'non-editable'
43
+ ));
44
+ $fieldset->addField('lastname', 'text', array(
45
+ 'label' => Mage::helper('makingsense_doppler')->__('Last Name'),
46
+ 'required' => false,
47
+ 'readonly' => true,
48
+ 'name' => 'lastname',
49
+ 'class' => 'non-editable'
50
+ ));
51
+ $fieldset->addField('email', 'text', array(
52
+ 'label' => Mage::helper('makingsense_doppler')->__('Email'),
53
+ 'required' => false,
54
+ 'readonly' => true,
55
+ 'name' => 'email',
56
+ 'class' => 'non-editable'
57
+ ));
58
+ $fieldset->addField('entity_id', 'hidden', array(
59
+ 'name' => 'entity_id',
60
+ ));
61
+ }
62
+
63
+ $dopplerLists = Mage::helper('makingsense_doppler')->getDopplerLists();
64
+
65
+ $fieldset->addField('doppler_list', 'select', array(
66
+ 'label' => Mage::helper('makingsense_doppler')->__('Doppler List'),
67
+ 'class' => 'required-entry',
68
+ 'required' => true,
69
+ 'name' => 'doppler_list',
70
+ 'values' => $dopplerLists
71
+ ));
72
+
73
+ $form->setUseContainer(true);
74
+ $form->setValues($model->getData());
75
+ $this->setForm($form);
76
+
77
+ return parent::_prepareForm();
78
+ }
79
+
80
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Subscribers/Grid.php ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Subscribers edit grid
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Subscribers_Grid extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+
12
+ /**
13
+ * Massaction block name
14
+ *
15
+ * @var string
16
+ */
17
+ protected $_massactionBlockName = 'makingsense_doppler/adminhtml_subscribers_grid_massaction';
18
+
19
+ /**
20
+ * Set grid ID, default sort by and direction
21
+ */
22
+ public function __construct()
23
+ {
24
+ parent::__construct();
25
+ $this->setId('customerGrid');
26
+ $this->setUseAjax(true);
27
+ $this->setDefaultSort('entity_id');
28
+ $this->setSaveParametersInSession(true);
29
+ }
30
+
31
+ /**
32
+ * override the _prepareCollection to add an other attribute to the grid
33
+ * @return $this
34
+ */
35
+ protected function _prepareCollection()
36
+ {
37
+ $collection = Mage::getResourceModel('customer/customer_collection')
38
+ ->addNameToSelect()
39
+ ->addAttributeToSelect('email')
40
+ ->addAttributeToSelect('created_at')
41
+ ->addAttributeToSelect('group_id')
42
+ // Add doppler_synced and status_doppler_sync attribute to grid
43
+ ->addAttributeToSelect('doppler_synced')
44
+ ->addAttributeToSelect('status_doppler_sync')
45
+ ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
46
+ ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
47
+ ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
48
+ ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
49
+ ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');
50
+
51
+ $this->setCollection($collection);
52
+
53
+ if ($this->getCollection()) {
54
+
55
+ $this->_preparePage();
56
+
57
+ $columnId = $this->getParam($this->getVarNameSort(), $this->_defaultSort);
58
+ $dir = $this->getParam($this->getVarNameDir(), $this->_defaultDir);
59
+ $filter = $this->getParam($this->getVarNameFilter(), null);
60
+
61
+ if (is_null($filter)) {
62
+ $filter = $this->_defaultFilter;
63
+ }
64
+
65
+ if (is_string($filter)) {
66
+ $data = $this->helper('adminhtml')->prepareFilterString($filter);
67
+ $this->_setFilterValues($data);
68
+ }
69
+ else if ($filter && is_array($filter)) {
70
+ $this->_setFilterValues($filter);
71
+ }
72
+ else if(0 !== sizeof($this->_defaultFilter)) {
73
+ $this->_setFilterValues($this->_defaultFilter);
74
+ }
75
+
76
+ if (isset($this->_columns[$columnId]) && $this->_columns[$columnId]->getIndex()) {
77
+ $dir = (strtolower($dir)=='desc') ? 'desc' : 'asc';
78
+ $this->_columns[$columnId]->setDir($dir);
79
+ $this->_setCollectionOrder($this->_columns[$columnId]);
80
+ }
81
+
82
+ if (!$this->_isExport) {
83
+ $this->getCollection()->load();
84
+ $this->_afterLoadCollection();
85
+ }
86
+ }
87
+
88
+ return $this;
89
+ }
90
+
91
+ /**
92
+ * Set mass actions for grid items
93
+ */
94
+ protected function _prepareMassaction()
95
+ {
96
+ $this->setMassactionIdField('entity_id');
97
+ $this->getMassactionBlock()->setFormFieldName('customer');
98
+
99
+ $dopplerLists = Mage::helper('makingsense_doppler')->getDopplerLists();
100
+
101
+ foreach ($dopplerLists as $dopplerList) {
102
+ $listIdentifier = array_search($dopplerList, $dopplerLists);
103
+
104
+ $this->getMassactionBlock()->addItem($listIdentifier, array(
105
+ 'label' => $dopplerList,
106
+ 'url' => $this->getUrl('*/*/massExport', array('list' => $listIdentifier))
107
+ ));
108
+ }
109
+
110
+ return $this;
111
+ }
112
+
113
+ /**
114
+ * Override the _prepareColumns method to add a new column after the 'email' column
115
+ * if you want the new column on a different position just change the 3rd parameter
116
+ * of the addColumnAfter method to the id of your desired column
117
+ */
118
+ protected function _prepareColumns(){
119
+ $this->addColumn('entity_id', array(
120
+ 'header' => Mage::helper('customer')->__('ID'),
121
+ 'width' => '50px',
122
+ 'index' => 'entity_id',
123
+ 'type' => 'number'
124
+ ));
125
+
126
+ $this->addColumn('name', array(
127
+ 'header' => Mage::helper('customer')->__('Name'),
128
+ 'index' => 'name',
129
+ 'width' => '150px'
130
+ ));
131
+
132
+ $this->addColumn('email', array(
133
+ 'header' => Mage::helper('customer')->__('Email'),
134
+ 'width' => '150',
135
+ 'index' => 'email'
136
+ ));
137
+
138
+ $groups = Mage::getResourceModel('customer/group_collection')
139
+ ->addFieldToFilter('customer_group_id', array('gt'=> 0))
140
+ ->load()
141
+ ->toOptionHash();
142
+
143
+ $this->addColumn('group', array(
144
+ 'header' => Mage::helper('customer')->__('Group'),
145
+ 'width' => '100',
146
+ 'index' => 'group_id',
147
+ 'type' => 'options',
148
+ 'options' => $groups,
149
+ ));
150
+
151
+ $this->addColumn('billing_country_id', array(
152
+ 'header' => Mage::helper('customer')->__('Country'),
153
+ 'width' => '100',
154
+ 'type' => 'country',
155
+ 'index' => 'billing_country_id',
156
+ ));
157
+
158
+ $this->addColumn('billing_region', array(
159
+ 'header' => Mage::helper('customer')->__('State/Province'),
160
+ 'width' => '100',
161
+ 'index' => 'billing_region',
162
+ ));
163
+
164
+ if (!Mage::app()->isSingleStoreMode()) {
165
+ $this->addColumn('website_id', array(
166
+ 'header' => Mage::helper('customer')->__('Website'),
167
+ 'align' => 'center',
168
+ 'width' => '80px',
169
+ 'type' => 'options',
170
+ 'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(true),
171
+ 'index' => 'website_id',
172
+ ));
173
+ }
174
+
175
+ $this->addColumnAfter('status_doppler_sync', array(
176
+ 'header' => Mage::helper('customer')->__('Doppler Export Status'),
177
+ 'index' => 'status_doppler_sync',
178
+ 'align' => 'center',
179
+ 'renderer' => 'makingsense_doppler/adminhtml_subscribers_grid_renderer_status',
180
+ 'column_css_class' => 'doppler-highlighted'
181
+ ),'website');
182
+
183
+ $this->addExportType('*/*/exportCsv', Mage::helper('customer')->__('CSV'));
184
+ $this->addExportType('*/*/exportXml', Mage::helper('customer')->__('Excel XML'));
185
+
186
+ }
187
+
188
+ public function getGridUrl()
189
+ {
190
+ return $this->getUrl('*/*/grid', array('_current'=> true));
191
+ }
192
+
193
+ public function getRowUrl($row)
194
+ {
195
+ return $this->getUrl('*/*/edit', array('id'=>$row->getId()));
196
+ }
197
+
198
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Subscribers/Grid/Massaction.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Mass-action block for subscribers grid
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Block_Adminhtml_Subscribers_Grid_Massaction extends Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract
10
+ {
11
+ /**
12
+ * Sets Massaction template
13
+ */
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+ $this->setTemplate('doppler/widget/grid/massaction.phtml');
18
+ $this->setErrorText(Mage::helper('catalog')->jsQuoteEscape(Mage::helper('catalog')->__('Please select subscribers.')));
19
+ }
20
+ }
app/code/local/MakingSense/Doppler/Block/Adminhtml/Subscribers/Grid/Renderer/Status.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MakingSense_Doppler_Block_Adminhtml_Subscribers_Grid_Renderer_Status extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
3
+ {
4
+ /**
5
+ * Renders grid column
6
+ *
7
+ * @param Varien_Object $row
8
+ * @return string
9
+ */
10
+ public function render(Varien_Object $row)
11
+ {
12
+ $dopplerExportStatus = $row->getData($this->getColumn()->getIndex());
13
+
14
+ // If the status is not "Pending (null)" or "Processing", then it's an error code for that customer
15
+ if (!$dopplerExportStatus)
16
+ {
17
+ $dopplerExportStatus = $this->__('Pending');
18
+ } else {
19
+
20
+ if ($dopplerExportStatus == 'Processing')
21
+ {
22
+ $dopplerExportStatus = $this->__('Processing');
23
+ } else {
24
+ $dopplerExportStatus =$this->__($dopplerExportStatus);
25
+ }
26
+ }
27
+
28
+ return $dopplerExportStatus;
29
+ }
30
+ }
app/code/local/MakingSense/Doppler/Block/System/Config/Form/Fieldset/Connection/Test.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Doppler module system config form field
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+
10
+ class MakingSense_Doppler_Block_System_Config_Form_Fieldset_Connection_Test extends Mage_Adminhtml_Block_System_Config_Form_Field
11
+ {
12
+
13
+ /**
14
+ * Add jQuery to system configuration section
15
+ */
16
+ public function _prepareLayout()
17
+ {
18
+ $head = $this->getLayout()->getBlock('head');
19
+ $head->addJs('lib/jquery/jquery-1.10.2.js');
20
+ $head->addJs('lib/jquery/noconflict.js');
21
+
22
+ return parent::_prepareLayout();
23
+ }
24
+
25
+ /**
26
+ * Customize test connection system configuration element
27
+ */
28
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
29
+ {
30
+ $block = Mage::app()->getLayout()->createBlock('adminhtml/widget_form_renderer_element')
31
+ ->setTemplate('doppler/form/testconnection.phtml');
32
+
33
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
34
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
35
+
36
+ if($usernameValue != '' && $apiKeyValue != '')
37
+ {
38
+ $status = Mage::helper('makingsense_doppler')->testAPIConnection();
39
+ $block->setStatusCode($status);
40
+ }
41
+
42
+ return $block->toHtml();
43
+ }
44
+
45
+
46
+ }
app/code/local/MakingSense/Doppler/Helper/Data.php ADDED
@@ -0,0 +1,1064 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Module data helper
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+
10
+ class MakingSense_Doppler_Helper_Data extends Mage_Core_Helper_Abstract
11
+ {
12
+ /**
13
+ * Doppler lead mapping array
14
+ *
15
+ * @var null|array
16
+ */
17
+ protected $_leadMapping = null;
18
+
19
+ /**
20
+ * Customer attributes from mapped fields
21
+ *
22
+ * @var null|array
23
+ */
24
+ protected $_customerAttributes = null;
25
+
26
+ /**
27
+ * Doppler fields array
28
+ *
29
+ * @var null|array
30
+ */
31
+ protected $_fieldsArray = null;
32
+
33
+ /**
34
+ * Doppler lists array
35
+ *
36
+ * @var null|array
37
+ */
38
+ protected $_listsArray = null;
39
+
40
+ /**
41
+ * Doppler list statuses
42
+ */
43
+ const DOPPLER_LIST_STATUS_DELETED = 'deleted';
44
+ const DOPPLER_LIST_STATUS_ENABLED = 'enabled';
45
+
46
+ /**
47
+ * API call to test if Doppler API is active
48
+ */
49
+ public function testAPIConnection()
50
+ {
51
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
52
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
53
+
54
+ // API not available error code
55
+ $statusCode = '4040';
56
+
57
+ if($usernameValue != '' && $apiKeyValue != '')
58
+ {
59
+ // Get cURL resource
60
+ $ch = curl_init();
61
+
62
+ // Set url
63
+ curl_setopt($ch, CURLOPT_URL, 'https://restapi.fromdoppler.com/accounts/' . $usernameValue . '/lists');
64
+
65
+ // Set method
66
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
67
+
68
+ // Set options
69
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
70
+
71
+ // Set headers
72
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
73
+ "Authorization: token " . $apiKeyValue,
74
+ ]
75
+ );
76
+
77
+ // Send the request & save response to $resp
78
+ $resp = curl_exec($ch);
79
+
80
+ if($resp) {
81
+ $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
82
+ }
83
+
84
+ // Close request to clear up some resources
85
+ curl_close($ch);
86
+ } else {
87
+ $statusCode = false;
88
+ }
89
+
90
+ return $statusCode;
91
+ }
92
+
93
+ /**
94
+ * Export Magento customer to Doppler
95
+ *
96
+ * @param Mage_Customer_Model_Customer $customer
97
+ * @param int $dopplerListId
98
+ *
99
+ * @return bool $errorOnExport
100
+ */
101
+ public function exportCustomerToDoppler($customer, $dopplerListId, $dopplerMappedFields, $dopplerFieldsDataType)
102
+ {
103
+ $errorOnExport = true;
104
+
105
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
106
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
107
+
108
+ if($usernameValue != '' && $apiKeyValue != '')
109
+ {
110
+ // Load customer address
111
+ $customerAddressData = array();
112
+ foreach ($customer->getAddresses() as $address)
113
+ {
114
+ $customerAddressData = $address->toArray();
115
+ }
116
+
117
+ // Load Magento customer attributes from mapped fields
118
+ foreach ($dopplerMappedFields as $field)
119
+ {
120
+ // Cleanup $field value
121
+ $trimmedFieldValue = trim($field);
122
+
123
+ // Get data from customer attribute
124
+ $customerData = $customer->getData($trimmedFieldValue);
125
+
126
+ // If the customer data is empty, then it's probably a customer address attribute
127
+ if (!$customerData)
128
+ {
129
+ $customerAddressFound = false;
130
+ foreach ($customerAddressData as $magentoAttribute => $value)
131
+ {
132
+ if ($magentoAttribute == $trimmedFieldValue)
133
+ {
134
+ $addressData = $customerAddressData[$trimmedFieldValue];
135
+ $this->_customerAttributes[$trimmedFieldValue] = $addressData;
136
+ $customerAddressFound = true;
137
+ }
138
+ }
139
+ if (!$customerAddressFound)
140
+ {
141
+ $this->_customerAttributes[$trimmedFieldValue] = $customerData;
142
+ }
143
+ } else {
144
+ $this->_customerAttributes[$trimmedFieldValue] = $customerData;
145
+ }
146
+
147
+ }
148
+
149
+ /* Sample body format for API (add subscriber to list)
150
+ * {"email": "eeef1cba-0718-4b18-b68f-5e56adaa08b9@mailinator.com",
151
+ "fields": [ {name: "FIRSTNAME", value: "First Name"},
152
+ {name: "LASTNAME", value: "Last Name"},
153
+ {name: "GENDER", value: "N"},
154
+ {name: "BIRTHDAY", value: "N"}]}
155
+ */
156
+
157
+ // Create body
158
+ $body = '{ "email": "' . $customer->getEmail() . '", ';
159
+ $body .= ' "fields": [ ';
160
+
161
+ $mappedFieldsCount = count($dopplerMappedFields);
162
+ $leadMappingArrayKeys = array_keys($dopplerMappedFields);
163
+ $customerAttributesArrayKeys = array_keys($this->_customerAttributes);
164
+
165
+ for ($i = 0; $i < $mappedFieldsCount; $i++)
166
+ {
167
+ $fieldName = $leadMappingArrayKeys[$i];
168
+ $customerAttributeValue = $this->_customerAttributes[$customerAttributesArrayKeys[$i]];
169
+
170
+ // Validate each mapped field before exporting
171
+ $dopplerFieldDataType = $dopplerFieldsDataType[$fieldName];
172
+
173
+ switch ($dopplerFieldDataType) {
174
+ case 'date':
175
+ // Format: yyyy-MM-dd
176
+ if ($dopplerFieldDataType == 'date' ||
177
+ $dopplerFieldDataType == 'datetime'
178
+ ) {
179
+ $customerAttributeValue = self::getFormattedDate($customerAttributeValue);
180
+ }
181
+ break;
182
+ case 'gender':
183
+ // M or F
184
+ // Magento saves 1 for Male and 2 for Female
185
+ // Conver that to M for Male and F for Female
186
+ if ($customerAttributesArrayKeys[$i] == 'gender')
187
+ {
188
+ if ($customerAttributeValue == 1)
189
+ {
190
+ $customerAttributeValue = 'M';
191
+ } else if ($customerAttributeValue == 2)
192
+ {
193
+ $customerAttributeValue = 'F';
194
+ }
195
+ }
196
+
197
+ break;
198
+ case 'country':
199
+ // Country: ISO 3166-1 alpha 2
200
+ // Check if attribute is 'country', if not return false
201
+ // Magento already stores the country in ISO 3166-1 alpha 2
202
+ // No conversion is necessary
203
+ break;
204
+ default:
205
+ }
206
+
207
+ $body .= '{ name: "' . $fieldName . '", value: "' . $customerAttributeValue . '" }, ';
208
+ }
209
+
210
+ $body .= ']}';
211
+
212
+ // Get cURL resource
213
+ $ch = curl_init();
214
+
215
+ // Set url
216
+ curl_setopt($ch, CURLOPT_URL, 'https://restapi.fromdoppler.com/accounts/' . $usernameValue . '/lists/' . $dopplerListId . '/subscribers');
217
+
218
+ // Set method
219
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
220
+
221
+ // Set options
222
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
223
+
224
+ // Set headers
225
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
226
+ "Authorization: token " . $apiKeyValue,
227
+ "Content-Type: application/json",
228
+ ]);
229
+
230
+ // Set body
231
+ curl_setopt($ch, CURLOPT_POST, 1);
232
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
233
+
234
+ // Send the request & save response to $resp
235
+ $resp = curl_exec($ch);
236
+
237
+ if ($resp)
238
+ {
239
+ $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
240
+
241
+ if ($statusCode == '200')
242
+ {
243
+ // Update 'status_doppler_sync' to 'Completed' since the customer was successfully exported
244
+ if($customer->getId() > 1){
245
+ $customer->setStatusDopplerSync('Completed');
246
+ $customer->save();
247
+ }
248
+
249
+ $errorOnExport = false;
250
+ } else {
251
+ // There has been an error when trying to export the customer to Doppler
252
+ // Then process the error message
253
+ $responseContent = json_decode($resp, true);
254
+
255
+ Mage::log($responseContent, null, 'error-response.log');
256
+
257
+ // If the response contains the 'errorCode' item, then get error code
258
+ $errorCode = $responseContent['errorCode'];
259
+
260
+ if ($statusCode == 400)
261
+ {
262
+ // Update 'status_doppler_sync' to the error code since the customer was not successfully exported but we have the error code
263
+ if ($errorCode == 1)
264
+ {
265
+ $customer->setStatusDopplerSync('Validation Error');
266
+ } elseif ($errorCode == 13) {
267
+ $customer->setStatusDopplerSync('Invalid Field Values');
268
+ } elseif ($errorCode == 4) {
269
+ $customer->setStatusDopplerSync('Invalid Email');
270
+ } elseif ($errorCode == 8) {
271
+ $customer->setStatusDopplerSync('Duplicated');
272
+ } elseif ($errorCode == 9) {
273
+ $customer->setStatusDopplerSync('Unsubscribed by User');
274
+ }
275
+ $customer->save();
276
+
277
+ } else {
278
+ // Update 'status_doppler_sync' to 'Error' since the customer was not successfully exported but we don't have the error code
279
+ $customer->setStatusDopplerSync('Error');
280
+ $customer->save();
281
+ }
282
+
283
+ // If the response contains the 'error' item, then it's a validation error
284
+ if (in_array('error', $responseContent))
285
+ {
286
+ $errorResponseArray = $responseContent['error'];
287
+
288
+ foreach ($errorResponseArray as $field)
289
+ {
290
+ $fieldName = $field['fieldName'];
291
+ $invalidValue = $field['invalidValue'];
292
+
293
+ $validationError = $this->__('The field "%s" is not compatible with the associated attribute value for the customer: %s', $fieldName, $invalidValue);
294
+ Mage::getSingleton('adminhtml/session')->addError($validationError);
295
+ }
296
+ } else {
297
+ $errorDetail = $responseContent['detail'];
298
+
299
+ $exportCustomerError = $this->__('The following error ocurred on the customer export: %s', $errorDetail);
300
+ Mage::getSingleton('adminhtml/session')->addError($exportCustomerError);
301
+ }
302
+
303
+ }
304
+ }
305
+
306
+ // Close request to clear up some resources
307
+ curl_close($ch);
308
+ }
309
+
310
+ return $errorOnExport;
311
+ }
312
+
313
+ /**
314
+ * Export multiple Magento customers to Doppler
315
+ *
316
+ * @param $customers
317
+ * @param $dopplerListId
318
+ *
319
+ * @return bool $errorOnExport
320
+ */
321
+ public function exportMultipleCustomersToDoppler($customers, $dopplerListId)
322
+ {
323
+ $errorOnExport = true;
324
+
325
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
326
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
327
+
328
+ if($usernameValue != '' && $apiKeyValue != '')
329
+ {
330
+ $dopplerMappedFields = Mage::helper('makingsense_doppler')->getDopplerMappedFields();
331
+
332
+ // Create body
333
+ $body = '{ "fields": [ ';
334
+
335
+ $mappedFieldsCount = count($dopplerMappedFields);
336
+ $leadMappingArrayKeys = array_keys($dopplerMappedFields);
337
+
338
+ $dopplerFieldsDataType = array();
339
+ for ($i = 0; $i < $mappedFieldsCount; $i++) {
340
+ $fieldName = $leadMappingArrayKeys[$i];
341
+ $dopplerFieldsDataType[$fieldName] = Mage::helper('makingsense_doppler')->getDopplerFieldDataType($fieldName);
342
+ }
343
+
344
+ // Get list of mapped fields
345
+ for ($i = 0; $i < $mappedFieldsCount; $i++)
346
+ {
347
+ $fieldName = $leadMappingArrayKeys[$i];
348
+ $body .= '"' . $fieldName . '"';
349
+
350
+ if (($i + 1) < $mappedFieldsCount)
351
+ {
352
+ $body .= ',';
353
+ }
354
+ }
355
+
356
+ $body .= '],';
357
+
358
+ $body .= '"items": [ ';
359
+
360
+ $customerCount = $customers->getSize();
361
+
362
+ $customerCounter = 1;
363
+ foreach ($customers as $customer)
364
+ {
365
+ // Load customer address
366
+ $customerAddressData = array();
367
+ foreach ($customer->getAddresses() as $address)
368
+ {
369
+ $customerAddressData = $address->toArray();
370
+ }
371
+
372
+ // Load Magento customer attributes from mapped fields
373
+ foreach ($dopplerMappedFields as $field)
374
+ {
375
+ // Cleanup $field value
376
+ $trimmedFieldValue = trim($field);
377
+
378
+ // Load customer
379
+ $customer = Mage::getModel('customer/customer')->load($customer->getId());
380
+
381
+ // Get data from customer attribute
382
+ $customerData = $customer->getData($trimmedFieldValue);
383
+
384
+ // If the customer data is empty, then it's probably a customer address attribute
385
+ if (!$customerData)
386
+ {
387
+ $customerAddressFound = false;
388
+ foreach ($customerAddressData as $magentoAttribute => $value)
389
+ {
390
+ if ($magentoAttribute == $trimmedFieldValue)
391
+ {
392
+ $addressData = $customerAddressData[$trimmedFieldValue];
393
+ $this->_customerAttributes[$trimmedFieldValue] = $addressData;
394
+ $customerAddressFound = true;
395
+ }
396
+ }
397
+ if (!$customerAddressFound)
398
+ {
399
+ $this->_customerAttributes[$trimmedFieldValue] = $customerData;
400
+ }
401
+ } else {
402
+ $this->_customerAttributes[$trimmedFieldValue] = $customerData;
403
+ }
404
+
405
+ }
406
+
407
+ Mage::log($this->_customerAttributes, null,'customer-attributes.log');
408
+
409
+ $body .= '{ "email": "' . $customer->getEmail() . '", ';
410
+
411
+ $body .= ' "fields": [ ';
412
+
413
+ $customerAttributesArrayKeys = array_keys($this->_customerAttributes);
414
+
415
+ for ($i = 0; $i < $mappedFieldsCount; $i++)
416
+ {
417
+ $fieldName = $leadMappingArrayKeys[$i];
418
+ $customerAttributeValue = $this->_customerAttributes[$customerAttributesArrayKeys[$i]];
419
+
420
+ // Validate each mapped field before exporting
421
+ $dopplerFieldDataType = $dopplerFieldsDataType[$fieldName];
422
+
423
+ switch ($dopplerFieldDataType) {
424
+ case 'date':
425
+ // Format: yyyy-MM-dd
426
+ if ($dopplerFieldDataType == 'date' ||
427
+ $dopplerFieldDataType == 'datetime'
428
+ ) {
429
+ $customerAttributeValue = self::getFormattedDate($customerAttributeValue);
430
+ }
431
+ break;
432
+ case 'gender':
433
+ // M or F
434
+ // Magento saves 1 for Male and 2 for Female
435
+ // Conver that to M for Male and F for Female
436
+ if ($customerAttributesArrayKeys[$i] == 'gender')
437
+ {
438
+ if ($customerAttributeValue == 1)
439
+ {
440
+ $customerAttributeValue = 'M';
441
+ } else if ($customerAttributeValue == 2)
442
+ {
443
+ $customerAttributeValue = 'F';
444
+ }
445
+ }
446
+
447
+ break;
448
+ case 'country':
449
+ // Country: ISO 3166-1 alpha 2
450
+ // Check if attribute is 'country', if not return false
451
+ // Magento already stores the country in ISO 3166-1 alpha 2
452
+ // No conversion is necessary
453
+ break;
454
+ default:
455
+ }
456
+
457
+ $body .= '{ "name": "' . $fieldName . '", "value": "' . $customerAttributeValue . '"';
458
+
459
+ if (($i + 1) < $mappedFieldsCount)
460
+ {
461
+ $body .= '},';
462
+ } else {
463
+ $body .= '}';
464
+ }
465
+ }
466
+
467
+ if ($customerCounter == $customerCount)
468
+ {
469
+ $body .= ']}';
470
+ } else {
471
+ $body .= ']},';
472
+ }
473
+
474
+ $customerCounter++;
475
+
476
+ }
477
+
478
+ $body .= '],}}';
479
+
480
+ // Get cURL resource
481
+ $ch = curl_init();
482
+
483
+ // Set url
484
+ curl_setopt($ch, CURLOPT_URL, 'https://restapi.fromdoppler.com/accounts/' . $usernameValue . '/lists/' . $dopplerListId . '/subscribers/import');
485
+
486
+ // Set method
487
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
488
+
489
+ // Set options
490
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
491
+
492
+ // Set headers
493
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
494
+ "Authorization: token " . $apiKeyValue,
495
+ "Content-Type: application/json",
496
+ ]);
497
+
498
+ // Set body
499
+ curl_setopt($ch, CURLOPT_POST, 1);
500
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
501
+
502
+ // Send the request & save response to $resp
503
+ $resp = curl_exec($ch);
504
+
505
+ if ($resp)
506
+ {
507
+ // There has been an error when trying to export the customer to Doppler
508
+ // Then process the error message
509
+ $responseContent = json_decode($resp, true);
510
+
511
+ // If the response contains the 'error' item, then it's a validation error
512
+ if (in_array('error', $responseContent))
513
+ {
514
+ $errorResponseArray = $responseContent['error'];
515
+
516
+ foreach ($errorResponseArray as $field)
517
+ {
518
+ $fieldName = $field['fieldName'];
519
+ $invalidValue = $field['invalidValue'];
520
+
521
+ $validationError = $this->__('The field "%s" is not compatible with the associated attribute value for the customer: %s', $fieldName, $invalidValue);
522
+ Mage::getSingleton('adminhtml/session')->addError($validationError);
523
+ }
524
+ } else {
525
+ $customerEmails = array();
526
+
527
+ // If the import task was successfully created, then update the customer attribute to let the user know
528
+ // that the customer is in process of being imported on Doppler
529
+ foreach ($customers as $customer)
530
+ {
531
+ $customer->setStatusDopplerSync('Processing');
532
+ $customer->save();
533
+
534
+ $customerEmails[] = $customer->getEmail();
535
+ }
536
+
537
+ // Prepare customers to save on the import task in the Magento 'doppler_importtasks' table
538
+ $encodedCustomersEmails = serialize($customerEmails);
539
+
540
+ // Save import task ID from Doppler into the 'doppler_importtasks' table
541
+ $importTaskId = $responseContent['createdResourceId'];
542
+ $importTaskStatus = 'Processing';
543
+ $importTask = Mage::getModel('makingsense_doppler/importtasks');
544
+ $importTask->setImportId($importTaskId);
545
+ $importTask->setStatus($importTaskStatus);
546
+ $importTask->setCustomers($encodedCustomersEmails);
547
+ $currentDateTime = Varien_Date::now();
548
+ Mage::log($currentDateTime, null,'$currentDateTime.log');
549
+ $importTask->setCreation($currentDateTime);
550
+ $importTask->save();
551
+
552
+ // Return the notice message informing the admin that the import is in progress
553
+ $importMessage = $responseContent['message'];
554
+ $exportCustomerError = $importMessage;
555
+ Mage::getSingleton('adminhtml/session')->addNotice($this->__($exportCustomerError));
556
+ }
557
+
558
+ }
559
+
560
+ // Close request to clear up some resources
561
+ curl_close($ch);
562
+ }
563
+
564
+ return $errorOnExport;
565
+ }
566
+
567
+ public function getDopplerMappedFields() {
568
+
569
+ // Get Doppler mapped fields from Magento
570
+ $leadmapCollection = Mage::getModel('makingsense_doppler/leadmap')->getCollection();
571
+
572
+ foreach ($leadmapCollection->getData() as $leadmap)
573
+ {
574
+ $this->_leadMapping[$leadmap['doppler_field_name']] = $leadmap['magento_field_name'];
575
+ }
576
+
577
+ return $this->_leadMapping;
578
+ }
579
+
580
+ /**
581
+ * Get all fields from Doppler
582
+ *
583
+ * @return array
584
+ */
585
+ public function getDopplerFields()
586
+ {
587
+ $this->_fieldsArray = array();
588
+
589
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
590
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
591
+
592
+ if($usernameValue != '' && $apiKeyValue != '') {
593
+ // Get cURL resource
594
+ $ch = curl_init();
595
+
596
+ // Set url
597
+ curl_setopt($ch, CURLOPT_URL, 'https://restapi.fromdoppler.com/accounts/' . $usernameValue. '/fields');
598
+
599
+ // Set method
600
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
601
+
602
+ // Set options
603
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
604
+
605
+ // Set headers
606
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
607
+ "Authorization: token " . $apiKeyValue,
608
+ ]
609
+ );
610
+
611
+ // Send the request & save response to $resp
612
+ $resp = curl_exec($ch);
613
+
614
+ if($resp)
615
+ {
616
+ $responseContent = json_decode($resp, true);
617
+ $fieldsResponseArray = $responseContent['items'];
618
+
619
+ foreach ($fieldsResponseArray as $field)
620
+ {
621
+ $fieldName = $field['name'];
622
+
623
+ // The 'EMAIL' field shouldn't be available since it's read-only in Doppler
624
+ if ($fieldName != 'EMAIL')
625
+ {
626
+ $this->_fieldsArray[$fieldName] = $fieldName;
627
+ }
628
+ }
629
+ }
630
+
631
+ // Close request to clear up some resources
632
+ curl_close($ch);
633
+ }
634
+
635
+ return $this->_fieldsArray;
636
+ }
637
+
638
+ /**
639
+ * Get all fields from Doppler with their data type
640
+ *
641
+ * @return array
642
+ */
643
+ public function getDopplerFieldsWithDataType()
644
+ {
645
+ $this->_fieldsArray = array();
646
+
647
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
648
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
649
+
650
+ if($usernameValue != '' && $apiKeyValue != '') {
651
+ // Get cURL resource
652
+ $ch = curl_init();
653
+
654
+ // Set url
655
+ curl_setopt($ch, CURLOPT_URL, 'https://restapi.fromdoppler.com/accounts/' . $usernameValue. '/fields');
656
+
657
+ // Set method
658
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
659
+
660
+ // Set options
661
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
662
+
663
+ // Set headers
664
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
665
+ "Authorization: token " . $apiKeyValue,
666
+ ]
667
+ );
668
+
669
+ // Send the request & save response to $resp
670
+ $resp = curl_exec($ch);
671
+
672
+ if($resp)
673
+ {
674
+ $responseContent = json_decode($resp, true);
675
+ $fieldsResponseArray = $responseContent['items'];
676
+
677
+ foreach ($fieldsResponseArray as $field)
678
+ {
679
+ $fieldName = $field['name'];
680
+ $fieldDataType = $field['type'];
681
+ $this->_fieldsArray[$fieldName] = $fieldDataType;
682
+ }
683
+ }
684
+
685
+ // Close request to clear up some resources
686
+ curl_close($ch);
687
+ }
688
+
689
+ return $this->_fieldsArray;
690
+ }
691
+
692
+ /**
693
+ * Get Doppler lists from API
694
+ *
695
+ * @return array
696
+ */
697
+ public function getDopplerLists()
698
+ {
699
+ $this->_listsArray = array();
700
+
701
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
702
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
703
+
704
+ if($usernameValue != '' && $apiKeyValue != '') {
705
+ // Get cURL resource
706
+ $ch = curl_init();
707
+
708
+ // Set url
709
+ curl_setopt($ch, CURLOPT_URL, 'https://restapi.fromdoppler.com/accounts/' . $usernameValue. '/lists?page=1&per_page=200');
710
+
711
+ // Set method
712
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
713
+
714
+ // Set options
715
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
716
+
717
+ // Set headers
718
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
719
+ "Authorization: token " . $apiKeyValue,
720
+ ]
721
+ );
722
+
723
+ // Send the request & save response to $resp
724
+ $resp = curl_exec($ch);
725
+
726
+ if($resp)
727
+ {
728
+ $responseContent = json_decode($resp, true);
729
+ $listsResponseArray = $responseContent['items'];
730
+
731
+ foreach ($listsResponseArray as $list)
732
+ {
733
+ $fieldName = $list['name'];
734
+ $listId = $list['listId'];
735
+ $this->_listsArray[$listId] = $fieldName;
736
+ }
737
+
738
+ }
739
+
740
+ // Close request to clear up some resources
741
+ curl_close($ch);
742
+ }
743
+
744
+ return $this->_listsArray;
745
+ }
746
+
747
+ /**
748
+ * Get default Doppler list from Magento
749
+ *
750
+ * @return int $defaultDopplerList
751
+ */
752
+ public function getDefaultDopplerList() {
753
+ $defaultDopplerList = 0;
754
+ $defaultListCollection = Mage::getModel('makingsense_doppler/defaultlist')->getCollection();
755
+
756
+ foreach ($defaultListCollection->getData() as $defaultList)
757
+ {
758
+ $listStatus = $defaultList['list_status'];
759
+
760
+ if ($listStatus == self::DOPPLER_LIST_STATUS_ENABLED) {
761
+ $defaultDopplerList = $defaultList['listId'];
762
+ }
763
+ }
764
+
765
+ return $defaultDopplerList;
766
+ }
767
+
768
+ /**
769
+ * Get default Doppler list status
770
+ *
771
+ * @return bool
772
+ */
773
+ public function isDefaultListEnabled() {
774
+ $defaultListCollection = Mage::getModel('makingsense_doppler/defaultlist')->getCollection();
775
+
776
+ foreach ($defaultListCollection->getData() as $defaultList)
777
+ {
778
+ $listStatus = $defaultList['list_status'];
779
+
780
+ if ($listStatus == self::DOPPLER_LIST_STATUS_ENABLED) {
781
+ return true;
782
+ }
783
+ }
784
+
785
+ return false;
786
+ }
787
+
788
+ /**
789
+ * Check if Doppler list is the default list
790
+ *
791
+ * @param int $listId
792
+ * @return int
793
+ */
794
+ public function isDefaultList($listId)
795
+ {
796
+ if ($listId)
797
+ {
798
+ $list = Mage::getModel('makingsense_doppler/lists')->load($listId);
799
+ $dopplerListId = $list->getListId();
800
+
801
+ $defaultListCollection = Mage::getModel('makingsense_doppler/defaultlist')->getCollection();
802
+ foreach ($defaultListCollection as $defaultList)
803
+ {
804
+ if ($dopplerListId == $defaultList->getData('listId'))
805
+ {
806
+ return 1;
807
+ }
808
+ }
809
+ }
810
+
811
+ return 0;
812
+ }
813
+
814
+ /**
815
+ * Get attribute data type
816
+ * The attribute could be a customer attribute
817
+ * or customer address attribute
818
+ *
819
+ * Possible returned data types:
820
+ * - text
821
+ * - varchar
822
+ * - int
823
+ * - static
824
+ * - datetime
825
+ * - decimal
826
+ *
827
+ * - In case of being static, it could be:
828
+ * varchar
829
+ * varbinary
830
+ * char
831
+ * date
832
+ * datetime
833
+ * timestamp
834
+ * time
835
+ * year
836
+ * enum
837
+ * set
838
+ * bit
839
+ * bool
840
+ * tinyint
841
+ * smallint
842
+ * mediumint
843
+ * int
844
+ * bigint
845
+ * float
846
+ * double
847
+ * decimal
848
+ *
849
+ * @param string $attributeCode
850
+ * @return string
851
+ */
852
+ public function getAttributeDataType($attributeCode)
853
+ {
854
+ // Get customer attributes
855
+ $attributes = Mage::getModel('customer/customer')->getAttributes();
856
+ $customerAttributesArray = array();
857
+ foreach ($attributes as $attribute) {
858
+ if (($label = $attribute->getName()))
859
+ {
860
+ $customerAttributesArray[$label] = $label;
861
+ }
862
+ }
863
+
864
+ // Check if attribute is a customer attribute
865
+ $isCustomerAttribute = false;
866
+ if (in_array($attributeCode, $customerAttributesArray))
867
+ {
868
+ // If customer attribute, then load attribute
869
+ $attribute = Mage::getModel('eav/entity_attribute')->loadByCode('customer', $attributeCode);
870
+ $attributeDataType = $attribute->getData('backend_type');
871
+
872
+ // If the attribute data type is static, then we have to load the table and check the DATA_TYPE column
873
+ // to see what is the data type for that attribute
874
+ if ($attributeDataType == 'static')
875
+ {
876
+ $backendTable = $attribute->getBackendTable();
877
+ if ($backendTable) {
878
+ $describe = Mage::getSingleton('core/resource')->getConnection('core_write')->describeTable($backendTable);
879
+
880
+ $prop = $describe[$attributeCode];
881
+
882
+ $indexDataTypes = array(
883
+ 'varchar',
884
+ 'varbinary',
885
+ 'char',
886
+ 'date',
887
+ 'datetime',
888
+ 'timestamp',
889
+ 'time',
890
+ 'year',
891
+ 'enum',
892
+ 'set',
893
+ 'bit',
894
+ 'bool',
895
+ 'tinyint',
896
+ 'smallint',
897
+ 'mediumint',
898
+ 'int',
899
+ 'bigint',
900
+ 'float',
901
+ 'double',
902
+ 'decimal',
903
+ );
904
+
905
+ if (in_array($prop['DATA_TYPE'], $indexDataTypes)) {
906
+ return $prop['DATA_TYPE'];
907
+ }
908
+ }
909
+ }
910
+
911
+ return $attributeDataType;
912
+ }
913
+
914
+ // Check if attribute is customer address attribute
915
+ if (!$isCustomerAttribute)
916
+ {
917
+ // Get customer address attributes
918
+ $customerAddressAttributesArray = array();
919
+ $customerAddressAttributes = Mage::getModel('customer/address')->getAttributes();
920
+ foreach ($customerAddressAttributes as $customerAddressAttribute) {
921
+ if (($label = $customerAddressAttribute->getName()))
922
+ {
923
+ $customerAddressAttributesArray[$label] = $label;
924
+ }
925
+ }
926
+
927
+ if (in_array($attributeCode, $customerAddressAttributesArray))
928
+ {
929
+ // If customer address attribute, then load attribute
930
+ $attribute = Mage::getModel('eav/entity_attribute')->loadByCode('customer_address', $attributeCode);
931
+ $attributeDataType = $attribute->getData('backend_type');
932
+
933
+ // If the attribute data type is static, then we have to load the table and check the DATA_TYPE column
934
+ // to see what is the data type for that attribute
935
+ if ($attributeDataType == 'static')
936
+ {
937
+ $backendTable = $attribute->getBackendTable();
938
+ if ($backendTable) {
939
+ $describe = Mage::getSingleton('core/resource')->getConnection('core_write')->describeTable($backendTable);
940
+
941
+ $prop = $describe[$attributeCode];
942
+
943
+ $indexDataTypes = array(
944
+ 'varchar',
945
+ 'varbinary',
946
+ 'char',
947
+ 'date',
948
+ 'datetime',
949
+ 'timestamp',
950
+ 'time',
951
+ 'year',
952
+ 'enum',
953
+ 'set',
954
+ 'bit',
955
+ 'bool',
956
+ 'tinyint',
957
+ 'smallint',
958
+ 'mediumint',
959
+ 'int',
960
+ 'bigint',
961
+ 'float',
962
+ 'double',
963
+ 'decimal',
964
+ );
965
+
966
+ if (in_array($prop['DATA_TYPE'], $indexDataTypes)) {
967
+ return $prop['DATA_TYPE'];
968
+ }
969
+ }
970
+ }
971
+
972
+ return $attributeDataType;
973
+ }
974
+ }
975
+
976
+ return '';
977
+ }
978
+
979
+ /**
980
+ * Get data type from Doppler field
981
+ *
982
+ * Possible results:
983
+ * boolean
984
+ * number
985
+ * string (400 character max)
986
+ * date (yyyy-MM-dd)
987
+ * gender (M or F)
988
+ * country (ISO 3166-1 alpha-2)
989
+ *
990
+ * @param string $dopplerFieldName
991
+ * @return string
992
+ */
993
+ public function getDopplerFieldDataType($dopplerFieldName)
994
+ {
995
+ $this->_fieldsArray = array();
996
+
997
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
998
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
999
+
1000
+ if($usernameValue != '' && $apiKeyValue != '') {
1001
+ // Get cURL resource
1002
+ $ch = curl_init();
1003
+
1004
+ // Set url
1005
+ curl_setopt($ch, CURLOPT_URL, 'https://restapi.fromdoppler.com/accounts/' . $usernameValue. '/fields');
1006
+
1007
+ // Set method
1008
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
1009
+
1010
+ // Set options
1011
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1012
+
1013
+ // Set headers
1014
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
1015
+ "Authorization: token " . $apiKeyValue,
1016
+ ]
1017
+ );
1018
+
1019
+ // Send the request & save response to $resp
1020
+ $resp = curl_exec($ch);
1021
+
1022
+ if($resp)
1023
+ {
1024
+ $responseContent = json_decode($resp, true);
1025
+ $fieldsResponseArray = $responseContent['items'];
1026
+
1027
+ foreach ($fieldsResponseArray as $field)
1028
+ {
1029
+ $fieldName = $field['name'];
1030
+
1031
+ if ($fieldName == $dopplerFieldName)
1032
+ {
1033
+ return $field['type'];
1034
+ }
1035
+ }
1036
+ }
1037
+
1038
+ // Close request to clear up some resources
1039
+ curl_close($ch);
1040
+ }
1041
+
1042
+ return '';
1043
+ }
1044
+
1045
+ /**
1046
+ * Get date in format yyyy-MM-dd
1047
+ *
1048
+ * Native Magento format: yyyy-mm-dd hh:mm:ss
1049
+ *
1050
+ * @return string
1051
+ */
1052
+ public function getFormattedDate($date)
1053
+ {
1054
+ $formattedDate = '';
1055
+
1056
+ if ($date)
1057
+ {
1058
+ $dateTime = strtotime($date);
1059
+ $formattedDate = date('Y-m-d', $dateTime);
1060
+ }
1061
+
1062
+ return $formattedDate;
1063
+ }
1064
+ }
app/code/local/MakingSense/Doppler/Model/Defaultlist.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MakingSense_Doppler_Model_Defaultlist extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('makingsense_doppler/doppler_defaultlist');
8
+ }
9
+
10
+ }
app/code/local/MakingSense/Doppler/Model/Importtasks.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MakingSense_Doppler_Model_Importtasks extends Mage_Core_Model_Abstract
3
+ {
4
+
5
+ protected function _construct()
6
+ {
7
+ $this->_init('makingsense_doppler/doppler_importtasks');
8
+ }
9
+
10
+ }
app/code/local/MakingSense/Doppler/Model/Leadmap.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MakingSense_Doppler_Model_Leadmap extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('makingsense_doppler/doppler_leadmap');
9
+ }
10
+
11
+ }
app/code/local/MakingSense/Doppler/Model/Lists.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MakingSense_Doppler_Model_Lists extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('makingsense_doppler/doppler_lists');
9
+ }
10
+
11
+ }
app/code/local/MakingSense/Doppler/Model/Observer.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MakingSense_Doppler module observer
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+ class MakingSense_Doppler_Model_Observer
10
+ {
11
+ /**
12
+ * When an user registers, then send customer data to Doppler default list
13
+ */
14
+ public function userRegistration()
15
+ {
16
+ // If the customer is logged in after the observer dispatch, that means that the customer was successfully registered
17
+ if (Mage::getSingleton('customer/session')->isLoggedIn())
18
+ {
19
+ // Get customer
20
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
21
+
22
+ // Get default Doppler list
23
+ $defaultDopplerList = Mage::helper('makingsense_doppler')->getDefaultDopplerList();
24
+
25
+ if ($defaultDopplerList)
26
+ {
27
+ // Export customer to Doppler
28
+ $dopplerMappedFields = Mage::helper('makingsense_doppler')->getDopplerMappedFields();
29
+ $mappedFieldsCount = count($dopplerMappedFields);
30
+ $leadMappingArrayKeys = array_keys($dopplerMappedFields);
31
+ $dopplerAttributeTypes = array();
32
+ for ($i = 0; $i < $mappedFieldsCount; $i++) {
33
+ $fieldName = $leadMappingArrayKeys[$i];
34
+ $dopplerAttributeTypes[$fieldName] = Mage::helper('makingsense_doppler')->getDopplerFieldDataType($fieldName);
35
+ }
36
+ $dopplerMappedFields = Mage::helper('makingsense_doppler')->getDopplerMappedFields();
37
+ $exportError = Mage::helper('makingsense_doppler')->exportCustomerToDoppler($customer, $defaultDopplerList, $dopplerMappedFields, $dopplerAttributeTypes);
38
+ }
39
+ }
40
+ }
41
+
42
+ /**
43
+ * When an user creates a new order and register, then send customer data to Doppler default list
44
+ * @param $observer
45
+ */
46
+ public function checkoutUserRegistration($observer)
47
+ {
48
+ /** @var $quote Mage_Sales_Model_Quote */
49
+ $quote = $observer->getEvent()->getQuote();
50
+
51
+ // Validate that the checkout method was "register"
52
+ if ($quote->getData('checkout_method') != Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER) {
53
+ return;
54
+ }
55
+
56
+ // Get customer
57
+ $customer = $quote->getCustomer();
58
+
59
+ // Get default Doppler list
60
+ $defaultDopplerList = Mage::helper('makingsense_doppler')->getDefaultDopplerList();
61
+
62
+ if ($defaultDopplerList)
63
+ {
64
+ // Export customer to Doppler
65
+ $dopplerMappedFields = Mage::helper('makingsense_doppler')->getDopplerMappedFields();
66
+ $mappedFieldsCount = count($dopplerMappedFields);
67
+ $leadMappingArrayKeys = array_keys($dopplerMappedFields);
68
+ $dopplerAttributeTypes = array();
69
+ for ($i = 0; $i < $mappedFieldsCount; $i++) {
70
+ $fieldName = $leadMappingArrayKeys[$i];
71
+ $dopplerAttributeTypes[$fieldName] = Mage::helper('makingsense_doppler')->getDopplerFieldDataType($fieldName);
72
+ }
73
+ $exportError = Mage::helper('makingsense_doppler')->exportCustomerToDoppler($customer, $defaultDopplerList, $dopplerMappedFields, $dopplerAttributeTypes);
74
+ }
75
+ }
76
+ }
app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Defaultlist.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MakingSense_Doppler_Model_Resource_Doppler_Defaultlist extends Mage_Core_Model_Resource_Db_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('makingsense_doppler/doppler_defaultlist', 'id');
7
+ }
8
+ }
app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Defaultlist/Collection.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class MakingSense_Doppler_Model_Resource_Doppler_Defaultlist_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
+ {
5
+ }
app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Importtasks.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MakingSense_Doppler_Model_Resource_Doppler_Importtasks extends Mage_Core_Model_Resource_Db_Abstract
3
+ {
4
+
5
+ protected function _construct()
6
+ {
7
+ $this->_init('makingsense_doppler/doppler_importtasks', 'id');
8
+ }
9
+
10
+ }
app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Importtasks/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MakingSense_Doppler_Model_Resource_Doppler_Importtasks_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
3
+ {
4
+
5
+ protected function _construct()
6
+ {
7
+ $this->_init('makingsense_doppler/importtasks');
8
+ }
9
+
10
+ }
app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Leadmap.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MakingSense_Doppler_Model_Resource_Doppler_Leadmap extends Mage_Core_Model_Resource_Db_Abstract
4
+ {
5
+ public function _construct (){
6
+ $this->_init('makingsense_doppler/doppler_leadmap', 'id');
7
+ }
8
+ }
app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Leadmap/Collection.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class MakingSense_Doppler_Model_Resource_Doppler_Leadmap_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
+ {
5
+ }
app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Lists.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MakingSense_Doppler_Model_Resource_Doppler_Lists extends Mage_Core_Model_Resource_Db_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('makingsense_doppler/doppler_lists', 'id');
8
+ }
9
+
10
+ }
app/code/local/MakingSense/Doppler/Model/Resource/Doppler/Lists/Collection.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class MakingSense_Doppler_Model_Resource_Doppler_Lists_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
+ {
5
+ }
app/code/local/MakingSense/Doppler/controllers/Adminhtml/DefaultlistController.php ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defaultlist admin page controller
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+
10
+ class MakingSense_Doppler_Adminhtml_DefaultlistController extends Mage_Adminhtml_Controller_Action
11
+ {
12
+ /**
13
+ * Set active menu
14
+ */
15
+ protected function initAction()
16
+ {
17
+ $this->loadLayout()
18
+ ->_setActiveMenu('makingsense_doppler/defaultlist');
19
+
20
+ return $this;
21
+ }
22
+
23
+ /**
24
+ * Create block for index action
25
+ */
26
+ public function indexAction()
27
+ {
28
+ $statusCode = Mage::helper('makingsense_doppler')->testAPIConnection();
29
+ $errorStatusCode = false;
30
+
31
+ if (!$statusCode)
32
+ {
33
+ $errorStatusCode = true;
34
+ Mage::getSingleton('core/session')->addError($this->__('Please, add your credentials for the Doppler API in System -> Configuration -> Doppler'));
35
+ } else {
36
+ if ($statusCode != '200')
37
+ {
38
+ if ($statusCode == '404' || $statusCode == '4040')
39
+ {
40
+ Mage::getSingleton('core/session')->addError($this->__('The Doppler API is not currently available, please try later'));
41
+ } else {
42
+ Mage::getSingleton('core/session')->addError($this->__('Your credentials are not valid, please check your username and API key and try again'));
43
+ $errorStatusCode = true;
44
+ }
45
+ }
46
+ }
47
+
48
+ if($errorStatusCode)
49
+ {
50
+ $this->initAction()
51
+ ->renderLayout();
52
+ } else {
53
+
54
+ // If there is a default list, then validate its status is Doppler
55
+ $defaultListCollection = Mage::getModel('makingsense_doppler/defaultlist')->getCollection();
56
+
57
+ if ($defaultListCollection->getData() > 0) {
58
+ $listId = 0;
59
+
60
+ foreach ($defaultListCollection as $defaultList)
61
+ {
62
+ $listId = $defaultList->getData('listId');
63
+ }
64
+
65
+ if ($listId != 0)
66
+ {
67
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
68
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
69
+
70
+ if($usernameValue != '' && $apiKeyValue != '')
71
+ {
72
+ // Get cURL resource
73
+ $ch = curl_init();
74
+
75
+ // Set url
76
+ curl_setopt($ch, CURLOPT_URL, 'https://restapi.fromdoppler.com/accounts/' . $usernameValue . '/lists/' . $listId);
77
+
78
+ // Set method
79
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
80
+
81
+ // Set options
82
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
83
+
84
+ // Set headers
85
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
86
+ "Authorization: token " . $apiKeyValue,
87
+ ]
88
+ );
89
+
90
+ // Send the request & save response to $resp
91
+ $resp = curl_exec($ch);
92
+
93
+ if ($resp)
94
+ {
95
+ $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
96
+
97
+ $responseContent = json_decode($resp, true);
98
+
99
+ if ($statusCode == '200')
100
+ {
101
+ $model = Mage::getModel('makingsense_doppler/defaultlist');
102
+
103
+ // Remove the old list information
104
+ foreach ($model->getCollection() as $list) {
105
+ $model->load($list->getId())->delete();
106
+ }
107
+
108
+ $data['name'] = $responseContent['name'];
109
+ $data['listId'] = $responseContent['listId'];
110
+
111
+ // If the list has been deleted, then let the user know about that
112
+ if ($responseContent['currentStatus'] == MakingSense_Doppler_Helper_Data::DOPPLER_LIST_STATUS_DELETED) {
113
+ $data['list_status'] = MakingSense_Doppler_Helper_Data::DOPPLER_LIST_STATUS_DELETED;
114
+ } else {
115
+ $data['list_status'] = MakingSense_Doppler_Helper_Data::DOPPLER_LIST_STATUS_ENABLED;
116
+ }
117
+
118
+ $model->setData($data);
119
+ $model->save();
120
+ } else {
121
+ $this->_getSession()->addError($this->__('The following errors occurred retrieving your default list: %s', $responseContent['title']));
122
+ }
123
+ }
124
+
125
+ // Close request to clear up some resources
126
+ curl_close($ch);
127
+ }
128
+ }
129
+ }
130
+
131
+ $this->initAction()
132
+ ->_addContent($this->getLayout()->createBlock('makingsense_doppler/adminhtml_defaultlist'))
133
+ ->renderLayout();
134
+
135
+ }
136
+
137
+ }
138
+
139
+ /**
140
+ * Forward new to edit action
141
+ */
142
+ public function newAction()
143
+ {
144
+ $this->_forward('edit');
145
+ }
146
+
147
+ /**
148
+ * Edit action logic
149
+ */
150
+ public function editAction()
151
+ {
152
+ $id = $this->getRequest()->getParam('id');
153
+
154
+ $model = Mage::getModel('makingsense_doppler/defaultlist');
155
+ if ($id){
156
+ $model->load($id);
157
+
158
+ if (!$model->getId()){
159
+ $this->_getSession()->addError($this->__('Default list does not exist'));
160
+ $this->_redirect('*/*/');
161
+ return;
162
+ }
163
+ }
164
+
165
+ Mage::register('defaultlist_data', $model);
166
+
167
+ $this->initAction()
168
+ ->_addContent($this->getLayout()->createBlock('makingsense_doppler/adminhtml_defaultlist_edit'))
169
+ ->renderLayout();
170
+ }
171
+
172
+ /**
173
+ * Delete action logic
174
+ */
175
+ public function deleteAction()
176
+ {
177
+ $id = $this->getRequest()->getParam('id');
178
+ if ($id){
179
+ try {
180
+ $list = Mage::getModel('makingsense_doppler/defaultlist')->load($id);
181
+ if (!$list->getId()){
182
+ $this->_getSession()->addError("Default list %s does not exist", $id);
183
+ $this->_redirect("*/*/");
184
+ return;
185
+ }
186
+
187
+ $list->delete();
188
+
189
+ } catch (Exception $e){
190
+ $this->_getSession()->addError($e->getMessage());
191
+ }
192
+ }
193
+
194
+ $this->_redirect("*/*/");
195
+ }
196
+
197
+ /**
198
+ * Save action logic
199
+ */
200
+ public function saveAction()
201
+ {
202
+ $data = $this->getRequest()->getPost();
203
+
204
+ if ($data){
205
+ try {
206
+ $model = Mage::getModel('makingsense_doppler/defaultlist');
207
+
208
+ // First, remove the previous default list
209
+ foreach ($model->getCollection() as $list) {
210
+ $model->load($list->getId())->delete();
211
+ }
212
+
213
+ // Then save the new default list
214
+ $listData = array();
215
+ $listData['listId'] = $data['doppler_list_id'];
216
+
217
+ $model->setData($listData);
218
+ $model->save();
219
+
220
+ $this->_getSession()->addSuccess($this->__('Saved'));
221
+ } catch (Exception $e){
222
+ $this->_getSession()->addError($e->getMessage());
223
+ }
224
+ }
225
+
226
+ $this->_redirect("*/*/");
227
+ }
228
+
229
+
230
+ }
app/code/local/MakingSense/Doppler/controllers/Adminhtml/LeadmapController.php ADDED
@@ -0,0 +1,308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Leadmap admin page controller
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+
10
+ class MakingSense_Doppler_Adminhtml_LeadmapController extends Mage_Adminhtml_Controller_Action
11
+ {
12
+ /**
13
+ * Set active menu
14
+ */
15
+ protected function initAction()
16
+ {
17
+ $this->loadLayout()
18
+ ->_setActiveMenu('makingsense_doppler/leadmap');
19
+
20
+ return $this;
21
+ }
22
+
23
+ /**
24
+ * Create block for index action
25
+ */
26
+ public function indexAction()
27
+ {
28
+ $statusCode = Mage::helper('makingsense_doppler')->testAPIConnection();
29
+ $errorStatusCode = false;
30
+
31
+ if (!$statusCode)
32
+ {
33
+ $errorStatusCode = true;
34
+ Mage::getSingleton('core/session')->addError($this->__('Please, add your credentials for the Doppler API in System -> Configuration -> Doppler'));
35
+ } else {
36
+ if ($statusCode != '200')
37
+ {
38
+ if ($statusCode == '404' || $statusCode == '4040')
39
+ {
40
+ Mage::getSingleton('core/session')->addError($this->__('The Doppler API is not currently available, please try later'));
41
+ } else {
42
+ Mage::getSingleton('core/session')->addError($this->__('Your credentials are not valid, please check your username and API key and try again'));
43
+ $errorStatusCode = true;
44
+ }
45
+ }
46
+ }
47
+
48
+ if($errorStatusCode)
49
+ {
50
+ $this->initAction()
51
+ ->renderLayout();
52
+ } else {
53
+ $this->initAction()
54
+ ->_addContent($this->getLayout()->createBlock('makingsense_doppler/adminhtml_leadmap'))
55
+ ->renderLayout();
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Forward new to edit action
61
+ */
62
+ public function newAction()
63
+ {
64
+ $this->_forward('edit');
65
+ }
66
+
67
+ /**
68
+ * Edit action logic
69
+ */
70
+ public function editAction()
71
+ {
72
+ $statusCode = Mage::helper('makingsense_doppler')->testAPIConnection();
73
+ $errorStatusCode = false;
74
+
75
+ if (!$statusCode)
76
+ {
77
+ $errorStatusCode = true;
78
+ Mage::getSingleton('core/session')->addError($this->__('Please, add your credentials for the Doppler API in System -> Configuration -> Doppler'));
79
+ } else {
80
+ if ($statusCode != '200')
81
+ {
82
+ if ($statusCode == '404' || $statusCode == '4040')
83
+ {
84
+ Mage::getSingleton('core/session')->addError($this->__('The Doppler API is not currently available, please try later'));
85
+ } else {
86
+ Mage::getSingleton('core/session')->addError($this->__('Your credentials are not valid, please check your username and API key and try again'));
87
+ $errorStatusCode = true;
88
+ }
89
+ }
90
+ }
91
+
92
+ if($errorStatusCode)
93
+ {
94
+ $this->initAction()
95
+ ->renderLayout();
96
+ } else {
97
+
98
+ $id = $this->getRequest()->getParam('id');
99
+
100
+ $model = Mage::getModel('makingsense_doppler/leadmap');
101
+ if ($id){
102
+ $model->load($id);
103
+
104
+ if (!$model->getId()){
105
+ $this->_getSession()->addError($this->__('Mapping does not exist'));
106
+ $this->_redirect('*/*/');
107
+ return;
108
+ }
109
+ }
110
+
111
+ Mage::register('leadmap_data', $model);
112
+
113
+ $this->initAction()
114
+ ->_addContent($this->getLayout()->createBlock('makingsense_doppler/adminhtml_leadmap_edit'))
115
+ ->renderLayout();
116
+ }
117
+
118
+ }
119
+
120
+ /**
121
+ * Delete action logic
122
+ */
123
+ public function deleteAction()
124
+ {
125
+ $id = $this->getRequest()->getParam('id');
126
+ if ($id){
127
+ try {
128
+ $model = Mage::getModel('makingsense_doppler/leadmap')->load($id);
129
+ if (!$model->getId()){
130
+ $this->_getSession()->addError("Leadmap with id '%s' does not exist", $id);
131
+ $this->_redirect("*/*/");
132
+ return;
133
+ }
134
+
135
+ $model->delete();
136
+ $this->_getSession()->addSuccess($this->__('Leadmap deleted'));
137
+ } catch (Exception $e){
138
+ $this->_getSession()->addError($e->getMessage());
139
+ }
140
+ }
141
+
142
+ $this->_redirect("*/*/");
143
+ }
144
+
145
+ /**
146
+ * Save action logic
147
+ */
148
+ public function saveAction()
149
+ {
150
+
151
+ $data = $this->getRequest()->getPost();
152
+
153
+ if ($data){
154
+ try {
155
+ // 1- Validate that there is no attribute already associated with this Doppler field
156
+ $fieldAlreadyExist = false;
157
+
158
+ $mappedFields = Mage::getModel('makingsense_doppler/leadmap')->getCollection()->getData();
159
+
160
+ $savedDopplerFieldName = '';
161
+
162
+ foreach ($mappedFields as $field)
163
+ {
164
+ $dopplerFieldName = $field['doppler_field_name'];
165
+ $savedDopplerFieldName = $data['doppler_field_name'];
166
+
167
+ // If editing mapping
168
+ if (array_key_exists('id', $data)) {
169
+ if ($field['id'] != $data['id']) {
170
+ if ($dopplerFieldName == $savedDopplerFieldName) {
171
+ $fieldAlreadyExist = true;
172
+ }
173
+ }
174
+ // If creating new mapping
175
+ } else {
176
+
177
+ if ($dopplerFieldName == $savedDopplerFieldName) {
178
+ $fieldAlreadyExist = true;
179
+ }
180
+ }
181
+ }
182
+
183
+ if (!$fieldAlreadyExist) {
184
+
185
+ $savedDopplerFieldName = $data['doppler_field_name'];
186
+ $savedMagentoAttributeCode = $data['magento_field_name'];
187
+
188
+ // Validate if the Magento attribute data type is the same
189
+ // than the Doppler attribute data type
190
+ $dopplerFieldDataType = Mage::helper('makingsense_doppler')->getDopplerFieldDataType($savedDopplerFieldName);
191
+ $magentoAttributeDataType = Mage::helper('makingsense_doppler')->getAttributeDataType($savedMagentoAttributeCode);
192
+
193
+ if ($magentoAttributeDataType != '') {
194
+ // Since there are less possible attribute types from the Doppler side
195
+ // Then iterate over the possible Doppler attribute types first
196
+ $compatibleDataTypes = false;
197
+ $error = 'Doppler: ' . $dopplerFieldDataType . ' – Magento: ' . $magentoAttributeDataType;
198
+
199
+ switch ($dopplerFieldDataType) {
200
+ case 'boolean':
201
+ if ($magentoAttributeDataType == 'bool') {
202
+ $compatibleDataTypes = true;
203
+ }
204
+ break;
205
+ case 'number':
206
+
207
+ if ($magentoAttributeDataType == 'varchar' ||
208
+ $magentoAttributeDataType == 'varbinary' ||
209
+ $magentoAttributeDataType == 'year' ||
210
+ $magentoAttributeDataType == 'enum' ||
211
+ $magentoAttributeDataType == 'bit' ||
212
+ $magentoAttributeDataType == 'tinyint' ||
213
+ $magentoAttributeDataType == 'smallint' ||
214
+ $magentoAttributeDataType == 'mediumint' ||
215
+ $magentoAttributeDataType == 'int' ||
216
+ $magentoAttributeDataType == 'bigint' ||
217
+ $magentoAttributeDataType == 'float' ||
218
+ $magentoAttributeDataType == 'double' ||
219
+ $magentoAttributeDataType == 'decimal'
220
+ ) {
221
+ $compatibleDataTypes = true;
222
+ }
223
+ break;
224
+ case 'date':
225
+ // Format: yyyy-MM-dd
226
+ if ($magentoAttributeDataType == 'date' ||
227
+ $magentoAttributeDataType == 'datetime'
228
+ ) {
229
+ $compatibleDataTypes = true;
230
+ }
231
+ break;
232
+ case 'gender':
233
+ // M or F
234
+ if ($savedMagentoAttributeCode == 'gender') {
235
+ $compatibleDataTypes = true;
236
+ $error = 'Doppler: gender – Magento: ' . $savedMagentoAttributeCode;
237
+ }
238
+
239
+ break;
240
+ case 'country':
241
+ // Country: ISO 3166-1 alpha 2
242
+ // The country in Magento is a varchar attribute
243
+ if ($savedMagentoAttributeCode == 'country_id') {
244
+ $compatibleDataTypes = true;
245
+ $error = 'Doppler: country – Magento: ' . $savedMagentoAttributeCode;
246
+ }
247
+ break;
248
+ default:
249
+ $compatibleDataTypes = true;
250
+ }
251
+
252
+ if (!$compatibleDataTypes) {
253
+ $this->_getSession()->addError($this->__('The Doppler field data type is not compatible with the selected Magento attribute data type: %s', $error));
254
+ $this->_redirect("*/*/");
255
+ } else {
256
+ $model = Mage::getModel('makingsense_doppler/leadmap');
257
+ $model->setData($data);
258
+ $model->save();
259
+
260
+ $this->_getSession()->addSuccess($this->__('Saved'));
261
+ }
262
+ } else {
263
+ $model = Mage::getModel('makingsense_doppler/leadmap');
264
+ $model->setData($data);
265
+ $model->save();
266
+
267
+ $this->_getSession()->addSuccess($this->__('Saved'));
268
+ }
269
+ } else {
270
+ $this->_getSession()->addError($this->__('There is already a Magento attribute associated with the following Doppler field: %s', $savedDopplerFieldName));
271
+ }
272
+
273
+ } catch (Exception $e){
274
+ $this->_getSession()->addError($e->getMessage());
275
+ }
276
+ }
277
+
278
+ $this->_redirect("*/*/");
279
+ }
280
+
281
+ /**
282
+ * MassDelete action logic
283
+ */
284
+ public function massDeleteAction()
285
+ {
286
+ $data = $this->getRequest()->getParam('leadmap');
287
+ if (!is_array($data)){
288
+ $this->_getSession()->addError(
289
+ $this->__("Please select at least one record")
290
+ );
291
+ } else {
292
+ try {
293
+ foreach ($data as $id){
294
+ $leadmap = Mage::getModel('makingsense_doppler/leadmap')->load($id);
295
+ $leadmap->delete();
296
+ }
297
+
298
+ $this->_getSession()->addSuccess(
299
+ $this->__('Total of %d record(s) have been deleted', count($data))
300
+ );
301
+ } catch (Exception $e){
302
+ $this->_getSession()->addError($e->getMessage());
303
+ }
304
+ }
305
+
306
+ $this->_redirect("*/*/");
307
+ }
308
+ }
app/code/local/MakingSense/Doppler/controllers/Adminhtml/ListsController.php ADDED
@@ -0,0 +1,492 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Lists admin page controller
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+
10
+ class MakingSense_Doppler_Adminhtml_ListsController extends Mage_Adminhtml_Controller_Action
11
+ {
12
+ /**
13
+ * Set active menu
14
+ */
15
+ protected function initAction()
16
+ {
17
+ $this->loadLayout()
18
+ ->_setActiveMenu('makingsense_doppler/lists');
19
+
20
+ return $this;
21
+ }
22
+
23
+ /**
24
+ * Create block for index action
25
+ */
26
+ public function indexAction()
27
+ {
28
+ $statusCode = Mage::helper('makingsense_doppler')->testAPIConnection();
29
+ $errorStatusCode = false;
30
+
31
+ if (!$statusCode)
32
+ {
33
+ $errorStatusCode = true;
34
+ Mage::getSingleton('core/session')->addError($this->__('Please, add your credentials for the Doppler API in System -> Configuration -> Doppler'));
35
+ } else {
36
+ if ($statusCode != '200')
37
+ {
38
+ if ($statusCode == '404' || $statusCode == '4040')
39
+ {
40
+ Mage::getSingleton('core/session')->addError($this->__('The Doppler API is not currently available, please try later'));
41
+ } else {
42
+ Mage::getSingleton('core/session')->addError($this->__('Your credentials are not valid, please check your username and API key and try again'));
43
+ $errorStatusCode = true;
44
+ }
45
+ }
46
+ }
47
+
48
+ if($errorStatusCode)
49
+ {
50
+ $this->initAction()
51
+ ->renderLayout();
52
+ } else {
53
+
54
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
55
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
56
+
57
+ if($usernameValue != '' && $apiKeyValue != '')
58
+ {
59
+ // Get cURL resource
60
+ $ch = curl_init();
61
+
62
+ // Set url
63
+ curl_setopt($ch, CURLOPT_URL, 'https://restapi.fromdoppler.com/accounts/' . $usernameValue . '/lists?page=1&per_page=200');
64
+
65
+ // Set method
66
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
67
+
68
+ // Set options
69
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
70
+
71
+ // Set headers
72
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
73
+ "Authorization: token " . $apiKeyValue,
74
+ ]
75
+ );
76
+
77
+ // Send the request & save response to $resp
78
+ $resp = curl_exec($ch);
79
+
80
+ if ($resp)
81
+ {
82
+ $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
83
+
84
+ $responseContent = json_decode($resp, true);
85
+
86
+ if ($statusCode == '200') {
87
+
88
+ $model = Mage::getModel('makingsense_doppler/lists');
89
+
90
+ // First, remove the old Doppler lists
91
+ foreach ($model->getCollection() as $list)
92
+ {
93
+ $model->load($list->getId())->delete();
94
+ }
95
+
96
+ // Then, store all list from latest API call
97
+ $fieldsResponseArray = $responseContent['items'];
98
+
99
+ foreach ($fieldsResponseArray as $field) {
100
+ $data = array();
101
+
102
+
103
+ $data['name'] = $field['name'];
104
+ $data['list_id'] = $field['listId'];
105
+ $data['status'] = $field['currentStatus'];
106
+ $data['subscribers_count'] = $field['subscribersCount'];
107
+ $data['creation_date'] = $field['creationDate'];
108
+
109
+ $model->setData($data);
110
+ $model->save();
111
+ }
112
+
113
+ } else
114
+ {
115
+ $this->_getSession()->addError($this->__('The following errors occurred creating your list: %s', $responseContent['title']));
116
+ }
117
+ }
118
+
119
+ // Close request to clear up some resources
120
+ curl_close($ch);
121
+ }
122
+
123
+ $this->initAction()
124
+ ->_addContent($this->getLayout()->createBlock('makingsense_doppler/adminhtml_lists'))
125
+ ->renderLayout();
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Forward new to edit action
131
+ */
132
+ public function newAction()
133
+ {
134
+ $this->_forward('edit');
135
+ }
136
+
137
+ /**
138
+ * Edit action logic
139
+ */
140
+ public function editAction()
141
+ {
142
+ $id = $this->getRequest()->getParam('id');
143
+
144
+ $model = Mage::getModel('makingsense_doppler/lists');
145
+ if ($id){
146
+ $model->load($id);
147
+
148
+ if (!$model->getId()){
149
+ $this->_getSession()->addError($this->__('List does not exist'));
150
+ $this->_redirect('*/*/');
151
+ return;
152
+ }
153
+ }
154
+
155
+ Mage::register('lists_data', $model);
156
+
157
+ $this->initAction()
158
+ ->_addContent($this->getLayout()->createBlock('makingsense_doppler/adminhtml_lists_edit'))
159
+ ->renderLayout();
160
+ }
161
+
162
+ /**
163
+ * Delete action logic
164
+ */
165
+ public function deleteAction()
166
+ {
167
+ $id = $this->getRequest()->getParam('id');
168
+ if ($id){
169
+ try {
170
+ $list = Mage::getModel('makingsense_doppler/lists')->load($id);
171
+ if (!$list->getId()){
172
+ $this->_getSession()->addError("List %s does not exist", $id);
173
+ $this->_redirect("*/*/");
174
+ return;
175
+ }
176
+
177
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
178
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
179
+
180
+ if($usernameValue != '' && $apiKeyValue != '') {
181
+ // Get cURL resource
182
+ $ch = curl_init();
183
+
184
+ // Set url
185
+ curl_setopt($ch, CURLOPT_URL, 'https://restapi.fromdoppler.com/accounts/' . $usernameValue. '/lists/' . $list->getListId());
186
+
187
+ // Set method
188
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
189
+
190
+ // Set options
191
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
192
+
193
+ // Set headers
194
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
195
+ "Authorization: token " . $apiKeyValue,
196
+ "Content-Type: application/json",
197
+ ]
198
+ );
199
+
200
+
201
+ // Send the request & save response to $resp
202
+ $resp = curl_exec($ch);
203
+
204
+ if($resp)
205
+ {
206
+ $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
207
+
208
+ if ($statusCode == '200')
209
+ {
210
+ $this->_getSession()->addSuccess($this->__("The list '%s' has been successfully removed", $list->getName()));
211
+ } else
212
+ {
213
+ $responseContent = json_decode($resp, true);
214
+ $this->_getSession()->addError($this->__('The following errors occurred removing your list: ' . $responseContent['title']));
215
+ }
216
+ }
217
+
218
+ // Close request to clear up some resources
219
+ curl_close($ch);
220
+
221
+ $list->delete();
222
+ }
223
+
224
+ } catch (Exception $e){
225
+ $this->_getSession()->addError($e->getMessage());
226
+ }
227
+ }
228
+
229
+ $this->_redirect("*/*/");
230
+ }
231
+
232
+ /**
233
+ * Save action logic
234
+ */
235
+ public function saveAction()
236
+ {
237
+ $data = $this->getRequest()->getPost();
238
+
239
+ if ($data)
240
+ {
241
+ // If we are editing a list, then save the new list name and check if the edited list should be the default list
242
+ if (array_key_exists('id', $data))
243
+ {
244
+ try {
245
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
246
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
247
+
248
+ if($usernameValue != '' && $apiKeyValue != '')
249
+ {
250
+ // Get cURL resource
251
+ $ch = curl_init();
252
+
253
+ // Set url
254
+ curl_setopt($ch, CURLOPT_URL, 'https://restapi.fromdoppler.com/accounts/' . $usernameValue. '/lists/' . $data['list_id']);
255
+
256
+ // Set method
257
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
258
+
259
+ // Set options
260
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
261
+
262
+ // Set headers
263
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
264
+ "Authorization: token " . $apiKeyValue,
265
+ "Content-Type: application/json",
266
+ ]
267
+ );
268
+
269
+ // Create body
270
+ $body = '{ name: "' . $data['name'] . '" }';
271
+
272
+ // Set body
273
+ curl_setopt($ch, CURLOPT_POST, 1);
274
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
275
+
276
+ // Send the request & save response to $resp
277
+ $resp = curl_exec($ch);
278
+
279
+ if ($resp)
280
+ {
281
+ $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
282
+
283
+ if ($statusCode == '200')
284
+ {
285
+ $this->_getSession()->addSuccess($this->__('The changes have been saved'));
286
+
287
+ // If the new list has been marked as default, then update default list in Magento
288
+ if (isset($data['default_list']))
289
+ {
290
+ $model = Mage::getModel('makingsense_doppler/defaultlist');
291
+
292
+ // Remove the old list information
293
+ foreach ($model->getCollection() as $list) {
294
+ $model->load($list->getId())->delete();
295
+ }
296
+
297
+ $newDefaultList = array();
298
+
299
+ $newDefaultList['name'] = $data['name'];
300
+ $newDefaultList['listId'] = $data['list_id'];
301
+
302
+ $model->setData($newDefaultList);
303
+ $model->save();
304
+ } else {
305
+ // If not, check if the current list was the default list and remove it if that was the case
306
+ $isDefaultList = Mage::helper('makingsense_doppler')->isDefaultList($data['id']);
307
+
308
+ if ($isDefaultList)
309
+ {
310
+ $model = Mage::getModel('makingsense_doppler/defaultlist');
311
+ foreach ($model->getCollection() as $list) {
312
+ $model->load($list->getId())->delete();
313
+ }
314
+ }
315
+ }
316
+ } else
317
+ {
318
+ $responseContent = json_decode($resp, true);
319
+ $this->_getSession()->addError($this->__('The following errors occurred creating your list: ' . $responseContent['title']));
320
+ }
321
+ }
322
+
323
+ // Close request to clear up some resources
324
+ curl_close($ch);
325
+ }
326
+
327
+ } catch (Exception $e) {
328
+ $this->_getSession()->addError($e->getMessage());
329
+ }
330
+ }
331
+ // Else, save the new list
332
+ else
333
+ {
334
+ try
335
+ {
336
+
337
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
338
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
339
+
340
+ if($usernameValue != '' && $apiKeyValue != '')
341
+ {
342
+ // Get cURL resource
343
+ $ch = curl_init();
344
+
345
+ // Set url
346
+ curl_setopt($ch, CURLOPT_URL, 'https://restapi.fromdoppler.com/accounts/' . $usernameValue . '/lists');
347
+
348
+ // Set method
349
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
350
+
351
+ // Set options
352
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
353
+
354
+ // Set headers
355
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
356
+ "Authorization: token " . $apiKeyValue,
357
+ "Content-Type: application/json",
358
+ ]
359
+ );
360
+
361
+ // Create body
362
+ $body = '{ name: "' . $data['name'] . '" }';
363
+
364
+ // Set body
365
+ curl_setopt($ch, CURLOPT_POST, 1);
366
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
367
+
368
+ // Send the request & save response to $resp
369
+ $resp = curl_exec($ch);
370
+
371
+ if ($resp)
372
+ {
373
+ $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
374
+
375
+ if ($statusCode == '201')
376
+ {
377
+ $this->_getSession()->addSuccess($this->__('The list has been successfully created'));
378
+
379
+ // If the new list has been marked as default, then update default list in Magento
380
+ if (isset($data['default_list']))
381
+ {
382
+ $responseContent = json_decode($resp, true);
383
+ $createdListId = $responseContent['createdResourceId'];
384
+
385
+ $model = Mage::getModel('makingsense_doppler/defaultlist');
386
+
387
+ // Remove the old list information
388
+ foreach ($model->getCollection() as $list)
389
+ {
390
+ $model->load($list->getId())->delete();
391
+ }
392
+
393
+ $newDefaultList = array();
394
+
395
+ $newDefaultList['name'] = $data['name'];
396
+ $newDefaultList['listId'] = $createdListId;
397
+
398
+ $model->setData($newDefaultList);
399
+ $model->save();
400
+ }
401
+ } else {
402
+ $responseContent = json_decode($resp, true);
403
+ $this->_getSession()->addError($this->__('The following errors occurred creating your list: ' . $responseContent['title']));
404
+ }
405
+ }
406
+
407
+ // Close request to clear up some resources
408
+ curl_close($ch);
409
+ }
410
+
411
+ } catch (Exception $e) {
412
+ $this->_getSession()->addError($e->getMessage());
413
+ }
414
+ }
415
+ }
416
+
417
+ $this->_redirect("*/*/");
418
+ }
419
+
420
+ /**
421
+ * MassDelete action logic
422
+ */
423
+ public function massDeleteAction()
424
+ {
425
+ $data = $this->getRequest()->getParam('lists');
426
+ if (!is_array($data))
427
+ {
428
+ $this->_getSession()->addError(
429
+ $this->__("Please select at least one record")
430
+ );
431
+ } else
432
+ {
433
+ try
434
+ {
435
+ foreach ($data as $id)
436
+ {
437
+ $list = Mage::getModel('makingsense_doppler/lists')->load($id);
438
+
439
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
440
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
441
+
442
+ if($usernameValue != '' && $apiKeyValue != '')
443
+ {
444
+ // Get cURL resource
445
+ $ch = curl_init();
446
+
447
+ // Set url
448
+ curl_setopt($ch, CURLOPT_URL, 'https://restapi.fromdoppler.com/accounts/' . $usernameValue . '/lists/' . $list->getListId());
449
+
450
+ // Set method
451
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
452
+
453
+ // Set options
454
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
455
+
456
+ // Set headers
457
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
458
+ "Authorization: token " . $apiKeyValue,
459
+ "Content-Type: application/json",
460
+ ]
461
+ );
462
+
463
+ // Send the request & save response to $resp
464
+ $resp = curl_exec($ch);
465
+
466
+ if ($resp)
467
+ {
468
+ $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
469
+
470
+ if ($statusCode == '200')
471
+ {
472
+ $this->_getSession()->addSuccess($this->__("The list '%s' has been successfully removed", $list->getName()));
473
+ } else {
474
+ $responseContent = json_decode($resp, true);
475
+ $this->_getSession()->addError($this->__('The following errors occurred removing your list: ' . $responseContent['title']));
476
+ }
477
+ }
478
+
479
+ // Close request to clear up some resources
480
+ curl_close($ch);
481
+
482
+ $list->delete();
483
+ }
484
+ }
485
+ } catch (Exception $e){
486
+ $this->_getSession()->addError($e->getMessage());
487
+ }
488
+ }
489
+
490
+ $this->_redirect("*/*/");
491
+ }
492
+ }
app/code/local/MakingSense/Doppler/controllers/Adminhtml/SubscribersController.php ADDED
@@ -0,0 +1,444 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Subscribers admin page controller
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+
10
+ class MakingSense_Doppler_Adminhtml_SubscribersController extends Mage_Adminhtml_Controller_Action
11
+ {
12
+
13
+ /**
14
+ * Set active menu
15
+ */
16
+ protected function initAction()
17
+ {
18
+ $this->loadLayout()
19
+ ->_setActiveMenu('makingsense_doppler/subscribers');
20
+
21
+ return $this;
22
+ }
23
+
24
+ /**
25
+ * Load current customer
26
+ */
27
+ protected function _initCustomer($idFieldName = 'id')
28
+ {
29
+ $this->_title($this->__('Customers'))->_title($this->__('Manage Subscribers'));
30
+
31
+ $customerId = (int) $this->getRequest()->getParam($idFieldName);
32
+ $customer = Mage::getModel('customer/customer');
33
+
34
+ if ($customerId) {
35
+ $customer->load($customerId);
36
+ }
37
+
38
+ Mage::register('current_customer', $customer);
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Customers list action
44
+ */
45
+ public function indexAction()
46
+ {
47
+ $statusCode = Mage::helper('makingsense_doppler')->testAPIConnection();
48
+ $errorStatusCode = false;
49
+
50
+ if (!$statusCode)
51
+ {
52
+ $errorStatusCode = true;
53
+ Mage::getSingleton('core/session')->addError($this->__('Please, add your credentials for the Doppler API in System -> Configuration -> Doppler'));
54
+ } else {
55
+ if ($statusCode != '200')
56
+ {
57
+ if ($statusCode == '404' || $statusCode == '4040')
58
+ {
59
+ Mage::getSingleton('core/session')->addError($this->__('The Doppler API is not currently available, please try later'));
60
+ } else {
61
+ Mage::getSingleton('core/session')->addError($this->__('Your credentials are not valid, please check your username and API key and try again'));
62
+ $errorStatusCode = true;
63
+ }
64
+ }
65
+ }
66
+
67
+ if($errorStatusCode)
68
+ {
69
+ $this->initAction()
70
+ ->renderLayout();
71
+ } else {
72
+
73
+ $usernameValue = Mage::getStoreConfig('doppler/connection/username');
74
+ $apiKeyValue = Mage::getStoreConfig('doppler/connection/key');
75
+
76
+ if($usernameValue != '' && $apiKeyValue != '')
77
+ {
78
+ // Before loading the page, get all the import tasks that are processing to check if they are completed now
79
+ $pendingImportTasks = Mage::getModel('makingsense_doppler/importtasks')
80
+ ->getCollection()
81
+ ->addFieldToFilter('status', array('eq' => 'Processing'));
82
+
83
+ if (count($pendingImportTasks))
84
+ {
85
+ foreach ($pendingImportTasks as $pendingImportTask)
86
+ {
87
+ $importTaskTime = $pendingImportTask->getCreation();
88
+ $format = Mage::app()->getLocale()->getDateFormat(
89
+ Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM
90
+ );
91
+ Mage::getSingleton('adminhtml/session')->addNotice($this->__('The export task that has been started at %s is in progress', Mage::helper('core')->formatTime($importTaskTime, 'long', true)));
92
+
93
+ $importTaskId = $pendingImportTask->getData('id');
94
+ $importId = $pendingImportTask->getImportId();
95
+
96
+ // Get cURL resource
97
+ $ch = curl_init();
98
+
99
+ // Set url
100
+ curl_setopt($ch, CURLOPT_URL, 'https://restapi.fromdoppler.com/accounts/' . $usernameValue . '/tasks/' . $importId . '/import-errors');
101
+
102
+ // Set method
103
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
104
+
105
+ // Set options
106
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
107
+
108
+ // Set headers
109
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
110
+ 'Authorization: token ' . $apiKeyValue,
111
+ ]
112
+ );
113
+
114
+ // Send the request & save response to $resp
115
+ $resp = curl_exec($ch);
116
+
117
+ if ($resp)
118
+ {
119
+ $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
120
+
121
+ if ($statusCode == '200')
122
+ {
123
+ $responseContent = json_decode($resp, true);
124
+ $numberOfErrors = $responseContent['itemsCount'];
125
+
126
+ $serializedCustomersEmailsFromImport = $pendingImportTask->getCustomers();
127
+ $customersEmailsFromImport = unserialize($serializedCustomersEmailsFromImport);
128
+
129
+ // If there are import errors, then get the emails from the emails with errors
130
+ if ($numberOfErrors > 0)
131
+ {
132
+ $itemsWithErrors = $responseContent['items'];
133
+
134
+ foreach ($customersEmailsFromImport as $customerEmail)
135
+ {
136
+ // Load this customer account for all the websites
137
+ $customerFromAllWebsites = Mage::getModel('customer/customer')
138
+ ->getCollection()
139
+ ->addAttributeToSelect('*')
140
+ ->addAttributeToFilter('email', $customerEmail);
141
+
142
+ foreach ($customerFromAllWebsites as $customer)
143
+ {
144
+ $errorInExport = false;
145
+ foreach ($itemsWithErrors as $item)
146
+ {
147
+ if (isset($item['email']))
148
+ {
149
+ if ($item['email'] == $customerEmail)
150
+ {
151
+ $errorInExport = true;
152
+ if (isset($item['errorCode']))
153
+ {
154
+ $customer->setStatusDopplerSync($item['errorCode']);
155
+ } else {
156
+ $customer->setStatusDopplerSync('Error');
157
+ }
158
+ $customer->save();
159
+ }
160
+ }
161
+ }
162
+ if (!$errorInExport)
163
+ {
164
+ $customer->setStatusDopplerSync('Completed');
165
+ $customer->save();
166
+ }
167
+ }
168
+
169
+ }
170
+
171
+ } else {
172
+
173
+ // If there are no errors, then iterate over all customrs and set status 'Completed'
174
+ foreach ($customersEmailsFromImport as $customerEmail)
175
+ {
176
+ // Load this customer account for all the websites
177
+ $customerFromAllWebsites = Mage::getModel('customer/customer')
178
+ ->getCollection()
179
+ ->addAttributeToSelect('*')
180
+ ->addAttributeToFilter('email', $customerEmail);
181
+
182
+ foreach ($customerFromAllWebsites as $customer)
183
+ {
184
+ $customer->setStatusDopplerSync('Completed');
185
+ $customer->save();
186
+ }
187
+ }
188
+ }
189
+
190
+ $importTask = Mage::getModel('makingsense_doppler/importtasks')->load($importTaskId);
191
+ $importTask->setStatus('Completed');
192
+ $importTask->save();
193
+
194
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The export task that has been started at %s has finished', Mage::helper('core')->formatTime($importTaskTime, 'long', true)));
195
+
196
+ }
197
+ }
198
+
199
+ // Close request to clear up some resources
200
+ curl_close($ch);
201
+ }
202
+ }
203
+
204
+ }
205
+
206
+ $this->_title($this->__('Customers'))->_title($this->__('Manage Subscribers'));
207
+
208
+ if ($this->getRequest()->getQuery('ajax')) {
209
+ $this->_forward('grid');
210
+ return;
211
+ }
212
+ $this->loadLayout();
213
+
214
+ /**
215
+ * Set active menu item
216
+ */
217
+ $this->_setActiveMenu('doppler/subscribers');
218
+
219
+ /**
220
+ * Append customers block to content
221
+ */
222
+ $this->_addContent(
223
+ $this->getLayout()->createBlock('makingsense_doppler/adminhtml_subscribers', 'subscribers')
224
+ );
225
+
226
+ /**
227
+ * Add breadcrumb item
228
+ */
229
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Customers'), Mage::helper('adminhtml')->__('Customers'));
230
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Manage Subscribers'), Mage::helper('adminhtml')->__('Manage Subscribers'));
231
+
232
+ $this->renderLayout();
233
+ }
234
+ }
235
+
236
+ public function gridAction()
237
+ {
238
+ $this->loadLayout();
239
+ $this->getResponse()->setBody(
240
+ $this->getLayout()->createBlock('makingsense_doppler/adminhtml_subscribers_grid')->toHtml()
241
+ );
242
+ }
243
+
244
+ /**
245
+ * Customer edit action
246
+ */
247
+ public function editAction()
248
+ {
249
+ $statusCode = Mage::helper('makingsense_doppler')->testAPIConnection();
250
+ $errorStatusCode = false;
251
+
252
+ if (!$statusCode)
253
+ {
254
+ $errorStatusCode = true;
255
+ Mage::getSingleton('core/session')->addError($this->__('Please, add your credentials for the Doppler API in System -> Configuration -> Doppler'));
256
+ } else {
257
+ if ($statusCode != '200')
258
+ {
259
+ if ($statusCode == '404' || $statusCode == '4040')
260
+ {
261
+ Mage::getSingleton('core/session')->addError($this->__('The Doppler API is not currently available, please try later'));
262
+ } else {
263
+ Mage::getSingleton('core/session')->addError($this->__('Your credentials are not valid, please check your username and API key and try again'));
264
+ $errorStatusCode = true;
265
+ }
266
+ }
267
+ }
268
+
269
+ if($errorStatusCode)
270
+ {
271
+ $this->initAction()
272
+ ->_addContent($this->getLayout()->createBlock('makingsense_doppler/adminhtml_leadmap_edit'))
273
+ ->renderLayout();
274
+ } else {
275
+
276
+ $id = $this->getRequest()->getParam('id');
277
+
278
+ $model = Mage::getModel('customer/customer');
279
+ if ($id){
280
+ $model->load($id);
281
+
282
+ if (!$model->getId()){
283
+ $this->_getSession()->addError($this->__('Mapping does not exist'));
284
+ $this->_redirect('*/*/');
285
+ return;
286
+ }
287
+ }
288
+
289
+ Mage::register('subscribers_data', $model);
290
+
291
+ $this->initAction()
292
+ ->_addContent($this->getLayout()->createBlock('makingsense_doppler/adminhtml_subscribers_edit'))
293
+ ->renderLayout();
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Create new customer action
299
+ */
300
+ public function newAction()
301
+ {
302
+ $this->_forward('edit');
303
+ }
304
+
305
+ /**
306
+ * Delete customer action
307
+ */
308
+ public function deleteAction()
309
+ {
310
+ $this->_initCustomer();
311
+ $customer = Mage::registry('current_customer');
312
+ if ($customer->getId()) {
313
+ try {
314
+ $customer->load($customer->getId());
315
+ $customer->delete();
316
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('The customer has been deleted.'));
317
+ }
318
+ catch (Exception $e){
319
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
320
+ }
321
+ }
322
+ $this->_redirect('*/customer');
323
+ }
324
+
325
+ /**
326
+ * Save customer action
327
+ */
328
+ public function saveAction()
329
+ {
330
+ $data = $this->getRequest()->getPost();
331
+
332
+ if ($data) {
333
+ try {
334
+ // Load customer
335
+ $customer = Mage::getModel('customer/customer');
336
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
337
+ $customer->load($data['entity_id']);
338
+
339
+ // Export customer to Doppler
340
+ $dopplerMappedFields = Mage::helper('makingsense_doppler')->getDopplerMappedFields();
341
+ $mappedFieldsCount = count($dopplerMappedFields);
342
+ $leadMappingArrayKeys = array_keys($dopplerMappedFields);
343
+ $dopplerAttributeTypes = array();
344
+ for ($i = 0; $i < $mappedFieldsCount; $i++) {
345
+ $fieldName = $leadMappingArrayKeys[$i];
346
+ $dopplerAttributeTypes[$fieldName] = Mage::helper('makingsense_doppler')->getDopplerFieldDataType($fieldName);
347
+ }
348
+ $exportError = Mage::helper('makingsense_doppler')->exportCustomerToDoppler($customer, $data['doppler_list'], $dopplerMappedFields, $dopplerAttributeTypes);
349
+
350
+ if (!$exportError)
351
+ {
352
+ Mage::getSingleton('core/session')->addSuccess($this->__('The customer has been subscribed to the selected list'));
353
+ }
354
+ } catch (Exception $e) {
355
+ $this->_getSession()->addError($e->getMessage());
356
+ }
357
+ }
358
+
359
+ $this->_redirect("*/*/");
360
+ }
361
+
362
+ /**
363
+ * Export customer grid to CSV format
364
+ */
365
+ public function exportCsvAction()
366
+ {
367
+ $fileName = 'customers.csv';
368
+ $content = $this->getLayout()->createBlock('adminhtml/customer_grid')
369
+ ->getCsvFile();
370
+
371
+ $this->_prepareDownloadResponse($fileName, $content);
372
+ }
373
+
374
+ /**
375
+ * Export customer grid to XML format
376
+ */
377
+ public function exportXmlAction()
378
+ {
379
+ $fileName = 'customers.xml';
380
+ $content = $this->getLayout()->createBlock('adminhtml/customer_grid')
381
+ ->getExcelFile();
382
+
383
+ $this->_prepareDownloadResponse($fileName, $content);
384
+ }
385
+
386
+ /**
387
+ * Prepare file download response
388
+ *
389
+ * @todo remove in 1.3
390
+ * @deprecated please use $this->_prepareDownloadResponse()
391
+ * @see Mage_Adminhtml_Controller_Action::_prepareDownloadResponse()
392
+ * @param string $fileName
393
+ * @param string $content
394
+ * @param string $contentType
395
+ */
396
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
397
+ {
398
+ $this->_prepareDownloadResponse($fileName, $content, $contentType);
399
+ }
400
+
401
+ /**
402
+ * MassExport action logic
403
+ */
404
+ public function massExportAction()
405
+ {
406
+ $customersIds = $this->getRequest()->getParam('customer');
407
+ if(!is_array($customersIds)) {
408
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select customer(s).'));
409
+
410
+ } else {
411
+ try {
412
+ $customers = Mage::getModel('customer/customer')->getCollection()
413
+ ->addFieldToFilter('entity_id', array('in' => $customersIds));
414
+
415
+ $dopplerListId = $this->getRequest()->getParam('list');
416
+ Mage::helper('makingsense_doppler')->exportMultipleCustomersToDoppler($customers, $dopplerListId);
417
+
418
+ } catch (Exception $e) {
419
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
420
+ }
421
+ }
422
+ $this->_redirect('*/*/index');
423
+ }
424
+
425
+ /**
426
+ * Validate admin user permissions
427
+ */
428
+ protected function _isAllowed()
429
+ {
430
+ return Mage::getSingleton('admin/session')->isAllowed('customer/manage');
431
+ }
432
+
433
+ /**
434
+ * Filtering posted data. Converting localized data if needed
435
+ *
436
+ * @param array
437
+ * @return array
438
+ */
439
+ protected function _filterPostData($data)
440
+ {
441
+ $data['account'] = $this->_filterDates($data['account'], array('dob'));
442
+ return $data;
443
+ }
444
+ }
app/code/local/MakingSense/Doppler/etc/adminhtml.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <menu>
4
+ <doppler translate="title" module="makingsense_doppler">
5
+ <title>Doppler</title>
6
+ <sort_order>65</sort_order>
7
+ <children>
8
+ <doppler_subscribers translate="title" module="makingsense_doppler">
9
+ <title>Subscribers</title>
10
+ <action>adminhtml/subscribers</action>
11
+ </doppler_subscribers>
12
+ <doppler_lists translate="title" module="makingsense_doppler">
13
+ <title>Doppler Lists</title>
14
+ <action>adminhtml/lists</action>
15
+ </doppler_lists>
16
+ <lead_mapping translate="title" module="makingsense_doppler">
17
+ <title>Lead Mapping</title>
18
+ <action>adminhtml/leadmap</action>
19
+ </lead_mapping>
20
+ <defaultlist translate="title" module="makingsense_doppler">
21
+ <title>Default Doppler List</title>
22
+ <action>adminhtml/defaultlist</action>
23
+ </defaultlist>
24
+ <api_connection translate="title" module="makingsense_doppler">
25
+ <title>API Connection</title>
26
+ <action>adminhtml/system_config/edit/section/doppler</action>
27
+ </api_connection>
28
+ </children>
29
+ </doppler>
30
+ </menu>
31
+ <acl>
32
+ <resources>
33
+ <admin>
34
+ <children>
35
+ <system>
36
+ <children>
37
+ <config>
38
+ <children>
39
+ <doppler translate="title" module="makingsense_doppler">
40
+ <title>Doppler API</title>
41
+ </doppler>
42
+ </children>
43
+ </config>
44
+ </children>
45
+ </system>
46
+ </children>
47
+ </admin>
48
+ </resources>
49
+ </acl>
50
+ </config>
app/code/local/MakingSense/Doppler/etc/config.xml ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <MakingSense_Doppler>
5
+ <version>0.1.6</version>
6
+ </MakingSense_Doppler>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <adminhtml>
11
+ <args>
12
+ <modules>
13
+ <MakingSense_Doppler before="Mage_Adminhtml">MakingSense_Doppler_Adminhtml</MakingSense_Doppler>
14
+ </modules>
15
+ </args>
16
+ </adminhtml>
17
+ </routers>
18
+ </admin>
19
+ <adminhtml>
20
+ <translate>
21
+ <modules>
22
+ <MakingSense_Doppler>
23
+ <files>
24
+ <default>MakingSense_Doppler.csv</default>
25
+ </files>
26
+ </MakingSense_Doppler>
27
+ </modules>
28
+ </translate>
29
+ <layout>
30
+ <updates>
31
+ <MakingSense_Doppler>
32
+ <file>makingsense_doppler.xml</file>
33
+ </MakingSense_Doppler>
34
+ </updates>
35
+ </layout>
36
+ </adminhtml>
37
+ <global>
38
+ <helpers>
39
+ <makingsense_doppler>
40
+ <class>MakingSense_Doppler_Helper</class>
41
+ </makingsense_doppler>
42
+ </helpers>
43
+ <blocks>
44
+ <makingsense_doppler>
45
+ <class>MakingSense_Doppler_Block</class>
46
+ </makingsense_doppler>
47
+ <adminhtml>
48
+ <rewrite>
49
+ <page_menu>MakingSense_Doppler_Block_Adminhtml_Page_Menu</page_menu>
50
+ </rewrite>
51
+ </adminhtml>
52
+ </blocks>
53
+ <models>
54
+ <makingsense_doppler>
55
+ <class>MakingSense_Doppler_Model</class>
56
+ <resourceModel>makingsense_doppler_resource</resourceModel>
57
+ </makingsense_doppler>
58
+ <makingsense_doppler_resource>
59
+ <class>MakingSense_Doppler_Model_Resource</class>
60
+ <entities>
61
+ <doppler_leadmap>
62
+ <table>doppler_leadmap</table>
63
+ </doppler_leadmap>
64
+ <doppler_lists>
65
+ <table>doppler_lists</table>
66
+ </doppler_lists>
67
+ <doppler_defaultlist>
68
+ <table>doppler_defaultlist</table>
69
+ </doppler_defaultlist>
70
+ <doppler_importtasks>
71
+ <table>doppler_importtasks</table>
72
+ </doppler_importtasks>
73
+ </entities>
74
+ </makingsense_doppler_resource>
75
+ </models>
76
+ <resources>
77
+ <makingsense_doppler_setup>
78
+ <setup>
79
+ <module>MakingSense_Doppler</module>
80
+ <class>Mage_Catalog_Model_Resource_Setup</class>
81
+ </setup>
82
+ </makingsense_doppler_setup>
83
+ </resources>
84
+ </global>
85
+ <frontend>
86
+ <events>
87
+ <controller_action_postdispatch_customer_account_createpost>
88
+ <observers>
89
+ <makingsense_doppler_user_registration>
90
+ <type>singleton</type>
91
+ <class>MakingSense_Doppler_Model_Observer</class>
92
+ <method>userRegistration</method>
93
+ </makingsense_doppler_user_registration>
94
+ </observers>
95
+ </controller_action_postdispatch_customer_account_createpost>
96
+ <sales_model_service_quote_submit_after>
97
+ <observers>
98
+ <makingsense_doppler_checkout_registration>
99
+ <type>singleton</type>
100
+ <class>MakingSense_Doppler_Model_Observer</class>
101
+ <method>checkoutUserRegistration</method>
102
+ </makingsense_doppler_checkout_registration>
103
+ </observers>
104
+ </sales_model_service_quote_submit_after>
105
+ </events>
106
+ </frontend>
107
+ </config>
app/code/local/MakingSense/Doppler/etc/system.xml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <doppler translate="label" module="makingsense_doppler">
5
+ <label>Doppler</label>
6
+ <tab>customer</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>15</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <connection translate="label">
14
+ <label>Doppler API</label>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>10</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <fields>
21
+ <username translate="label">
22
+ <label>Username</label>
23
+ <frontend_type>text</frontend_type>
24
+ <validate>validate-email</validate>
25
+ <comment>This is your Doppler email address.</comment>
26
+ <sort_order>10</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ </username>
31
+ <key translate="label">
32
+ <label>API key</label>
33
+ <frontend_type>text</frontend_type>
34
+ <validate>validate-alphanum</validate>
35
+ <sort_order>20</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ </key>
40
+ <test_connection>
41
+ <label></label>
42
+ <comment></comment>
43
+ <frontend_type>text</frontend_type>
44
+ <frontend_model>makingsense_doppler/system_config_form_fieldset_connection_test</frontend_model>
45
+ <sort_order>50</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>0</show_in_website>
48
+ <show_in_store>0</show_in_store>
49
+ </test_connection>
50
+ </fields>
51
+ </connection>
52
+ </groups>
53
+ </doppler>
54
+ </sections>
55
+ </config>
app/code/local/MakingSense/Doppler/sql/makingsense_doppler_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Default installer
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+
10
+ $installer = $this;
11
+
12
+ $installer->startSetup();
13
+ $installer->endSetup();
app/code/local/MakingSense/Doppler/sql/makingsense_doppler_setup/mysql4-upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * 0.1.0 - 0.1.1 upgrade installer
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+
10
+ $installer = $this;
11
+
12
+ $installer->startSetup();
13
+
14
+ if (!$installer->tableExists($installer->getTable('makingsense_doppler/doppler_leadmap'))) {
15
+ $installer->run("
16
+ CREATE TABLE `{$installer->getTable('makingsense_doppler/doppler_leadmap')}` (
17
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
18
+ `doppler_field_name` varchar(255) DEFAULT NULL,
19
+ `magento_field_name` varchar(255) DEFAULT NULL,
20
+ PRIMARY KEY (`id`)
21
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
22
+ ");
23
+ }
24
+
25
+ $installer->endSetup();
app/code/local/MakingSense/Doppler/sql/makingsense_doppler_setup/mysql4-upgrade-0.1.1-0.1.2.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * 0.1.1 - 0.1.2 upgrade installer
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+
13
+ $entityTypeId = $installer->getEntityTypeId(Mage_Catalog_Model_Category::ENTITY);
14
+ $attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
15
+ $attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
16
+
17
+ $installer->addAttribute('customer', 'doppler_synced', array(
18
+ 'input' => 'boolean',
19
+ 'type' => 'int',
20
+ 'label' => 'Exported to Doppler',
21
+ 'visible' => 1,
22
+ 'required' => 0,
23
+ 'user_defined' => 0,
24
+ 'default' => 0
25
+ ));
26
+
27
+ $installer->addAttributeToGroup(
28
+ $entityTypeId,
29
+ $attributeSetId,
30
+ $attributeGroupId,
31
+ 'doppler_synced',
32
+ '999'
33
+ );
34
+
35
+ $oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'doppler_synced');
36
+ $oAttribute->save();
37
+
38
+ $installer->endSetup();
app/code/local/MakingSense/Doppler/sql/makingsense_doppler_setup/mysql4-upgrade-0.1.2-0.1.3.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * 0.1.2 - 0.1.3 upgrade installer
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+
10
+ $installer = $this;
11
+
12
+ $installer->startSetup();
13
+
14
+ if (!$installer->tableExists($installer->getTable('makingsense_doppler/doppler_lists'))) {
15
+ $installer->run("
16
+ CREATE TABLE `{$installer->getTable('makingsense_doppler/doppler_lists')}` (
17
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
18
+ `list_id` int(11) unsigned NOT NULL,
19
+ `name` varchar(255) DEFAULT NULL,
20
+ `status` varchar(255) DEFAULT NULL,
21
+ `subscribers_count` int(11) unsigned NOT NULL,
22
+ `last_usage` datetime DEFAULT NULL,
23
+ `creation_date` datetime DEFAULT NULL,
24
+ PRIMARY KEY (`id`)
25
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
26
+ ");
27
+ }
28
+
29
+ $installer->endSetup();
app/code/local/MakingSense/Doppler/sql/makingsense_doppler_setup/mysql4-upgrade-0.1.3-0.1.4.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * 0.1.3 - 0.1.4 upgrade installer
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+
10
+ $installer = $this;
11
+
12
+ $installer->startSetup();
13
+
14
+ if (!$installer->tableExists($installer->getTable('makingsense_doppler/doppler_defaultlist'))) {
15
+ $installer->run("
16
+ CREATE TABLE `{$installer->getTable('makingsense_doppler/doppler_defaultlist')}` (
17
+ `id` int(11) unsigned NOT NULL,
18
+ `listId` int(11) unsigned NOT NULL,
19
+ `name` varchar(255) DEFAULT NULL,
20
+ `list_status` varchar(255) DEFAULT NULL,
21
+ PRIMARY KEY (`id`)
22
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
23
+ ");
24
+ }
25
+
26
+ $installer->endSetup();
app/code/local/MakingSense/Doppler/sql/makingsense_doppler_setup/mysql4-upgrade-0.1.4-0.1.5.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * 0.1.4 - 0.1.5 upgrade installer
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+
13
+ $entityTypeId = $installer->getEntityTypeId(Mage_Catalog_Model_Category::ENTITY);
14
+ $attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
15
+ $attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
16
+
17
+ $installer->addAttribute('customer', 'status_doppler_sync', array(
18
+ 'input' => 'text',
19
+ 'type' => 'varchar',
20
+ 'label' => 'Doppler Export Status',
21
+ 'default' => 'Pending',
22
+ 'visible' => 1,
23
+ 'required' => 0,
24
+ 'user_defined' => 0
25
+ ));
26
+
27
+ $installer->addAttributeToGroup(
28
+ $entityTypeId,
29
+ $attributeSetId,
30
+ $attributeGroupId,
31
+ 'status_doppler_sync',
32
+ '999'
33
+ );
34
+
35
+ $oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'status_doppler_sync');
36
+ $oAttribute->save();
37
+
38
+ $installer->endSetup();
app/code/local/MakingSense/Doppler/sql/makingsense_doppler_setup/mysql4-upgrade-0.1.5-0.1.6.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * 0.1.5- 0.1.6 upgrade installer
4
+ *
5
+ * @category MakingSense
6
+ * @package Doppler
7
+
8
+ */
9
+
10
+ $installer = $this;
11
+
12
+ $installer->startSetup();
13
+
14
+ if (!$installer->tableExists($installer->getTable('makingsense_doppler/doppler_importtasks'))) {
15
+ $table = $installer->getConnection()
16
+ ->newTable($installer->getTable('makingsense_doppler/doppler_importtasks'))
17
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
18
+ 'identity' => true,
19
+ 'unsigned' => true,
20
+ 'nullable' => false,
21
+ 'primary' => true,
22
+ ), 'ID')
23
+ ->addColumn('import_id', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
24
+ ), 'Import ID')
25
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
26
+ ), 'Status')
27
+ ->addColumn('creation', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
28
+ 'nullable' => false,
29
+ ), 'Created At')
30
+ ->addColumn('customers', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
31
+ ), 'Customers');
32
+
33
+ $installer->getConnection()->createTable($table);
34
+ }
35
+
36
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/makingsense_doppler.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addCss">
6
+ <name>makingsense_doppler/custom.css</name>
7
+ </action>
8
+ </reference>
9
+ <reference name="menu">
10
+ <action method="setTemplate">
11
+ <template>doppler/menu.phtml</template>
12
+ </action>
13
+ </reference>
14
+ </default>
15
+ </layout>
app/etc/modules/MakingSense_Doppler.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <MakingSense_Doppler>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <depends>
8
+ <Mage_Customer />
9
+ <Mage_Adminhtml />
10
+ </depends>
11
+ </MakingSense_Doppler>
12
+ </modules>
13
+ </config>
app/locale/es_AR/MakingSense_Doppler.csv ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Field Mapping information","Información de mapeo de Campos"
2
+ "Doppler Field Name","Nombre del Campo en Doppler"
3
+ "Magento Field Name","Nombre del Campo en Magento"
4
+ "Lead Mapping","Mapeo de Campos"
5
+ "Delete","Eliminar"
6
+ "Are you sure?","¿Estás seguro?"
7
+ "List Name","Nombre de la Lista"
8
+ "Last Usage","Último Uso"
9
+ "Create a new Doppler's Subscribers List","Crea una nueva Lista de Suscriptores de Doppler"
10
+ "List Name","Nombre de Lista"
11
+ "Subscribers information","Información de Suscriptores"
12
+ "Subscribers","Suscriptores"
13
+ "Lead mapping admin","Administrador de mapeo de Campos"
14
+ "Add Field","Nuevo Mapeo"
15
+ "Doppler's Subscribers Lists","Listas de Suscriptores de Doppler"
16
+ "Doppler's Subscribers List","Lista de Suscriptores de Doppler"
17
+ "List Name","Nombre de la Lista"
18
+ "Add List","Nueva Lista"
19
+ "Subscribers Manager","Administrador de Suscriptores"
20
+ "Add Subscribers","Agregar Suscriptores"
21
+ "The Doppler API is not currently available, please try later","La API de Doppler no se encuentra disponible en estos momentos, intente nuevamente más tarde"
22
+ "Mapping does not exist","El mapeo no existe"
23
+ "Lead Mapping deleted","Mapeo de Campos eliminado"
24
+ "Leadmap with id '%s' does not exist","El mapeo con ID '%s' no existe"
25
+ "You've already associated a Magento Field with the NOMBRE DEL CAMPO Field in Doppler: %s","Ya has asociado un Campo de Magento con el Campo %s en Doppler"
26
+ "Please select at least one record","Por favor seleccione al menos un registro"
27
+ "Total of %d record(s) have been deleted","Un total de %d registro(s) han sido eliminado(s)"
28
+ "The lists have been successfully synced","Las listas han sido exitosamente sincronizadas"
29
+ "The following errors occurred creating your list: %s","Los siguientes errores ocurrieron creando su lista: %s"
30
+ "List does not exist","La lista no existe"
31
+ "List %s does not exist","La lista %s no existe"
32
+ "List deleted","Lista eliminada"
33
+ "Saved","Guardado"
34
+ "Doppler API Connection","Conexión con la API de Doppler"
35
+ "Magento Subscribers","Suscriptores de Magento"
36
+ "Doppler Lists","Listas de Doppler"
37
+ "Lead Mapping","Mapeo de Campos"
38
+ "Default synchronizing List","Lista a sincronizar por defecto"
39
+ "API Connection","Conexión de la API"
40
+ "Username","Usuario"
41
+ "API key","API key"
42
+ "The connection with Doppler has been successfully.","La conexión con Doppler ha sido exitosa."
43
+ "There's been an error with your connection with Doppler. Please verify your user and API Key information","Ha habido un error en la conexión con tu cuenta de Doppler. Por favor verifica el usuario y API Key ingresados."
44
+ "Please, add your credentials above and save this page to test your API connection","Por favor, agregue sus credenciales y guarde esta página para comprobar la conexión de la API"
45
+ "Some error occurs. Please, retry type selection","Algunos errores ocurrieron. Por favor, intente nuevamente"
46
+ "Exported to Doppler","Exportado a Doppler"
47
+ "Creation Date","Fecha de Creación"
48
+ "Subscribers Count","Cantidad de Suscriptores"
49
+ "Name","Nombre"
50
+ "The list '%s' has been successfully removed","La lista '%s' ha sido exitosamente removida"
51
+ "The following errors occurred removing your list: ","Los siguientes errores ocurrieron eliminando su lista: "
52
+ "The list has been successfully created","La lista ha sido creada exitosamente"
53
+ "The changes have been saved","Los cambios han sido guardados"
54
+ "Export to Doppler","Exportar a Doppler"
55
+ "Set Default List","Elegir Lista por Defecto"
56
+ "Export customer to list","Exportar cliente a lista"
57
+ "Export Customer","Exportar Cliente"
58
+ "Mapping ID","ID del Mapeo"
59
+ "Export selected customers to the following Doppler list","Exportar clientes seleccionados a la siguiente lista de Doppler"
60
+ "Please select subscribers.","Por favor, seleccione suscriptores."
61
+ "%d customer(s) successfully subscribed to the selected list","%d client(es) exitosamente suscriptos a la lista seleccionada"
62
+ "Some errors ocurred when exporting %d customer(s)","Algunos errores ocurrieron exportando %d cliente(s)"
63
+ "There is no Doppler default list. Please, choose a list and set that list as default.","No existe ninguna lista de Doppler por defecto. Por favor, elija una lista y a continuación seleccionela por defecto."
64
+ "Default List","Lista por Defecto"
65
+ "Last Import Date","Fecha de Última Importación"
66
+ "Default List Configuration","Configuración de la Lista por Defecto"
67
+ "There is no default Doppler list.","No existe lista de Doppler por defecto"
68
+ "The following errors occurred retrieving your default list","Los siguientes errores ocurrieron obteniendo su lista por defecto"
69
+ "You've activated the automatic contact synchronization.","Has activado la sincronización automática de contactos."
70
+ "Default list unavailable. New customers auto-import disabled.","Lista por defecto no disponible. Importación automatica de nuevos clientes desactivada."
71
+ "The list has been deleted and the new customers auto-import process has been disabled. Please choose a new list.","La lista ha sido eliminada en Doppler y la importación automática de clientes ha sido desactivada. Por favor elija una nueva lista."
72
+ "There has been an error exporting the customer to Doppler","Ha habido un error exportando el cliente a Doppler"
73
+ "The field "%s" is not compatible with the associated attribute value for the customer: %s", "El campo "%s" en Doppler no es compatible con el valor del atributo de Magento asociado: %s"
74
+ "The following error ocurred on the customer export: %s","El siguiente error ha ocurrido cuando se intentó exportar el cliente: %s"
75
+ "Customer(s) sucessfully subscribed: %d. Customer(s) not subscribed for the errors mentioned above: %d customer(s)","Clientes exitosamente suscriptos: %d client(es). Clientes no suscriptos debido a los errores mencionados: %d client(es)."
76
+ "Please, add your credentials for the Doppler API in System -> Configuration -> Doppler","Por favor, agregue sus credenciales para la API de Doppler en Sistema -> Configuración -> Doppler"
77
+ "Import task successfully created","Tarea de exportación de clientes exitosamente iniciado"
78
+ "The export task that has been started at %s is in progress","La tarea de exportación que ha sido iniciada el %s está en progreso"
79
+ "The export task that has been started at %s has finished","La tarea de exportación que ha sido iniciada el %s ha finalizado"
80
+ "Processing","Procesando"
81
+ "Pending","Pendiente"
82
+ "Completed","Exportado"
83
+ "Duplicated","Duplicado"
84
+ "UnsubscribedByUser","Previamente Eliminado de la Lista por Usuario"
85
+ "Doppler Export Status","Estado Exportación a Doppler"
86
+ "The customer has been subscribed to the selected list","El cliente ha sido exitosamente exportado a la lista seleccionada"
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>doppler</name>
4
+ <version>0.1.6</version>
5
+ <stability>stable</stability>
6
+ <license>GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Integrate your Magento Ecommerce with the #1 Email Marketing app in Latin America.</summary>
10
+ <description>Integrate your Magento Ecommerce with the #1 Email Marketing app in Latin America.&#xD;
11
+ Easily connect your Magento store with Doppler Email Marketing via API. Create and feed Lists with your Subscribers and keep them updated about offers, related products and upcoming events.</description>
12
+ <notes>First stable release</notes>
13
+ <authors><author><name>Diego Noya</name><user>fromdoppler</user><email>info@fromdoppler.com</email></author></authors>
14
+ <date>2016-04-22</date>
15
+ <time>00:52:31</time>
16
+ <contents><target name="magelocal"><dir name="MakingSense"><dir name="Doppler"><dir name="Block"><dir name="Adminhtml"><dir name="Defaultlist"><dir name="Edit"><file name="Form.php" hash="275282eaf7cf50d02a0c6bf161f48756"/></dir><file name="Edit.php" hash="dd96f133d719ef8d8f3ad2a8850d739a"/><file name="Grid.php" hash="b4824a36d21fd92a0185c98dfdcd35be"/></dir><file name="Defaultlist.php" hash="e6cc7220c68c7871353f35f357f6c8cd"/><dir name="Leadmap"><dir name="Edit"><file name="Form.php" hash="b035e77fda37069647d85dff8486378e"/></dir><file name="Edit.php" hash="18bceea1de7d0e9d3e8df151128d6366"/><file name="Grid.php" hash="2a4d19f4f8133d5501947358a59edf44"/></dir><file name="Leadmap.php" hash="4be963f6145dd6747025f3f97f935a7e"/><dir name="Lists"><dir name="Edit"><file name="Form.php" hash="f32ee3fb9254e644696d9bbe39d228b0"/></dir><file name="Edit.php" hash="2b4f832f106bf7f216b148cc294c9818"/><file name="Grid.php" hash="83034f4b418ea4db9b8d7cc74784fd34"/></dir><file name="Lists.php" hash="3c7bbbb7bb0dfd605c69cd4d449822c1"/><dir name="Page"><file name="Menu.php" hash="f6084398a4759e5b44a341ea4a31071c"/></dir><dir name="Subscribers"><dir name="Edit"><file name="Form.php" hash="eff1d4c4abb544b57e7c1b2ccba81b37"/></dir><file name="Edit.php" hash="86d0a296798146f1f7b6ab0bf2d97263"/><dir name="Grid"><file name="Massaction.php" hash="eb3bf3252eeaaf6e12d10db8cb367c82"/><dir name="Renderer"><file name="Status.php" hash="24dd5c6f01c6d8cddf1926328b8dfb88"/></dir></dir><file name="Grid.php" hash="3fa03acdec0bedd0fd10b02462f24acb"/></dir><file name="Subscribers.php" hash="848080dce7b3ff4077fe1c9a2a3faec6"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Fieldset"><dir name="Connection"><file name="Test.php" hash="7f379041cdf908eef0043d62ba83ea61"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="e0a6d660915d9812e1cebb3e4dfdc7f9"/></dir><dir name="Model"><file name="Defaultlist.php" hash="dbbd7f25156e5a32b22241a45c4e34de"/><file name="Importtasks.php" hash="b4b74f349b5defbfb7cefb7fcd595816"/><file name="Leadmap.php" hash="77f20672db0a9f087b7ee501ae2ab957"/><file name="Lists.php" hash="e7acb4f6f40d469a35399ac076a8845f"/><file name="Observer.php" hash="caad137fd1a196c4686f460751a6d459"/><dir name="Resource"><dir name="Doppler"><dir name="Defaultlist"><file name="Collection.php" hash="fdf5477e12e45dccbe1dca87e85307a6"/></dir><file name="Defaultlist.php" hash="fed14c6c8d4baf44fb514c8214ff3c0b"/><dir name="Importtasks"><file name="Collection.php" hash="3a5b3b592bc5f797d86179df8bf70124"/></dir><file name="Importtasks.php" hash="96944fd94691352b24cc05525ee3690e"/><dir name="Leadmap"><file name="Collection.php" hash="5842fadb316b297ffbbbfa71809f935d"/></dir><file name="Leadmap.php" hash="6cfa33b1dff95237c6f3c29b04fc154a"/><dir name="Lists"><file name="Collection.php" hash="1f659cdcfc0417df5ff4e15dec3e3490"/></dir><file name="Lists.php" hash="898ccf06c30fdee3cdc431ca73f7b35d"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="DefaultlistController.php" hash="c1d2dbf86beed5540958292fb5e45252"/><file name="LeadmapController.php" hash="1ce2a9da4de566fe115d2d93622f2cb5"/><file name="ListsController.php" hash="d40e66846b7d0f6341e39bdabd054c5a"/><file name="SubscribersController.php" hash="1eefb6432719a2b6385ab47a3a3247c2"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="819da510c7c6ac5105ff02be4819c345"/><file name="config.xml" hash="7e4704287a9e46abbb906d1731742a93"/><file name="system.xml" hash="e0f28e099a1a40671754f33e9e7f1f35"/></dir><dir name="sql"><dir name="makingsense_doppler_setup"><file name="mysql4-install-0.1.0.php" hash="8325a9967a4875fddb598da3bd007087"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="0dc4ca318a0df5c2b47051b6156997e8"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="e46e845f4402ef1de1b11201bb4f3f8b"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="5ac55a4d87d5d0d97c02e09ce6fd64b5"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="01a312a208b4f389e8f2b349fb2f5dca"/><file name="mysql4-upgrade-0.1.4-0.1.5.php" hash="33fa34c98228f4ebd38e71dbde4cf5c8"/><file name="mysql4-upgrade-0.1.5-0.1.6.php" hash="27d72daaae65d2a1d840a8e2336f8045"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MakingSense_Doppler.xml" hash="c2cab7fee09972139d514c6c92e2efd8"/></dir></target><target name="magelocale"><dir><dir name="es_AR"><file name="MakingSense_Doppler.csv" hash="f1932e8149e90954f9514b63fed650f8"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="makingsense_doppler.xml" hash="e67494c7f0c90b118589765c5c86bea9"/></dir></dir></dir></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
19
+ </package>