sendmachine - Version 1.0.1

Version Notes

Stable release. Included multistore support.

Download this release

Release Info

Developer Sendmachine
Extension sendmachine
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

Files changed (26) hide show
  1. app/code/community/Sendmachine/Sendmachine/Block/AppContainer/Grid.php +3 -1
  2. app/code/community/Sendmachine/Sendmachine/Block/AppContainer/Tab/Email.php +47 -33
  3. app/code/community/Sendmachine/Sendmachine/Block/AppContainer/Tab/General.php +23 -15
  4. app/code/community/Sendmachine/Sendmachine/Block/AppContainer/Tab/Lists.php +58 -51
  5. app/code/community/Sendmachine/Sendmachine/Block/AppContainer/Tabs.php +13 -3
  6. app/code/community/Sendmachine/Sendmachine/Block/PopupBlock.php +6 -8
  7. app/code/community/Sendmachine/Sendmachine/Helper/Data.php +3 -3
  8. app/code/community/Sendmachine/Sendmachine/Model/...Observer.php +0 -20
  9. app/code/community/Sendmachine/Sendmachine/Model/Cronjobs.php +1 -2
  10. app/code/community/Sendmachine/Sendmachine/Model/Email/Template.php +4 -0
  11. app/code/community/Sendmachine/Sendmachine/Model/Observer.php +1 -3
  12. app/code/community/Sendmachine/Sendmachine/Model/Sendmachine.php +60 -11
  13. app/code/community/Sendmachine/Sendmachine/Model/Source/Contactlist.php +4 -6
  14. app/code/community/Sendmachine/Sendmachine/Model/Source/ImportExportLimit.php +3 -3
  15. app/code/community/Sendmachine/Sendmachine/Model/Source/Smtp.php +4 -8
  16. app/code/community/Sendmachine/Sendmachine/Model/Source/TransactionalCampAreas.php +1 -1
  17. app/code/community/Sendmachine/Sendmachine/controllers/SendmachineController.php +89 -19
  18. app/code/community/Sendmachine/Sendmachine/controllers/SubscribeController.php +5 -6
  19. app/code/community/Sendmachine/Sendmachine/etc/config.xml +4 -4
  20. app/code/community/Sendmachine/Sendmachine/sql/sendmachine_setup/mysql4-install-1.0.0.php +2 -2
  21. app/code/community/Sendmachine/Sendmachine/sql/sendmachine_setup/mysql4-upgrade-1.0.0-1.0.1.php +9 -0
  22. app/locale/en_US/template/email/sendmachine/sm_send_test_email.html +19 -0
  23. js/sendmachine/admin.js +25 -6
  24. package.xml +32 -23
  25. skin/adminhtml/default/default/sendmachine/logo2.png +0 -0
  26. skin/adminhtml/default/default/sendmachine/logo3.png +0 -0
app/code/community/Sendmachine/Sendmachine/Block/AppContainer/Grid.php CHANGED
@@ -17,7 +17,9 @@ class Sendmachine_Sendmachine_Block_AppContainer_Grid extends Mage_Adminhtml_Blo
17
 
18
  protected function _prepareCollection() {
19
 
20
- $collection = Mage::getResourceModel($this->_getCollectionClass());
 
 
21
  $this->setCollection($collection);
22
 
23
  return parent::_prepareCollection();
17
 
18
  protected function _prepareCollection() {
19
 
20
+ $store_id = Mage::getModel('core/store')->load($this->getRequest()->getParam('store'), 'code')->getId();
21
+
22
+ $collection = Mage::getResourceModel($this->_getCollectionClass())->addFieldToFilter('store', $store_id);
23
  $this->setCollection($collection);
24
 
25
  return parent::_prepareCollection();
app/code/community/Sendmachine/Sendmachine/Block/AppContainer/Tab/Email.php CHANGED
@@ -2,6 +2,8 @@
2
 
3
  class Sendmachine_Sendmachine_Block_AppContainer_Tab_Email extends Mage_Adminhtml_Block_Widget_Form {
4
 
 
 
5
  protected function _prepareForm() {
6
 
7
  $sm = Mage::registry('sm_model');
@@ -12,85 +14,97 @@ class Sendmachine_Sendmachine_Block_AppContainer_Tab_Email extends Mage_Adminhtm
12
  )
13
  );
14
 
 
 
 
15
  $form->setUseContainer(true);
16
 
17
 
18
- $fieldset = $form->addFieldset('email_fieldset', ['legend' => Mage::helper('sendmachine')->__('Email Settings')]);
19
- $testfieldset = $form->addFieldset('emailtest_fieldset', ['legend' => Mage::helper('sendmachine')->__('Test Configuration')]);
 
 
20
 
21
- $fieldset->addField('tab_email', 'hidden', [
22
  'name' => 'tab',
23
  'value' => 'email'
24
- ]);
25
-
26
- $fieldset->addField('email_enabled', 'select', [
 
 
 
 
 
 
 
 
 
 
27
  'name' => 'email_enabled',
28
  'label' => Mage::helper('sendmachine')->__('Enable email sending'),
29
  'title' => Mage::helper('sendmachine')->__('Enable email sending'),
30
  'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()
31
- ]);
32
 
33
- $fieldset->addField('smtp_encryption', 'select', [
34
  'name' => 'smtp_encryption',
35
  'label' => Mage::helper('sendmachine')->__('SMTP Encryption'),
36
  'title' => Mage::helper('sendmachine')->__('SMTP Encryption'),
37
  'values' => Mage::getModel('sendmachine/source_smtp')->toOptionArray()
38
- ]);
39
 
40
- $fieldset->addField('from_email', 'text', [
41
  'name' => 'from_email',
42
  'label' => Mage::helper('sendmachine')->__('From Email'),
43
  'title' => Mage::helper('sendmachine')->__('From Email'),
44
  'after_element_html' => '<small>' . Mage::helper('sendmachine')->__("Note! If you set a 'From email' here, all other 'from emails' will be overriden") . '<small>'
45
- ]
46
- );
47
 
48
- $fieldset->addField('from_name', 'text', [
49
  'name' => 'from_name',
50
  'label' => Mage::helper('sendmachine')->__('From Name'),
51
  'title' => Mage::helper('sendmachine')->__('From Name'),
52
  'after_element_html' => '<small>' . Mage::helper('sendmachine')->__("Note! If you set a 'From name' here, all other 'from names' will be overriden") . '<small>'
53
- ]
54
- );
55
 
56
- $fieldset->addField('transactional_campaigns_enabled', 'select', [
57
  'name' => 'transactional_campaigns_enabled',
58
  'label' => Mage::helper('sendmachine')->__('Use transactional emails'),
59
  'title' => Mage::helper('sendmachine')->__('Use transactional emails'),
60
  'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()
61
- ]);
62
 
63
- $fieldset->addField('transactional_campaign_prefix', 'text', [
64
  'name' => 'transactional_campaign_prefix',
65
  'label' => Mage::helper('sendmachine')->__('Transactional campaigns prefix'),
66
  'title' => Mage::helper('sendmachine')->__('Transactional campaigns prefix'),
67
  'after_element_html' => '<small>Campaign\'s prefix<small>'
68
- ]
69
- );
70
 
71
- $fieldset->addField('transactional_campaign_areas', 'multiselect', [
72
  'name' => 'transactional_campaign_areas',
73
  'label' => Mage::helper('sendmachine')->__('Transactional campaigns areas'),
74
  'title' => Mage::helper('sendmachine')->__('Transactional campaigns areas'),
75
  'values' => Mage::getModel('sendmachine/source_transactionalCampAreas')->toOptionArray(),
76
  'after_element_html' => '<small>' . Mage::helper('sendmachine')->__("Note! Hold 'ctrl' and click the area you want to select/deselect for multiple selection") . '</small>'
77
- ]);
78
 
79
- $fieldset->addField('transactional_campaign_suffix', 'text', [
80
  'name' => 'transactional_campaign_suffix',
81
  'label' => Mage::helper('sendmachine')->__('Transactional campaigns suffix'),
82
  'title' => Mage::helper('sendmachine')->__('Transactional campaigns suffix'),
83
  'after_element_html' => '<small>Campaign\'s suffix<small>'
84
- ]
85
- );
86
-
87
- $testfieldset->addField('smMageTestEmail', 'text', [
88
- 'label' => Mage::helper('sendmachine')->__('Send a test email'),
89
- 'title' => Mage::helper('sendmachine')->__('Send a test email'),
90
- 'style' => 'width:240px',
91
- 'after_element_html' => '<button onClick=\'smSendTestEmail("' . Mage::helper('adminhtml')->getUrl('adminhtml/sendmachine/sendtestmail') . '");return false;\' >' . Mage::helper('sendmachine')->__('Send') . '</button><small>' . Mage::helper('sendmachine')->__('Send a test email to make sure that settings were applied correctly') . '<small>',
92
- ]
93
- );
94
 
95
  $form->addValues($sm->get());
96
  $this->setForm($form);
2
 
3
  class Sendmachine_Sendmachine_Block_AppContainer_Tab_Email extends Mage_Adminhtml_Block_Widget_Form {
4
 
5
+ private $store = null;
6
+
7
  protected function _prepareForm() {
8
 
9
  $sm = Mage::registry('sm_model');
14
  )
15
  );
16
 
17
+ $request = Mage::app()->getRequest();
18
+ $this->store = $request->getParam('store');
19
+
20
  $form->setUseContainer(true);
21
 
22
 
23
+ $fieldset = $form->addFieldset('email_fieldset', array('legend' => Mage::helper('sendmachine')->__('Email Settings')));
24
+ if($this->store) {
25
+ $testfieldset = $form->addFieldset('emailtest_fieldset', array('legend' => Mage::helper('sendmachine')->__('Test Configuration')));
26
+ }
27
 
28
+ $fieldset->addField('tab_email', 'hidden', array(
29
  'name' => 'tab',
30
  'value' => 'email'
31
+ ));
32
+
33
+ $fieldset->addField('website_email', 'hidden', array(
34
+ 'name' => 'website',
35
+ 'value' => $request->getParam('website')
36
+ ));
37
+
38
+ $fieldset->addField('store_email', 'hidden', array(
39
+ 'name' => 'store',
40
+ 'value' => $request->getParam('store')
41
+ ));
42
+
43
+ $fieldset->addField('email_enabled', 'select', array(
44
  'name' => 'email_enabled',
45
  'label' => Mage::helper('sendmachine')->__('Enable email sending'),
46
  'title' => Mage::helper('sendmachine')->__('Enable email sending'),
47
  'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()
48
+ ));
49
 
50
+ $fieldset->addField('smtp_encryption', 'select', array(
51
  'name' => 'smtp_encryption',
52
  'label' => Mage::helper('sendmachine')->__('SMTP Encryption'),
53
  'title' => Mage::helper('sendmachine')->__('SMTP Encryption'),
54
  'values' => Mage::getModel('sendmachine/source_smtp')->toOptionArray()
55
+ ));
56
 
57
+ $fieldset->addField('from_email', 'text', array(
58
  'name' => 'from_email',
59
  'label' => Mage::helper('sendmachine')->__('From Email'),
60
  'title' => Mage::helper('sendmachine')->__('From Email'),
61
  'after_element_html' => '<small>' . Mage::helper('sendmachine')->__("Note! If you set a 'From email' here, all other 'from emails' will be overriden") . '<small>'
62
+ ));
 
63
 
64
+ $fieldset->addField('from_name', 'text', array(
65
  'name' => 'from_name',
66
  'label' => Mage::helper('sendmachine')->__('From Name'),
67
  'title' => Mage::helper('sendmachine')->__('From Name'),
68
  'after_element_html' => '<small>' . Mage::helper('sendmachine')->__("Note! If you set a 'From name' here, all other 'from names' will be overriden") . '<small>'
69
+ ));
 
70
 
71
+ $fieldset->addField('transactional_campaigns_enabled', 'select', array(
72
  'name' => 'transactional_campaigns_enabled',
73
  'label' => Mage::helper('sendmachine')->__('Use transactional emails'),
74
  'title' => Mage::helper('sendmachine')->__('Use transactional emails'),
75
  'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()
76
+ ));
77
 
78
+ $fieldset->addField('transactional_campaign_prefix', 'text', array(
79
  'name' => 'transactional_campaign_prefix',
80
  'label' => Mage::helper('sendmachine')->__('Transactional campaigns prefix'),
81
  'title' => Mage::helper('sendmachine')->__('Transactional campaigns prefix'),
82
  'after_element_html' => '<small>Campaign\'s prefix<small>'
83
+ ));
 
84
 
85
+ $fieldset->addField('transactional_campaign_areas', 'multiselect', array(
86
  'name' => 'transactional_campaign_areas',
87
  'label' => Mage::helper('sendmachine')->__('Transactional campaigns areas'),
88
  'title' => Mage::helper('sendmachine')->__('Transactional campaigns areas'),
89
  'values' => Mage::getModel('sendmachine/source_transactionalCampAreas')->toOptionArray(),
90
  'after_element_html' => '<small>' . Mage::helper('sendmachine')->__("Note! Hold 'ctrl' and click the area you want to select/deselect for multiple selection") . '</small>'
91
+ ));
92
 
93
+ $fieldset->addField('transactional_campaign_suffix', 'text', array(
94
  'name' => 'transactional_campaign_suffix',
95
  'label' => Mage::helper('sendmachine')->__('Transactional campaigns suffix'),
96
  'title' => Mage::helper('sendmachine')->__('Transactional campaigns suffix'),
97
  'after_element_html' => '<small>Campaign\'s suffix<small>'
98
+ ));
99
+
100
+ if ($this->store) {
101
+ $testfieldset->addField('smMageTestEmail', 'text', array(
102
+ 'label' => Mage::helper('sendmachine')->__('Send a test email'),
103
+ 'title' => Mage::helper('sendmachine')->__('Send a test email'),
104
+ 'style' => 'width:240px',
105
+ 'after_element_html' => '<button onClick=\'smSendTestEmail("' . Mage::helper('adminhtml')->getUrl('adminhtml/sendmachine/sendtestmail') . '");return false;\' >' . Mage::helper('sendmachine')->__('Send') . '</button><small>' . Mage::helper('sendmachine')->__('Send a test email to make sure that settings were applied correctly') . '<small>',
106
+ ));
107
+ }
108
 
109
  $form->addValues($sm->get());
110
  $this->setForm($form);
app/code/community/Sendmachine/Sendmachine/Block/AppContainer/Tab/General.php CHANGED
@@ -9,40 +9,48 @@ class Sendmachine_Sendmachine_Block_AppContainer_Tab_General extends Mage_Adminh
9
  'id' => 'edit_form',
10
  'action' => $this->getUrl('*/*/save'),
11
  'method' => 'post'
12
- )
13
- );
14
-
15
  $form->setUseContainer(true);
