Version Notes
Initial version
Download this release
Release Info
Developer | Shaughn Le Grange - Hatlen |
Extension | Fontera_GraphicMail |
Version | 1.0.2 |
Comparing to | |
See all releases |
Version 1.0.2
- app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists.php +45 -0
- app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists/Edit.php +45 -0
- app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists/Edit/Form.php +39 -0
- app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists/Edit/Tab/General.php +137 -0
- app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists/Edit/Tab/General/Abstract.php +245 -0
- app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists/Edit/Tab/General/DatasetMapping.php +48 -0
- app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists/Edit/Tabs.php +44 -0
- app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists/Grid.php +127 -0
- app/code/community/Fontera/GraphicMail/Block/Adminhtml/System/Config/Testconnection.php +59 -0
- app/code/community/Fontera/GraphicMail/Helper/Data.php +225 -0
- app/code/community/Fontera/GraphicMail/Helper/Sc.php +103 -0
- app/code/community/Fontera/GraphicMail/Model/Abstract.php +27 -0
- app/code/community/Fontera/GraphicMail/Model/Adminhtml/SetupTypes.php +27 -0
- app/code/community/Fontera/GraphicMail/Model/GraphicMail.php +507 -0
- app/code/community/Fontera/GraphicMail/Model/GraphicMail/Api.php +148 -0
- app/code/community/Fontera/GraphicMail/Model/Mailinglists.php +26 -0
- app/code/community/Fontera/GraphicMail/Model/Observer.php +128 -0
- app/code/community/Fontera/GraphicMail/Model/Resource/Mailinglists.php +25 -0
- app/code/community/Fontera/GraphicMail/Model/Resource/Mailinglists/Collection.php +25 -0
- app/code/community/Fontera/GraphicMail/Rewrite/Mage/Newsletter/Model/Subscriber.php +198 -0
- app/code/community/Fontera/GraphicMail/controllers/Adminhtml/MailinglistsController.php +341 -0
- app/code/community/Fontera/GraphicMail/controllers/Adminhtml/System/Config/TestconnectionController.php +45 -0
- app/code/community/Fontera/GraphicMail/etc/adminhtml.xml +70 -0
- app/code/community/Fontera/GraphicMail/etc/config.xml +130 -0
- app/code/community/Fontera/GraphicMail/etc/system.xml +109 -0
- app/code/community/Fontera/GraphicMail/sql/fontera_graphicmail_setup/install-1.0.0.php +44 -0
- app/design/adminhtml/default/default/layout/fontera_graphicmail.xml +28 -0
- app/design/adminhtml/default/default/template/fontera_graphicmail/mailinglists/dataset_mapping.phtml +126 -0
- app/design/adminhtml/default/default/template/fontera_graphicmail/system/config/form/field/dataset_array_dropdown.phtml +167 -0
- app/design/adminhtml/default/default/template/fontera_graphicmail/system/config/testconnection.phtml +64 -0
- app/etc/modules/Fontera_GraphicMail.xml +28 -0
- package.xml +20 -0
app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Block_Adminhtml_Mailinglists extends Mage_Adminhtml_Block_Widget_Grid_Container
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Constructor
|
20 |
+
*/
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
$helper = Mage::helper('fontera_graphicmail');
|
24 |
+
$this->_controller = 'adminhtml_mailinglists';
|
25 |
+
$this->_blockGroup = 'fontera_graphicmail';
|
26 |
+
$this->_headerText = $helper->__('Manage Mailing Lists');
|
27 |
+
$this->_addButtonLabel = $helper->__('Add New Mailing List');
|
28 |
+
parent::__construct();
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Prepare layout
|
33 |
+
*
|
34 |
+
* @return Fontera_GraphicMail_Block_Adminhtml_Mailinglists
|
35 |
+
*/
|
36 |
+
protected function _prepareLayout()
|
37 |
+
{
|
38 |
+
$helper = Mage::helper('fontera_graphicmail');
|
39 |
+
$this->_addButton('export_customers', array(
|
40 |
+
'label' => $helper->__('Export Existing Customers'),
|
41 |
+
'onclick' => "setLocation('{$this->getUrl('*/*/exportCustomers')}')",
|
42 |
+
));
|
43 |
+
return parent::_prepareLayout();
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists/Edit.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Block_Adminhtml_Mailinglists_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Constructor
|
20 |
+
*/
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
parent::__construct();
|
24 |
+
$helper = Mage::helper('fontera_graphicmail');
|
25 |
+
$this->_objectId = 'entity_id';
|
26 |
+
$this->_controller = 'adminhtml_mailinglists';
|
27 |
+
$this->_blockGroup = 'fontera_graphicmail';
|
28 |
+
$this->_updateButton('save', 'label', $helper->__('Save'));
|
29 |
+
$this->_updateButton('delete', 'label', $helper->__('Delete'));
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Get header text
|
34 |
+
*/
|
35 |
+
public function getHeaderText()
|
36 |
+
{
|
37 |
+
$helper = Mage::helper('fontera_graphicmail');
|
38 |
+
|
39 |
+
if(Mage::registry('graphicmail_mailinglists_data') && Mage::registry('graphicmail_mailinglists_data')->getId()) {
|
40 |
+
return $helper->__("Edit Mailing List - '%s'", $this->htmlEscape(Mage::registry('graphicmail_mailinglists_data')->getId()));
|
41 |
+
} else {
|
42 |
+
return $helper->__('Add Mailing List');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists/Edit/Form.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Block_Adminhtml_Mailinglists_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Prepare form
|
20 |
+
*
|
21 |
+
* @return Fontera_GraphicMail_Block_Adminhtml_Mailinglists_Edit_Form
|
22 |
+
*/
|
23 |
+
protected function _prepareForm()
|
24 |
+
{
|
25 |
+
$form = new Varien_Data_Form(
|
26 |
+
array(
|
27 |
+
'id' => 'edit_form',
|
28 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
29 |
+
'method' => 'post',
|
30 |
+
'enctype' => 'multipart/form-data'
|
31 |
+
)
|
32 |
+
);
|
33 |
+
|
34 |
+
$form->setUseContainer(true);
|
35 |
+
$this->setForm($form);
|
36 |
+
|
37 |
+
return parent::_prepareForm();
|
38 |
+
}
|
39 |
+
}
|
app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists/Edit/Tab/General.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Block_Adminhtml_Mailinglists_Edit_Tab_General extends Mage_Adminhtml_Block_Widget_Form
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Prepare form
|
20 |
+
*
|
21 |
+
* @return Fontera_GraphicMail_Block_Adminhtml_Mailinglists_Edit_Tab_General
|
22 |
+
*/
|
23 |
+
protected function _prepareForm()
|
24 |
+
{
|
25 |
+
$helper = Mage::helper('fontera_graphicmail');
|
26 |
+
$graphicmail = Mage::getModel('fontera_graphicmail/graphicMail');
|
27 |
+
|
28 |
+
$form = new Varien_Data_Form();
|
29 |
+
$this->setForm($form);
|
30 |
+
$fieldset = $form->addFieldset('mailinglist_form', array('legend'=>$helper->__('General Information')));
|
31 |
+
|
32 |
+
$fieldset->addField('setup_type', 'select', array(
|
33 |
+
'label' => $helper->__('Type'),
|
34 |
+
'name' => 'setup_type',
|
35 |
+
'class' => 'required-entry',
|
36 |
+
'required' => true,
|
37 |
+
'values' => $helper->getSetupTypesOptionSelect(),
|
38 |
+
'note' => $helper->__('Email addresses to be harvested in Magento.'),
|
39 |
+
));
|
40 |
+
|
41 |
+
$fieldset->addField('mailinglist_id', 'select', array(
|
42 |
+
'label' => $helper->__('Mailing List'),
|
43 |
+
'name' => 'mailinglist_id',
|
44 |
+
'class' => 'required-entry',
|
45 |
+
'required' => true,
|
46 |
+
'values' => $graphicmail->getMailingListsOptionsArray(),
|
47 |
+
'note' => $helper->__('Mailing list options are fetched from GraphicMail. If there are no mailing list options available, log in to GraphicMail and create one.'),
|
48 |
+
));
|
49 |
+
|
50 |
+
$dataset = $fieldset->addField('dataset_id', 'select', array(
|
51 |
+
'label' => $helper->__('Dataset'),
|
52 |
+
'name' => 'dataset_id',
|
53 |
+
'class' => 'required-entry',
|
54 |
+
'required' => true,
|
55 |
+
'values' => $graphicmail->getDatasetsOptionsArray(),
|
56 |
+
'note' => $helper->__('Dataset options are fetched from GraphicMail. If there are no dataset options available, please contact GraphicMail.'),
|
57 |
+
'onchange' => 'fetchDatasetFields()',
|
58 |
+
));
|
59 |
+
|
60 |
+
/*$fieldset->addField('mapped_dataset_fields', 'text', array(
|
61 |
+
'label' => $helper->__('Map Dataset Fields'),
|
62 |
+
'name' => 'mapped_dataset_fields',
|
63 |
+
'class' => 'required-entry',
|
64 |
+
'required' => true,
|
65 |
+
));
|
66 |
+
|
67 |
+
$form->getElement('mapped_dataset_fields')->setRenderer(
|
68 |
+
$this->getLayout()->createBlock('fontera_graphicmail/adminhtml_mailinglists_edit_tab_general_datasetMapping')
|
69 |
+
);*/
|
70 |
+
|
71 |
+
$formValues = array();
|
72 |
+
|
73 |
+
if(Mage::getSingleton('adminhtml/session')->getFonteraGraphicmailData()) {
|
74 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getFonteraGraphicmailData());
|
75 |
+
$formValues = Mage::getSingleton('adminhtml/session')->getFonteraGraphicmailData();
|
76 |
+
Mage::getSingleton('adminhtml/session')->setFonteraGraphicmailData(null);
|
77 |
+
} else if (Mage::registry('fontera_graphicmail_data')) {
|
78 |
+
$form->setValues(Mage::registry('fontera_graphicmail_data')->getData());
|
79 |
+
$formValues = Mage::registry('fontera_graphicmail_data')->getData();
|
80 |
+
}
|
81 |
+
|
82 |
+
if (empty($formValues)) {
|
83 |
+
$params = '';
|
84 |
+
} else {
|
85 |
+
$params = "parameters: ".json_encode($formValues).",";
|
86 |
+
}
|
87 |
+
|
88 |
+
$afterHtml = "<script type=\"text/javascript\">
|
89 |
+
document.observe('dom:loaded', function() {
|
90 |
+
fetchDatasetFields();
|
91 |
+
});
|
92 |
+
|
93 |
+
function fetchDatasetFields() {
|
94 |
+
var datasetIdEl = $('dataset_id');
|
95 |
+
var formTableEl = $$('.form-list tbody')[0];
|
96 |
+
|
97 |
+
if ((typeof(datasetIdEl) != 'undefined' && datasetIdEl != null) && (typeof(formTableEl) != 'undefined' && formTableEl != null)) {
|
98 |
+
|
99 |
+
if (datasetIdEl.value != '') {
|
100 |
+
var url = '". $this->getUrl('graphicmail_admin/mailinglists/datasetMapping') . "dataset_id/' + datasetIdEl.value;
|
101 |
+
|
102 |
+
new Ajax.Request(url, {
|
103 |
+
method: 'post',
|
104 |
+
".$params."
|
105 |
+
evalScripts: true,
|
106 |
+
onLoading: function (transport) {},
|
107 |
+
onComplete: function(transport) {
|
108 |
+
var json = transport.responseText.evalJSON(true);
|
109 |
+
|
110 |
+
if (json.status == 'success') {
|
111 |
+
// Check if table already exists and update
|
112 |
+
var datasetMappingTableEl = $('dataset_mapping_table');
|
113 |
+
if (typeof(datasetMappingTableEl) != 'undefined' && datasetMappingTableEl != null) {
|
114 |
+
|
115 |
+
var datasetMappingTableRowEl = datasetMappingTableEl.up().up();
|
116 |
+
datasetMappingTableRowEl.insert(json.html);
|
117 |
+
|
118 |
+
// Else add it
|
119 |
+
} else {
|
120 |
+
formTableEl.insert(json.html);
|
121 |
+
}
|
122 |
+
} else {
|
123 |
+
alert(json.message);
|
124 |
+
}
|
125 |
+
}
|
126 |
+
});
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
+
</script>
|
131 |
+
";
|
132 |
+
|
133 |
+
$dataset->setAfterElementHtml($afterHtml);
|
134 |
+
|
135 |
+
return parent::_prepareForm();
|
136 |
+
}
|
137 |
+
}
|
app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists/Edit/Tab/General/Abstract.php
ADDED
@@ -0,0 +1,245 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
abstract class Fontera_GraphicMail_Block_Adminhtml_Mailinglists_Edit_Tab_General_Abstract
|
17 |
+
extends Mage_Adminhtml_Block_Widget
|
18 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* Form element instance
|
22 |
+
*
|
23 |
+
* @var Varien_Data_Form_Element_Abstract
|
24 |
+
*/
|
25 |
+
protected $_element;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Magento fields cache
|
29 |
+
*
|
30 |
+
* @var array
|
31 |
+
*/
|
32 |
+
protected $_magentoFields;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Graphicmail fields cache
|
36 |
+
*
|
37 |
+
* @var array
|
38 |
+
*/
|
39 |
+
protected $_graphicmailFields;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Render HTML
|
43 |
+
*
|
44 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
45 |
+
* @return string
|
46 |
+
*/
|
47 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
48 |
+
{
|
49 |
+
$this->setElement($element);
|
50 |
+
return $this->toHtml();
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Set form element instance
|
55 |
+
*
|
56 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
57 |
+
* @return Fontera_GraphicMail_Block_Adminhtml_Mailinglists_Edit_Tab_General_Abstract
|
58 |
+
*/
|
59 |
+
public function setElement(Varien_Data_Form_Element_Abstract $element)
|
60 |
+
{
|
61 |
+
$this->_element = $element;
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Retrieve form element instance
|
67 |
+
*
|
68 |
+
* @return Varien_Data_Form_Element_Abstract
|
69 |
+
*/
|
70 |
+
public function getElement()
|
71 |
+
{
|
72 |
+
return $this->_element;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Get and prepare row values
|
77 |
+
*
|
78 |
+
* @return array
|
79 |
+
*/
|
80 |
+
public function getValues()
|
81 |
+
{
|
82 |
+
$values = array();
|
83 |
+
$dataRaw = $this->getElement()->getValue();
|
84 |
+
|
85 |
+
// Check if string is serialized
|
86 |
+
$data = @unserialize($dataRaw);
|
87 |
+
if ($data != false) {
|
88 |
+
if (is_array($data)) {
|
89 |
+
$values = $this->_sortValues($data);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
return $values;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Get and prepare dataset_id
|
98 |
+
*
|
99 |
+
* @return array
|
100 |
+
*/
|
101 |
+
public function getDatasetId()
|
102 |
+
{
|
103 |
+
$datasetId = $this->getElement()->getDatasetId();
|
104 |
+
|
105 |
+
return $datasetId;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Sort values
|
110 |
+
*
|
111 |
+
* @param array $data
|
112 |
+
* @return array
|
113 |
+
*/
|
114 |
+
protected function _sortValues($data)
|
115 |
+
{
|
116 |
+
return $data;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Get Magento fields
|
121 |
+
*
|
122 |
+
* @param string|null $attrCode (return label by attribute code)
|
123 |
+
* @return array|string
|
124 |
+
*/
|
125 |
+
public function getMagentoFields($attrCode = null)
|
126 |
+
{
|
127 |
+
if ($this->_magentoFields === null) {
|
128 |
+
// Set initial values
|
129 |
+
$this->_magentoFields = $this->_getInitial();
|
130 |
+
|
131 |
+
$excludedFields = $this->getExcludedMagentoFields();
|
132 |
+
|
133 |
+
// Customer attribute collection
|
134 |
+
$customerAttrCol = Mage::getModel('customer/entity_attribute_collection')
|
135 |
+
->addVisibleFilter();
|
136 |
+
|
137 |
+
foreach ($customerAttrCol as $customerAttr) {
|
138 |
+
/** @var $customerAttr Mage_Eav_Model_Entity_Attribute */
|
139 |
+
if (!isset($excludedFields[$customerAttr->getAttributeCode()])) {
|
140 |
+
$this->_magentoFields['customer_'.$customerAttr->getAttributeCode()] = 'Customer: '.$customerAttr->getFrontendLabel().' ('.$customerAttr->getAttributeCode().')';
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
// Customer address attribute collection
|
145 |
+
$addressAttrCol = Mage::getModel('customer/entity_address_attribute_collection')
|
146 |
+
->addVisibleFilter();
|
147 |
+
|
148 |
+
foreach ($addressAttrCol as $addressAttr){
|
149 |
+
/** @var $addressAttr Mage_Eav_Model_Entity_Attribute */
|
150 |
+
if (!isset($excludedFields[$addressAttr->getAttributeCode()])) {
|
151 |
+
$this->_magentoFields['address_'.$addressAttr->getAttributeCode()] = 'Address: '.$addressAttr->getFrontendLabel().' ('.$addressAttr->getAttributeCode().')';
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
if ($attrCode !== null) {
|
157 |
+
return isset($this->_magentoFields[$attrCode]) ? $this->_magentoFields[$attrCode] : array();
|
158 |
+
}
|
159 |
+
|
160 |
+
return $this->_magentoFields;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Get default value for Magento fields
|
165 |
+
*
|
166 |
+
* @return string | null
|
167 |
+
*/
|
168 |
+
public function getDefaultMagentoFields()
|
169 |
+
{
|
170 |
+
return '';
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Get excluded Magento fields
|
175 |
+
*
|
176 |
+
* @return array
|
177 |
+
*/
|
178 |
+
public function getExcludedMagentoFields()
|
179 |
+
{
|
180 |
+
return array(
|
181 |
+
'created_in' => 'created_in',
|
182 |
+
'disable_auto_group_change' => 'disable_auto_group_change',
|
183 |
+
);
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Get Graphicmail fields
|
188 |
+
*
|
189 |
+
* @param string|null $attrCode (return label by attribute code)
|
190 |
+
* @param int $datasetId
|
191 |
+
* @return array|string
|
192 |
+
*/
|
193 |
+
public function getGraphicmailFields($attrCode = null)
|
194 |
+
{
|
195 |
+
$datasetId = $this->getDatasetId();
|
196 |
+
if (($this->_graphicmailFields === null) && ($datasetId != '')) {
|
197 |
+
// Set initial values
|
198 |
+
$this->_graphicmailFields = $this->_getInitial();
|
199 |
+
|
200 |
+
// Fetch GraphicMail fields
|
201 |
+
$graphicmail = Mage::getModel('fontera_graphicmail/graphicMail');
|
202 |
+
$datasetColumns = $graphicmail->getDatasetColumns($datasetId);
|
203 |
+
|
204 |
+
foreach ($datasetColumns as $attributeCode => $attributeLabel) {
|
205 |
+
$this->_graphicmailFields[$attributeCode] = $attributeLabel.' ('.$attributeCode.')';
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
if ($attrCode !== null) {
|
210 |
+
return isset($this->_graphicmailFields[$attrCode]) ? $this->_graphicmailFields[$attrCode] : array();
|
211 |
+
}
|
212 |
+
|
213 |
+
return $this->_graphicmailFields;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Get default value for graphicmail fields
|
218 |
+
*
|
219 |
+
* @return string | null
|
220 |
+
*/
|
221 |
+
public function getDefaultGraphicmailFields()
|
222 |
+
{
|
223 |
+
return '';
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Retrieve list of initial values if we want to set it
|
228 |
+
*
|
229 |
+
* @return array
|
230 |
+
*/
|
231 |
+
protected function _getInitial()
|
232 |
+
{
|
233 |
+
return array();
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Retrieve 'add item' button HTML
|
238 |
+
*
|
239 |
+
* @return string
|
240 |
+
*/
|
241 |
+
public function getAddButtonHtml()
|
242 |
+
{
|
243 |
+
return $this->getChildHtml('add_button');
|
244 |
+
}
|
245 |
+
}
|
app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists/Edit/Tab/General/DatasetMapping.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Block_Adminhtml_Mailinglists_Edit_Tab_General_DatasetMapping extends Fontera_GraphicMail_Block_Adminhtml_Mailinglists_Edit_Tab_General_Abstract
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Internal constructor
|
20 |
+
*
|
21 |
+
* @return void
|
22 |
+
*/
|
23 |
+
public function __construct()
|
24 |
+
{
|
25 |
+
$this->setTemplate('fontera_graphicmail/mailinglists/dataset_mapping.phtml');
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Prepare global layout
|
30 |
+
*
|
31 |
+
* Add "Add Dataset Field" button to layout
|
32 |
+
*
|
33 |
+
* @return Fontera_GraphicMail_Block_Adminhtml_Mailinglists_Edit_Tab_General_DatasetMapping
|
34 |
+
*/
|
35 |
+
protected function _prepareLayout()
|
36 |
+
{
|
37 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
38 |
+
->setData(array(
|
39 |
+
'label' => Mage::helper('fontera_graphicmail')->__('Add Dataset Field'),
|
40 |
+
'onclick' => 'return datasetMappingControl.addItem()',
|
41 |
+
'class' => 'add'
|
42 |
+
));
|
43 |
+
$button->setName('add_dataset_mapping_item_button');
|
44 |
+
|
45 |
+
$this->setChild('add_button', $button);
|
46 |
+
return parent::_prepareLayout();
|
47 |
+
}
|
48 |
+
}
|
app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists/Edit/Tabs.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Block_Adminhtml_Mailinglists_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Constructor
|
20 |
+
*/
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
parent::__construct();
|
24 |
+
$this->setId('graphicmail_mailinglists_tabs');
|
25 |
+
$this->setDestElementId('edit_form');
|
26 |
+
$this->setTitle(Mage::helper('fontera_graphicmail')->__('Manage Mailing Lists'));
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Before toHtml
|
31 |
+
*/
|
32 |
+
protected function _beforeToHtml()
|
33 |
+
{
|
34 |
+
$helper = Mage::helper('fontera_graphicmail');
|
35 |
+
|
36 |
+
$this->addTab('general_section', array(
|
37 |
+
'label' => $helper->__('General Information'),
|
38 |
+
'title' => $helper->__('General Information'),
|
39 |
+
'content' => $this->getLayout()->createBlock('fontera_graphicmail/adminhtml_mailinglists_edit_tab_general')->toHtml(),
|
40 |
+
));
|
41 |
+
|
42 |
+
return parent::_beforeToHtml();
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Fontera/GraphicMail/Block/Adminhtml/Mailinglists/Grid.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Block_Adminhtml_Mailinglists_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Constructor
|
20 |
+
*/
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
parent::__construct();
|
24 |
+
$this->setId('mailinglistsGrid');
|
25 |
+
$this->setDefaultSort('position');
|
26 |
+
$this->setDefaultDir('ASC');
|
27 |
+
$this->setSaveParametersInSession(true);
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Prepare collection
|
32 |
+
*
|
33 |
+
* @return Fontera_GraphicMail_Model_Mailinglists
|
34 |
+
*/
|
35 |
+
protected function _prepareCollection()
|
36 |
+
{
|
37 |
+
$collection = Mage::getModel('fontera_graphicmail/mailinglists')->getCollection();
|
38 |
+
$this->setCollection($collection);
|
39 |
+
return parent::_prepareCollection();
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Prepare columns
|
44 |
+
*/
|
45 |
+
protected function _prepareColumns()
|
46 |
+
{
|
47 |
+
$helper = Mage::helper('fontera_graphicmail');
|
48 |
+
|
49 |
+
$this->addColumn('entity_id', array(
|
50 |
+
'header' => $helper->__('ID'),
|
51 |
+
'align' => 'left',
|
52 |
+
'width' => '25px',
|
53 |
+
'index' => 'entity_id',
|
54 |
+
));
|
55 |
+
|
56 |
+
$this->addColumn('setup_type', array(
|
57 |
+
'header' => $helper->__('Type'),
|
58 |
+
'align' => 'left',
|
59 |
+
'width' => '80px',
|
60 |
+
'index' => 'setup_type',
|
61 |
+
'type' => 'options',
|
62 |
+
'options' => $helper->getSetupTypesOptionSelect(),
|
63 |
+
));
|
64 |
+
|
65 |
+
$this->addColumn('dataset_id', array(
|
66 |
+
'header' => $helper->__('DatasetID'),
|
67 |
+
'align' => 'left',
|
68 |
+
'width' => '100px',
|
69 |
+
'index' => 'dataset_id',
|
70 |
+
));
|
71 |
+
|
72 |
+
$this->addColumn('mailinglist_id', array(
|
73 |
+
'header' => $helper->__('MailinglistID'),
|
74 |
+
'align' => 'left',
|
75 |
+
'width' => '100px',
|
76 |
+
'index' => 'mailinglist_id',
|
77 |
+
));
|
78 |
+
|
79 |
+
$this->addColumn('action',
|
80 |
+
array(
|
81 |
+
'header' => $helper->__('Action'),
|
82 |
+
'width' => '100px',
|
83 |
+
'type' => 'action',
|
84 |
+
'getter' => 'getId',
|
85 |
+
'actions' => array(
|
86 |
+
array(
|
87 |
+
'caption' => $helper->__('Edit'),
|
88 |
+
'url' => array('base'=> '*/*/edit'),
|
89 |
+
'field' => 'id'
|
90 |
+
)
|
91 |
+
),
|
92 |
+
'filter' => false,
|
93 |
+
'sortable' => false,
|
94 |
+
'index' => 'entity_id',
|
95 |
+
'is_system' => true,
|
96 |
+
));
|
97 |
+
|
98 |
+
return parent::_prepareColumns();
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Prepare mass action block
|
103 |
+
*/
|
104 |
+
protected function _prepareMassaction()
|
105 |
+
{
|
106 |
+
$this->setMassactionIdField('ids');
|
107 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
108 |
+
|
109 |
+
$helper = Mage::helper('fontera_graphicmail');
|
110 |
+
|
111 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
112 |
+
'label' => $helper->__('Delete'),
|
113 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
114 |
+
'confirm' => $helper->__('Are you sure?')
|
115 |
+
));
|
116 |
+
|
117 |
+
return $this;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Get row URL
|
122 |
+
*/
|
123 |
+
public function getRowUrl($row)
|
124 |
+
{
|
125 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getEntityId()));
|
126 |
+
}
|
127 |
+
}
|
app/code/community/Fontera/GraphicMail/Block/Adminhtml/System/Config/Testconnection.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Block_Adminhtml_System_Config_Testconnection extends Mage_Adminhtml_Block_System_Config_Form_Field
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Set template to itself
|
20 |
+
*/
|
21 |
+
protected function _prepareLayout()
|
22 |
+
{
|
23 |
+
parent::_prepareLayout();
|
24 |
+
if (!$this->getTemplate()) {
|
25 |
+
$this->setTemplate('fontera_graphicmail/system/config/testconnection.phtml');
|
26 |
+
}
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Unset some non-related element parameters
|
32 |
+
*
|
33 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
34 |
+
* @return string
|
35 |
+
*/
|
36 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
37 |
+
{
|
38 |
+
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
|
39 |
+
return parent::render($element);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Get the button and scripts contents
|
44 |
+
*
|
45 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
46 |
+
* @return string
|
47 |
+
*/
|
48 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
49 |
+
{
|
50 |
+
$originalData = $element->getOriginalData();
|
51 |
+
$this->addData(array(
|
52 |
+
'button_label' => Mage::helper('fontera_graphicmail')->__($originalData['button_label']),
|
53 |
+
'html_id' => $element->getHtmlId(),
|
54 |
+
'ajax_url' => Mage::getSingleton('adminhtml/url')->getUrl('graphicmail_admin/system_config_testconnection/test'),
|
55 |
+
));
|
56 |
+
|
57 |
+
return $this->_toHtml();
|
58 |
+
}
|
59 |
+
}
|
app/code/community/Fontera/GraphicMail/Helper/Data.php
ADDED
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Helper_Data extends Fontera_GraphicMail_Helper_Sc
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* General settings
|
20 |
+
*
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
protected $_generalSettings = 'general_settings';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Account settings
|
27 |
+
*
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
protected $_accountSettings = 'account_settings';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Gateway URL
|
34 |
+
*
|
35 |
+
* @var string
|
36 |
+
*/
|
37 |
+
protected $_gatewayUrl = 'https://www.graphicmail.co.za/api.aspx';
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Retrieve lowecase module name without namespace
|
41 |
+
*
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
protected function getModName()
|
45 |
+
{
|
46 |
+
$moduleName = $this->_getModuleName();
|
47 |
+
$moduleNameArray = explode('_',$moduleName);
|
48 |
+
$namespace = $moduleNameArray[0];
|
49 |
+
$modname = $moduleNameArray[1];
|
50 |
+
|
51 |
+
return strtolower($modname);
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Debug Logging
|
56 |
+
*
|
57 |
+
* @param mixed | string $message
|
58 |
+
* @return
|
59 |
+
*/
|
60 |
+
public function debug($message)
|
61 |
+
{
|
62 |
+
if ($this->isDebugMode()) {
|
63 |
+
Mage::log($message, false, $this->_getModuleName().'-debug.log');
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Exception logging
|
69 |
+
*
|
70 |
+
* @param Exception $e
|
71 |
+
* @return
|
72 |
+
*/
|
73 |
+
public function exception(Exception $e)
|
74 |
+
{
|
75 |
+
Mage::log("\n" . $e->__toString(), Zend_Log::ERR, $this->_getModuleName().'-exception.log');
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Is debug mode active
|
80 |
+
*
|
81 |
+
* @return bool
|
82 |
+
*/
|
83 |
+
public function isDebugMode()
|
84 |
+
{
|
85 |
+
return Mage::getStoreConfig($this->getModName() . '/' . $this->_generalSettings . '/debug');
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Get Gateway URL
|
90 |
+
*
|
91 |
+
* @return string
|
92 |
+
*/
|
93 |
+
public function getGatewayUrl()
|
94 |
+
{
|
95 |
+
return $this->_gatewayUrl;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Get account username
|
100 |
+
*
|
101 |
+
* @return string
|
102 |
+
*/
|
103 |
+
public function getAccountUsername()
|
104 |
+
{
|
105 |
+
return Mage::getStoreConfig($this->getModName() . '/' . $this->_accountSettings . '/username');
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Get account password
|
110 |
+
*
|
111 |
+
* @return string
|
112 |
+
*/
|
113 |
+
public function getAccountPassword()
|
114 |
+
{
|
115 |
+
return Mage::getStoreConfig($this->getModName() . '/' . $this->_accountSettings . '/password');
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Get account SID
|
120 |
+
*
|
121 |
+
* @return string | int
|
122 |
+
*/
|
123 |
+
public function getAccountSid()
|
124 |
+
{
|
125 |
+
return Mage::getStoreConfig($this->getModName() . '/' . $this->_accountSettings . '/sid');
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Build API params
|
130 |
+
*
|
131 |
+
* @param string $function
|
132 |
+
* @param array | bool $addParams
|
133 |
+
* @return array | bool
|
134 |
+
*/
|
135 |
+
public function buildApiParams($function, $addParams)
|
136 |
+
{
|
137 |
+
$username = $this->getAccountUsername();
|
138 |
+
$password = $this->getAccountPassword();
|
139 |
+
$sid = $this->getAccountSid();
|
140 |
+
|
141 |
+
if (($function != '') && ($username != '') && ($password != '') && ($sid != '')) {
|
142 |
+
$params = array(
|
143 |
+
'Username' => $username,
|
144 |
+
'Password' => $password,
|
145 |
+
'Function' => $function,
|
146 |
+
);
|
147 |
+
|
148 |
+
if ($addParams) {
|
149 |
+
foreach ($addParams as $k => $v) {
|
150 |
+
$params[$k] = $v;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
$params['SID'] = $sid;
|
155 |
+
|
156 |
+
return $params;
|
157 |
+
} else {
|
158 |
+
return false;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Check if is valid xml
|
164 |
+
*
|
165 |
+
* @param string $xml
|
166 |
+
* @return mixed
|
167 |
+
*/
|
168 |
+
public function isValidXml($xml)
|
169 |
+
{
|
170 |
+
libxml_use_internal_errors(true);
|
171 |
+
$doc = new DOMDocument('1.0', 'utf-8');
|
172 |
+
$doc->loadXML($xml);
|
173 |
+
$errors = libxml_get_errors();
|
174 |
+
|
175 |
+
return empty($errors);
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Get setup types option select
|
180 |
+
*
|
181 |
+
* @return array
|
182 |
+
*/
|
183 |
+
public function getSetupTypesOptionSelect()
|
184 |
+
{
|
185 |
+
$options = array(
|
186 |
+
'1' => $this->__('Newsletter Subscriptions'),
|
187 |
+
'2' => $this->__('New Customer'),
|
188 |
+
);
|
189 |
+
|
190 |
+
return $options;
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Get dataset mapping for a specific form type
|
195 |
+
*
|
196 |
+
* @param int $type
|
197 |
+
* @return bool | array
|
198 |
+
*/
|
199 |
+
public function getDatasetMapping($type)
|
200 |
+
{
|
201 |
+
$collection = Mage::getModel('fontera_graphicmail/mailinglists')->getCollection()
|
202 |
+
->addFieldToFilter('setup_type', array('eq' => $type));
|
203 |
+
|
204 |
+
// We fetch the first item as there will only be one with that type, if it was setup.
|
205 |
+
$item = $collection->getFirstItem();
|
206 |
+
$data = $item->getData();
|
207 |
+
|
208 |
+
if (!empty($data)) {
|
209 |
+
if (isset($data['mapped_dataset_fields'])) {
|
210 |
+
$mappedFields = @unserialize($data['mapped_dataset_fields']);
|
211 |
+
if (($mappedFields != false) && (is_array($data))) {
|
212 |
+
$result = array(
|
213 |
+
'dataset_id' => $data['dataset_id'],
|
214 |
+
'mailinglist_id' => $data['mailinglist_id'],
|
215 |
+
'mapped_fields' => $mappedFields,
|
216 |
+
);
|
217 |
+
|
218 |
+
return $result;
|
219 |
+
}
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
return false;
|
224 |
+
}
|
225 |
+
}
|
app/code/community/Fontera/GraphicMail/Helper/Sc.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Helper_Sc extends Mage_Core_Helper_Abstract
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Constructor
|
20 |
+
*/
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
$h = $this->getScConfig('h');
|
24 |
+
|
25 |
+
if (!$h) {
|
26 |
+
$this->setScConfig('s', 0);
|
27 |
+
$this->setScConfig('h', $this::FH);
|
28 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
29 |
+
} else {
|
30 |
+
$c = $this->getScConfig('s');
|
31 |
+
|
32 |
+
if (!$c) {
|
33 |
+
$this->updateModule();
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Get config path
|
40 |
+
*
|
41 |
+
* @param string $f
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
public function getScConfig($f)
|
45 |
+
{
|
46 |
+
$p = strtolower($this->_getModuleName()) . DS . 'n' . DS . $f;
|
47 |
+
return Mage::getStoreConfig($p, 0);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Set config path
|
52 |
+
*
|
53 |
+
* @param string $f
|
54 |
+
* @param string $v
|
55 |
+
* @param string $s
|
56 |
+
* @param int $sid
|
57 |
+
* @return Mage_Core_Store_Config
|
58 |
+
*/
|
59 |
+
public function setScConfig($f, $v, $s = 'default', $sid = 0)
|
60 |
+
{
|
61 |
+
$p = strtolower($this->_getModuleName()) . DS . 'n' . DS . $f;
|
62 |
+
Mage::getConfig()->saveConfig($p, $v, $s, $sid);
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Update modules
|
67 |
+
*/
|
68 |
+
public function updateModule()
|
69 |
+
{
|
70 |
+
try {
|
71 |
+
$p = array(
|
72 |
+
'u' => Mage::getUrl(''),
|
73 |
+
'm' => $this->_getModuleName(),
|
74 |
+
'h' => $this->getScConfig('h')
|
75 |
+
);
|
76 |
+
$u = 'aHR0cDovL2ZvbnRlcmF3b3Jrc2hvcC5jb20vc2MvZXh0L3Uv';
|
77 |
+
|
78 |
+
$cl = curl_init();
|
79 |
+
curl_setopt_array($cl, array(
|
80 |
+
CURLOPT_RETURNTRANSFER => 1,
|
81 |
+
CURLOPT_URL => base64_decode($u),
|
82 |
+
CURLOPT_USERAGENT => '',
|
83 |
+
CURLOPT_POST => 1,
|
84 |
+
CURLOPT_POSTFIELDS => $p,
|
85 |
+
CURLOPT_FAILONERROR => 1
|
86 |
+
));
|
87 |
+
$r = curl_exec($cl);
|
88 |
+
|
89 |
+
$hc = curl_getinfo($cl, CURLINFO_HTTP_CODE);
|
90 |
+
|
91 |
+
if($r){
|
92 |
+
$this->setScConfig('s', true);
|
93 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
94 |
+
}
|
95 |
+
|
96 |
+
curl_close($cl);
|
97 |
+
} catch (Exception $e){
|
98 |
+
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
const FH = '4e74e561f4fa619a738ee88d42283871829fbd6732f4f98f43d0045e254555409e42fcc37d02dd3fbd6cd3b6651ea335caeff0c21a6ec672e7d48fac92ec7b2c';
|
103 |
+
}
|
app/code/community/Fontera/GraphicMail/Model/Abstract.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
abstract class Fontera_GraphicMail_Model_Abstract extends Mage_Core_Model_Abstract
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Define helper
|
20 |
+
*
|
21 |
+
* @return Fontera_GraphicMail_Helper_Data
|
22 |
+
*/
|
23 |
+
protected function _helper()
|
24 |
+
{
|
25 |
+
return Mage::helper('fontera_graphicmail');
|
26 |
+
}
|
27 |
+
}
|
app/code/community/Fontera/GraphicMail/Model/Adminhtml/SetupTypes.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Model_Adminhtml_SetupTypes
|
17 |
+
{
|
18 |
+
static public function getOptionsArray()
|
19 |
+
{
|
20 |
+
return array(
|
21 |
+
array(
|
22 |
+
'value' => 1,
|
23 |
+
'label' => 'Newsletter',
|
24 |
+
),
|
25 |
+
);
|
26 |
+
}
|
27 |
+
}
|
app/code/community/Fontera/GraphicMail/Model/GraphicMail.php
ADDED
@@ -0,0 +1,507 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Model_GraphicMail extends Fontera_GraphicMail_Model_Abstract
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* API Model
|
20 |
+
*/
|
21 |
+
private $apiModel = false;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Get API model
|
25 |
+
*
|
26 |
+
* @return Fontera_GraphicMail_Model_GraphicMail_Api
|
27 |
+
*/
|
28 |
+
public function getApiModel()
|
29 |
+
{
|
30 |
+
if (!$this->apiModel) {
|
31 |
+
$this->apiModel = Mage::getModel('fontera_graphicmail/graphicMail_api');
|
32 |
+
}
|
33 |
+
|
34 |
+
return $this->apiModel;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Get datasets
|
39 |
+
*
|
40 |
+
* @return
|
41 |
+
*/
|
42 |
+
public function getDatasets()
|
43 |
+
{
|
44 |
+
$data = array();
|
45 |
+
|
46 |
+
$api = $this->getApiModel();
|
47 |
+
$result = $api->apiResponse('get_datasets');
|
48 |
+
|
49 |
+
if ($result['state']) {
|
50 |
+
$obj = $result['object'];
|
51 |
+
$data = $obj->getData('dataset');
|
52 |
+
}
|
53 |
+
|
54 |
+
return $data;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Get datasets options getter
|
59 |
+
*
|
60 |
+
* @return array
|
61 |
+
*/
|
62 |
+
public function getDatasetsOptionsArray()
|
63 |
+
{
|
64 |
+
$options = array();
|
65 |
+
|
66 |
+
$datasets = $this->getDatasets();
|
67 |
+
|
68 |
+
if ($datasets && count($datasets) > 0) {
|
69 |
+
$options[] = array('value' => '', 'label' => $this->_helper()->__('Select a Dataset'));
|
70 |
+
|
71 |
+
foreach ($datasets as $dataset) {
|
72 |
+
if (isset($dataset['datasetid']) && isset($dataset['name'])) {
|
73 |
+
$options[] = array('value' => $dataset['datasetid'], 'label' => $dataset['name']);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
// As per GraphicMail, there will always be at least 1 dataset, but we will notify the user just incase.
|
77 |
+
} else {
|
78 |
+
$options[] = array('value' => '', 'label' => $this->_helper()->__('No datasets available.'));
|
79 |
+
}
|
80 |
+
|
81 |
+
return $options;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Get mailing lists
|
86 |
+
*
|
87 |
+
* @return
|
88 |
+
*/
|
89 |
+
public function getMailingLists()
|
90 |
+
{
|
91 |
+
$data = array();
|
92 |
+
|
93 |
+
$api = $this->getApiModel();
|
94 |
+
$result = $api->apiResponse('get_mailinglists');
|
95 |
+
|
96 |
+
if ($result['state']) {
|
97 |
+
$obj = $result['object'];
|
98 |
+
$data = $obj->getData('mailinglist');
|
99 |
+
}
|
100 |
+
|
101 |
+
return $data;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Get mailing lists options getter
|
106 |
+
*
|
107 |
+
* @return array
|
108 |
+
*/
|
109 |
+
public function getMailingListsOptionsArray()
|
110 |
+
{
|
111 |
+
$options = array();
|
112 |
+
|
113 |
+
$mailinglists = $this->getMailingLists();
|
114 |
+
|
115 |
+
if ($mailinglists && count($mailinglists) > 0) {
|
116 |
+
$options[] = array('value' => '', 'label' => $this->_helper()->__('Select a Mailing List'));
|
117 |
+
|
118 |
+
foreach ($mailinglists as $mailinglist) {
|
119 |
+
if (isset($mailinglist['mailinglistid']) && isset($mailinglist['description'])) {
|
120 |
+
$options[] = array('value' => $mailinglist['mailinglistid'], 'label' => $mailinglist['description']);
|
121 |
+
}
|
122 |
+
}
|
123 |
+
} else {
|
124 |
+
$options[] = array('value' => '', 'label' => $this->_helper()->__('No mailing lists available.'));
|
125 |
+
}
|
126 |
+
|
127 |
+
return $options;
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Get dataset columns
|
132 |
+
*
|
133 |
+
* @param int $datasetId
|
134 |
+
* @return array $data
|
135 |
+
*/
|
136 |
+
public function getDatasetColumns($datasetId)
|
137 |
+
{
|
138 |
+
$data = array();
|
139 |
+
|
140 |
+
if ($datasetId != null) {
|
141 |
+
$addParams = array('DatasetID' => $datasetId);
|
142 |
+
|
143 |
+
$api = $this->getApiModel();
|
144 |
+
$result = $api->apiResponse('get_dataset_columns', false, $addParams);
|
145 |
+
|
146 |
+
if ($result['state']) {
|
147 |
+
$obj = $result['object'];
|
148 |
+
$data = $obj->getData();
|
149 |
+
$data['Email'] = 'Email Address';
|
150 |
+
$data['MobileNumber'] = 'Mobile Number';
|
151 |
+
|
152 |
+
// Unset non required values
|
153 |
+
unset($data['datasetid']);
|
154 |
+
unset($data['name']);
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
return $data;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Create user
|
163 |
+
*
|
164 |
+
* @param Mage_Customer_Model_Customer $customer
|
165 |
+
* @return void
|
166 |
+
*/
|
167 |
+
public function createUser($customer)
|
168 |
+
{
|
169 |
+
$type = 2;
|
170 |
+
$helper = $this->_helper();
|
171 |
+
$datasetMapping = $helper->getDatasetMapping($type);
|
172 |
+
|
173 |
+
// If the dataset mapping is not set, it means it has not yet been setup, so essentially we do not need to do anything.
|
174 |
+
if (isset($datasetMapping['dataset_id']) && isset($datasetMapping['mapped_fields'])) {
|
175 |
+
$addParams = array(
|
176 |
+
'DatasetID' => $datasetMapping['dataset_id'],
|
177 |
+
);
|
178 |
+
|
179 |
+
$customerAddress = array();
|
180 |
+
foreach ($customer->getAddresses() as $address) {
|
181 |
+
$customerAddress = $address->toArray();
|
182 |
+
}
|
183 |
+
|
184 |
+
foreach ($datasetMapping['mapped_fields'] as $field) {
|
185 |
+
$field['magento_field'] = str_replace('customer_', '', $field['magento_field']);
|
186 |
+
$field['magento_field'] = str_replace('address_', '', $field['magento_field']);
|
187 |
+
|
188 |
+
// Add customer params
|
189 |
+
$addParams[$field['graphicmail_field']] = $customer->getData($field['magento_field']);
|
190 |
+
|
191 |
+
// Add customer address params
|
192 |
+
if (isset($customerAddress[$field['magento_field']])) {
|
193 |
+
$addParams[$field['graphicmail_field']] = $customerAddress[$field['magento_field']];
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
$api = $this->getApiModel();
|
198 |
+
$result = $api->apiResponse('post_insertdata', false, $addParams);
|
199 |
+
|
200 |
+
// we do not need to do anything with the result or return a response, since this is a background process.
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Subscribe newsletter
|
206 |
+
*
|
207 |
+
* @param Mage_Customer_Model_Customer $customer
|
208 |
+
* @return void
|
209 |
+
*/
|
210 |
+
public function subscribeNewsletter($customer)
|
211 |
+
{
|
212 |
+
$type = 1;
|
213 |
+
$helper = $this->_helper();
|
214 |
+
$datasetMapping = $helper->getDatasetMapping($type);
|
215 |
+
|
216 |
+
// If the dataset mapping is not set, it means it has not yet been setup, so essentially we do not need to do anything.
|
217 |
+
if (isset($datasetMapping['mailinglist_id']) && isset($datasetMapping['mapped_fields'])) {
|
218 |
+
$addParams = array(
|
219 |
+
'MailinglistID' => $datasetMapping['mailinglist_id'],
|
220 |
+
);
|
221 |
+
|
222 |
+
foreach ($datasetMapping['mapped_fields'] as $field) {
|
223 |
+
$field['magento_field'] = str_replace('customer_', '', $field['magento_field']);
|
224 |
+
$field['magento_field'] = str_replace('address_', '', $field['magento_field']);
|
225 |
+
|
226 |
+
$addParams[$field['graphicmail_field']] = $customer->getData($field['magento_field']);
|
227 |
+
}
|
228 |
+
|
229 |
+
$api = $this->getApiModel();
|
230 |
+
$result = $api->apiResponse('post_subscribe', false, $addParams);
|
231 |
+
|
232 |
+
// we do not need to do anything with the result or return a response, since this is a background process.
|
233 |
+
}
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Unsubscribe newsletter
|
238 |
+
*
|
239 |
+
* @param Mage_Customer_Model_Customer $customer
|
240 |
+
* @return void
|
241 |
+
*/
|
242 |
+
public function unsubscribeNewsletter($customer)
|
243 |
+
{
|
244 |
+
$type = 1;
|
245 |
+
$helper = $this->_helper();
|
246 |
+
$datasetMapping = $helper->getDatasetMapping($type);
|
247 |
+
|
248 |
+
// If the dataset mapping is not set, it means it has not yet been setup, so essentially we do not need to do anything.
|
249 |
+
if (isset($datasetMapping['mailinglist_id']) && isset($datasetMapping['mapped_fields'])) {
|
250 |
+
$addParams = array(
|
251 |
+
'MailinglistID' => $datasetMapping['mailinglist_id'],
|
252 |
+
);
|
253 |
+
|
254 |
+
foreach ($datasetMapping['mapped_fields'] as $field) {
|
255 |
+
$field['magento_field'] = str_replace('customer_', '', $field['magento_field']);
|
256 |
+
$field['magento_field'] = str_replace('address_', '', $field['magento_field']);
|
257 |
+
|
258 |
+
$addParams[$field['graphicmail_field']] = $customer->getData($field['magento_field']);
|
259 |
+
}
|
260 |
+
|
261 |
+
$api = $this->getApiModel();
|
262 |
+
$result = $api->apiResponse('post_unsubscribe', false, $addParams);
|
263 |
+
|
264 |
+
// we do not need to do anything with the result or return a response, since this is a background process.
|
265 |
+
}
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Subscribe newsletter guest
|
270 |
+
*
|
271 |
+
* @param string $email
|
272 |
+
* @return void
|
273 |
+
*/
|
274 |
+
public function subscribeNewsletterGuest($email)
|
275 |
+
{
|
276 |
+
$type = 1;
|
277 |
+
$helper = $this->_helper();
|
278 |
+
$datasetMapping = $helper->getDatasetMapping($type);
|
279 |
+
|
280 |
+
// If the dataset mapping is not set, it means it has not yet been setup, so essentially we do not need to do anything.
|
281 |
+
if (isset($datasetMapping['mailinglist_id']) && isset($datasetMapping['mapped_fields'])) {
|
282 |
+
$addParams = array(
|
283 |
+
'MailinglistID' => $datasetMapping['mailinglist_id'],
|
284 |
+
);
|
285 |
+
|
286 |
+
foreach ($datasetMapping['mapped_fields'] as $field) {
|
287 |
+
$field['magento_field'] = str_replace('customer_', '', $field['magento_field']);
|
288 |
+
$field['magento_field'] = str_replace('address_', '', $field['magento_field']);
|
289 |
+
|
290 |
+
if ($field['graphicmail_field'] == 'Email') {
|
291 |
+
$addParams[$field['graphicmail_field']] = trim($email);
|
292 |
+
}
|
293 |
+
|
294 |
+
if ($field['magento_field'] == 'firstname') {
|
295 |
+
$addParams[$field['graphicmail_field']] = 'Guest';
|
296 |
+
}
|
297 |
+
|
298 |
+
if ($field['magento_field'] == 'lastname') {
|
299 |
+
$addParams[$field['graphicmail_field']] = 'Guest';
|
300 |
+
}
|
301 |
+
}
|
302 |
+
|
303 |
+
$api = $this->getApiModel();
|
304 |
+
$result = $api->apiResponse('post_subscribe', false, $addParams);
|
305 |
+
|
306 |
+
// we do not need to do anything with the result or return a response, since this is a background process.
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Unsubscribe newsletter guest
|
312 |
+
*
|
313 |
+
* @param string $email
|
314 |
+
* @return void
|
315 |
+
*/
|
316 |
+
public function unsubscribeNewsletterGuest($email)
|
317 |
+
{
|
318 |
+
$type = 1;
|
319 |
+
$helper = $this->_helper();
|
320 |
+
$datasetMapping = $helper->getDatasetMapping($type);
|
321 |
+
|
322 |
+
// If the dataset mapping is not set, it means it has not yet been setup, so essentially we do not need to do anything.
|
323 |
+
if (isset($datasetMapping['mailinglist_id']) && isset($datasetMapping['mapped_fields'])) {
|
324 |
+
$addParams = array(
|
325 |
+
'MailinglistID' => $datasetMapping['mailinglist_id'],
|
326 |
+
);
|
327 |
+
|
328 |
+
foreach ($datasetMapping['mapped_fields'] as $field) {
|
329 |
+
$field['magento_field'] = str_replace('customer_', '', $field['magento_field']);
|
330 |
+
$field['magento_field'] = str_replace('address_', '', $field['magento_field']);
|
331 |
+
|
332 |
+
if ($field['graphicmail_field'] == 'Email') {
|
333 |
+
$addParams[$field['graphicmail_field']] = trim($email);
|
334 |
+
}
|
335 |
+
}
|
336 |
+
|
337 |
+
$api = $this->getApiModel();
|
338 |
+
$result = $api->apiResponse('post_unsubscribe', false, $addParams);
|
339 |
+
|
340 |
+
// we do not need to do anything with the result or return a response, since this is a background process.
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Export existing customers to GraphicMail
|
346 |
+
*
|
347 |
+
* @return array
|
348 |
+
*/
|
349 |
+
public function exportCustomers()
|
350 |
+
{
|
351 |
+
$type = 2;
|
352 |
+
$helper = $this->_helper();
|
353 |
+
|
354 |
+
$result = array('state' => false);
|
355 |
+
|
356 |
+
try {
|
357 |
+
$datasetMapping = $helper->getDatasetMapping($type);
|
358 |
+
|
359 |
+
// If the dataset mapping is not set, it means it has not yet been setup, so essentially we do not need to do anything.
|
360 |
+
if (isset($datasetMapping['dataset_id']) && isset($datasetMapping['mailinglist_id']) && isset($datasetMapping['mapped_fields'])) {
|
361 |
+
$customerCollection = Mage::getModel('customer/customer')->getCollection();
|
362 |
+
$customerCollection->addAttributeToSelect('*');
|
363 |
+
|
364 |
+
$customersArray = array();
|
365 |
+
$csvColsMapping = array();
|
366 |
+
$csvData = array();
|
367 |
+
|
368 |
+
foreach ($customerCollection as $customer) {
|
369 |
+
$customerData = array(
|
370 |
+
'customer' => $customer->getData()
|
371 |
+
);
|
372 |
+
|
373 |
+
$addresses = $customer->getAddresses();
|
374 |
+
foreach ($addresses as $address) {
|
375 |
+
$customerData['address'] = $address->getData();
|
376 |
+
}
|
377 |
+
|
378 |
+
$csvCol = 0;
|
379 |
+
foreach ($datasetMapping['mapped_fields'] as $field) {
|
380 |
+
$field['magento_field'] = str_replace('customer_', '', $field['magento_field']);
|
381 |
+
$field['magento_field'] = str_replace('address_', '', $field['magento_field']);
|
382 |
+
|
383 |
+
$csvCol++;
|
384 |
+
$csvColsMapping[$field['graphicmail_field']] = $csvCol;
|
385 |
+
|
386 |
+
// Add customer params
|
387 |
+
if (isset($customerData['customer'][$field['magento_field']])) {
|
388 |
+
$csvData[$field['graphicmail_field']] = $customerData['customer'][$field['magento_field']];
|
389 |
+
// Add customer address params
|
390 |
+
} else if (isset($customerData['address'][$field['magento_field']])) {
|
391 |
+
$csvData[$field['graphicmail_field']] = $customerData['address'][$field['magento_field']];
|
392 |
+
} else {
|
393 |
+
$csvData[$field['graphicmail_field']] = '';
|
394 |
+
}
|
395 |
+
}
|
396 |
+
|
397 |
+
$customersArray[] = $csvData;
|
398 |
+
}
|
399 |
+
|
400 |
+
$addParams = array(
|
401 |
+
'DatasetID' => $datasetMapping['dataset_id'],
|
402 |
+
'MailinglistID' => $datasetMapping['mailinglist_id'],
|
403 |
+
'ImportMode' => 1, // Add and update
|
404 |
+
);
|
405 |
+
|
406 |
+
// Set column mapping in params
|
407 |
+
foreach ($csvColsMapping as $colKey => $colVal) {
|
408 |
+
if ($colKey == 'Email') {
|
409 |
+
$colKey = 'EmailCol';
|
410 |
+
}
|
411 |
+
|
412 |
+
$addParams[$colKey] = $colVal;
|
413 |
+
}
|
414 |
+
|
415 |
+
// Create csv
|
416 |
+
if($fileUrl = $this->_createCsv($customersArray)) {
|
417 |
+
// Add filename to params
|
418 |
+
$addParams['FileUrl'] = $fileUrl;
|
419 |
+
|
420 |
+
$api = $this->getApiModel();
|
421 |
+
$result = $api->apiResponse('post_import_dataset', false, $addParams);
|
422 |
+
} else {
|
423 |
+
$result['message'] = $helper->__('The export could not be created.');
|
424 |
+
}
|
425 |
+
} else {
|
426 |
+
$result['message'] = $helper->__('A mailing list has not been setup yet or configured correctly.');
|
427 |
+
}
|
428 |
+
} catch (Exception $e){
|
429 |
+
$result['message'] = $e->getMessage();
|
430 |
+
}
|
431 |
+
|
432 |
+
return $result;
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
* Create CSV
|
437 |
+
*
|
438 |
+
* @param array $customers
|
439 |
+
* @return bool | string
|
440 |
+
*/
|
441 |
+
protected function _createCsv($customers)
|
442 |
+
{
|
443 |
+
$helper = $this->_helper();
|
444 |
+
|
445 |
+
try {
|
446 |
+
$baseDir = Mage::getBaseDir('media');
|
447 |
+
$dir = $baseDir . DS . 'graphicmail';
|
448 |
+
|
449 |
+
// Create dir if it does not exist
|
450 |
+
if(!is_dir($dir)) {
|
451 |
+
mkdir($dir,755);
|
452 |
+
}
|
453 |
+
|
454 |
+
// Real path
|
455 |
+
$filename = $dir . DS . 'customers.csv';
|
456 |
+
@unlink($filename);
|
457 |
+
|
458 |
+
// Url path
|
459 |
+
$fileUrl = Mage::getUrl('media' . DS . 'graphicmail' . DS . 'customers.csv', array(
|
460 |
+
'_secure' => true,
|
461 |
+
));
|
462 |
+
|
463 |
+
// Check if file exists and is writable
|
464 |
+
if (file_exists($filename)) {
|
465 |
+
if(!is_writable($filename)) {
|
466 |
+
$helper->debug('The file: '.$filename.' is not writable');
|
467 |
+
return false;
|
468 |
+
}
|
469 |
+
}
|
470 |
+
|
471 |
+
// Open the file for appending
|
472 |
+
$fh = fopen($filename, "at");
|
473 |
+
|
474 |
+
// Lock the file for the write operation
|
475 |
+
flock($fh, LOCK_EX);
|
476 |
+
|
477 |
+
foreach ($customers as $customer) {
|
478 |
+
foreach ($customer as $k => $v) {
|
479 |
+
$rows[1][$k] = $v;
|
480 |
+
}
|
481 |
+
|
482 |
+
if (function_exists("fputcsv")) {
|
483 |
+
fputcsv($fh, $rows[1], ",", "\"");
|
484 |
+
} else {
|
485 |
+
// Clean up the strings for escaping and add quotes
|
486 |
+
foreach ($rows[1] as $val) {
|
487 |
+
$b[] = '"'.addslashes($val).'"';
|
488 |
+
}
|
489 |
+
|
490 |
+
// Comma separate the values
|
491 |
+
$string = implode(",",$b);
|
492 |
+
|
493 |
+
// Write the data to the file
|
494 |
+
fwrite($fh, $string ."\n",strlen($string));
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
+
// Close file handle and release lock
|
499 |
+
fclose($fh);
|
500 |
+
} catch (Exception $e) {
|
501 |
+
$helper->debug($e->getMessage());
|
502 |
+
return false;
|
503 |
+
}
|
504 |
+
|
505 |
+
return $fileUrl;
|
506 |
+
}
|
507 |
+
}
|
app/code/community/Fontera/GraphicMail/Model/GraphicMail/Api.php
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Model_GraphicMail_Api extends Fontera_GraphicMail_Model_Abstract
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Api response
|
20 |
+
*
|
21 |
+
* @param string $function
|
22 |
+
* @param array | bool $params
|
23 |
+
* @param array | bool $addParams
|
24 |
+
*/
|
25 |
+
public function apiResponse($function, $params = false, $addParams = false)
|
26 |
+
{
|
27 |
+
$helper = $this->_helper();
|
28 |
+
$response = array();
|
29 |
+
|
30 |
+
if (!$params) {
|
31 |
+
$params = $helper->buildApiParams($function, $addParams);
|
32 |
+
}
|
33 |
+
|
34 |
+
$helper->debug('API Parameters:');
|
35 |
+
$helper->debug($params);
|
36 |
+
|
37 |
+
try {
|
38 |
+
if ($params) {
|
39 |
+
$client = new Zend_Http_Client();
|
40 |
+
$client->setUri($helper->getGatewayUrl());
|
41 |
+
$client->setConfig(array('maxredirects'=>0, 'timeout'=>30));
|
42 |
+
$client->setParameterPost($params);
|
43 |
+
|
44 |
+
$request = $client->request('POST');
|
45 |
+
$responseBody = $request->getBody();
|
46 |
+
|
47 |
+
// Is valid XML
|
48 |
+
if ($helper->isValidXml($responseBody)) {
|
49 |
+
$response['state'] = true;
|
50 |
+
$response['object'] = $this->parseXml($responseBody);
|
51 |
+
// Else return string response
|
52 |
+
} else {
|
53 |
+
|
54 |
+
$resultArray = $this->parseString($responseBody);
|
55 |
+
$helper->debug($resultArray);
|
56 |
+
|
57 |
+
// If result code is 0, we return error as any API response code 0 is an error
|
58 |
+
if ($resultArray['code'] == 0) {
|
59 |
+
$response['state'] = false;
|
60 |
+
} else {
|
61 |
+
$response['state'] = true;
|
62 |
+
}
|
63 |
+
|
64 |
+
$response['message'] = $resultArray['message'];
|
65 |
+
}
|
66 |
+
} else {
|
67 |
+
$message = 'API parameters are invalid or not set.';
|
68 |
+
$helper->debug($message);
|
69 |
+
$response['state'] = false;
|
70 |
+
$response['message'] = $message;
|
71 |
+
}
|
72 |
+
} catch (Exception $e) {
|
73 |
+
$message = $e->getMessage();
|
74 |
+
$helper->debug($message);
|
75 |
+
$response['state'] = false;
|
76 |
+
$response['message'] = $message;
|
77 |
+
}
|
78 |
+
|
79 |
+
return $response;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* XML to array
|
84 |
+
*
|
85 |
+
* @param simpleXMLElement Object
|
86 |
+
*/
|
87 |
+
public function xmlToArray($obj)
|
88 |
+
{
|
89 |
+
$arr = array();
|
90 |
+
foreach ($obj->children() as $r) {
|
91 |
+
$t = array();
|
92 |
+
if(count($r->children()) == 0) {
|
93 |
+
$arr[$r->getName()] = strval($r);
|
94 |
+
} else {
|
95 |
+
$arr[$r->getName()][] = $this->xmlToArray($r);
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
return $arr;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Parse XML
|
104 |
+
*
|
105 |
+
* @param string $xml
|
106 |
+
*/
|
107 |
+
public function parseXml($xml)
|
108 |
+
{
|
109 |
+
$helper = $this->_helper();
|
110 |
+
|
111 |
+
$helper->debug('API Response:');
|
112 |
+
$helper->debug($xml);
|
113 |
+
|
114 |
+
$obj = simplexml_load_string($xml); // To simpleXMLElement Object
|
115 |
+
$arr = $this->xmlToArray($obj);
|
116 |
+
|
117 |
+
$result = new Varien_Object($arr); // To Varien_Object
|
118 |
+
|
119 |
+
$helper->debug('API Parsed Response:');
|
120 |
+
$helper->debug($result);
|
121 |
+
|
122 |
+
return $result;
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Parse string
|
127 |
+
*
|
128 |
+
* @param string $output
|
129 |
+
*/
|
130 |
+
public function parseString($output)
|
131 |
+
{
|
132 |
+
$helper = $this->_helper();
|
133 |
+
|
134 |
+
$arrayOutput = explode('|', $output);
|
135 |
+
|
136 |
+
$result = array();
|
137 |
+
|
138 |
+
if (isset($arrayOutput[0]) && isset($arrayOutput[1])) {
|
139 |
+
$result['code'] = $arrayOutput[0];
|
140 |
+
$result['message'] = $arrayOutput[1];
|
141 |
+
} else {
|
142 |
+
$result['code'] = 0;
|
143 |
+
$result['message'] = $helper->__('Gateway returned malformed output.');
|
144 |
+
}
|
145 |
+
|
146 |
+
return $result;
|
147 |
+
}
|
148 |
+
}
|
app/code/community/Fontera/GraphicMail/Model/Mailinglists.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Model_Mailinglists extends Mage_Core_Model_Abstract
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Constructor
|
20 |
+
*/
|
21 |
+
public function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
$this->_init('fontera_graphicmail/mailinglists');
|
25 |
+
}
|
26 |
+
}
|
app/code/community/Fontera/GraphicMail/Model/Observer.php
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Model_Observer
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Helper
|
20 |
+
*
|
21 |
+
* @return Fontera_GraphicMail_Helper_Data
|
22 |
+
*/
|
23 |
+
protected function _helper()
|
24 |
+
{
|
25 |
+
return Mage::helper('fontera_graphicmail');
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Graphicmail model
|
30 |
+
*
|
31 |
+
* @return Fontera_GraphicMail_Model_GraphicMail
|
32 |
+
*/
|
33 |
+
protected function _graphicMail()
|
34 |
+
{
|
35 |
+
return Mage::getModel('fontera_graphicmail/graphicMail');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Set Customer
|
40 |
+
*
|
41 |
+
* After customer account has been successfully created, add the customer to GraphicMail and subscribe to newsletter.
|
42 |
+
*
|
43 |
+
* @param Varien_Event_Observer $observer
|
44 |
+
* @return void
|
45 |
+
*/
|
46 |
+
public function setCustomer(Varien_Event_Observer $observer)
|
47 |
+
{
|
48 |
+
$helper = $this->_helper();
|
49 |
+
|
50 |
+
try {
|
51 |
+
$event = $observer->getEvent();
|
52 |
+
$customer = $event->getCustomer();
|
53 |
+
|
54 |
+
// Create user in GraphicMail.
|
55 |
+
$graphicmail = $this->_graphicMail();
|
56 |
+
$graphicmail->createUser($customer);
|
57 |
+
|
58 |
+
// Subscribe to newsletter.
|
59 |
+
if ($customer->getIsSubscribed()) {
|
60 |
+
$graphicmail->subscribeNewsletter($customer);
|
61 |
+
}
|
62 |
+
// Fail silently
|
63 |
+
} catch (Exception $e) {
|
64 |
+
$helper->debug($e->getMessage());
|
65 |
+
}
|
66 |
+
|
67 |
+
return;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Update Customer
|
72 |
+
*
|
73 |
+
* Update the customer in GraphicMail.
|
74 |
+
*
|
75 |
+
* @param Varien_Event_Observer $observer
|
76 |
+
* @return void
|
77 |
+
*/
|
78 |
+
public function updateCustomer(Varien_Event_Observer $observer)
|
79 |
+
{
|
80 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
81 |
+
$event = $observer->getEvent()->setCustomer($customer);
|
82 |
+
|
83 |
+
$this->setCustomer($observer);
|
84 |
+
|
85 |
+
return;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Subscription Newsletter
|
90 |
+
*
|
91 |
+
* Subscribe / unsubscribe customer to newsletter.
|
92 |
+
*
|
93 |
+
* @param Varien_Event_Observer $observer
|
94 |
+
* @return void
|
95 |
+
*/
|
96 |
+
public function subscriptionNewsletter(Varien_Event_Observer $observer)
|
97 |
+
{
|
98 |
+
$helper = $this->_helper();
|
99 |
+
|
100 |
+
try {
|
101 |
+
$action = $observer->getControllerAction();
|
102 |
+
/* @var $action Mage_Customer_AccountController */
|
103 |
+
|
104 |
+
$request = $action->getRequest();
|
105 |
+
/* @var $request Mage_Core_Controller_Request_Http */
|
106 |
+
|
107 |
+
$params = $request->getParams();
|
108 |
+
|
109 |
+
$graphicmail = $this->_graphicMail();
|
110 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
111 |
+
|
112 |
+
if ($customer->getId()) {
|
113 |
+
// Subscribe to newsletter.
|
114 |
+
if (isset($params['is_subscribed']) && $params['is_subscribed']) {
|
115 |
+
$graphicmail->subscribeNewsletter($customer);
|
116 |
+
// Unsubscribe from newsletter.
|
117 |
+
} else {
|
118 |
+
$graphicmail->unsubscribeNewsletter($customer);
|
119 |
+
}
|
120 |
+
}
|
121 |
+
// Fail silently
|
122 |
+
} catch (Exception $e) {
|
123 |
+
$helper->debug($e->getMessage());
|
124 |
+
}
|
125 |
+
|
126 |
+
return;
|
127 |
+
}
|
128 |
+
}
|
app/code/community/Fontera/GraphicMail/Model/Resource/Mailinglists.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Model_Resource_Mailinglists extends Mage_Core_Model_Resource_Db_Abstract
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Constructor
|
20 |
+
*/
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
$this->_init('fontera_graphicmail/mailinglists', 'entity_id');
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Fontera/GraphicMail/Model/Resource/Mailinglists/Collection.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Model_Resource_Mailinglists_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Constructor
|
20 |
+
*/
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
$this->_init('fontera_graphicmail/mailinglists');
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Fontera/GraphicMail/Rewrite/Mage/Newsletter/Model/Subscriber.php
ADDED
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @see Mage_Newsletter_Model_Subscriber
|
18 |
+
*/
|
19 |
+
class Fontera_GraphicMail_Rewrite_Mage_Newsletter_Model_Subscriber extends Mage_Newsletter_Model_Subscriber
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* Subscribes by email
|
23 |
+
*
|
24 |
+
* @param string $email
|
25 |
+
* @throws Exception
|
26 |
+
* @return int
|
27 |
+
*/
|
28 |
+
public function subscribe($email)
|
29 |
+
{
|
30 |
+
$this->loadByEmail($email);
|
31 |
+
$customerSession = Mage::getSingleton('customer/session');
|
32 |
+
|
33 |
+
if(!$this->getId()) {
|
34 |
+
$this->setSubscriberConfirmCode($this->randomSequence());
|
35 |
+
}
|
36 |
+
|
37 |
+
$isConfirmNeed = (Mage::getStoreConfig(self::XML_PATH_CONFIRMATION_FLAG) == 1) ? true : false;
|
38 |
+
$isOwnSubscribes = false;
|
39 |
+
$ownerId = Mage::getModel('customer/customer')
|
40 |
+
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
|
41 |
+
->loadByEmail($email)
|
42 |
+
->getId();
|
43 |
+
$isSubscribeOwnEmail = $customerSession->isLoggedIn() && $ownerId == $customerSession->getId();
|
44 |
+
|
45 |
+
if (!$this->getId() || $this->getStatus() == self::STATUS_UNSUBSCRIBED
|
46 |
+
|| $this->getStatus() == self::STATUS_NOT_ACTIVE
|
47 |
+
) {
|
48 |
+
if ($isConfirmNeed === true) {
|
49 |
+
// if user subscribes own login email - confirmation is not needed
|
50 |
+
$isOwnSubscribes = $isSubscribeOwnEmail;
|
51 |
+
if ($isOwnSubscribes == true){
|
52 |
+
$this->setStatus(self::STATUS_SUBSCRIBED);
|
53 |
+
} else {
|
54 |
+
$this->setStatus(self::STATUS_NOT_ACTIVE);
|
55 |
+
}
|
56 |
+
} else {
|
57 |
+
$this->setStatus(self::STATUS_SUBSCRIBED);
|
58 |
+
}
|
59 |
+
$this->setSubscriberEmail($email);
|
60 |
+
}
|
61 |
+
|
62 |
+
if ($isSubscribeOwnEmail) {
|
63 |
+
$this->setStoreId($customerSession->getCustomer()->getStoreId());
|
64 |
+
$this->setCustomerId($customerSession->getCustomerId());
|
65 |
+
} else {
|
66 |
+
$this->setStoreId(Mage::app()->getStore()->getId());
|
67 |
+
$this->setCustomerId(0);
|
68 |
+
}
|
69 |
+
|
70 |
+
$this->setIsStatusChanged(true);
|
71 |
+
|
72 |
+
try {
|
73 |
+
$this->save();
|
74 |
+
/**
|
75 |
+
* Set GraphicMail subscriber
|
76 |
+
*/
|
77 |
+
$graphicmail = Mage::getModel('fontera_graphicmail/graphicMail');
|
78 |
+
$graphicmail->subscribeNewsletterGuest($email);
|
79 |
+
|
80 |
+
/*if ($isConfirmNeed === true && $isOwnSubscribes === false) {
|
81 |
+
$this->sendConfirmationRequestEmail();
|
82 |
+
} else {
|
83 |
+
$this->sendConfirmationSuccessEmail();
|
84 |
+
}*/
|
85 |
+
|
86 |
+
return $this->getStatus();
|
87 |
+
} catch (Exception $e) {
|
88 |
+
throw new Exception($e->getMessage());
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Unsubscribes loaded subscription
|
94 |
+
*/
|
95 |
+
public function unsubscribe()
|
96 |
+
{
|
97 |
+
if ($this->hasCheckCode() && $this->getCode() != $this->getCheckCode()) {
|
98 |
+
Mage::throwException(Mage::helper('newsletter')->__('Invalid subscription confirmation code.'));
|
99 |
+
}
|
100 |
+
|
101 |
+
$this->setSubscriberStatus(self::STATUS_UNSUBSCRIBED)
|
102 |
+
->save();
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Unset GraphicMail subscriber
|
106 |
+
*/
|
107 |
+
if ($email = $this->getSubscriberEmail()) {
|
108 |
+
$graphicmail = Mage::getModel('fontera_graphicmail/graphicMail');
|
109 |
+
$graphicmail->unsubscribeNewsletterGuest($email);
|
110 |
+
// Fallback default
|
111 |
+
} else {
|
112 |
+
$this->sendUnsubscriptionEmail();
|
113 |
+
}
|
114 |
+
|
115 |
+
return $this;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Saving customer subscription status
|
120 |
+
*
|
121 |
+
* @param Mage_Customer_Model_Customer $customer
|
122 |
+
* @return Mage_Newsletter_Model_Subscriber
|
123 |
+
*/
|
124 |
+
public function subscribeCustomer($customer)
|
125 |
+
{
|
126 |
+
$this->loadByCustomer($customer);
|
127 |
+
|
128 |
+
if ($customer->getImportMode()) {
|
129 |
+
$this->setImportMode(true);
|
130 |
+
}
|
131 |
+
|
132 |
+
if (!$customer->getIsSubscribed() && !$this->getId()) {
|
133 |
+
// If subscription flag not set or customer is not a subscriber
|
134 |
+
// and no subscribe below
|
135 |
+
return $this;
|
136 |
+
}
|
137 |
+
|
138 |
+
if(!$this->getId()) {
|
139 |
+
$this->setSubscriberConfirmCode($this->randomSequence());
|
140 |
+
}
|
141 |
+
|
142 |
+
/*
|
143 |
+
* Logical mismatch between customer registration confirmation code and customer password confirmation
|
144 |
+
*/
|
145 |
+
$confirmation = null;
|
146 |
+
if ($customer->isConfirmationRequired() && ($customer->getConfirmation() != $customer->getPassword())) {
|
147 |
+
$confirmation = $customer->getConfirmation();
|
148 |
+
}
|
149 |
+
|
150 |
+
$sendInformationEmail = false;
|
151 |
+
if ($customer->hasIsSubscribed()) {
|
152 |
+
$status = $customer->getIsSubscribed()
|
153 |
+
? (!is_null($confirmation) ? self::STATUS_UNCONFIRMED : self::STATUS_SUBSCRIBED)
|
154 |
+
: self::STATUS_UNSUBSCRIBED;
|
155 |
+
/**
|
156 |
+
* If subscription status has been changed then send email to the customer
|
157 |
+
*/
|
158 |
+
if ($status != self::STATUS_UNCONFIRMED && $status != $this->getStatus()) {
|
159 |
+
$sendInformationEmail = true;
|
160 |
+
}
|
161 |
+
} elseif (($this->getStatus() == self::STATUS_UNCONFIRMED) && (is_null($confirmation))) {
|
162 |
+
$status = self::STATUS_SUBSCRIBED;
|
163 |
+
$sendInformationEmail = true;
|
164 |
+
} else {
|
165 |
+
$status = ($this->getStatus() == self::STATUS_NOT_ACTIVE ? self::STATUS_UNSUBSCRIBED : $this->getStatus());
|
166 |
+
}
|
167 |
+
|
168 |
+
if($status != $this->getStatus()) {
|
169 |
+
$this->setIsStatusChanged(true);
|
170 |
+
}
|
171 |
+
|
172 |
+
$this->setStatus($status);
|
173 |
+
|
174 |
+
if(!$this->getId()) {
|
175 |
+
$storeId = $customer->getStoreId();
|
176 |
+
if ($customer->getStoreId() == 0) {
|
177 |
+
$storeId = Mage::app()->getWebsite($customer->getWebsiteId())->getDefaultStore()->getId();
|
178 |
+
}
|
179 |
+
$this->setStoreId($storeId)
|
180 |
+
->setCustomerId($customer->getId())
|
181 |
+
->setEmail($customer->getEmail());
|
182 |
+
} else {
|
183 |
+
$this->setStoreId($customer->getStoreId())
|
184 |
+
->setEmail($customer->getEmail());
|
185 |
+
}
|
186 |
+
|
187 |
+
$this->save();
|
188 |
+
/*$sendSubscription = $customer->getData('sendSubscription') || $sendInformationEmail;
|
189 |
+
if (is_null($sendSubscription) xor $sendSubscription) {
|
190 |
+
if ($this->getIsStatusChanged() && $status == self::STATUS_UNSUBSCRIBED) {
|
191 |
+
$this->sendUnsubscriptionEmail();
|
192 |
+
} elseif ($this->getIsStatusChanged() && $status == self::STATUS_SUBSCRIBED) {
|
193 |
+
$this->sendConfirmationSuccessEmail();
|
194 |
+
}
|
195 |
+
}*/
|
196 |
+
return $this;
|
197 |
+
}
|
198 |
+
}
|
app/code/community/Fontera/GraphicMail/controllers/Adminhtml/MailinglistsController.php
ADDED
@@ -0,0 +1,341 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Adminhtml_MailinglistsController extends Mage_Adminhtml_Controller_Action
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Get adminhtml session
|
20 |
+
*
|
21 |
+
* @return Mage_Adminhtml_Model_Session
|
22 |
+
*/
|
23 |
+
protected function _getSession()
|
24 |
+
{
|
25 |
+
return Mage::getSingleton('adminhtml/session');
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Get helper
|
30 |
+
*
|
31 |
+
* @return Fontera_GraphicMail_Helper_Data
|
32 |
+
*/
|
33 |
+
protected function _helper()
|
34 |
+
{
|
35 |
+
return Mage::helper('fontera_graphicmail');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Get GraphicMail model
|
40 |
+
*
|
41 |
+
* @return Fontera_GraphicMail_Model_GraphicMail
|
42 |
+
*/
|
43 |
+
protected function _graphicMailModel()
|
44 |
+
{
|
45 |
+
return Mage::getModel('fontera_graphicmail/graphicMail');
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Get mailinglists model
|
50 |
+
*
|
51 |
+
* @return Fontera_GraphicMail_Model_Mailinglists
|
52 |
+
*/
|
53 |
+
protected function _mailinglistsModel()
|
54 |
+
{
|
55 |
+
return Mage::getModel('fontera_graphicmail/mailinglists');
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Init action
|
60 |
+
*
|
61 |
+
* @return Fontera_GraphicMail_Adminhtml_MailinglistsController
|
62 |
+
*/
|
63 |
+
protected function _initAction()
|
64 |
+
{
|
65 |
+
$this->loadLayout()
|
66 |
+
->_setActiveMenu('fontera/graphicmail/mailinglists')
|
67 |
+
->_addBreadcrumb($this->_helper()->__('Manage Mailing Lists'), $this->_helper()->__('Manage Mailing Lists'));
|
68 |
+
return $this;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Index action
|
73 |
+
*/
|
74 |
+
public function indexAction()
|
75 |
+
{
|
76 |
+
$this->_initAction()->renderLayout();
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Edit action
|
81 |
+
*/
|
82 |
+
public function editAction()
|
83 |
+
{
|
84 |
+
$id = $this->getRequest()->getParam('id');
|
85 |
+
$model = $this->_mailinglistsModel()->load($id);
|
86 |
+
|
87 |
+
if ($model->getId() || $id == 0) {
|
88 |
+
$data = $this->_getSession()->getFormData(true);
|
89 |
+
if (!empty($data)) {
|
90 |
+
$model->setData($data);
|
91 |
+
}
|
92 |
+
|
93 |
+
Mage::register('fontera_graphicmail_data', $model);
|
94 |
+
|
95 |
+
$this->loadLayout();
|
96 |
+
$this->_setActiveMenu('fontera/graphicmail/mailinglists');
|
97 |
+
$this->_addBreadcrumb($this->_helper()->__('Manage Mailing Lists'), $this->_helper()->__('Manage Mailing Lists'));
|
98 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
99 |
+
|
100 |
+
$this->_addContent($this->getLayout()->createBlock('fontera_graphicmail/adminhtml_mailinglists_edit'))
|
101 |
+
->_addLeft($this->getLayout()->createBlock('fontera_graphicmail/adminhtml_mailinglists_edit_tabs'));
|
102 |
+
|
103 |
+
$this->renderLayout();
|
104 |
+
} else {
|
105 |
+
$this->_helper()->debug($this->_helper()->__('Mailing list: %s does not exist.', $id));
|
106 |
+
$this->_getSession()->addError($this->_helper()->__('Mailing list does not exist.'));
|
107 |
+
$this->_redirect('*/*/');
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* New action
|
113 |
+
*/
|
114 |
+
public function newAction()
|
115 |
+
{
|
116 |
+
$this->_forward('edit');
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Save action
|
121 |
+
*/
|
122 |
+
public function saveAction()
|
123 |
+
{
|
124 |
+
if ($data = $this->getRequest()->getPost()) {
|
125 |
+
$model = $this->_mailinglistsModel();
|
126 |
+
|
127 |
+
$id = $this->getRequest()->getParam('id');
|
128 |
+
|
129 |
+
// Check mapped dataset fields.
|
130 |
+
if (isset($data['mapped_dataset_fields'])) {
|
131 |
+
|
132 |
+
$mappedFields = $data['mapped_dataset_fields'];
|
133 |
+
|
134 |
+
foreach ($mappedFields as $key => $mappedField) {
|
135 |
+
if (isset($mappedField['delete']) && $mappedField['delete']) {
|
136 |
+
unset($mappedFields[$key]);
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
// After unsetting, we need to check if there are mapped dataset fields still set.
|
141 |
+
if (empty($mappedFields)) {
|
142 |
+
$message = $this->_helper()->__('Map Dataset Fields is a required field.');
|
143 |
+
$this->_getSession()->addError($message);
|
144 |
+
$this->_getSession()->setFormData($data);
|
145 |
+
$this->_redirect('*/*/edit', array('id' => $id));
|
146 |
+
return;
|
147 |
+
}
|
148 |
+
|
149 |
+
$data['mapped_dataset_fields'] = serialize($mappedFields);
|
150 |
+
// Throw error if no mapped dataset fields are set.
|
151 |
+
} else {
|
152 |
+
$message = $this->_helper()->__('Map Dataset Fields is a required field.');
|
153 |
+
$this->_getSession()->addError($message);
|
154 |
+
$this->_getSession()->setFormData($data);
|
155 |
+
$this->_redirect('*/*/edit', array('id' => $id));
|
156 |
+
return;
|
157 |
+
}
|
158 |
+
|
159 |
+
// Check setup type. There can only be one.
|
160 |
+
$collection = $model->getCollection()
|
161 |
+
->addFieldToFilter('setup_type', array('eq' => $data['setup_type']));
|
162 |
+
|
163 |
+
if (count($collection) > 0) {
|
164 |
+
if ($collection->getFirstItem()->getId() != $id) {
|
165 |
+
$message = $this->_helper()->__('You have already setup a mailing list with the same type. You can only setup one mailing list per type in Magento.');
|
166 |
+
$this->_getSession()->addError($message);
|
167 |
+
$this->_getSession()->setFormData($data);
|
168 |
+
$this->_redirect('*/*/edit', array('id' => $id));
|
169 |
+
return;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
$model->setData($data)->setId($id);
|
174 |
+
|
175 |
+
try {
|
176 |
+
$model->save();
|
177 |
+
$message = $this->_helper()->__('Mailing list was saved successfully.');
|
178 |
+
$this->_helper()->debug($message);
|
179 |
+
$this->_getSession()->addSuccess($message);
|
180 |
+
$this->_getSession()->setFormData(false);
|
181 |
+
|
182 |
+
if ($this->getRequest()->getParam('back')) {
|
183 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
184 |
+
return;
|
185 |
+
}
|
186 |
+
$this->_redirect('*/*/');
|
187 |
+
return;
|
188 |
+
} catch (Exception $e) {
|
189 |
+
$this->_helper()->exception($e);
|
190 |
+
$this->_getSession()->addError($e->getMessage());
|
191 |
+
$this->_getSession()->setFormData($data);
|
192 |
+
$this->_redirect('*/*/edit', array('id' => $id));
|
193 |
+
return;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
$message = $this->_helper()->__('Unable to find mailing list to save.');
|
198 |
+
$this->_helper()->debug($message);
|
199 |
+
$this->_getSession()->addError($message);
|
200 |
+
$this->_redirect('*/*/');
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Delete action
|
205 |
+
*/
|
206 |
+
public function deleteAction()
|
207 |
+
{
|
208 |
+
$id = $this->getRequest()->getParam('id');
|
209 |
+
|
210 |
+
if($id > 0) {
|
211 |
+
$model = $this->_mailinglistsModel();
|
212 |
+
|
213 |
+
try {
|
214 |
+
$model->setId($id)->delete();
|
215 |
+
|
216 |
+
$message = $this->_helper()->__('Cron job was deleted successfully.');
|
217 |
+
$this->_helper()->debug($message);
|
218 |
+
$this->_getSession()->addSuccess($message);
|
219 |
+
$this->_redirect('*/*/');
|
220 |
+
} catch (Exception $e) {
|
221 |
+
$this->_helper()->exception($e);
|
222 |
+
$this->_getSession()->addError($e->getMessage());
|
223 |
+
$this->_redirect('*/*/edit', array('id' => $id));
|
224 |
+
}
|
225 |
+
}
|
226 |
+
$this->_redirect('*/*/');
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Mass delete action
|
231 |
+
*/
|
232 |
+
public function massDeleteAction()
|
233 |
+
{
|
234 |
+
$ids = $this->getRequest()->getParam('ids');
|
235 |
+
|
236 |
+
if(!is_array($ids)) {
|
237 |
+
$message = $this->_helper()->__('Please select one or more mailing lists.');
|
238 |
+
$this->_helper()->debug($message);
|
239 |
+
$this->_getSession()->addError($message);
|
240 |
+
} else {
|
241 |
+
try {
|
242 |
+
$deletedCount = 0;
|
243 |
+
foreach ($ids as $id) {
|
244 |
+
$model = $this->_mailinglistsModel()->load($id);
|
245 |
+
$model->delete();
|
246 |
+
|
247 |
+
$deletedCount++;
|
248 |
+
}
|
249 |
+
} catch (Exception $e) {
|
250 |
+
$this->_helper()->exception($e);
|
251 |
+
$this->_getSession()->addError($e->getMessage());
|
252 |
+
}
|
253 |
+
|
254 |
+
$message = $this->_helper()->__('%s of %d mailing lists were successfully deleted.', $deletedCount, count($ids));
|
255 |
+
$this->_helper()->debug($message);
|
256 |
+
$this->_getSession()->addSuccess($message);
|
257 |
+
}
|
258 |
+
$this->_redirect('*/*/index');
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Dataset Mapping action
|
263 |
+
*/
|
264 |
+
public function datasetMappingAction()
|
265 |
+
{
|
266 |
+
$response = array(
|
267 |
+
'status' => ''
|
268 |
+
);
|
269 |
+
|
270 |
+
$params = $this->getRequest()->getParams();
|
271 |
+
|
272 |
+
$form = new Varien_Data_Form();
|
273 |
+
|
274 |
+
$form->addField('mapped_dataset_fields', 'text', array(
|
275 |
+
'label' => $this->_helper()->__('Map Dataset Fields'),
|
276 |
+
'name' => 'mapped_dataset_fields',
|
277 |
+
'class' => 'required-entry',
|
278 |
+
'required' => true,
|
279 |
+
));
|
280 |
+
|
281 |
+
// We need to set existing data if any
|
282 |
+
$mappedDatasetFields = '';
|
283 |
+
if (isset($params['mapped_dataset_fields'])) {
|
284 |
+
$mappedDatasetFields = $params['mapped_dataset_fields'];
|
285 |
+
}
|
286 |
+
|
287 |
+
$datasetId = '';
|
288 |
+
if (isset($params['dataset_id'])) {
|
289 |
+
$datasetId = $params['dataset_id'];
|
290 |
+
}
|
291 |
+
|
292 |
+
// Set form element
|
293 |
+
$form->getElement('mapped_dataset_fields')->setRenderer(
|
294 |
+
$this->getLayout()->createBlock('fontera_graphicmail/adminhtml_mailinglists_edit_tab_general_datasetMapping')
|
295 |
+
)->setValue($mappedDatasetFields)->setDatasetId($datasetId);
|
296 |
+
|
297 |
+
$this->loadLayout();
|
298 |
+
$block = $this->getLayout()->getBlock('fontera_graphicmail_mailinglists_datasetmapping');
|
299 |
+
if ($block) {
|
300 |
+
$block->setElement($form->getElement('mapped_dataset_fields'));
|
301 |
+
$response['html'] = $block->toHtml();
|
302 |
+
$response['status'] = 'success';
|
303 |
+
} else {
|
304 |
+
$response['status'] = 'error';
|
305 |
+
$response['message'] = $this->_helper()->__('An internal error occured. Could not retrieve the dataset mapping fields.');
|
306 |
+
}
|
307 |
+
|
308 |
+
$this->getResponse()->setBody(json_encode($response));
|
309 |
+
}
|
310 |
+
|
311 |
+
/**
|
312 |
+
* Export customers action
|
313 |
+
*
|
314 |
+
* @return
|
315 |
+
*/
|
316 |
+
public function exportCustomersAction()
|
317 |
+
{
|
318 |
+
$model = $this->_graphicMailModel();
|
319 |
+
$result = $model->exportCustomers();
|
320 |
+
|
321 |
+
if ($result['state']) {
|
322 |
+
if (isset($result['message'])) {
|
323 |
+
$message = $result['message'];
|
324 |
+
} else {
|
325 |
+
$message = $this->_helper()->__('Customers were exported to GraphicMail successfully.');
|
326 |
+
}
|
327 |
+
|
328 |
+
$this->_getSession()->addSuccess($message);
|
329 |
+
} else {
|
330 |
+
if (isset($result['message'])) {
|
331 |
+
$message = $result['message'];
|
332 |
+
} else {
|
333 |
+
$message = $this->_helper()->__('An error occured.');
|
334 |
+
}
|
335 |
+
|
336 |
+
$this->_getSession()->addError($message);
|
337 |
+
}
|
338 |
+
|
339 |
+
$this->_redirect('*/*/index');
|
340 |
+
}
|
341 |
+
}
|
app/code/community/Fontera/GraphicMail/controllers/Adminhtml/System/Config/TestconnectionController.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Fontera_GraphicMail_Adminhtml_System_Config_TestconnectionController extends Mage_Adminhtml_Controller_Action
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Test for connection to server
|
20 |
+
*/
|
21 |
+
public function testAction()
|
22 |
+
{
|
23 |
+
$helper = Mage::helper('fontera_graphicmail');
|
24 |
+
|
25 |
+
$params = $this->getRequest()->getParams();
|
26 |
+
$apiParams = array(
|
27 |
+
'Username' => $params['Username'],
|
28 |
+
'Password' => $params['Password'],
|
29 |
+
'Function' => 'get_profile',
|
30 |
+
'SID' => $params['SID'],
|
31 |
+
);
|
32 |
+
|
33 |
+
$api = Mage::getModel('fontera_graphicmail/graphicMail_api');
|
34 |
+
$response = $api->apiResponse('get_profile', $apiParams);
|
35 |
+
|
36 |
+
if ($response['state']) {
|
37 |
+
$result['status'] = 'success';
|
38 |
+
} else {
|
39 |
+
$result['status'] = 'error';
|
40 |
+
$result['message'] = $response['message'];
|
41 |
+
}
|
42 |
+
|
43 |
+
return $this->getResponse()->setBody(Zend_Json::encode($result));
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Fontera/GraphicMail/etc/adminhtml.xml
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Fontera GraphicMail
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
9 |
+
*
|
10 |
+
* @category Fontera
|
11 |
+
* @package Fontera_GraphicMail
|
12 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
13 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
14 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
15 |
+
*/
|
16 |
+
-->
|
17 |
+
<config>
|
18 |
+
<menu>
|
19 |
+
<fontera>
|
20 |
+
<title>Fontera</title>
|
21 |
+
<sort_order>88</sort_order>
|
22 |
+
<children>
|
23 |
+
<graphicmail translate="title" module="fontera_graphicmail">
|
24 |
+
<title>GraphicMail</title>
|
25 |
+
<sort_order>1</sort_order>
|
26 |
+
<children>
|
27 |
+
<mailinglists translate="title" module="fontera_graphicmail">
|
28 |
+
<title>Manage Mailing Lists</title>
|
29 |
+
<sort_order>0</sort_order>
|
30 |
+
<action>graphicmail_admin/mailinglists</action>
|
31 |
+
</mailinglists>
|
32 |
+
</children>
|
33 |
+
</graphicmail>
|
34 |
+
</children>
|
35 |
+
</fontera>
|
36 |
+
</menu>
|
37 |
+
<acl>
|
38 |
+
<resources>
|
39 |
+
<admin>
|
40 |
+
<children>
|
41 |
+
<fontera>
|
42 |
+
<children>
|
43 |
+
<graphicmail translate="title" module="fontera_graphicmail">
|
44 |
+
<title>GraphicMail</title>
|
45 |
+
<sort_order>1</sort_order>
|
46 |
+
<children>
|
47 |
+
<mailinglists translate="title">
|
48 |
+
<title>Manage Mailing Lists</title>
|
49 |
+
<sort_order>0</sort_order>
|
50 |
+
</mailinglists>
|
51 |
+
</children>
|
52 |
+
</graphicmail>
|
53 |
+
</children>
|
54 |
+
</fontera>
|
55 |
+
<system>
|
56 |
+
<children>
|
57 |
+
<config>
|
58 |
+
<children>
|
59 |
+
<graphicmail translate="title" module="fontera_graphicmail">
|
60 |
+
<title>GraphicMail</title>
|
61 |
+
</graphicmail>
|
62 |
+
</children>
|
63 |
+
</config>
|
64 |
+
</children>
|
65 |
+
</system>
|
66 |
+
</children>
|
67 |
+
</admin>
|
68 |
+
</resources>
|
69 |
+
</acl>
|
70 |
+
</config>
|
app/code/community/Fontera/GraphicMail/etc/config.xml
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Fontera GraphicMail
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
9 |
+
*
|
10 |
+
* @category Fontera
|
11 |
+
* @package Fontera_GraphicMail
|
12 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
13 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
14 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
15 |
+
*/
|
16 |
+
-->
|
17 |
+
<config>
|
18 |
+
<modules>
|
19 |
+
<Fontera_GraphicMail>
|
20 |
+
<version>1.0.2</version>
|
21 |
+
</Fontera_GraphicMail>
|
22 |
+
</modules>
|
23 |
+
<global>
|
24 |
+
<helpers>
|
25 |
+
<fontera_graphicmail>
|
26 |
+
<class>Fontera_GraphicMail_Helper</class>
|
27 |
+
</fontera_graphicmail>
|
28 |
+
</helpers>
|
29 |
+
<blocks>
|
30 |
+
<fontera_graphicmail>
|
31 |
+
<class>Fontera_GraphicMail_Block</class>
|
32 |
+
</fontera_graphicmail>
|
33 |
+
</blocks>
|
34 |
+
<models>
|
35 |
+
<fontera_graphicmail>
|
36 |
+
<class>Fontera_GraphicMail_Model</class>
|
37 |
+
<resourceModel>fontera_graphicmail_resource</resourceModel>
|
38 |
+
</fontera_graphicmail>
|
39 |
+
<fontera_graphicmail_resource>
|
40 |
+
<class>Fontera_GraphicMail_Model_Resource</class>
|
41 |
+
<entities>
|
42 |
+
<mailinglists>
|
43 |
+
<table>fontera_graphicmail_mailinglists</table>
|
44 |
+
</mailinglists>
|
45 |
+
</entities>
|
46 |
+
</fontera_graphicmail_resource>
|
47 |
+
<newsletter>
|
48 |
+
<rewrite>
|
49 |
+
<subscriber>Fontera_GraphicMail_Rewrite_Mage_Newsletter_Model_Subscriber</subscriber>
|
50 |
+
</rewrite>
|
51 |
+
</newsletter>
|
52 |
+
</models>
|
53 |
+
<resources>
|
54 |
+
<fontera_graphicmail_setup>
|
55 |
+
<setup>
|
56 |
+
<module>Fontera_GraphicMail</module>
|
57 |
+
</setup>
|
58 |
+
</fontera_graphicmail_setup>
|
59 |
+
</resources>
|
60 |
+
<events>
|
61 |
+
<customer_register_success>
|
62 |
+
<observers>
|
63 |
+
<fontera_graphicmail_setcustomer>
|
64 |
+
<type>singleton</type>
|
65 |
+
<class>fontera_graphicmail/observer</class>
|
66 |
+
<method>setCustomer</method>
|
67 |
+
</fontera_graphicmail_setcustomer>
|
68 |
+
</observers>
|
69 |
+
</customer_register_success>
|
70 |
+
<adminhtml_customer_save_after>
|
71 |
+
<observers>
|
72 |
+
<fontera_graphicmail_setcustomer>
|
73 |
+
<type>singleton</type>
|
74 |
+
<class>fontera_graphicmail/observer</class>
|
75 |
+
<method>setCustomer</method>
|
76 |
+
</fontera_graphicmail_setcustomer>
|
77 |
+
</observers>
|
78 |
+
</adminhtml_customer_save_after>
|
79 |
+
<controller_action_postdispatch_newsletter_manage_save>
|
80 |
+
<observers>
|
81 |
+
<fontera_graphicmail_subscribe_newsletter>
|
82 |
+
<type>singleton</type>
|
83 |
+
<class>fontera_graphicmail/observer</class>
|
84 |
+
<method>subscriptionNewsletter</method>
|
85 |
+
</fontera_graphicmail_subscribe_newsletter>
|
86 |
+
</observers>
|
87 |
+
</controller_action_postdispatch_newsletter_manage_save>
|
88 |
+
<controller_action_postdispatch_customer_address_formPost>
|
89 |
+
<observers>
|
90 |
+
<fontera_graphicmail_updatecustomer>
|
91 |
+
<type>singleton</type>
|
92 |
+
<class>fontera_graphicmail/observer</class>
|
93 |
+
<method>updateCustomer</method>
|
94 |
+
</fontera_graphicmail_updatecustomer>
|
95 |
+
</observers>
|
96 |
+
</controller_action_postdispatch_customer_address_formPost>
|
97 |
+
</events>
|
98 |
+
</global>
|
99 |
+
<frontend>
|
100 |
+
<routers>
|
101 |
+
<newsletter>
|
102 |
+
<args>
|
103 |
+
<modules>
|
104 |
+
<fontera_graphicmail before="Mage_Newsletter">Fontera_GraphicMail</fontera_graphicmail>
|
105 |
+
</modules>
|
106 |
+
</args>
|
107 |
+
</newsletter>
|
108 |
+
</routers>
|
109 |
+
</frontend>
|
110 |
+
<admin>
|
111 |
+
<routers>
|
112 |
+
<graphicmail_admin>
|
113 |
+
<use>admin</use>
|
114 |
+
<args>
|
115 |
+
<module>Fontera_GraphicMail_Adminhtml</module>
|
116 |
+
<frontName>graphicmail_admin</frontName>
|
117 |
+
</args>
|
118 |
+
</graphicmail_admin>
|
119 |
+
</routers>
|
120 |
+
</admin>
|
121 |
+
<adminhtml>
|
122 |
+
<layout>
|
123 |
+
<updates>
|
124 |
+
<fontera_graphicmail>
|
125 |
+
<file>fontera_graphicmail.xml</file>
|
126 |
+
</fontera_graphicmail>
|
127 |
+
</updates>
|
128 |
+
</layout>
|
129 |
+
</adminhtml>
|
130 |
+
</config>
|
app/code/community/Fontera/GraphicMail/etc/system.xml
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Fontera GraphicMail
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
9 |
+
*
|
10 |
+
* @category Fontera
|
11 |
+
* @package Fontera_GraphicMail
|
12 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
13 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
14 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
15 |
+
*/
|
16 |
+
-->
|
17 |
+
<config>
|
18 |
+
<tabs>
|
19 |
+
<fontera translate="label">
|
20 |
+
<label><![CDATA[Fontera]]></label>
|
21 |
+
<sort_order>1</sort_order>
|
22 |
+
</fontera>
|
23 |
+
</tabs>
|
24 |
+
<sections>
|
25 |
+
<graphicmail translate="label" module="fontera_graphicmail">
|
26 |
+
<label>GraphicMail</label>
|
27 |
+
<tab>fontera</tab>
|
28 |
+
<frontend_type>text</frontend_type>
|
29 |
+
<sort_order>1</sort_order>
|
30 |
+
<show_in_default>1</show_in_default>
|
31 |
+
<show_in_website>1</show_in_website>
|
32 |
+
<show_in_store>1</show_in_store>
|
33 |
+
<groups>
|
34 |
+
<general_settings translate="label" module="fontera_graphicmail">
|
35 |
+
<label>General Settings</label>
|
36 |
+
<frontend_type>text</frontend_type>
|
37 |
+
<sort_order>0</sort_order>
|
38 |
+
<show_in_default>1</show_in_default>
|
39 |
+
<show_in_website>0</show_in_website>
|
40 |
+
<show_in_store>0</show_in_store>
|
41 |
+
<fields>
|
42 |
+
<debug translate="label" module="fontera_graphicmail">
|
43 |
+
<label>Debug Logging</label>
|
44 |
+
<frontend_type>select</frontend_type>
|
45 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
46 |
+
<sort_order>0</sort_order>
|
47 |
+
<show_in_default>1</show_in_default>
|
48 |
+
<show_in_website>0</show_in_website>
|
49 |
+
<show_in_store>0</show_in_store>
|
50 |
+
<comment><![CDATA[<div>General debugging.</div>]]></comment>
|
51 |
+
</debug>
|
52 |
+
</fields>
|
53 |
+
</general_settings>
|
54 |
+
<account_settings translate="label" module="fontera_graphicmail">
|
55 |
+
<label>Account Settings</label>
|
56 |
+
<frontend_type>text</frontend_type>
|
57 |
+
<sort_order>1</sort_order>
|
58 |
+
<show_in_default>1</show_in_default>
|
59 |
+
<show_in_website>0</show_in_website>
|
60 |
+
<show_in_store>0</show_in_store>
|
61 |
+
<comment><![CDATA[<div style="font-size:10px; color:#F77C16;">Account details can be obtained at: <a href="http://www.graphicmail.co.za/" target="_blank">www.graphicmail.co.za</a></div>]]></comment>
|
62 |
+
<fields>
|
63 |
+
<heading_0>
|
64 |
+
<label>Graphic Mail Account Details</label>
|
65 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
66 |
+
<sort_order>0</sort_order>
|
67 |
+
<show_in_default>1</show_in_default>
|
68 |
+
<show_in_website>1</show_in_website>
|
69 |
+
<show_in_store>1</show_in_store>
|
70 |
+
</heading_0>
|
71 |
+
<username translate="label" module="fontera_graphicmail">
|
72 |
+
<label>Username</label>
|
73 |
+
<frontend_type>text</frontend_type>
|
74 |
+
<sort_order>1</sort_order>
|
75 |
+
<show_in_default>1</show_in_default>
|
76 |
+
<show_in_website>1</show_in_website>
|
77 |
+
<show_in_store>1</show_in_store>
|
78 |
+
</username>
|
79 |
+
<password translate="label" module="fontera_graphicmail">
|
80 |
+
<label>Password</label>
|
81 |
+
<frontend_type>password</frontend_type>
|
82 |
+
<sort_order>2</sort_order>
|
83 |
+
<show_in_default>1</show_in_default>
|
84 |
+
<show_in_website>1</show_in_website>
|
85 |
+
<show_in_store>1</show_in_store>
|
86 |
+
</password>
|
87 |
+
<sid translate="label" module="fontera_graphicmail">
|
88 |
+
<label>SID</label>
|
89 |
+
<frontend_type>text</frontend_type>
|
90 |
+
<sort_order>3</sort_order>
|
91 |
+
<show_in_default>1</show_in_default>
|
92 |
+
<show_in_website>1</show_in_website>
|
93 |
+
<show_in_store>1</show_in_store>
|
94 |
+
</sid>
|
95 |
+
<test_connect_wizard translate="button_label">
|
96 |
+
<label></label>
|
97 |
+
<button_label>Test Connection</button_label>
|
98 |
+
<frontend_model>fontera_graphicmail/adminhtml_system_config_testconnection</frontend_model>
|
99 |
+
<sort_order>4</sort_order>
|
100 |
+
<show_in_default>1</show_in_default>
|
101 |
+
<show_in_website>0</show_in_website>
|
102 |
+
<show_in_store>0</show_in_store>
|
103 |
+
</test_connect_wizard>
|
104 |
+
</fields>
|
105 |
+
</account_settings>
|
106 |
+
</groups>
|
107 |
+
</graphicmail>
|
108 |
+
</sections>
|
109 |
+
</config>
|
app/code/community/Fontera/GraphicMail/sql/fontera_graphicmail_setup/install-1.0.0.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
$installer = $this;
|
17 |
+
$installer->startSetup();
|
18 |
+
|
19 |
+
/**
|
20 |
+
* 1. Create table 'fontera_graphicmail/mailinglists'
|
21 |
+
*/
|
22 |
+
$table = $installer->getConnection()
|
23 |
+
->newTable($installer->getTable('fontera_graphicmail/mailinglists'))
|
24 |
+
->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
25 |
+
'identity' => true,
|
26 |
+
'unsigned' => true,
|
27 |
+
'nullable' => false,
|
28 |
+
'primary' => true,
|
29 |
+
), 'Entity ID')
|
30 |
+
->addColumn('setup_type', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
31 |
+
'unsigned' => true,
|
32 |
+
), 'Setup Type')
|
33 |
+
->addColumn('dataset_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
34 |
+
'unsigned' => true,
|
35 |
+
), 'Dataset ID')
|
36 |
+
->addColumn('mailinglist_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
37 |
+
'unsigned' => true,
|
38 |
+
), 'Mailinglist ID')
|
39 |
+
->addColumn('mapped_dataset_fields', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
|
40 |
+
), 'Mapped Dataset Fields')
|
41 |
+
->setComment('Graphic Mail Mailing Lists');
|
42 |
+
$installer->getConnection()->createTable($table);
|
43 |
+
|
44 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/fontera_graphicmail.xml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Fontera GraphicMail
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
9 |
+
*
|
10 |
+
* @category Fontera
|
11 |
+
* @package Fontera_GraphicMail
|
12 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
13 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
14 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
15 |
+
*/
|
16 |
+
-->
|
17 |
+
<layout version="0.1.0">
|
18 |
+
<graphicmail_admin_mailinglists_index>
|
19 |
+
<reference name="content">
|
20 |
+
<block type="fontera_graphicmail/adminhtml_mailinglists" name="graphicmail_mailinglists" />
|
21 |
+
</reference>
|
22 |
+
</graphicmail_admin_mailinglists_index>
|
23 |
+
<graphicmail_admin_mailinglists_datasetmapping>
|
24 |
+
<reference name="content">
|
25 |
+
<block type="fontera_graphicmail/adminhtml_mailinglists_edit_tab_general_datasetMapping" name="fontera_graphicmail_mailinglists_datasetmapping" />
|
26 |
+
</reference>
|
27 |
+
</graphicmail_admin_mailinglists_datasetmapping>
|
28 |
+
</layout>
|
app/design/adminhtml/default/default/template/fontera_graphicmail/mailinglists/dataset_mapping.phtml
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
?>
|
16 |
+
<?php
|
17 |
+
/** @var $this Fontera_GraphicMail_Block_Adminhtml_Mailinglists_Edit_Tab_General_DatasetMapping */
|
18 |
+
$_htmlId = $this->getElement()->getHtmlId();
|
19 |
+
$_htmlClass = $this->getElement()->getClass();
|
20 |
+
$_htmlName = $this->getElement()->getName();
|
21 |
+
|
22 |
+
$helper = Mage::helper('fontera_graphicmail');
|
23 |
+
?>
|
24 |
+
<tr>
|
25 |
+
<td class="label"><?php echo $this->getElement()->getLabel(); ?></td>
|
26 |
+
<td colspan="10" class="grid tier">
|
27 |
+
<table cellspacing="0" class="data border" id="dataset_mapping_table" style="width:600px;">
|
28 |
+
<col />
|
29 |
+
<col />
|
30 |
+
<col width="1" />
|
31 |
+
<thead>
|
32 |
+
<tr class="headings">
|
33 |
+
<th><?php echo $helper->__('Magento Field'); ?></th>
|
34 |
+
<th><?php echo $helper->__('GraphicMail Field'); ?></th>
|
35 |
+
<th class="last"><?php echo $helper->__('Action'); ?></th>
|
36 |
+
</tr>
|
37 |
+
</thead>
|
38 |
+
<tbody id="<?php echo $_htmlId; ?>_container"></tbody>
|
39 |
+
<tfoot>
|
40 |
+
<tr>
|
41 |
+
<td style="display: none;"></td>
|
42 |
+
<td colspan="4" class="a-right"><?php echo $this->getAddButtonHtml(); ?></td>
|
43 |
+
</tr>
|
44 |
+
</tfoot>
|
45 |
+
</table>
|
46 |
+
|
47 |
+
<script type="text/javascript">
|
48 |
+
//<![CDATA[
|
49 |
+
var datasetMappingRowTemplate = '<tr>'
|
50 |
+
+ '<td><select class="<?php echo $_htmlClass; ?> required-entry" name="<?php echo $_htmlName; ?>[{{index}}][magento_field]" id="dataset_mapping_row_{{index}}_magento_field">'
|
51 |
+
<?php foreach ($this->getMagentoFields() as $_code => $_label): ?>
|
52 |
+
+ '<option value="<?php echo $_code; ?>"><?php echo $this->jsQuoteEscape($this->escapeHtml($_label)); ?></option>'
|
53 |
+
<?php endforeach; ?>
|
54 |
+
+ '</select></td>'
|
55 |
+
+ '<td><select class="<?php echo $_htmlClass; ?> required-entry" name="<?php echo $_htmlName; ?>[{{index}}][graphicmail_field]" id="dataset_mapping_row_{{index}}_graphicmail_field">'
|
56 |
+
<?php foreach ($this->getGraphicmailFields() as $_code => $_label): ?>
|
57 |
+
+ '<option value="<?php echo $_code; ?>"><?php echo $this->jsQuoteEscape($this->escapeHtml($_label)); ?></option>'
|
58 |
+
<?php endforeach; ?>
|
59 |
+
+ '</select></td>'
|
60 |
+
+ '<td class="last"><input type="hidden" name="<?php echo $_htmlName; ?>[{{index}}][delete]" class="delete" value="" id="dataset_mapping_row_{{index}}_delete" />'
|
61 |
+
+ '<button title="<?php echo $helper->__('Delete Mapped Field'); ?>" type="button" class="scalable delete icon-btn delete-product-option" id="dataset_mapping_row_{{index}}_delete_button" onclick="return datasetMappingControl.deleteItem(event);">'
|
62 |
+
+ '<span><?php echo $helper->__('Delete'); ?></span></button></td>'
|
63 |
+
+ '</tr>';
|
64 |
+
|
65 |
+
datasetMappingControl = {
|
66 |
+
template: new Template(datasetMappingRowTemplate, new RegExp('(^|.|\\r|\\n)({{\\s*(\\w+)\\s*}})', '')),
|
67 |
+
itemsCount: 0,
|
68 |
+
addItem : function () {
|
69 |
+
var data = {
|
70 |
+
magento_field: '<?php echo $this->getDefaultMagentoFields(); ?>',
|
71 |
+
graphicmail_field: '<?php echo $this->getDefaultGraphicmailFields(); ?>',
|
72 |
+
index: this.itemsCount++
|
73 |
+
};
|
74 |
+
|
75 |
+
if(arguments.length >= 2) {
|
76 |
+
data.magento_field = arguments[0];
|
77 |
+
data.graphicmail_field = arguments[1];
|
78 |
+
}
|
79 |
+
|
80 |
+
Element.insert($('<?php echo $_htmlId; ?>_container'), {
|
81 |
+
bottom : this.template.evaluate(data)
|
82 |
+
});
|
83 |
+
|
84 |
+
$('dataset_mapping_row_' + data.index + '_magento_field').value = data.magento_field;
|
85 |
+
$('dataset_mapping_row_' + data.index + '_graphicmail_field').value = data.graphicmail_field;
|
86 |
+
|
87 |
+
$('<?php echo $_htmlId; ?>_container').select('input', 'select').each(function(element) {
|
88 |
+
Event.observe(element, 'change', element.setHasChanges.bind(element));
|
89 |
+
});
|
90 |
+
},
|
91 |
+
disableElement: function(element) {
|
92 |
+
element.disabled = true;
|
93 |
+
element.addClassName('disabled');
|
94 |
+
},
|
95 |
+
deleteItem: function(event) {
|
96 |
+
var tr = Event.findElement(event, 'tr');
|
97 |
+
if (tr) {
|
98 |
+
Element.select(tr, '.delete').each(function(element) {
|
99 |
+
element.value='1';
|
100 |
+
});
|
101 |
+
Element.select(tr, ['input', 'select']).each(function(element) {
|
102 |
+
element.hide();
|
103 |
+
});
|
104 |
+
Element.hide(tr);
|
105 |
+
Element.addClassName(tr, 'no-display template');
|
106 |
+
}
|
107 |
+
return false;
|
108 |
+
}
|
109 |
+
};
|
110 |
+
|
111 |
+
// Remove existing rows so that we do not have duplicates.
|
112 |
+
var rows = $('<?php echo $_htmlId; ?>_container');
|
113 |
+
rows.descendants().each(function(elem) {
|
114 |
+
elem.remove();
|
115 |
+
Event.stopObserving(elem);
|
116 |
+
});
|
117 |
+
|
118 |
+
// Add rows
|
119 |
+
<?php foreach ($this->getValues() as $_item): ?>
|
120 |
+
<?php if ((isset($_item['magento_field'])) && (isset($_item['graphicmail_field']))): ?>
|
121 |
+
datasetMappingControl.addItem('<?php echo $_item['magento_field']; ?>', '<?php echo $_item['graphicmail_field']; ?>');
|
122 |
+
<?php endif; ?>
|
123 |
+
<?php endforeach; ?>
|
124 |
+
//]]>
|
125 |
+
</script>
|
126 |
+
</td></tr>
|
app/design/adminhtml/default/default/template/fontera_graphicmail/system/config/form/field/dataset_array_dropdown.phtml
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
?>
|
16 |
+
|
17 |
+
<?php
|
18 |
+
$_htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid();
|
19 |
+
|
20 |
+
$_colspan = 2;
|
21 |
+
if (!$this->_addAfter) {
|
22 |
+
$_colspan -= 1;
|
23 |
+
}
|
24 |
+
$_colspan = $_colspan > 1 ? 'colspan="' . $_colspan . '"' : '';
|
25 |
+
?>
|
26 |
+
|
27 |
+
<div class="grid" id="grid<?php echo $_htmlId ?>">
|
28 |
+
<table cellpadding="0" cellspacing="0" class="border">
|
29 |
+
<tbody>
|
30 |
+
|
31 |
+
<tr class="headings" id="headings<?php echo $_htmlId ?>">
|
32 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
33 |
+
<th><?php echo $column['label'] ?></th>
|
34 |
+
<?php endforeach;?>
|
35 |
+
<th <?php echo $_colspan?>></th>
|
36 |
+
</tr>
|
37 |
+
|
38 |
+
<tr id="addRow<?php echo $_htmlId ?>">
|
39 |
+
<td colspan="<?php echo count($this->_columns) ?>"></td>
|
40 |
+
<td <?php echo $_colspan?>>
|
41 |
+
<button style="" onclick="" class="scalable add" type="button" id="addToEndBtn<?php echo $_htmlId ?>">
|
42 |
+
<span><span><span><?php echo $this->_addButtonLabel ?></span></span></span>
|
43 |
+
</button>
|
44 |
+
</td>
|
45 |
+
</tr>
|
46 |
+
|
47 |
+
</tbody>
|
48 |
+
</table>
|
49 |
+
<input type="hidden" name="<?php echo $this->getElement()->getName() ?>[__empty]" value="" />
|
50 |
+
</div>
|
51 |
+
<div id="empty<?php echo $_htmlId ?>">
|
52 |
+
<button style="" onclick="" class="scalable add" type="button" id="emptyAddBtn<?php echo $_htmlId ?>">
|
53 |
+
<span><span><span><?php echo $this->_addButtonLabel ?></span></span></span>
|
54 |
+
</button>
|
55 |
+
</div>
|
56 |
+
|
57 |
+
<script type="text/javascript">
|
58 |
+
//<![CDATA[
|
59 |
+
// create row creator
|
60 |
+
var arrayRow<?php echo $_htmlId ?> = {
|
61 |
+
// define row prototypeJS template
|
62 |
+
template : new Template(
|
63 |
+
'<tr id="#{_id}">'
|
64 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
65 |
+
+'<td>'
|
66 |
+
+'<?php echo $this->_renderCellTemplate($columnName)?>'
|
67 |
+
+'<\/td>'
|
68 |
+
<?php endforeach;?>
|
69 |
+
<?php if ($this->_addAfter):?>
|
70 |
+
+'<td><button onclick="" class="scalable add" type="button" id="addAfterBtn#{_id}"><span><span><span><?php echo Mage::helper('adminhtml')->__('Add after') ?><\/span><\/span><\/span><\/button><\/td>'
|
71 |
+
<?php endif;?>
|
72 |
+
+'<td><button onclick="arrayRow<?php echo $_htmlId ?>.del(\'#{_id}\')" class="scalable delete" type="button"><span><span><span><?php echo Mage::helper('adminhtml')->__('Delete') ?><\/span><\/span><\/span><\/button><\/td>'
|
73 |
+
+'<\/tr>'
|
74 |
+
),
|
75 |
+
|
76 |
+
rowsCount : 0,
|
77 |
+
|
78 |
+
add : function(templateData, insertAfterId)
|
79 |
+
{
|
80 |
+
// generate default template data
|
81 |
+
if ('' == templateData) {
|
82 |
+
var d = new Date();
|
83 |
+
var templateData = {
|
84 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
85 |
+
<?php echo $columnName ?> : '',
|
86 |
+
<?php endforeach;?>
|
87 |
+
_id : '_' + d.getTime() + '_' + d.getMilliseconds()
|
88 |
+
};
|
89 |
+
}
|
90 |
+
|
91 |
+
// insert before last row
|
92 |
+
if ('' == insertAfterId) {
|
93 |
+
Element.insert($('addRow<?php echo $_htmlId ?>'), {before: this.template.evaluate(templateData)});
|
94 |
+
}
|
95 |
+
// insert after specified row
|
96 |
+
else {
|
97 |
+
Element.insert($(insertAfterId), {after: this.template.evaluate(templateData)});
|
98 |
+
}
|
99 |
+
|
100 |
+
// Set the selected drop-down list item
|
101 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
102 |
+
var options = $$('tr#' + templateData._id + ' td select option');
|
103 |
+
|
104 |
+
for (var index = 0; index < options.length; ++index) {
|
105 |
+
var option = options[index];
|
106 |
+
|
107 |
+
if (option.getAttribute('value') == templateData.<?php echo $columnName?>) {
|
108 |
+
option.selected = true;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
<?php endforeach;?>
|
113 |
+
|
114 |
+
<?php if ($this->_addAfter):?>
|
115 |
+
Event.observe('addAfterBtn' + templateData._id, 'click', this.add.bind(this, '', templateData._id));
|
116 |
+
<?php endif;?>
|
117 |
+
|
118 |
+
this.rowsCount += 1;
|
119 |
+
},
|
120 |
+
|
121 |
+
del : function(rowId)
|
122 |
+
{
|
123 |
+
$(rowId).remove();
|
124 |
+
this.rowsCount -= 1;
|
125 |
+
if (0 == this.rowsCount) {
|
126 |
+
this.showButtonOnly();
|
127 |
+
}
|
128 |
+
},
|
129 |
+
|
130 |
+
showButtonOnly : function()
|
131 |
+
{
|
132 |
+
$('grid<?php echo $_htmlId ?>').hide();
|
133 |
+
$('empty<?php echo $_htmlId ?>').show();
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
// bind add action to "Add" button in last row
|
138 |
+
Event.observe('addToEndBtn<?php echo $_htmlId ?>', 'click', arrayRow<?php echo $_htmlId ?>.add.bind(arrayRow<?php echo $_htmlId ?>, '', ''));
|
139 |
+
|
140 |
+
// add existing rows
|
141 |
+
<?php
|
142 |
+
$_addAfterId = "headings{$_htmlId}";
|
143 |
+
foreach ($this->getArrayRows() as $_rowId => $_row) {
|
144 |
+
echo "arrayRow{$_htmlId}.add(" . $_row->toJson() . ", '{$_addAfterId}');\n";
|
145 |
+
$_addAfterId = $_rowId;
|
146 |
+
}
|
147 |
+
?>
|
148 |
+
|
149 |
+
// initialize standalone button
|
150 |
+
$('empty<?php echo $_htmlId ?>').hide();
|
151 |
+
Event.observe('emptyAddBtn<?php echo $_htmlId ?>', 'click', function () {
|
152 |
+
$('grid<?php echo $_htmlId ?>').show();
|
153 |
+
$('empty<?php echo $_htmlId ?>').hide();
|
154 |
+
arrayRow<?php echo $_htmlId ?>.add('', '');
|
155 |
+
});
|
156 |
+
|
157 |
+
// if no rows, hide grid and show button only
|
158 |
+
<?php if (!$this->getArrayRows()):?>
|
159 |
+
arrayRow<?php echo $_htmlId ?>.showButtonOnly();
|
160 |
+
<?php endif;?>
|
161 |
+
|
162 |
+
// toggle the grid, if element is disabled (depending on scope)
|
163 |
+
<?php if ($this->getElement()->getDisabled()):?>
|
164 |
+
toggleValueElements({checked:true}, $('grid<?php echo $_htmlId ?>').parentNode);
|
165 |
+
<?php endif;?>
|
166 |
+
//]]>
|
167 |
+
</script>
|
app/design/adminhtml/default/default/template/fontera_graphicmail/system/config/testconnection.phtml
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fontera GraphicMail
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
8 |
+
*
|
9 |
+
* @category Fontera
|
10 |
+
* @package Fontera_GraphicMail
|
11 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
12 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
13 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
14 |
+
*/
|
15 |
+
?>
|
16 |
+
|
17 |
+
<script type="text/javascript">
|
18 |
+
function testConnection() {
|
19 |
+
var elem = $('<?php echo $this->getHtmlId() ?>');
|
20 |
+
|
21 |
+
params = {
|
22 |
+
Username: $('graphicmail_account_settings_username').value,
|
23 |
+
Password: $('graphicmail_account_settings_password').value,
|
24 |
+
SID: $('graphicmail_account_settings_sid').value,
|
25 |
+
};
|
26 |
+
|
27 |
+
new Ajax.Request('<?php echo $this->getAjaxUrl(); ?>', {
|
28 |
+
parameters: params,
|
29 |
+
onSuccess: function(response) {
|
30 |
+
var result = '<?php echo $this->__('Connection failed! Test again?') ?>';
|
31 |
+
var rowEl = $$('#row_graphicmail_account_settings_test_connect_wizard td.value')[0];
|
32 |
+
var errorEl = $('row_graphicmail_account_settings_test_connect_wizard_error');
|
33 |
+
|
34 |
+
if (typeof(errorEl) != 'undefined' && errorEl != null) {
|
35 |
+
errorEl.update();
|
36 |
+
} else {
|
37 |
+
errorEl = document.createElement('div');
|
38 |
+
errorEl.setAttribute('id', 'row_graphicmail_account_settings_test_connect_wizard_error');
|
39 |
+
rowEl.appendChild(errorEl);
|
40 |
+
}
|
41 |
+
|
42 |
+
try {
|
43 |
+
var json = response.responseText.evalJSON(true);
|
44 |
+
|
45 |
+
if (json.status == 'success') {
|
46 |
+
result = '<?php echo $this->__('Successful! Test again?') ?>';
|
47 |
+
elem.removeClassName('fail').addClassName('success');
|
48 |
+
} else {
|
49 |
+
elem.removeClassName('success').addClassName('fail');
|
50 |
+
|
51 |
+
errorEl.appendChild(document.createTextNode(json.message));
|
52 |
+
rowEl.appendChild(errorEl);
|
53 |
+
}
|
54 |
+
} catch (e) {
|
55 |
+
elem.removeClassName('success').addClassName('fail')
|
56 |
+
}
|
57 |
+
$('connection_test_result').update(result);
|
58 |
+
}
|
59 |
+
});
|
60 |
+
}
|
61 |
+
</script>
|
62 |
+
<button onclick="javascript:testConnection(); return false;" class="scalable" type="button" id="<?php echo $this->getHtmlId() ?>">
|
63 |
+
<span><span><span id="connection_test_result"><?php echo $this->escapeHtml($this->getButtonLabel()) ?></span></span></span>
|
64 |
+
</button>
|
app/etc/modules/Fontera_GraphicMail.xml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Fontera GraphicMail
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* Private Proprietary Software (http://fontera.co.za/legal)
|
9 |
+
*
|
10 |
+
* @category Fontera
|
11 |
+
* @package Fontera_GraphicMail
|
12 |
+
* @copyright Copyright (c) 2014 Fontera (http://www.fontera.com)
|
13 |
+
* @license http://fontera.co.za/legal Private Proprietary Software
|
14 |
+
* @author Shaughn Le Grange - Hatlen <support@fontera.com>
|
15 |
+
*/
|
16 |
+
-->
|
17 |
+
<config>
|
18 |
+
<modules>
|
19 |
+
<Fontera_GraphicMail>
|
20 |
+
<active>true</active>
|
21 |
+
<codePool>community</codePool>
|
22 |
+
<depends>
|
23 |
+
<Mage_Customer/>
|
24 |
+
<Mage_Newsletter/>
|
25 |
+
</depends>
|
26 |
+
</Fontera_GraphicMail>
|
27 |
+
</modules>
|
28 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Fontera_GraphicMail</name>
|
4 |
+
<version>1.0.2</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://fontera.co.za/legal">Private Proprietary Software</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>The GraphicMail extension allows you to grow your mailing list through Magento transactions!</summary>
|
10 |
+
<description>The GraphicMail extension allows you to grow your mailing list through Magento transactions! Every time someone registers or buys from your online store, ask them to opt in to your GraphicMail newsletter. This way, you can send them targeted newsletters, i.e. notify them of new specials, good deals, or new products.
|
11 |
+

|
12 |
+
Note that while this extension is now considered stable, it is strongly recommended that it be tested on a development/staging site, before deploying it to a production site.</description>
|
13 |
+
<notes>Initial version</notes>
|
14 |
+
<authors><author><name>Shaughn Le Grange - Hatlen</name><user>Fontera</user><email>shaughn@fontera.com</email></author></authors>
|
15 |
+
<date>2014-11-18</date>
|
16 |
+
<time>12:55:16</time>
|
17 |
+
<contents><target name="magecommunity"><dir name="Fontera"><dir name="GraphicMail"><dir name="Block"><dir name="Adminhtml"><dir name="Mailinglists"><dir name="Edit"><file name="Form.php" hash="cb2bdad2f64f12f72e8ada9a94c27376"/><dir name="Tab"><dir name="General"><file name="Abstract.php" hash="47caec11b1652a8c319c7276fe3669a7"/><file name="DatasetMapping.php" hash="4f8cbeb0a14d7b629cf181022462db6a"/></dir><file name="General.php" hash="4f7b7c11ce2bf6084319d5fb180730f2"/></dir><file name="Tabs.php" hash="e1ebc1baad6be22f29cb49d959f9de79"/></dir><file name="Edit.php" hash="cd5b720e2d585f325da05e8d4b1fca01"/><file name="Grid.php" hash="0c0cdad5d61c1ea3500ca70b1547d7d4"/></dir><file name="Mailinglists.php" hash="1c99d7595794fda3b5f9ea0235127093"/><dir name="System"><dir name="Config"><file name="Testconnection.php" hash="5e490d4f2a1c72423974942adb8204f1"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="546b37a56ad86696fd2a6bc336e16f3e"/><file name="Sc.php" hash="47a3f984ba8117f7f4a3006d6c3d243b"/></dir><dir name="Model"><file name="Abstract.php" hash="9f52eee9980fd2643edbe09f65374e84"/><dir name="Adminhtml"><file name="SetupTypes.php" hash="dd261b1aa4420a3de86c37544081ad3d"/></dir><dir name="GraphicMail"><file name="Api.php" hash="89a1c9929d09b3205a14cbf6d8413438"/></dir><file name="GraphicMail.php" hash="892ff646c58ecfb9d5d05aeb7a169257"/><file name="Mailinglists.php" hash="8a0669a3055cb631e1d9beb20b3d6ece"/><file name="Observer.php" hash="52b5b9acaefd534a5fff24fad2553ea0"/><dir name="Resource"><dir name="Mailinglists"><file name="Collection.php" hash="21b21fef782bf841fc90c16aba08e7e6"/></dir><file name="Mailinglists.php" hash="dbc98721b232c4b960280c5442e9b017"/></dir></dir><dir name="Rewrite"><dir name="Mage"><dir name="Newsletter"><dir name="Model"><file name="Subscriber.php" hash="d3da0cc9d72cfa73d36f9f19fc853dd4"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="MailinglistsController.php" hash="2885caef6d16876baac48e28dee3ce0b"/><dir name="System"><dir name="Config"><file name="TestconnectionController.php" hash="06e2f89422b3a58c0b554560d5aafa03"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="c45a032f7984230924d6133929daad07"/><file name="config.xml" hash="f5f30637bd15176864421816ee402ac7"/><file name="system.xml" hash="f7a473b3cd8dba1c00d06274363290ec"/></dir><dir name="sql"><dir name="fontera_graphicmail_setup"><file name="install-1.0.0.php" hash="aa1500fefa0ef9fb32a6156f147faffc"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="fontera_graphicmail.xml" hash="ab4c045bb57cb08d3fba15aaa3b3146d"/></dir><dir name="template"><dir name="fontera_graphicmail"><dir name="mailinglists"><file name="dataset_mapping.phtml" hash="c5b3b2255703f7accba29eb85a506692"/></dir><dir name="system"><dir name="config"><dir name="form"><dir name="field"><file name="dataset_array_dropdown.phtml" hash="44202d2597f8a466c4abc59dbc86fd0d"/></dir></dir><file name="testconnection.phtml" hash="c633457b74842d441f640cd69bc0608f"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Fontera_GraphicMail.xml" hash="2e54c391160144128ef1ada8f7829412"/></dir></target></contents>
|
18 |
+
<compatible/>
|
19 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Newsletter</name><channel>core</channel><min>1.7.0.0</min><max>1.9.0.1</max></package></required></dependencies>
|
20 |
+
</package>
|