16
 
17
- $fieldset = $form->addFieldset('general_fieldset', ['legend' => Mage::helper('sendmachine')->__('General Settings')]);
18
 
19
- $fieldset->addField('tab_general', 'hidden', [
20
  'name' => 'tab',
21
  'value' => 'index'
22
- ]);
23
-
24
- $fieldset->addField('plugin_enabled', 'select', [
 
 
 
 
 
 
 
 
 
 
25
  'name' => 'plugin_enabled',
26
  'label' => Mage::helper('sendmachine')->__('Plugin enabled'),
27
  'title' => Mage::helper('sendmachine')->__('Plugin enabled'),
28
  'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()
29
- ]);
30
 
31
- $fieldset->addField('api_username', 'text', [
32
  'name' => 'api_username',
33
  'label' => Mage::helper('sendmachine')->__('Api username'),
34
  'title' => Mage::helper('sendmachine')->__('Api username'),
35
  'after_element_html' => '<button id="button_api_username" onClick="smToggleCredentialsVisibility(\'api_username\');return false;" >' . Mage::helper('sendmachine')->__('Show') . '</button>'
36
- ]
37
- );
38
 
39
- $fieldset->addField('api_password', 'text', [
40
  'name' => 'api_password',
41
  'label' => Mage::helper('adminhtml')->__('API password'),
42
  'title' => Mage::helper('adminhtml')->__('API password'),
43
  'after_element_html' => '<button id="button_api_password" onClick="smToggleCredentialsVisibility(\'api_password\');return false;" >' . Mage::helper('sendmachine')->__('Show') . '</button><script>smInitCredentialsBlur()</script>'
44
- ]
45
- );
46
 
47
  $form->addValues($sm->get());
48
  $this->setForm($form);
9
  'id' => 'edit_form',
10
  'action' => $this->getUrl('*/*/save'),
11
  'method' => 'post'
12
+ ));
13
+
14
+ $request = Mage::app()->getRequest();
15
  $form->setUseContainer(true);
16
 
17
+ $fieldset = $form->addFieldset('general_fieldset', array('legend' => Mage::helper('sendmachine')->__('General Settings')));
18
 
19
+ $fieldset->addField('tab_general', 'hidden', array(
20
  'name' => 'tab',
21
  'value' => 'index'
22
+ ));
23
+
24
+ $fieldset->addField('website_general', 'hidden', array(
25
+ 'name' => 'website',
26
+ 'value' => $request->getParam('website')
27
+ ));
28
+
29
+ $fieldset->addField('store_general', 'hidden', array(
30
+ 'name' => 'store',
31
+ 'value' => $request->getParam('store')
32
+ ));
33
+
34
+ $fieldset->addField('plugin_enabled', 'select', array(
35
  'name' => 'plugin_enabled',
36
  'label' => Mage::helper('sendmachine')->__('Plugin enabled'),
37
  'title' => Mage::helper('sendmachine')->__('Plugin enabled'),
38
  'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()
39
+ ));
40
 
41
+ $fieldset->addField('api_username', 'text', array(
42
  'name' => 'api_username',
43
  'label' => Mage::helper('sendmachine')->__('Api username'),
44
  'title' => Mage::helper('sendmachine')->__('Api username'),
45
  'after_element_html' => '<button id="button_api_username" onClick="smToggleCredentialsVisibility(\'api_username\');return false;" >' . Mage::helper('sendmachine')->__('Show') . '</button>'
46
+ ));
 
47
 
48
+ $fieldset->addField('api_password', 'text', array(
49
  'name' => 'api_password',
50
  'label' => Mage::helper('adminhtml')->__('API password'),
51
  'title' => Mage::helper('adminhtml')->__('API password'),
52
  'after_element_html' => '<button id="button_api_password" onClick="smToggleCredentialsVisibility(\'api_password\');return false;" >' . Mage::helper('sendmachine')->__('Show') . '</button><script>smInitCredentialsBlur()</script>'
53
+ ));
 
54
 
55
  $form->addValues($sm->get());
56
  $this->setForm($form);
app/code/community/Sendmachine/Sendmachine/Block/AppContainer/Tab/Lists.php CHANGED
@@ -2,6 +2,8 @@
2
 
3
  class Sendmachine_Sendmachine_Block_AppContainer_Tab_Lists extends Mage_Adminhtml_Block_Widget_Form {
4
 
 
 
5
  protected function _prepareForm() {
6
 
7
  $sm = Mage::registry('sm_model');
@@ -12,77 +14,85 @@ class Sendmachine_Sendmachine_Block_AppContainer_Tab_Lists extends Mage_Adminhtm
12
  )
13
  );
14
 
 
 
 
15
  $form->setUseContainer(true);
16
 
17
- $fieldset = $form->addFieldset('lists_fieldset', ['legend' => Mage::helper('sendmachine')->__('List Settings')]);
18
- $popupfieldset = $form->addFieldset('lists_fieldset_popup', ['legend' => Mage::helper('sendmachine')->__('Popup Settings')]);
19
- $importexport = $form->addFieldset('lists_fieldset_importexport', ['legend' => Mage::helper('sendmachine')->__('Import/Export Users')]);
 
 
20
 
21
- $fieldset->addField('tab_lists', 'hidden', [
22
  'name' => 'tab',
23
  'value' => 'list'
24
- ]);
 
 
 
 
 
 
 
 
 
 
25
 
26
- $fieldset->addField('selected_contact_list', 'select', [
27
  'name' => 'selected_contact_list',
28
  'label' => Mage::helper('sendmachine')->__('Contact List'),
29
  'title' => Mage::helper('sendmachine')->__('Contact List'),
30
  'values' => Mage::getModel('sendmachine/source_contactlist')->toOptionArray(),
31
  'after_element_html' => '<button style="margin-top:10px;" onClick="smRefreshCachedLists(\'' . Mage::helper('adminhtml')->getUrl('adminhtml/sendmachine/refreshCachedLists') . '\');return false;" >' . Mage::helper('sendmachine')->__('Refresh contact lists') . '</button><br><small>' . Mage::helper('sendmachine')->__("Contact lists do not update each time you visit this page. Click 'refresh' to update them when needed") . '</small>'
32
- ]);
33
 
34
- $fieldset->addField('keep_users_synced', 'select', [
35
  'name' => 'keep_users_synced',
36
  'label' => Mage::helper('sendmachine')->__('Keep subscribers synced'),
37
  'title' => Mage::helper('sendmachine')->__('Keep subscribers synced'),
38
  'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()
39
- ]);
40
 
41
- $fieldset->addField('import_subscribers_limit', 'select', [
42
  'name' => 'import_subscribers_limit',
43
  'label' => Mage::helper('sendmachine')->__('Import subscribers limit'),
44
  'title' => Mage::helper('sendmachine')->__('Import subscribers limit'),
45
  'values' => Mage::getModel('sendmachine/source_importExportLimit')->toOptionArray()
46
- ]);
47
 
48
- $fieldset->addField('export_subscribers_limit', 'select', [
49
  'name' => 'export_subscribers_limit',
50
  'label' => Mage::helper('sendmachine')->__('Export subscribers limit'),
51
  'title' => Mage::helper('sendmachine')->__('Export subscribers limit'),
52
  'values' => Mage::getModel('sendmachine/source_importExportLimit')->toOptionArray()
53
- ]);
54
 
55
- $popupfieldset->addField('enable_subscribe_popup', 'select', [
56
  'name' => 'enable_subscribe_popup',
57
  'label' => Mage::helper('sendmachine')->__('Subscribe popup'),
58
  'title' => Mage::helper('sendmachine')->__('Subscribe popup'),
59
  'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()
60
- ]);
61
 
62
- $popupfieldset->addField('popup_show_after_page', 'text', [
63
  'name' => 'popup_show_after_page',
64
  'label' => Mage::helper('sendmachine')->__('Show On Page View'),
65
  'title' => Mage::helper('sendmachine')->__('Show On Page View'),
66
- ]);
67
 
68
- $popupfieldset->addField('popup_delay', 'text', [
69
  'name' => 'popup_delay',
70
  'label' => Mage::helper('sendmachine')->__('Popup Delay (ms)'),
71
  'title' => Mage::helper('sendmachine')->__('Popup Delay (ms)'),
72
- ]);
73
 
74
- $popupfieldset->addField('hide_after_subscribe', 'text', [
75
  'name' => 'hide_after_subscribe',
76
  'label' => Mage::helper('sendmachine')->__('Dismiss popup (s)'),
77
  'title' => Mage::helper('sendmachine')->__('Dismiss popup (s)'),
78
  'after_element_html' => '<small>' . Mage::helper('sendmachine')->__('Dismiss popup box after successful subscribe or no activity. 0 means no dismiss') . '</small>'
79
- ]);
80
-
81
- $popupfieldset->addField('popup_show_on_store', 'select', array(
82
- 'name' => 'popup_show_on_store',
83
- 'label' => Mage::helper('sendmachine')->__('Show in store'),
84
- 'title' => Mage::helper('sendmachine')->__('Show in store'),
85
- 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
86
  ));
87
 
88
  $popupfieldset->addField('popup_text_header', 'text', array(
@@ -97,29 +107,25 @@ class Sendmachine_Sendmachine_Block_AppContainer_Tab_Lists extends Mage_Adminhtm
97
  'title' => Mage::helper('sendmachine')->__("Popup custom fields"),
98
  'after_element_html' => Mage::helper('sendmachine')->customfields2checkbox($sm->get('list_custom_fields'))
99
  ));
100
-
101
- $importexport->addField('sm_import_export_store', 'select', array(
102
- 'name' => 'sm_import_export_store',
103
- 'label' => Mage::helper('sendmachine')->__("Store"),
104
- 'title' => Mage::helper('sendmachine')->__("Store"),
105
- 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
106
- ));
107
-
108
- $importexport->addField('smImportToNewsletter', 'button', [
109
- 'label' => Mage::helper('sendmachine')->__("Import subscribers"),
110
- 'value' => 'Import to Newsletter',
111
- 'class' => 'form-button',
112
- 'onclick' => "smImport('" . Mage::helper('adminhtml')->getUrl('adminhtml/sendmachine/importToNewsletter') . "')",
113
- 'after_element_html' => '<br><small>' . Mage::helper('sendmachine')->__("Import your sendmachine subscribers to 'Newsletter Subscribers' page.") . '<br><b>' . Mage::helper('sendmachine')->__('Note!') . '</b> ' . Mage::helper('sendmachine')->__("You must select a contact list first.") . '<br>' . Mage::helper('sendmachine')->__("If 'All store views' option is selected, users will be subscribed to the default store") . '</small>'
114
- ]);
115
-
116
- $importexport->addField('smExportToSendmachine', 'button', [
117
- 'label' => Mage::helper('sendmachine')->__('Export subscribers'),
118
- 'value' => 'Export to Sendmachine',
119
- 'class' => 'form-button',
120
- 'onclick' => "smExport('" . Mage::helper('adminhtml')->getUrl('adminhtml/sendmachine/exportToSendmachine') . "')",
121
- 'after_element_html' => '<br><small>' . Mage::helper('sendmachine')->__("Export your subscribed customers to a contact list in your sendmachine account.") . '<br><b>' . Mage::helper('sendmachine')->__("Note!") . '</b> ' . Mage::helper('sendmachine')->__("You must select a contact list first") . '</small>'
122
- ]);
123
 
124
  $form->addValues($sm->get());
125
  $this->setForm($form);
@@ -128,7 +134,8 @@ class Sendmachine_Sendmachine_Block_AppContainer_Tab_Lists extends Mage_Adminhtm
128
 
129
  protected function _afterToHtml($html) {
130
 
131
- $extra = $this->getLayout()->createBlock('sendmachine/appContainer_grid')->toHtml();
 
132
  return $html . $extra;
133
  }
134
 
2
 
3
  class Sendmachine_Sendmachine_Block_AppContainer_Tab_Lists extends Mage_Adminhtml_Block_Widget_Form {
4
 
5
+ private $store = null;
6
+
7
  protected function _prepareForm() {
8
 
9
  $sm = Mage::registry('sm_model');
14
  )
15
  );
16
 
17
+ $request = Mage::app()->getRequest();
18
+ $this->store = $request->getParam('store');
19
+
20
  $form->setUseContainer(true);
21
 
22
+ $fieldset = $form->addFieldset('lists_fieldset', array('legend' => Mage::helper('sendmachine')->__('List Settings')));
23
+ $popupfieldset = $form->addFieldset('lists_fieldset_popup', array('legend' => Mage::helper('sendmachine')->__('Popup Settings')));
24
+ if($this->store) {
25
+ $importexport = $form->addFieldset('lists_fieldset_importexport', array('legend' => Mage::helper('sendmachine')->__('Import/Export Users')));
26
+ }
27
 
28
+ $fieldset->addField('tab_lists', 'hidden', array(
29
  'name' => 'tab',
30
  'value' => 'list'
31
+ ));
32
+
33
+ $fieldset->addField('website_lists', 'hidden', array(
34
+ 'name' => 'website',
35
+ 'value' => $request->getParam('website')
36
+ ));
37
+
38
+ $fieldset->addField('store_lists', 'hidden', array(
39
+ 'name' => 'store',
40
+ 'value' => $this->store
41
+ ));
42
 
43
+ $fieldset->addField('selected_contact_list', 'select', array(
44
  'name' => 'selected_contact_list',
45
  'label' => Mage::helper('sendmachine')->__('Contact List'),
46
  'title' => Mage::helper('sendmachine')->__('Contact List'),
47
  'values' => Mage::getModel('sendmachine/source_contactlist')->toOptionArray(),
48
  'after_element_html' => '<button style="margin-top:10px;" onClick="smRefreshCachedLists(\'' . Mage::helper('adminhtml')->getUrl('adminhtml/sendmachine/refreshCachedLists') . '\');return false;" >' . Mage::helper('sendmachine')->__('Refresh contact lists') . '</button><br><small>' . Mage::helper('sendmachine')->__("Contact lists do not update each time you visit this page. Click 'refresh' to update them when needed") . '</small>'
49
+ ));
50
 
51
+ $fieldset->addField('keep_users_synced', 'select', array(
52
  'name' => 'keep_users_synced',
53
  'label' => Mage::helper('sendmachine')->__('Keep subscribers synced'),
54
  'title' => Mage::helper('sendmachine')->__('Keep subscribers synced'),
55
  'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()
56
+ ));
57
 
58
+ $fieldset->addField('import_subscribers_limit', 'select', array(
59
  'name' => 'import_subscribers_limit',
60
  'label' => Mage::helper('sendmachine')->__('Import subscribers limit'),
61
  'title' => Mage::helper('sendmachine')->__('Import subscribers limit'),
62
  'values' => Mage::getModel('sendmachine/source_importExportLimit')->toOptionArray()
63
+ ));
64
 
65
+ $fieldset->addField('export_subscribers_limit', 'select', array(
66
  'name' => 'export_subscribers_limit',
67
  'label' => Mage::helper('sendmachine')->__('Export subscribers limit'),
68
  'title' => Mage::helper('sendmachine')->__('Export subscribers limit'),
69
  'values' => Mage::getModel('sendmachine/source_importExportLimit')->toOptionArray()
70
+ ));
71
 
72
+ $popupfieldset->addField('enable_subscribe_popup', 'select', array(
73
  'name' => 'enable_subscribe_popup',
74
  'label' => Mage::helper('sendmachine')->__('Subscribe popup'),
75
  'title' => Mage::helper('sendmachine')->__('Subscribe popup'),
76
  'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()
77
+ ));
78
 
79
+ $popupfieldset->addField('popup_show_after_page', 'text', array(
80
  'name' => 'popup_show_after_page',
81
  'label' => Mage::helper('sendmachine')->__('Show On Page View'),
82
  'title' => Mage::helper('sendmachine')->__('Show On Page View'),
83
+ ));
84
 
85
+ $popupfieldset->addField('popup_delay', 'text', array(
86
  'name' => 'popup_delay',
87
  'label' => Mage::helper('sendmachine')->__('Popup Delay (ms)'),
88
  'title' => Mage::helper('sendmachine')->__('Popup Delay (ms)'),
89
+ ));
90
 
91
+ $popupfieldset->addField('hide_after_subscribe', 'text', array(
92
  'name' => 'hide_after_subscribe',
93
  'label' => Mage::helper('sendmachine')->__('Dismiss popup (s)'),
94
  'title' => Mage::helper('sendmachine')->__('Dismiss popup (s)'),
95
  'after_element_html' => '<small>' . Mage::helper('sendmachine')->__('Dismiss popup box after successful subscribe or no activity. 0 means no dismiss') . '</small>'
 
 
 
 
 
 
 
96
  ));
97
 
98
  $popupfieldset->addField('popup_text_header', 'text', array(
107
  'title' => Mage::helper('sendmachine')->__("Popup custom fields"),
108
  'after_element_html' => Mage::helper('sendmachine')->customfields2checkbox($sm->get('list_custom_fields'))
109
  ));
110
+
111
+ if ($this->store) {
112
+
113
+ $importexport->addField('smImportToNewsletter', 'button', array(
114
+ 'label' => Mage::helper('sendmachine')->__("Import subscribers"),
115
+ 'value' => 'Import to Newsletter',
116
+ 'class' => 'form-button',
117
+ 'onclick' => "smImport('" . Mage::helper('adminhtml')->getUrl('adminhtml/sendmachine/importToNewsletter') . "')",
118
+ 'after_element_html' => '<br><small>' . Mage::helper('sendmachine')->__("Import your sendmachine subscribers to 'Newsletter Subscribers' page.") . '<br><b>' . Mage::helper('sendmachine')->__('Note!') . '</b> ' . Mage::helper('sendmachine')->__("You must select a contact list first.") . '<br>' . Mage::helper('sendmachine')->__("If 'All store views' option is selected, users will be subscribed to the default store") . '</small>'
119
+ ));
120
+
121
+ $importexport->addField('smExportToSendmachine', 'button', array(
122
+ 'label' => Mage::helper('sendmachine')->__('Export subscribers'),
123
+ 'value' => 'Export to Sendmachine',
124
+ 'class' => 'form-button',
125
+ 'onclick' => "smExport('" . Mage::helper('adminhtml')->getUrl('adminhtml/sendmachine/exportToSendmachine') . "')",
126
+ 'after_element_html' => '<br><small>' . Mage::helper('sendmachine')->__("Export your subscribed customers to a contact list in your sendmachine account.") . '<br><b>' . Mage::helper('sendmachine')->__("Note!") . '</b> ' . Mage::helper('sendmachine')->__("You must select a contact list first") . '</small>'
127
+ ));
128
+ }
 
 
 
 
129
 
130
  $form->addValues($sm->get());
131
  $this->setForm($form);
134
 
135
  protected function _afterToHtml($html) {
136
 
137
+ $extra = "";
138
+ if($this->store) $extra = $this->getLayout()->createBlock('sendmachine/appContainer_grid')->toHtml();
139
  return $html . $extra;
140
  }
141
 
app/code/community/Sendmachine/Sendmachine/Block/AppContainer/Tabs.php CHANGED
@@ -2,12 +2,22 @@
2
 
3
  class Sendmachine_Sendmachine_Block_AppContainer_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
4
 
 
 
5
  public function __construct() {
6
 
7
  parent::__construct();
8
 
9
  $this->setId('sendmachine_tabs');
10
  $this->setTitle("<img style='height:44px;' src='" . $this->getSkinUrl('sendmachine/logo.png') . "'>");
 
 
 
 
 
 
 
 
11
  }
12
 
13
  protected function _beforeToHtml() {
@@ -15,20 +25,20 @@ class Sendmachine_Sendmachine_Block_AppContainer_Tabs extends Mage_Adminhtml_Blo
15
  $this->addTab('general_section', array(
16
  'label' => Mage::helper('sendmachine')->__('General'),
17
  'title' => Mage::helper('sendmachine')->__('General'),
18
- 'url' => $this->getUrl('*/*/index')
19
  ));
20
 
21
  $this->addTab('list_section', array(
22
  'label' => Mage::helper('sendmachine')->__('List'),
23
  'title' => Mage::helper('sendmachine')->__('List'),
24
- 'url' => $this->getUrl('*/*/list'),
25
  'active' => (Mage::app()->getRequest()->getActionName() == 'list' ) ? true : false
26
  ));
27
 
28
  $this->addTab('email_section', array(
29
  'label' => Mage::helper('sendmachine')->__('Email'),
30
  'title' => Mage::helper('sendmachine')->__('Email'),
31
- 'url' => $this->getUrl('*/*/email'),
32
  'active' => (Mage::app()->getRequest()->getActionName() == 'email' ) ? true : false
33
  ));
34
 
2
 
3
  class Sendmachine_Sendmachine_Block_AppContainer_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
4
 
5
+ private $suffix = "";
6
+
7
  public function __construct() {
8
 
9
  parent::__construct();
10
 
11
  $this->setId('sendmachine_tabs');
12
  $this->setTitle("<img style='height:44px;' src='" . $this->getSkinUrl('sendmachine/logo.png') . "'>");
13
+
14
+ $request = Mage::app()->getRequest();
15
+
16
+ $website = $request->getParam('website');
17
+ $store = $request->getParam('store');
18
+
19
+ if($website) $this->suffix .= "/website/$website";
20
+ if($store) $this->suffix .= "/store/$store";
21
  }
22
 
23
  protected function _beforeToHtml() {
25
  $this->addTab('general_section', array(
26
  'label' => Mage::helper('sendmachine')->__('General'),
27
  'title' => Mage::helper('sendmachine')->__('General'),
28
+ 'url' => $this->getUrl('*/*/index' . $this->suffix)
29
  ));
30
 
31
  $this->addTab('list_section', array(
32
  'label' => Mage::helper('sendmachine')->__('List'),
33
  'title' => Mage::helper('sendmachine')->__('List'),
34
+ 'url' => $this->getUrl('*/*/list' . $this->suffix),
35
  'active' => (Mage::app()->getRequest()->getActionName() == 'list' ) ? true : false
36
  ));
37
 
38
  $this->addTab('email_section', array(
39
  'label' => Mage::helper('sendmachine')->__('Email'),
40
  'title' => Mage::helper('sendmachine')->__('Email'),
41
+ 'url' => $this->getUrl('*/*/email' .$this->suffix),
42
  'active' => (Mage::app()->getRequest()->getActionName() == 'email' ) ? true : false
43
  ));
44
 
app/code/community/Sendmachine/Sendmachine/Block/PopupBlock.php CHANGED
@@ -9,14 +9,12 @@ Class Sendmachine_Sendmachine_Block_PopupBlock extends Mage_Core_Block_Template
9
  $smInstance = Mage::registry('sm_model');
10
  $this->sm = $smInstance ? $smInstance : Mage::getModel('sendmachine/sendmachine');
11
 
12
- $store = $this->sm->get('popup_show_on_store');
13
- $currentStore = Mage::app()->getStore()->getStoreId();
14
-
15
- if ($this->sm->apiConnected() && $this->sm->get('plugin_enabled') && $this->sm->get('enable_subscribe_popup') && (!$store || $store == $currentStore)) {
16
-
17
  $cookie = Mage::getSingleton('core/cookie');
18
- if (!$count = $cookie->get('sendmachine_popup_count')) {
19
- $cookie->set('sendmachine_popup_count', 1, 3600 * 24 * 365, '/');
 
20
  $count = 0;
21
  }
22
 
@@ -24,7 +22,7 @@ Class Sendmachine_Sendmachine_Block_PopupBlock extends Mage_Core_Block_Template
24
 
25
  if ($configCount > $count) {
26
  $count++;
27
- $cookie->set('sendmachine_popup_count', $count, 3600 * 24 * 365, '/');
28
 
29
  if ($configCount == $count) {
30
  return true;
9
  $smInstance = Mage::registry('sm_model');
10
  $this->sm = $smInstance ? $smInstance : Mage::getModel('sendmachine/sendmachine');
11
 
12
+ if ($this->sm->apiConnected() && $this->sm->get('plugin_enabled') && $this->sm->get('enable_subscribe_popup')) {
13
+
 
 
 
14
  $cookie = Mage::getSingleton('core/cookie');
15
+ $cookie_key = 'sendmachine_popup_count_'.Mage::app()->getStore()->getStoreId();
16
+ if (!$count = $cookie->get($cookie_key)) {
17
+ $cookie->set($cookie_key, 1, 3600 * 24 * 365, '/');
18
  $count = 0;
19
  }
20
 
22
 
23
  if ($configCount > $count) {
24
  $count++;
25
+ $cookie->set($cookie_key, $count, 3600 * 24 * 365, '/');
26
 
27
  if ($configCount == $count) {
28
  return true;
app/code/community/Sendmachine/Sendmachine/Helper/Data.php CHANGED
@@ -6,11 +6,11 @@ class Sendmachine_Sendmachine_Helper_Data extends Mage_Core_Helper_Abstract {
6
 
7
  if ($smtp_settings) {
8
 
9
- $config = [
10
  "host" => $smtp_settings['hostname'],
11
  "username" => $smtp_settings["username"],
12
  "password" => $smtp_settings['password'],
13
- ];
14
 
15
  switch ($smtpEncryptionType) {
16
  case "SSL":
@@ -87,7 +87,7 @@ class Sendmachine_Sendmachine_Helper_Data extends Mage_Core_Helper_Abstract {
87
  if (!$fields || !count($fields))
88
  return NULL;
89
 
90
- $_fields = [];
91
  foreach ($fields as $v) {
92
 
93
  if (!isset($v['form_name']))
6
 
7
  if ($smtp_settings) {
8
 
9
+ $config = array(
10
  "host" => $smtp_settings['hostname'],
11
  "username" => $smtp_settings["username"],
12
  "password" => $smtp_settings['password'],
13
+ );
14
 
15
  switch ($smtpEncryptionType) {
16
  case "SSL":
87
  if (!$fields || !count($fields))
88
  return NULL;
89
 
90
+ $_fields = array();
91
  foreach ($fields as $v) {
92
 
93
  if (!isset($v['form_name']))
app/code/community/Sendmachine/Sendmachine/Model/...Observer.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
-
3
- class Septi_Sendmachine_Model_Observer {
4
-
5
- public function __construct() {
6
-
7
- $this->sm = Mage::getModel('sendmachine/sm4magento');
8
- }
9
-
10
- public function sendmachineObserver() {
11
-
12
- $credentials = $this->sm->getCredentials();
13
- $this->sm->connectApi($credentials);
14
-
15
- if (Mage::getStoreConfigFlag('system/smtp/disable')) {
16
- $this->sm->setData('system/smtp/disable', 0);
17
- }
18
- }
19
-
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Sendmachine/Sendmachine/Model/Cronjobs.php CHANGED
@@ -14,6 +14,7 @@ class Sendmachine_Sendmachine_Model_Cronjobs {
14
 
15
  public function importToNewsletter($store, $logId, $listId) {
16
 
 
17
  $this->sm->importMode = true;
18
 
19
  $_limit = $this->sm->get('import_subscribers_limit');
@@ -34,8 +35,6 @@ class Sendmachine_Sendmachine_Model_Cronjobs {
34
  }
35
  }
36
 
37
- Mage::app()->setCurrentStore((int) $store);
38
-
39
  if ($sm_subscribers && count($sm_subscribers)) {
40
 
41
  $subscribe_model = Mage::getModel('newsletter/subscriber');
14
 
15
  public function importToNewsletter($store, $logId, $listId) {
16
 
17
+ $this->sm->setStore($store);
18
  $this->sm->importMode = true;
19
 
20
  $_limit = $this->sm->get('import_subscribers_limit');
35
  }
36
  }
37
 
 
 
38
  if ($sm_subscribers && count($sm_subscribers)) {
39
 
40
  $subscribe_model = Mage::getModel('newsletter/subscriber');
app/code/community/Sendmachine/Sendmachine/Model/Email/Template.php CHANGED
@@ -93,17 +93,21 @@ class Sendmachine_Sendmachine_Model_Email_Template extends Mage_Core_Model_Email
93
 
94
  $mail->setSubject('=?utf-8?B?' . base64_encode($subject) . '?=');
95
 
 
96
  $_fromEmail = $sm->get('from_email');
97
  $_fromName = $sm->get('from_name');
98
 
99
  $fromEmail = $_fromEmail ? $_fromEmail : $this->getSenderEmail();
100
  $fromName = $_fromName ? $_fromName : $this->getSenderName();
 
101
 
102
  $mail->setFrom($fromEmail, $fromName);
103
 
 
104
  if ($trCmp = $sm->createTransactionalCampaign($this->getId())) {
105
  $mail->addHeader($trCmp['header_name'], $trCmp['header_value']);
106
  }
 
107
 
108
  try {
109
  $mail->send();
93
 
94
  $mail->setSubject('=?utf-8?B?' . base64_encode($subject) . '?=');
95
 
96
+ /* take a look at this chunk of code */
97
  $_fromEmail = $sm->get('from_email');
98
  $_fromName = $sm->get('from_name');
99
 
100
  $fromEmail = $_fromEmail ? $_fromEmail : $this->getSenderEmail();
101
  $fromName = $_fromName ? $_fromName : $this->getSenderName();
102
+ /* take a look at this chunk of code */
103
 
104
  $mail->setFrom($fromEmail, $fromName);
105
 
106
+ /* take a look at this chunk of code */
107
  if ($trCmp = $sm->createTransactionalCampaign($this->getId())) {
108
  $mail->addHeader($trCmp['header_name'], $trCmp['header_value']);
109
  }
110
+ /* take a look at this chunk of code */
111
 
112
  try {
113
  $mail->send();
app/code/community/Sendmachine/Sendmachine/Model/Observer.php CHANGED
@@ -9,8 +9,6 @@ class Sendmachine_Sendmachine_Model_Observer {
9
 
10
  if ($sm->get('api_connected') && $sm->get('keep_users_synced') && !$sm->importMode) {
11
 
12
- file_put_contents('/home/septi/work/logs/log', PHP_EOL . "Observer hit!!", FILE_APPEND);
13
-
14
  $event = $observer->getEvent();
15
  $subscriber = $event->getDataObject();
16
  $data = $subscriber->getData();
@@ -18,7 +16,7 @@ class Sendmachine_Sendmachine_Model_Observer {
18
  if ($data['subscriber_status'] == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
19
 
20
  $listId = $sm->get('selected_contact_list');
21
- $sm->subscribeToList([$data['subscriber_email']], $listId);
22
  }
23
  }
24
 
9
 
10
  if ($sm->get('api_connected') && $sm->get('keep_users_synced') && !$sm->importMode) {
11
 
 
 
12
  $event = $observer->getEvent();
13
  $subscriber = $event->getDataObject();
14
  $data = $subscriber->getData();
16
  if ($data['subscriber_status'] == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
17
 
18
  $listId = $sm->get('selected_contact_list');
19
+ $sm->subscribeToList(array($data['subscriber_email']), $listId);
20
  }
21
  }
22
 
app/code/community/Sendmachine/Sendmachine/Model/Sendmachine.php CHANGED
@@ -6,18 +6,43 @@ class Sendmachine_Sendmachine_Model_Sendmachine extends Mage_Core_Model_Abstract
6
 
7
  protected $api = NULL;
8
  protected $appData = NULL;
 
 
 
9
 
10
  protected function _construct() {
11
 
12
  parent::_construct();
13
  $this->_init('sendmachine/sendmachine');
14
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  public function get($key = NULL, $forceFetch = false) {
17
 
18
  if ($this->appData === NULL || $forceFetch) {
19
 
20
- $tmpData = Mage::getStoreConfig(self::SM_APP, Mage::app()->getStore(0));
 
 
 
 
 
21
  $this->appData = json_decode($tmpData, true);
22
  }
23
 
@@ -76,12 +101,33 @@ class Sendmachine_Sendmachine_Model_Sendmachine extends Mage_Core_Model_Abstract
76
  }
77
 
78
  public function commit($path = self::SM_APP, $value = NULL) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
  if (is_null($value)) {
81
  $value = json_encode($this->appData);
82
  }
83
 
84
- Mage::getModel('core/config')->saveConfig($path, $value);
85
 
86
  Mage::app()->getCacheInstance()->cleanType('config');
87
  }
@@ -134,10 +180,10 @@ class Sendmachine_Sendmachine_Model_Sendmachine extends Mage_Core_Model_Abstract
134
 
135
  $savedQueueData = $this->get('sm_cronjob');
136
  if (!is_array($savedQueueData)) {
137
- $savedQueueData = [];
138
  }
139
 
140
- array_push($savedQueueData, ['method' => $method, 'args' => $args]);
141
 
142
  $this->set('sm_cronjob', $savedQueueData, true);
143
  }
@@ -152,7 +198,7 @@ class Sendmachine_Sendmachine_Model_Sendmachine extends Mage_Core_Model_Abstract
152
  if ($sqd && is_array($sqd) && count($sqd)) {
153
 
154
  foreach ($sqd as $v) {
155
- call_user_func_array([Mage::getModel('sendmachine/cronjobs'), $v['method']], $v['args']);
156
  }
157
  }
158
  }
@@ -241,7 +287,7 @@ class Sendmachine_Sendmachine_Model_Sendmachine extends Mage_Core_Model_Abstract
241
  }
242
  }
243
 
244
- public function subscribeToList($subscribers = [], $listId = NULL) {
245
 
246
  try {
247
  $this->initApiClass();
@@ -290,10 +336,10 @@ class Sendmachine_Sendmachine_Model_Sendmachine extends Mage_Core_Model_Abstract
290
  $template_list = Mage::getModel('core/email_template')->getDefaultTemplates();
291
  $template_name = $template_list[trim($template_id)]['label'];
292
 
293
- return [
294
  "header_name" => "X-Sendmachine-Campaign",
295
  "header_value" => $trCmpPrexif . $template_name . $trCmpSuffix
296
- ];
297
  }
298
  return false;
299
  }
@@ -302,10 +348,10 @@ class Sendmachine_Sendmachine_Model_Sendmachine extends Mage_Core_Model_Abstract
302
 
303
  public function getCredentials() {
304
 
305
- return [
306
  "username" => $this->get('api_username'),
307
  "password" => $this->get('api_password')
308
- ];
309
  }
310
 
311
  public function addImportExportLog($action, $state = 'pending', $number = 0, $logId = NULL) {
@@ -319,7 +365,10 @@ class Sendmachine_Sendmachine_Model_Sendmachine extends Mage_Core_Model_Abstract
319
  $listName = $v['name'];
320
  }
321
  }
322
- $data = array('action' => $action, 'state' => $state, 'list_name' => $listName, 'sdate' => date('Y-m-d H:i:s'));
 
 
 
323
  $this->setData($data);
324
  return $this->save()->getId();
325
  } else {
6
 
7
  protected $api = NULL;
8
  protected $appData = NULL;
9
+
10
+ private $website = null;
11
+ private $store = null;
12
 
13
  protected function _construct() {
14
 
15
  parent::_construct();
16
  $this->_init('sendmachine/sendmachine');
17
  }
18
+
19
+ public function setWebsite($website = null) {
20
+ $this->website = $website;
21
+ }
22
+
23
+ public function getWebsite() {
24
+ return $this->website;
25
+ }
26
+
27
+ public function setStore($store = null, $setCurrentStore = true) {
28
+ $this->store = $store;
29
+ if($this->store AND $setCurrentStore) Mage::app()->setCurrentStore($store);
30
+ }
31
+
32
+ public function getStore() {
33
+ return $this->store;
34
+ }
35
 
36
  public function get($key = NULL, $forceFetch = false) {
37
 
38
  if ($this->appData === NULL || $forceFetch) {
39
 
40
+ if ($this->website AND !$this->store) {
41
+ $tmpData = Mage::app()->getWebsite($this->website)->getConfig(self::SM_APP);
42
+ } else {
43
+ $tmpData = Mage::getStoreConfig(self::SM_APP, $this->store);
44
+ }
45
+
46
  $this->appData = json_decode($tmpData, true);
47
  }
48
 
101
  }
102
 
103
  public function commit($path = self::SM_APP, $value = NULL) {
104
+
105
+ $scope = "default";
106
+ $scope_id = 0;
107
+
108
+ if ($this->website AND $this->store) {
109
+ $scope = "stores";
110
+ $scope_id = Mage::getModel('core/store')->load($this->store, 'code')->getId();
111
+ } elseif ($this->website) {
112
+ $websites = Mage::app()->getWebsites();
113
+ foreach ($websites as $id => $website) {
114
+ if($website->getCode() == $this->website) {
115
+ $website_id = $id;
116
+ continue;
117
+ }
118
+ }
119
+
120
+ if(!$website_id) $website_id = 0;
121
+
122
+ $scope = "websites";
123
+ $scope_id = $website_id;
124
+ }
125
 
126
  if (is_null($value)) {
127
  $value = json_encode($this->appData);
128
  }
129
 
130
+ Mage::getModel('core/config')->saveConfig($path, $value, $scope, $scope_id);
131
 
132
  Mage::app()->getCacheInstance()->cleanType('config');
133
  }
180
 
181
  $savedQueueData = $this->get('sm_cronjob');
182
  if (!is_array($savedQueueData)) {
183
+ $savedQueueData = array();
184
  }
185
 
186
+ array_push($savedQueueData, array('method' => $method, 'args' => $args));
187
 
188
  $this->set('sm_cronjob', $savedQueueData, true);
189
  }
198
  if ($sqd && is_array($sqd) && count($sqd)) {
199
 
200
  foreach ($sqd as $v) {
201
+ call_user_func_array(array(Mage::getModel('sendmachine/cronjobs'), $v['method']), $v['args']);
202
  }
203
  }
204
  }
287
  }
288
  }
289
 
290
+ public function subscribeToList($subscribers = array(), $listId = NULL) {
291
 
292
  try {
293
  $this->initApiClass();
336
  $template_list = Mage::getModel('core/email_template')->getDefaultTemplates();
337
  $template_name = $template_list[trim($template_id)]['label'];
338
 
339
+ return array(
340
  "header_name" => "X-Sendmachine-Campaign",
341
  "header_value" => $trCmpPrexif . $template_name . $trCmpSuffix
342
+ );
343
  }
344
  return false;
345
  }
348
 
349
  public function getCredentials() {
350
 
351
+ return array(
352
  "username" => $this->get('api_username'),
353
  "password" => $this->get('api_password')
354
+ );
355
  }
356
 
357
  public function addImportExportLog($action, $state = 'pending', $number = 0, $logId = NULL) {
365
  $listName = $v['name'];
366
  }
367
  }
368
+
369
+ $store_id = Mage::getModel('core/store')->load($this->store, 'code')->getId();
370
+
371
+ $data = array('store' => $store_id, 'action' => $action, 'state' => $state, 'list_name' => $listName, 'sdate' => date('Y-m-d H:i:s'));
372
  $this->setData($data);
373
  return $this->save()->getId();
374
  } else {
app/code/community/Sendmachine/Sendmachine/Model/Source/Contactlist.php CHANGED
@@ -9,21 +9,19 @@ class Sendmachine_Sendmachine_Model_Source_Contactlist {
9
 
10
  public function toOptionArray() {
11
 
12
- $cl = [
13
- [
14
  'value' => '0',
15
  'label' => ''
16
- ]
17
- ];
18
  if ($this->sm->apiConnected()) {
19
 
20
  $data = $this->sm->get('contact_lists');
21
  if (count($data)) {
22
  foreach ($data as $value) {
23
- array_push($cl, [
24
  'value' => $value['list_id'],
25
  'label' => $value['name']
26
- ]);
27
  }
28
  }
29
  }
9
 
10
  public function toOptionArray() {
11
 
12
+ $cl = array(array(
 
13
  'value' => '0',
14
  'label' => ''
15
+ ));
 
16
  if ($this->sm->apiConnected()) {
17
 
18
  $data = $this->sm->get('contact_lists');
19
  if (count($data)) {
20
  foreach ($data as $value) {
21
+ array_push($cl, array(
22
  'value' => $value['list_id'],
23
  'label' => $value['name']
24
+ ));
25
  }
26
  }
27
  }
app/code/community/Sendmachine/Sendmachine/Model/Source/ImportExportLimit.php CHANGED
@@ -4,12 +4,12 @@ class Sendmachine_Sendmachine_Model_Source_ImportExportLimit {
4
 
5
  public function toOptionArray() {
6
 
7
- $values = [100, 200, 500, 1000, 5000, 10000];
8
 
9
- $ret = [];
10
 
11
  foreach ($values as $val) {
12
- array_push($ret, ['value' => $val, 'label' => $val]);
13
  }
14
 
15
  return $ret;
4
 
5
  public function toOptionArray() {
6
 
7
+ $values = array(100, 200, 500, 1000, 5000, 10000);
8
 
9
+ $ret = array();
10
 
11
  foreach ($values as $val) {
12
+ array_push($ret, array('value' => $val, 'label' => $val));
13
  }
14
 
15
  return $ret;
app/code/community/Sendmachine/Sendmachine/Model/Source/Smtp.php CHANGED
@@ -4,20 +4,16 @@ class Sendmachine_Sendmachine_Model_Source_Smtp {
4
 
5
  public function toOptionArray() {
6
 
7
- return [
8
- [
9
  'value' => 'OPEN',
10
  'label' => 'No Encryption',
11
- ],
12
- [
13
  'value' => 'SSL',
14
  'label' => 'SSL',
15
- ],
16
- [
17
  'value' => 'TLS',
18
  'label' => 'TLS'
19
- ]
20
- ];
21
  }
22
 
23
  }
4
 
5
  public function toOptionArray() {
6
 
7
+ return array(array(
 
8
  'value' => 'OPEN',
9
  'label' => 'No Encryption',
10
+ ), array(
 
11
  'value' => 'SSL',
12
  'label' => 'SSL',
13
+ ), array(
 
14
  'value' => 'TLS',
15
  'label' => 'TLS'
16
+ ));
 
17
  }
18
 
19
  }
app/code/community/Sendmachine/Sendmachine/Model/Source/TransactionalCampAreas.php CHANGED
@@ -9,7 +9,7 @@ class Sendmachine_Sendmachine_Model_Source_TransactionalCampAreas {
9
 
10
  public function toOptionArray() {
11
 
12
- $cl = [];
13
  if ($this->sm->get('api_connected')) {
14
 
15
  $cl = Mage::getModel('core/email_template')->getDefaultTemplatesAsOptionsArray();
9
 
10
  public function toOptionArray() {
11
 
12
+ $cl = array();
13
  if ($this->sm->get('api_connected')) {
14
 
15
  $cl = Mage::getModel('core/email_template')->getDefaultTemplatesAsOptionsArray();
app/code/community/Sendmachine/Sendmachine/controllers/SendmachineController.php CHANGED
@@ -4,21 +4,49 @@ class Sendmachine_Sendmachine_SendmachineController extends Mage_Adminhtml_Contr
4
 
5
  private $sm;
6
 
7
- public function __construct($request, $response, $invokeArgs = []) {
8
 
9
  parent::__construct($request, $response, $invokeArgs);
10
 
11
  $smInstance = Mage::registry('sm_model');
12
  $this->sm = $smInstance ? $smInstance : Mage::getModel('sendmachine/sendmachine');
13
  }
 
 
14
 
15
  private function _renderApp($tab = '') {
16
 
17
  Mage::register('sm_model', $this->sm);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  $this->loadLayout();
20
  $this->_setActiveMenu('system/sendmachine');
21
- $this->_addContent($this->getLayout()->createBlock('sendmachine/appContainer_main', 'smMainFormContainer', ['tab' => $tab]));
 
 
 
 
22
  $this->_addLeft($this->getLayout()->createBlock('sendmachine/appContainer_tabs'));
23
  $this->getLayout()->getBlock('head')->addJs("sendmachine/admin.js");
24
  $this->renderLayout();
@@ -46,12 +74,36 @@ class Sendmachine_Sendmachine_SendmachineController extends Mage_Adminhtml_Contr
46
 
47
  $params = $this->getRequest()->getParams();
48
  $tab = isset($params['tab']) ? $params['tab'] : "index";
49
-
 
 
50
  unset($params['tab']);
51
  unset($params['limit']);
52
  unset($params['page']);
53
  unset($params['key']);
54
  unset($params['form_key']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  $initial_credentials = $this->sm->getCredentials();
57
  $initial_listid = $this->sm->get('selected_contact_list');
@@ -64,13 +116,15 @@ class Sendmachine_Sendmachine_SendmachineController extends Mage_Adminhtml_Contr
64
 
65
  if ($initial_credentials != $credentials) {
66
 
67
- if (($connectApi = $this->sm->connectApi()) === true)
68
  $this->_initApp();
 
69
 
70
  else {
71
 
72
- if (!$connectApi)
73
  $connectApi = "Unexpected error occurred!";
 
74
 
75
  $errorHandled = true;
76
  Mage::getSingleton('adminhtml/session')->addError($this->__($connectApi));
@@ -93,13 +147,27 @@ class Sendmachine_Sendmachine_SendmachineController extends Mage_Adminhtml_Contr
93
 
94
  $this->sm->commit();
95
 
96
- if (!$errorHandled)
97
  Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Successfully saved'));
98
- $this->getResponse()->setRedirect($this->getUrl("*/*/" . $tab));
 
 
 
 
 
 
99
  }
100
 
 
 
 
101
  public function sendtestmailAction() {
102
-
 
 
 
 
 
103
  if (!$this->sm->apiConnected()) {
104
 
105
  Mage::getSingleton('adminhtml/session')->addError($this->__('Api not connected'));
@@ -113,27 +181,27 @@ class Sendmachine_Sendmachine_SendmachineController extends Mage_Adminhtml_Contr
113
 
114
  $mailer = Mage::getModel('core/email_template');
115
 
116
- $recipientEmail = $this->getRequest()->getParam('emailAddress');
117
 
118
  $sender['name'] = Mage::getStoreConfig('trans_email/ident_general/name');
119
  $sender['email'] = Mage::getStoreConfig('trans_email/ident_general/email');
120
 
121
- $result = $mailer->sendTransactional("smSendTestEmail", $sender, $recipientEmail);
122
 
123
- if ($result->sent_success)
124
  Mage::getSingleton('adminhtml/session')->addSuccess(sprintf($this->__("Test message to '%s' sent successfully"), $recipientEmail));
125
- else
126
  Mage::getSingleton('adminhtml/session')->addError($this->__('Something went wrong, message not sent'));
 
127
  }
128
 
129
  public function importToNewsletterAction() {
130
 
 
 
 
131
  if ($this->sm->apiConnected()) {
132
 
133
- $store = $this->getRequest()->getParam('store');
134
- if (!$store) {
135
- $store = Mage::app()->getWebsite(true)->getDefaultGroup()->getDefaultStoreId();
136
- }
137
  $logId = $this->sm->addImportExportLog('import');
138
  $listId = $this->sm->get('selected_contact_list');
139
 
@@ -147,17 +215,19 @@ class Sendmachine_Sendmachine_SendmachineController extends Mage_Adminhtml_Contr
147
  }
148
 
149
  public function exportToSendmachineAction() {
 
 
 
150
 
151
  if ($this->sm->apiConnected()) {
152
 
153
- $subscribe_status = [Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED];
154
 
155
  $logId = $this->sm->addImportExportLog('export');
156
 
157
- $store = $this->getRequest()->getParam('sm_import_export_store');
158
  $limit = $this->sm->get('export_subscribers_limit');
159
  $subscribers = Mage::getModel('newsletter/subscriber')->getCollection()->setPageSize((int) $limit);
160
- $_subscribers = [];
161
 
162
  if ($subscribers && count($subscribers)) {
163
 
4
 
5
  private $sm;
6
 
7
+ public function __construct($request, $response, $invokeArgs = array()) {
8
 
9
  parent::__construct($request, $response, $invokeArgs);
10
 
11
  $smInstance = Mage::registry('sm_model');
12
  $this->sm = $smInstance ? $smInstance : Mage::getModel('sendmachine/sendmachine');
13
  }
14
+
15
+ /* MAGENTO PLUGIN CONFIGURATION ACTIONS */
16
 
17
  private function _renderApp($tab = '') {
18
 
19
  Mage::register('sm_model', $this->sm);
20
+
21
+ $request = Mage::app()->getRequest();
22
+ $website = $request->getParam('website');
23
+ $store = $request->getParam('store');
24
+ $button_data = null;
25
+
26
+ $this->sm->setWebsite($website);
27
+ $this->sm->setStore($store, false);
28
+
29
+ if ($website AND $store) {
30
+ $button_data = array(
31
+ 'label' => $this->__('Reset values to website'),
32
+ 'class' => 'reset_to_parent',
33
+ 'onclick' => "resetToParent('" . Mage::helper('adminhtml')->getUrl('adminhtml/sendmachine/resetoparent') . "', '$website', '$store', 'website')"
34
+ );
35
+ } elseif ($website) {
36
+ $button_data = array(
37
+ 'label' => $this->__('Reset values to default'),
38
+ 'class' => 'reset_to_parent',
39
+ 'onclick' => "resetToParent('" . Mage::helper('adminhtml')->getUrl('adminhtml/sendmachine/resetoparent') . "', '$website', '$store', 'default')"
40
+ );
41
+ }
42
 
43
  $this->loadLayout();
44
  $this->_setActiveMenu('system/sendmachine');
45
+ $this->_addContent($this->getLayout()->createBlock('adminhtml/system_config_switcher'));
46
+ if($button_data) {
47
+ $this->_addContent($this->getLayout()->createBlock('sendmachine/appContainer_main', 'smMainFormContainer', array('tab' => $tab))->addButton('reset_to_parent', $button_data, -1, 1));
48
+ }
49
+ else $this->_addContent($this->getLayout()->createBlock('sendmachine/appContainer_main', 'smMainFormContainer', array('tab' => $tab)));
50
  $this->_addLeft($this->getLayout()->createBlock('sendmachine/appContainer_tabs'));
51
  $this->getLayout()->getBlock('head')->addJs("sendmachine/admin.js");
52
  $this->renderLayout();
74
 
75
  $params = $this->getRequest()->getParams();
76
  $tab = isset($params['tab']) ? $params['tab'] : "index";
77
+ $website = $params['website'];
78
+ $store = $params['store'];
79
+
80
  unset($params['tab']);
81
  unset($params['limit']);
82
  unset($params['page']);
83
  unset($params['key']);
84
  unset($params['form_key']);
85
+ unset($params['website']);
86
+ unset($params['store']);
87
+
88
+ if(isset($params['reset_to_parent']) AND $params['reset_to_parent'] AND ($website OR $store)) {
89
+
90
+ if($store AND $website) {
91
+ $this->sm->setWebsite($website);
92
+ $this->sm->setStore(null, false);
93
+ }
94
+ else {
95
+ $this->sm->setWebsite(null);
96
+ $this->sm->setStore(null, false);
97
+ }
98
+
99
+ $_params = $this->sm->get();
100
+ foreach($params as $k => &$v) {
101
+ $v = isset($_params[$k]) ? $_params[$k] : "";
102
+ }
103
+ }
104
+
105
+ $this->sm->setWebsite($website);
106
+ $this->sm->setStore($store);
107
 
108
  $initial_credentials = $this->sm->getCredentials();
109
  $initial_listid = $this->sm->get('selected_contact_list');
116
 
117
  if ($initial_credentials != $credentials) {
118
 
119
+ if (($connectApi = $this->sm->connectApi()) === true) {
120
  $this->_initApp();
121
+ }
122
 
123
  else {
124
 
125
+ if (!$connectApi) {
126
  $connectApi = "Unexpected error occurred!";
127
+ }
128
 
129
  $errorHandled = true;
130
  Mage::getSingleton('adminhtml/session')->addError($this->__($connectApi));
147
 
148
  $this->sm->commit();
149
 
150
+ if (!$errorHandled) {
151
  Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Successfully saved'));
152
+ }
153
+
154
+ $suffix = "";
155
+ if($website) $suffix .= "/website/$website";
156
+ if($store) $suffix .= "/store/$store";
157
+
158
+ $this->getResponse()->setRedirect($this->getUrl("*/*/" . $tab . $suffix));
159
  }
160
 
161
+
162
+ /* MAGENTO ADMIN ACTIONS */
163
+
164
  public function sendtestmailAction() {
165
+
166
+ $request = Mage::app()->getRequest();
167
+
168
+ $this->sm->setWebsite($request->getParam('website'));
169
+ $this->sm->setStore($request->getParam('store'));
170
+
171
  if (!$this->sm->apiConnected()) {
172
 
173
  Mage::getSingleton('adminhtml/session')->addError($this->__('Api not connected'));
181
 
182
  $mailer = Mage::getModel('core/email_template');
183
 
184
+ $recipientEmail = $request->getParam('emailAddress');
185
 
186
  $sender['name'] = Mage::getStoreConfig('trans_email/ident_general/name');
187
  $sender['email'] = Mage::getStoreConfig('trans_email/ident_general/email');
188
 
189
+ $result = $mailer->sendTransactional("smSendTestEmail", $sender, $recipientEmail, null, array(), $this->sm->getStore());
190
 
191
+ if ($result->sent_success) {
192
  Mage::getSingleton('adminhtml/session')->addSuccess(sprintf($this->__("Test message to '%s' sent successfully"), $recipientEmail));
193
+ } else {
194
  Mage::getSingleton('adminhtml/session')->addError($this->__('Something went wrong, message not sent'));
195
+ }
196
  }
197
 
198
  public function importToNewsletterAction() {
199
 
200
+ $store = $this->getRequest()->getParam('store');
201
+ $this->sm->setStore($store);
202
+
203
  if ($this->sm->apiConnected()) {
204
 
 
 
 
 
205
  $logId = $this->sm->addImportExportLog('import');
206
  $listId = $this->sm->get('selected_contact_list');
207
 
215
  }
216
 
217
  public function exportToSendmachineAction() {
218
+
219
+ $store = $this->getRequest()->getParam('store');
220
+ $this->sm->setStore($store);
221
 
222
  if ($this->sm->apiConnected()) {
223
 
224
+ $subscribe_status = array(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
225
 
226
  $logId = $this->sm->addImportExportLog('export');
227
 
 
228
  $limit = $this->sm->get('export_subscribers_limit');
229
  $subscribers = Mage::getModel('newsletter/subscriber')->getCollection()->setPageSize((int) $limit);
230
+ $_subscribers = array();
231
 
232
  if ($subscribers && count($subscribers)) {
233
 
app/code/community/Sendmachine/Sendmachine/controllers/SubscribeController.php CHANGED
@@ -12,14 +12,14 @@ class Sendmachine_Sendmachine_SubscribeController extends Mage_Core_Controller_F
12
  $fields = $sm->get('list_custom_fields');
13
  $response = NULL;
14
  if (!$fields || !count($fields)) {
15
- $response = ['code' => 0, 'message' => $this->__('Something went wrong.You were not subscribed')];
16
  } else {
17
 
18
- $arr = [];
19
  foreach ($fields as $k => $v) {
20
 
21
  if ($v['required'] && empty($params[$k])) {
22
- $response = ['code' => 0, 'message' => $this->__('Required data was not filled')];
23
  break;
24
  }
25
 
@@ -31,14 +31,13 @@ class Sendmachine_Sendmachine_SubscribeController extends Mage_Core_Controller_F
31
 
32
  $listId = $sm->get('selected_contact_list');
33
  if ($sm->subscribeToList([$arr], $listId))
34
- $response = ['code' => 1, 'message' => $this->__('You have been successfully subscribed')];
35
  else
36
- $response = ['code' => 0, 'message' => $this->__('Something went wrong.You were not subscribed')];
37
  }
38
  }
39
 
40
  $this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
41
  $this->getResponse()->setBody(json_encode($response));
42
  }
43
-
44
  }
12
  $fields = $sm->get('list_custom_fields');
13
  $response = NULL;
14
  if (!$fields || !count($fields)) {
15
+ $response = array('code' => 0, 'message' => $this->__('Something went wrong.You were not subscribed'));
16
  } else {
17
 
18
+ $arr = array();
19
  foreach ($fields as $k => $v) {
20
 
21
  if ($v['required'] && empty($params[$k])) {
22
+ $response = array('code' => 0, 'message' => $this->__('Required data was not filled'));
23
  break;
24
  }
25
 
31
 
32
  $listId = $sm->get('selected_contact_list');
33
  if ($sm->subscribeToList([$arr], $listId))
34
+ $response = array('code' => 1, 'message' => $this->__('You have been successfully subscribed'));
35
  else
36
+ $response = array('code' => 0, 'message' => $this->__('Something went wrong.You were not subscribed'));
37
  }
38
  }
39
 
40
  $this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
41
  $this->getResponse()->setBody(json_encode($response));
42
  }
 
43
  }
app/code/community/Sendmachine/Sendmachine/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Sendmachine_Sendmachine>
5
- <version>1.0.0</version>
6
  </Sendmachine_Sendmachine>
7
  </modules>
8
  <global>
@@ -42,9 +42,9 @@
42
  <sendmachine_mysql4>
43
  <class>Sendmachine_Sendmachine_Model_Mysql4</class>
44
  <entities>
45
- <sendmachine>
46
  <table>sm_import_export_log</table>
47
- </sendmachine>
48
  </entities>
49
  </sendmachine_mysql4>
50
  </models>
@@ -72,7 +72,7 @@
72
  <email>
73
  <smSendTestEmail translate="label" module="sendmachine">
74
  <label>Sendmachine Test Email</label>
75
- <file>sendmachine/smSendTestEmail.html</file>
76
  <type>html</type>
77
  </smSendTestEmail>
78
  </email>
2
  <config>
3
  <modules>
4
  <Sendmachine_Sendmachine>
5
+ <version>1.0.1</version>
6
  </Sendmachine_Sendmachine>
7
  </modules>
8
  <global>
42
  <sendmachine_mysql4>
43
  <class>Sendmachine_Sendmachine_Model_Mysql4</class>
44
  <entities>
45
+ <importexportlog>
46
  <table>sm_import_export_log</table>
47
+ </importexportlog>
48
  </entities>
49
  </sendmachine_mysql4>
50
  </models>
72
  <email>
73
  <smSendTestEmail translate="label" module="sendmachine">
74
  <label>Sendmachine Test Email</label>
75
+ <file>sendmachine/sm_send_test_email.html</file>
76
  <type>html</type>
77
  </smSendTestEmail>
78
  </email>
app/code/community/Sendmachine/Sendmachine/sql/sendmachine_setup/mysql4-install-1.0.0.php CHANGED
@@ -5,8 +5,8 @@ $installer = $this;
5
  $installer->startSetup();
6
 
7
  $installer->run("
8
- -- DROP TABLE IF EXISTS {$this->getTable('sm_import_export_log')};
9
- CREATE TABLE {$this->getTable('sm_import_export_log')} (
10
  `id` int(11) unsigned NOT NULL auto_increment,
11
  `action` ENUM('import','export') NOT NULL,
12
  `state` ENUM('pending','completed','failed') NOT NULL,
5
  $installer->startSetup();
6
 
7
  $installer->run("
8
+
9
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('sm_import_export_log')}` (
10
  `id` int(11) unsigned NOT NULL auto_increment,
11
  `action` ENUM('import','export') NOT NULL,
12
  `state` ENUM('pending','completed','failed') NOT NULL,
app/code/community/Sendmachine/Sendmachine/sql/sendmachine_setup/mysql4-upgrade-1.0.0-1.0.1.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("ALTER TABLE `{$this->getTable('sm_import_export_log')}` ADD COLUMN `store` SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0 AFTER `id`;");
8
+
9
+ $installer->endSetup();
app/locale/en_US/template/email/sendmachine/sm_send_test_email.html ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Test email @-->
2
+
3
+ <!--@styles
4
+ @-->
5
+
6
+ {{template config_path="design/email/header"}}
7
+ {{inlinecss file="email-inline.css"}}
8
+
9
+ <table cellpadding="0" cellspacing="0" border="0">
10
+ <tr>
11
+ <td class="action-content">
12
+ <h1>Test message</h1>
13
+ <p>This message was sent for testing purposes. It was triggered from the <a href="https://www.magentocommerce.com/magento-connect/sendmachine.html">Sendmachine</a> plugin.</p>
14
+ <p>If you see this message it means that everything is ok, configuration went smoothly.</p>
15
+ </td>
16
+ </tr>
17
+ </table>
18
+
19
+ {{template config_path="design/email/footer"}}
js/sendmachine/admin.js CHANGED
@@ -29,8 +29,7 @@ function smToggleCredentialsVisibility(id, state) {
29
  if (state === 'hide') {
30
  style = 'color:transparent;text-shadow:0 0 5px rgba(0,0,0,0.5)';
31
  text = 'show';
32
- }
33
- else if (state === 'show') {
34
  style = '';
35
  text = 'hide';
36
  }
@@ -43,9 +42,17 @@ function smToggleCredentialsVisibility(id, state) {
43
  function smSendTestEmail(url) {
44
 
45
  var emailAddress = document.getElementById('smMageTestEmail');
 
 
 
 
 
 
 
 
46
  new Ajax.Request(url, {
47
  method: 'post',
48
- parameters: {emailAddress: emailAddress.value},
49
  onSuccess: function () {
50
  location.reload();
51
  }
@@ -54,7 +61,7 @@ function smSendTestEmail(url) {
54
 
55
  function smImport(url) {
56
 
57
- var store = document.getElementById('sm_import_export_store').value;
58
  new Ajax.Request(url, {
59
  method: 'post',
60
  parameters: {
@@ -68,10 +75,10 @@ function smImport(url) {
68
 
69
  function smExport(url) {
70
 
71
- var store = document.getElementById('sm_import_export_store').value;
72
  new Ajax.Request(url, {
73
  method: 'post',
74
- parameters: {sm_import_export_store: store},
75
  onSuccess: function () {
76
  location.reload();
77
  }
@@ -86,4 +93,16 @@ function smRefreshCachedLists(url) {
86
  location.reload();
87
  }
88
  });
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
29
  if (state === 'hide') {
30
  style = 'color:transparent;text-shadow:0 0 5px rgba(0,0,0,0.5)';
31
  text = 'show';
32
+ } else if (state === 'show') {
 
33
  style = '';
34
  text = 'hide';
35
  }
42
  function smSendTestEmail(url) {
43
 
44
  var emailAddress = document.getElementById('smMageTestEmail');
45
+ var website = document.getElementById('website_email');
46
+ var store = document.getElementById('store_email');
47
+
48
+ var data = {
49
+ emailAddress: emailAddress.value,
50
+ website: website.value,
51
+ store: store.value
52
+ };
53
  new Ajax.Request(url, {
54
  method: 'post',
55
+ parameters: data,
56
  onSuccess: function () {
57
  location.reload();
58
  }
61
 
62
  function smImport(url) {
63
 
64
+ var store = document.getElementById('store_lists').value;
65
  new Ajax.Request(url, {
66
  method: 'post',
67
  parameters: {
75
 
76
  function smExport(url) {
77
 
78
+ var store = document.getElementById('store_lists').value;
79
  new Ajax.Request(url, {
80
  method: 'post',
81
+ parameters: {store: store},
82
  onSuccess: function () {
83
  location.reload();
84
  }
93
  location.reload();
94
  }
95
  });
96
+ }
97
+
98
+ function resetToParent() {
99
+
100
+ var input = document.createElement("input");
101
+
102
+ input.setAttribute("type", "hidden");
103
+ input.setAttribute("name", "reset_to_parent");
104
+ input.setAttribute("value", "1");
105
+
106
+ document.getElementById("edit_form").appendChild(input);
107
+ editForm.submit();
108
  }
package.xml CHANGED
@@ -1,33 +1,42 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>sendmachine</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Official Sendmachine plugin featuring subscribe popup, users sync, email sending and transactional campaigns.</summary>
10
- <description>Sendmachine's official plugin will enable you to:&#xD;
11
- &#xD;
12
- Subscribe Popup&#xD;
13
- After you've successfully connected to the extension (using your sendmachine API credentials) you can configure a subscribe popup modal to allow your customers to easily subscribe to one of your contact lists.&#xD;
14
- &#xD;
15
- Import/Export subscribers&#xD;
16
- You want to send emails to all your users but don't know how? Well, don't worry, we can help you with that. After you've successfully selected a contact list, you can use the "Export to sendmachine" button, to export all your subscribers to your sendmachine account in the selected contact list. If you want to send a campaign from your magento store, there's an "Import to newsletter" button that imports all your sendmachine subscribers (from the selected list) to your magento newsletter subscribers tab. &#xD;
17
- If you have multiple stores you can import/export subscribers to a specific store instead of all.&#xD;
18
- &#xD;
19
- Send emails through our services&#xD;
20
- No need for nasty, geeky configurations. Just insert your API credentials and you are good to go. Also, make sure that "enable email sending" is set to on.&#xD;
21
- If you set a from email that doesn't already exist in your sendmachine account as a sender address, a confirmation email will be generated and sent to that address.&#xD;
22
- Not quite sure if you've done everything right? You can test if everything is ok by sending a test email. If you got the mail, you can sit back and relax: you've done it, otherwise something went wrong.&#xD;
23
- &#xD;
24
- Send transactional emails&#xD;
25
- Using our services you can now monitor an email's activity (opens, clicks, geolocations, user agents). In order to enable this option, after you install our plugin, go to "email" tab, set "Use transactional emails" to "yes" and mark the email areas that you want you want to be transactional and that's it.</description>
26
- <notes>Fist stable release.</notes>
27
- <authors><author><name>Sendmachine Team</name><user>sendmachine</user><email>support@sendmachine.com</email></author></authors>
28
- <date>2015-09-08</date>
29
- <time>07:50:07</time>
30
- <contents><target name="magecommunity"><dir name="Sendmachine"><dir name="Sendmachine"><dir name="Block"><dir name="AppContainer"><file name="Grid.php" hash="7a5feeb317e4859197140ee06d218039"/><file name="Main.php" hash="72bfae321e391f0f6c9534b2c2cf5bdb"/><dir name="Tab"><file name="Email.php" hash="97760a4c62225f6a8a977b5c2a1c60ea"/><file name="General.php" hash="10465b7692811b4ae467e827bfd27183"/><file name="Lists.php" hash="c65b5bb6ee523f65513d5316fd66518e"/></dir><file name="Tabs.php" hash="13507bb6578e80fec5084726b96acf07"/></dir><file name="PopupBlock.php" hash="7e42dab9ba8bef6bffdf8e496a64b3e4"/></dir><dir name="Helper"><file name="Data.php" hash="3e54639ada6047e12827df7be1b02746"/></dir><dir name="Model"><file name="Cronjobs.php" hash="fd431a87859a56f562937e8487e655ba"/><dir name="Email"><file name="Queue.php" hash="565cf2bee7c364027bd853ccac13a0c8"/><file name="Template.php" hash="15cbff0acaff99e9daa13cf9df4239e0"/></dir><dir name="Mysql4"><dir name="Sendmachine"><file name="Collection.php" hash="9308e4f5e4cc12f76028b3401ed76c58"/></dir><file name="Sendmachine.php" hash="70d59dd115baa6d9e6d7f398508eeb95"/></dir><file name="Observer.php" hash="fd7177c751474337a56cbdd9c731beda"/><file name="Sendmachine.php" hash="50f3f9b43e654eb4354f584aef15839b"/><dir name="Source"><file name="Contactlist.php" hash="7cb8e66b769da607a311dffba12304b3"/><file name="ImportExportLimit.php" hash="701b16f0f58ad1865b09efde615e3cf0"/><file name="Smtp.php" hash="041e6f75734ff963531f8ab979f3f0f4"/><file name="TransactionalCampAreas.php" hash="ddacac0ea340ce06ccf1b02b282d69b2"/></dir><file name="...Observer.php" hash="760b42e52cdf87ef65f109128f95a24e"/></dir><dir name="controllers"><file name="SendmachineController.php" hash="cae0cfaad4e26a6bb3b38e5cdd72e8e0"/><file name="SubscribeController.php" hash="7d56a808e79c2b6cf7bf45d7a8178f78"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2b9bc07f400202cbf4a92e4256319d28"/><file name="config.xml" hash="f4b1d6844da04e5f8eec790b5e02fc4d"/></dir><dir name="sql"><dir name="sendmachine_setup"><file name="mysql4-install-1.0.0.php" hash="5e5132b88f61df798c61284e98938230"/></dir></dir></dir></dir></target><target name="magelib"><dir name="SendmachineApi"><file name="README.md" hash="4f3be41975112c7b0e2d1b420362ca88"/><file name="SendmachineApiClient.php" hash="9990716a4159b2f57c91637126a0993e"/><file name="composer.json" hash="14472d29d81169ec0865135d75ceda44"/><dir name="library"><file name="Account.php" hash="d385b9bf2c6ab2cfe59224376b6e5ddd"/><file name="Campaigns.php" hash="675639e847d88e22d5ecfc23d9b931ed"/><file name="Lists.php" hash="be9f6d9dbb9be2948cc1c562063c2b28"/><file name="Sender.php" hash="c776b61c527ceadb1779c95c66e5cdb9"/><file name="Templates.php" hash="44b181d899bdf444a9ea66b95f648557"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="sendmachine"><file name="logo.png" hash="3ded087eb9efd7c6bdcaade0fec6f9e5"/><file name="logo2.png" hash="d0cdd8f8688b086dbba5dd7ce774e912"/><file name="logo3.png" hash="5c367ffbe7a6422668b3c0fa503a60fb"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="sendmachine"><file name="frontend.css" hash="d02fbf9fe0d145c7a9e8d59a91b7055d"/><file name="frontend.js" hash="ca7ca5de929041908f263f68ade035bf"/><file name="loading.gif" hash="3fce1e41ae8b01675553928349770faa"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="sendmachine"><file name="admin.js" hash="a6c7e0e797f4a996c469c4f32ee26988"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sendmachine_Sendmachine.xml" hash="8378d3fff65502b2677cb5439af9a091"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Sendmachine_Sendmachine.csv" hash="bdfdd5fda92cf52a1e9c07801f7b2a64"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="sendmachine.xml" hash="111176ded682edb4732351af44f2fa66"/></dir><dir name="template"><dir name="sendmachine"><file name="popup.phtml" hash="456a82301ee6d038a4964ab857645d6b"/></dir></dir></dir></dir></dir></target></contents>
 
 
 
 
 
 
 
 
 
31
  <compatible/>
32
  <dependencies><required><php><min>5.0.0</min><max>5.6.13</max></php><extension><name>curl</name><min/><max/></extension></required></dependencies>
33
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>sendmachine</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Sendmachine extension featuring subscribe popup, user import/export, email sending and transactional campaigns</summary>
10
+ <description>&lt;div&gt;&#xD;
11
+ &lt;p&gt;Sendmachine's official extension will enable you to:&lt;/p&gt;&#xD;
12
+ &lt;ul&gt;&#xD;
13
+ &lt;li&gt;&#xD;
14
+ &lt;b&gt;Set up subscribe popup&lt;/b&gt;&#xD;
15
+ &lt;br&gt;&#xD;
16
+ &lt;span&gt;After you've successfully connected to the extension (using your sendmachine API &lt;a target="_blank" href="https://www.sendmachine.com/admin/#/myaccount/smtp_settings"&gt;credentials&lt;/a&gt;) you can configure a subscribe popup modal to allow your customers to easily subscribe to one of your contact lists.&lt;/span&gt;&#xD;
17
+ &lt;/li&gt;&#xD;
18
+ &lt;li&gt;&#xD;
19
+ &lt;b&gt;Import/Export subscribers&lt;/b&gt;&#xD;
20
+ &lt;br&gt;&#xD;
21
+ &lt;span&gt;You want to send emails to all your users but don't know how? Well, don't worry, we can help you with that. After you've successfully selected a contact list, you can use the "Export to sendmachine" button, to export all your subscribers to your sendmachine account in the selected contact list. If you want to send a campaign from your magento store, there's an "Import to newsletter" button that imports all your sendmachine subscribers (from the selected list) to your magento newsletter subscribers tab. If you have multiple stores you can import/export subscribers to a specific store instead of all.&lt;/span&gt;&#xD;
22
+ &lt;/li&gt;&#xD;
23
+ &lt;li&gt;&#xD;
24
+ &lt;b&gt;Send emails through our services&lt;/b&gt;&#xD;
25
+ &lt;br&gt;&#xD;
26
+ &lt;span&gt;No need for nasty, geeky configurations. Just insert your API credentials and you are good to go. Also, make sure that "enable email sending" is set to on. If you set a from email that doesn't already exist in your sendmachine account as a sender address, a confirmation email will be generated and sent to that address. Not quite sure if you've done everything right? You can test if everything is ok by sending a test email. If you got the mail, you can sit back and relax: you've done it, otherwise something went wrong.&lt;/span&gt;&#xD;
27
+ &lt;/li&gt;&#xD;
28
+ &lt;li&gt;&#xD;
29
+ &lt;b&gt;Send transactional emails&lt;/b&gt;&#xD;
30
+ &lt;br&gt;&#xD;
31
+ &lt;span&gt;Using our services you can now monitor an email's activity (opens, clicks, geolocations, user agents). In order to enable this option, after you install our extension, go to "email" tab, set "Use transactional emails" to "yes" and mark the email areas that you want you want to be transactional and that's it.&lt;/span&gt;&#xD;
32
+ &lt;/li&gt;&#xD;
33
+ &lt;/ul&gt;&#xD;
34
+ &lt;/div&gt;</description>
35
+ <notes>Stable release. Included multistore support.</notes>
36
+ <authors><author><name>Sendmachine</name><user>sendmachine</user><email>support@sendmachine.com</email></author></authors>
37
+ <date>2016-07-13</date>
38
+ <time>06:07:57</time>
39
+ <contents><target name="magecommunity"><dir name="Sendmachine"><dir name="Sendmachine"><dir name="Block"><dir name="AppContainer"><file name="Grid.php" hash="93132a7ae131d9a446cd6897aeface90"/><file name="Main.php" hash="72bfae321e391f0f6c9534b2c2cf5bdb"/><dir name="Tab"><file name="Email.php" hash="cb60345586e0aa2e7047dbe8bbd517f0"/><file name="General.php" hash="43131871f9862e88d5bbf2aea388cda6"/><file name="Lists.php" hash="b4422f9c2f7043bb280bf789f2955a14"/></dir><file name="Tabs.php" hash="35a2ee900e946b65dbbe9f025b45a7d2"/></dir><file name="PopupBlock.php" hash="4cd81d501ad55345a8d9af28bd5271af"/></dir><dir name="Helper"><file name="Data.php" hash="0a4cb51951417c0c30f2c4489af55cf3"/></dir><dir name="Model"><file name="Cronjobs.php" hash="c9189af524b66278b60a272382777313"/><dir name="Email"><file name="Queue.php" hash="565cf2bee7c364027bd853ccac13a0c8"/><file name="Template.php" hash="e34560b42fad5c838a58655fb2d1e7c4"/></dir><dir name="Mysql4"><dir name="Sendmachine"><file name="Collection.php" hash="9308e4f5e4cc12f76028b3401ed76c58"/></dir><file name="Sendmachine.php" hash="70d59dd115baa6d9e6d7f398508eeb95"/></dir><file name="Observer.php" hash="5cd573bc8bc33e94ad145dc385f8d8ef"/><file name="Sendmachine.php" hash="70e93e9b9d272f6fa98427a2e3e4977a"/><dir name="Source"><file name="Contactlist.php" hash="399c3de2d3616e98bb97310a34c8ae16"/><file name="ImportExportLimit.php" hash="3bde4faece90495bef39e6c862f09350"/><file name="Smtp.php" hash="a99f6c2795a1a2c479bfcef9e8b4d9de"/><file name="TransactionalCampAreas.php" hash="94ec1556a650739051c5d3d3da38be60"/></dir></dir><dir name="controllers"><file name="SendmachineController.php" hash="8cfc211398fa222a049807c9b89e9e78"/><file name="SubscribeController.php" hash="e672a2c10dc2d480ad07ddaa4294a100"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2b9bc07f400202cbf4a92e4256319d28"/><file name="config.xml" hash="fb88759ddb8581a62bbe4a6b106ba66b"/></dir><dir name="sql"><dir name="sendmachine_setup"><file name="mysql4-install-1.0.0.php" hash="c7fb051da24f17f073dd0c3fc76a79c1"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="062cab72ea965e951acd43c3f3abc2bb"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sendmachine_Sendmachine.xml" hash="8378d3fff65502b2677cb5439af9a091"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="sendmachine.xml" hash="111176ded682edb4732351af44f2fa66"/></dir><dir name="template"><dir name="sendmachine"><file name="popup.phtml" hash="456a82301ee6d038a4964ab857645d6b"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Sendmachine_Sendmachine.csv" hash="bdfdd5fda92cf52a1e9c07801f7b2a64"/><dir name="template"><dir name="email"><dir name="sendmachine"><file name="sm_send_test_email.html" hash="572e49104e369c140ea691b83e4888c0"/></dir></dir></dir></dir></target><target name="magelib"><dir name="SendmachineApi"><file name="README.md" hash="4f3be41975112c7b0e2d1b420362ca88"/><file name="SendmachineApiClient.php" hash="9990716a4159b2f57c91637126a0993e"/><file name="composer.json" hash="14472d29d81169ec0865135d75ceda44"/><dir name="library"><file name="Account.php" hash="d385b9bf2c6ab2cfe59224376b6e5ddd"/><file name="Campaigns.php" hash="675639e847d88e22d5ecfc23d9b931ed"/><file name="Lists.php" hash="be9f6d9dbb9be2948cc1c562063c2b28"/><file name="Sender.php" hash="c776b61c527ceadb1779c95c66e5cdb9"/><file name="Templates.php" hash="44b181d899bdf444a9ea66b95f648557"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="sendmachine"><file name="logo.png" hash="3ded087eb9efd7c6bdcaade0fec6f9e5"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="sendmachine"><file name="frontend.css" hash="d02fbf9fe0d145c7a9e8d59a91b7055d"/><file name="frontend.js" hash="ca7ca5de929041908f263f68ade035bf"/><file name="loading.gif" hash="3fce1e41ae8b01675553928349770faa"/></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="sendmachine"><file name="admin.js" hash="d8c93bf08f8fb4831787aa53fb5aef11"/></dir></dir></target></contents>
40
  <compatible/>
41
  <dependencies><required><php><min>5.0.0</min><max>5.6.13</max></php><extension><name>curl</name><min/><max/></extension></required></dependencies>
42
  </package>
skin/adminhtml/default/default/sendmachine/logo2.png DELETED
Binary file
skin/adminhtml/default/default/sendmachine/logo3.png DELETED
Binary file