INinbox_Emailmarketing - Version 1.2.0

Version Notes

First Preview Release

Download this release

Release Info

Developer INinbox.com
Extension INinbox_Emailmarketing
Version 1.2.0
Comparing to
See all releases


Version 1.2.0

Files changed (26) hide show
  1. app/code/local/Ininbox/Emailmarketing/Block/Adminhtml/Customer/Grid.php +32 -0
  2. app/code/local/Ininbox/Emailmarketing/Block/Adminhtml/Menu.php +24 -0
  3. app/code/local/Ininbox/Emailmarketing/Block/Adminhtml/Newsletter/Subscriber/Grid.php +32 -0
  4. app/code/local/Ininbox/Emailmarketing/Block/Adminhtml/Sales/Order/Grid.php +32 -0
  5. app/code/local/Ininbox/Emailmarketing/Block/Field.php +103 -0
  6. app/code/local/Ininbox/Emailmarketing/Block/Select.php +14 -0
  7. app/code/local/Ininbox/Emailmarketing/Helper/Data.php +33 -0
  8. app/code/local/Ininbox/Emailmarketing/Model/Ininbox/Base.php +84 -0
  9. app/code/local/Ininbox/Emailmarketing/Model/Ininbox/Contact.php +35 -0
  10. app/code/local/Ininbox/Emailmarketing/Model/Ininbox/Customfield.php +23 -0
  11. app/code/local/Ininbox/Emailmarketing/Model/Ininbox/Group.php +23 -0
  12. app/code/local/Ininbox/Emailmarketing/Model/Observer.php +352 -0
  13. app/code/local/Ininbox/Emailmarketing/Model/System/Config/Source/Customer/Attribute.php +42 -0
  14. app/code/local/Ininbox/Emailmarketing/Model/System/Config/Source/Field/List.php +60 -0
  15. app/code/local/Ininbox/Emailmarketing/Model/System/Config/Source/Group/List.php +32 -0
  16. app/code/local/Ininbox/Emailmarketing/controllers/AccountController.php +109 -0
  17. app/code/local/Ininbox/Emailmarketing/controllers/Adminhtml/CustomerController.php +45 -0
  18. app/code/local/Ininbox/Emailmarketing/controllers/Adminhtml/MassactionController.php +132 -0
  19. app/code/local/Ininbox/Emailmarketing/controllers/ManageController.php +38 -0
  20. app/code/local/Ininbox/Emailmarketing/controllers/SubscriberController.php +59 -0
  21. app/code/local/Ininbox/Emailmarketing/etc/config.xml +208 -0
  22. app/code/local/Ininbox/Emailmarketing/etc/system.xml +404 -0
  23. app/code/local/Ininbox/Emailmarketing/sql/emailmarketing_setup/mysql4-install-0.1.0.php +38 -0
  24. app/etc/modules/Ininbox_Emailmarketing.xml +9 -0
  25. package.xml +27 -0
  26. skin/adminhtml/default/default/images/ininbox/ininbox.png +0 -0
app/code/local/Ininbox/Emailmarketing/Block/Adminhtml/Customer/Grid.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Block_Adminhtml_Customer_Grid extends Mage_Adminhtml_Block_Customer_Grid
8
+ {
9
+ protected function _prepareMassaction()
10
+ {
11
+ parent::_prepareMassaction();
12
+
13
+ // Check weather extension is enabled or not.
14
+ if(Mage::helper('emailmarketing')->isEnabled())
15
+ {
16
+ // Check weather feature is enabled or not and get the INinbox list id for edit.
17
+ $isIninboxSendCustomerEnabled = Mage::helper('emailmarketing')->getConfig($group = 'customer_settings', $field = 'send_customer');
18
+ $ininboxCustomerGroupList = Mage::helper('emailmarketing')->getConfig($group = 'customer_settings', $field = 'customer_group_list');
19
+
20
+ if($isIninboxSendCustomerEnabled && !is_null($ininboxCustomerGroupList))
21
+ {
22
+ $this->getMassactionBlock()->addItem(
23
+ 'emailmarketing',
24
+ array('label' => $this->__('Add to INinbox List'),
25
+ 'url' => $this->getUrl('emailmarketing/adminhtml_massaction/customer')
26
+ )
27
+ );
28
+ }
29
+ }
30
+ }
31
+ }
32
+ ?>
app/code/local/Ininbox/Emailmarketing/Block/Adminhtml/Menu.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Block_Adminhtml_Menu extends Mage_Adminhtml_Block_Page_Menu
8
+ {
9
+ protected $_ininboxUrl = "https://www.ininbox.com/login.html";
10
+
11
+ protected $_inspiredSupportUrl = "http://www.ininbox.com/support";
12
+
13
+ public function getMenuArray()
14
+ {
15
+ //Load standard menu
16
+ $parentArr = parent::getMenuArray();
17
+
18
+ $parentArr['ininbox']['children']['ininboxlogin']['click'] = "window.open('" . $this->_ininboxUrl . "', '_blank')";
19
+ $parentArr['ininbox']['children']['inspiredsupport']['click'] = "window.open('" . $this->_inspiredSupportUrl . "', '_blank')";
20
+
21
+ return $parentArr;
22
+ }
23
+ }
24
+ ?>
app/code/local/Ininbox/Emailmarketing/Block/Adminhtml/Newsletter/Subscriber/Grid.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Block_Adminhtml_Newsletter_Subscriber_Grid extends Mage_Adminhtml_Block_Newsletter_Subscriber_Grid
8
+ {
9
+ protected function _prepareMassaction()
10
+ {
11
+ parent::_prepareMassaction();
12
+
13
+ // Checkout extension is enabled or not.
14
+ if(Mage::helper('emailmarketing')->isEnabled())
15
+ {
16
+ // Check weather feature is enabled or not and get the INinbox list id for edit.
17
+ $isIninboxSendSubscriberEnabled = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_settings', $field = 'send_subscriber');
18
+ $ininboxSubscriberGroupList = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_settings', $field = 'subscriber_group_list');
19
+
20
+ if($isIninboxSendSubscriberEnabled && !is_null($ininboxSubscriberGroupList))
21
+ {
22
+ $this->getMassactionBlock()->addItem(
23
+ 'emailmarketing',
24
+ array('label' => $this->__('Add to INinbox List'),
25
+ 'url' => $this->getUrl('emailmarketing/adminhtml_massaction/newsletter') //this should be the url where there will be mass operation
26
+ )
27
+ );
28
+ }
29
+ }
30
+ }
31
+ }
32
+ ?>
app/code/local/Ininbox/Emailmarketing/Block/Adminhtml/Sales/Order/Grid.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
8
+ {
9
+ protected function _prepareMassaction()
10
+ {
11
+ parent::_prepareMassaction();
12
+
13
+ // Checkout extension is enabled or not.
14
+ if(Mage::helper('emailmarketing')->isEnabled())
15
+ {
16
+ // Check weather feature is enabled or not and get the INinbox list id for edit.
17
+ $isIninboxSendOrderEnabled = Mage::helper('emailmarketing')->getConfig($group = 'order_settings', $field = 'send_order');
18
+ $ininboxOrderGroupList = Mage::helper('emailmarketing')->getConfig($group = 'order_settings', $field = 'order_group_list');
19
+
20
+ if($isIninboxSendOrderEnabled && !is_null($ininboxOrderGroupList))
21
+ {
22
+ $this->getMassactionBlock()->addItem(
23
+ 'emailmarketing',
24
+ array('label' => $this->__('Add to INinbox List'),
25
+ 'url' => $this->getUrl('emailmarketing/adminhtml_massaction/salesorder') //this should be the url where there will be mass operation
26
+ )
27
+ );
28
+ }
29
+ }
30
+ }
31
+ }
32
+ ?>
app/code/local/Ininbox/Emailmarketing/Block/Field.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+
8
+ class Ininbox_Emailmarketing_Block_Field extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
9
+ {
10
+ protected $_customerAttributeRenderer;
11
+
12
+ protected $_ininboxCustomFieldRenderer;
13
+
14
+ protected $_customerAttribute;
15
+
16
+ public function __construct()
17
+ {
18
+ parent::__construct();
19
+ }
20
+
21
+ /**
22
+ * Use to get the customer attribute dropdown.
23
+ *
24
+ * @Return: return dropdown layout for customer attribute
25
+ */
26
+ protected function _getCustomerAttributeRenderer()
27
+ {
28
+ if (!$this->_customerAttributeRenderer) {
29
+ $this->_customerAttributeRenderer = Mage::app()->getLayout()
30
+ ->createBlock('emailmarketing/select')
31
+ ->setIsRenderToJsTemplate(true);
32
+ }
33
+ return $this->_customerAttributeRenderer;
34
+ }
35
+
36
+ protected function _getIninboxCustomFieldRenderer()
37
+ {
38
+ if (!$this->_ininboxCustomFieldRenderer) {
39
+ $this->_ininboxCustomFieldRenderer = Mage::app()->getLayout()
40
+ ->createBlock('emailmarketing/select')
41
+ ->setIsRenderToJsTemplate(true);
42
+ }
43
+ return $this->_ininboxCustomFieldRenderer;
44
+ }
45
+
46
+ protected function _getCustomerAttribute()
47
+ {
48
+ if (!$this->_customerAttribute) {
49
+ $this->_customerAttribute = Mage::getModel('emailmarketing/system_config_source_customer_attribute')
50
+ ->toOptionArray();
51
+ }
52
+ return $this->_customerAttribute;
53
+ }
54
+
55
+ protected function _prepareToRender()
56
+ {
57
+ $this->_ininboxCustomFieldRenderer = null;
58
+ $this->_customerAttributeRenderer = null;
59
+
60
+ $this->addColumn('customer_attributes', array(
61
+ 'label' => Mage::helper('emailmarketing')->__('Customer Attributes'),
62
+ 'style' => 'width:150px',
63
+ ));
64
+ $this->addColumn('ininbox_custom_fields', array(
65
+ 'label' => Mage::helper('emailmarketing')->__('INinbox Custom Fields'),
66
+ 'style' => 'width:150px',
67
+ ));
68
+
69
+ $this->_addAfter = false;
70
+ $this->_addButtonLabel = Mage::helper('emailmarketing')->__('Add Field Mapping');
71
+ }
72
+
73
+ protected function _renderCellTemplate($columnName)
74
+ {
75
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
76
+ $column = $this->_columns[$columnName];
77
+
78
+ if ($columnName == 'customer_attributes') {
79
+ return $this->_getCustomerAttributeRenderer()
80
+ ->setName($inputName)
81
+ ->setTitle($columnName)
82
+ ->setExtraParams((isset($column['style']) ? 'style="' . $column['style'] . '"' : ""))
83
+ ->setOptions($this->_getCustomerAttribute())
84
+ ->toHtml();
85
+ }
86
+ else if($columnName == 'ininbox_custom_fields') {
87
+ return $this->_getIninboxCustomFieldRenderer()
88
+ ->setName($inputName)
89
+ ->setTitle($columnName)
90
+ ->setExtraParams((isset($column['style']) ? 'style="' . $column['style'] . '"' : ""))
91
+ ->setOptions($this->getElement()->getValues())
92
+ ->toHtml();
93
+ }
94
+ return parent::_renderCellTemplate($columnName);
95
+ }
96
+
97
+ protected function _prepareArrayRow(Varien_Object $row)
98
+ {
99
+ $row->setData('option_extra_attr_' . $this->_getCustomerAttributeRenderer()->calcOptionHash($row->getData('customer_attributes')), 'selected="selected"');
100
+ $row->setData('option_extra_attr_' . $this->_getIninboxCustomFieldRenderer()->calcOptionHash($row->getData('ininbox_custom_fields')), 'selected="selected"');
101
+ }
102
+ }
103
+ ?>
app/code/local/Ininbox/Emailmarketing/Block/Select.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Block_Select extends Mage_Core_Block_Html_Select
8
+ {
9
+ public function _toHtml()
10
+ {
11
+ return trim(preg_replace('/\s+/', ' ',parent::_toHtml()));
12
+ }
13
+ }
14
+ ?>
app/code/local/Ininbox/Emailmarketing/Helper/Data.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Helper_Data extends Mage_Core_Helper_Abstract
8
+ {
9
+ /**
10
+ * Checkout weather extension is enabled or not
11
+ *
12
+ * @return - true or false on extension is enabled or not.
13
+ */
14
+ public function isEnabled()
15
+ {
16
+ return Mage::getStoreConfig('emailmarketing_options/general/enabled', Mage::app()->getStore());
17
+ }
18
+
19
+ /**
20
+ * Use to get configuration values
21
+ *
22
+ * @Params
23
+ * $group - define group of configuration
24
+ * $field - define variable for which you want to get the value.
25
+ *
26
+ * @return - configuration value
27
+ */
28
+ public function getConfig($group, $field)
29
+ {
30
+ return Mage::getStoreConfig('emailmarketing_options/' . $group . '/' . $field, Mage::app()->getStore());
31
+ }
32
+ }
33
+ ?>
app/code/local/Ininbox/Emailmarketing/Model/Ininbox/Base.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Model_Ininbox_Base extends Mage_Core_Model_Abstract {
8
+
9
+ protected $api_key = '';
10
+ protected $curl = true;
11
+ protected $curlExists = true;
12
+ protected $api_url = '';
13
+
14
+ public $api_isready = false;
15
+
16
+ protected function _construct() {
17
+
18
+ $this->_init('emailmarketing/ininbox_base');
19
+
20
+ $helper = Mage::helper('emailmarketing');
21
+ if($helper->isEnabled())
22
+ {
23
+ $this->api_key = $helper->getConfig($group = 'general', $field = 'key');
24
+ $this->api_url = $helper->getConfig($group = 'general', $field = 'url');
25
+ $this->curlExists = function_exists( 'curl_init' ) && function_exists( 'curl_setopt' );
26
+
27
+ if($this->api_key != '' && $this->api_url != '' && $this->curlExists)
28
+ {
29
+ $this->api_isready = true;
30
+ }
31
+ }
32
+ }
33
+
34
+ /**
35
+ * The direct way to make an API call.
36
+ *
37
+ * @param string $action The API call.
38
+ * @param string $format API call format - json or xml.
39
+ * @param array $options An associative array of values to send as part of the request.
40
+ * @return array parsed to array XML or JSON response.
41
+ */
42
+ public function makeCall($action = '', $parameters='' , $format='json', $options = null){
43
+
44
+ $postdata = null; $result = null;
45
+
46
+ if ( isset( $options['params'] ) ){
47
+ $postdata = $options['params'];
48
+ }
49
+
50
+ if ($this->api_isready && $this->curl && $this->curlExists ){
51
+
52
+ $url=$this->api_url.$action.'.'.$format;
53
+ if($parameters != '')
54
+ $url.='?'.$parameters;
55
+ $ch = curl_init( );
56
+
57
+ $postdata = json_encode( $postdata );
58
+
59
+ curl_setopt($ch, CURLOPT_URL,$url);
60
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
61
+
62
+ curl_setopt($ch, CURLOPT_FAILONERROR, 1);
63
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // Returns result to a variable instead of echoing
64
+ curl_setopt($ch, CURLOPT_TIMEOUT, 3); // Sets a time limit for curl in seconds (do not set too low)
65
+
66
+ curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
67
+ curl_setopt($ch, CURLOPT_USERPWD, $this->api_key.":");
68
+
69
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
70
+ if($format=='json'){
71
+ curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'Content-Length: ' . strlen($postdata)));
72
+ }
73
+
74
+ $result = curl_exec($ch);
75
+ curl_close($ch);
76
+
77
+ if($format=='json'){
78
+ return json_decode($result, true);
79
+ }
80
+ }
81
+ return $result;
82
+ }
83
+ }
84
+ ?>
app/code/local/Ininbox/Emailmarketing/Model/Ininbox/Contact.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Model_Ininbox_Contact extends Mage_Core_Model_Abstract {
8
+
9
+ protected function _construct() {
10
+ $this->_init('emailmarketing/ininbox_contact');
11
+ }
12
+
13
+ /**
14
+ * use to get the list of contacts from ininbox
15
+ *
16
+ * @return list of contact in json format
17
+ */
18
+ public function getList()
19
+ {
20
+ return Mage::getModel('emailmarketing/ininbox_base')
21
+ ->makeCall('contacts/list', 'PageSize=500');
22
+ }
23
+
24
+ /**
25
+ * use to add or update contact in ininbox
26
+ *
27
+ * @return response for add or edit details
28
+ */
29
+ public function add($params)
30
+ {
31
+ return Mage::getModel('emailmarketing/ininbox_base')
32
+ ->makeCall('contacts/create', '', 'json', $params);
33
+ }
34
+ }
35
+ ?>
app/code/local/Ininbox/Emailmarketing/Model/Ininbox/Customfield.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Model_Ininbox_Customfield extends Mage_Core_Model_Abstract {
8
+
9
+ protected function _construct() {
10
+ $this->_init('emailmarketing/ininbox_customfield');
11
+ }
12
+
13
+ /**
14
+ * use to get the list of custom fields from ininbox
15
+ *
16
+ * @return list of custom fields in json format
17
+ */
18
+ public function getList()
19
+ {
20
+ return Mage::getModel('emailmarketing/ininbox_base')->makeCall('customfields/list', 'PageSize=500');
21
+ }
22
+ }
23
+ ?>
app/code/local/Ininbox/Emailmarketing/Model/Ininbox/Group.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Model_Ininbox_Group extends Mage_Core_Model_Abstract {
8
+
9
+ protected function _construct() {
10
+ $this->_init('emailmarketing/ininbox_group');
11
+ }
12
+
13
+ /**
14
+ * use to get the list of lists from ininbox
15
+ *
16
+ * @return list of lists in json format
17
+ */
18
+ public function getList()
19
+ {
20
+ return Mage::getModel('emailmarketing/ininbox_base')->makeCall('lists/list', 'PageSize=500');
21
+ }
22
+ }
23
+ ?>
app/code/local/Ininbox/Emailmarketing/Model/Observer.php ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Model_Observer
8
+ {
9
+ /**
10
+ * event listener on customer detail save
11
+ *
12
+ * @Params
13
+ * $observer - contains customer details
14
+ */
15
+ public function customerSaveObserver(Varien_Event_Observer $observer)
16
+ {
17
+ if(Mage::helper('emailmarketing')->isEnabled())
18
+ {
19
+ $isIninboxSendCustomerEnabled = Mage::helper('emailmarketing')->getConfig($group = 'customer_settings', $field = 'send_customer');
20
+ $ininboxCustomerGroupList = Mage::helper('emailmarketing')->getConfig($group = 'customer_settings', $field = 'customer_group_list');
21
+
22
+ $ininboxResubscriber = Mage::helper('emailmarketing')->getConfig($group = 'customer_misc_settings', $field = 'update_subscriber') ? true : false;
23
+ $ininboxSendConfirmationEmail = Mage::helper('emailmarketing')->getConfig($group = 'customer_misc_settings', $field = 'confirm_email') ? true : false;
24
+ $ininboxAddContactToAutoresponderCycle = Mage::helper('emailmarketing')->getConfig($group = 'customer_misc_settings', $field = 'send_autoresponder') ? true : false;
25
+
26
+ if($isIninboxSendCustomerEnabled && !is_null($ininboxCustomerGroupList))
27
+ {
28
+ $currentCustomer = $observer->getCustomer();
29
+
30
+ $ininboxContactId = $currentCustomer->getIninboxContactId();
31
+
32
+ if(isset($ininboxContactId) && !is_null($ininboxContactId))
33
+ $this->updateIninboxContactGroup($currentCustomer->getEmail(), $ininboxCustomerGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle);
34
+ else
35
+ $this->createIninboxContact($currentCustomer, $ininboxCustomerGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle);
36
+ }
37
+ }
38
+
39
+ $this->_customerRegistrationNewsletterSubscribe($observer);
40
+ }
41
+
42
+ /**
43
+ * protected function called to check new newsletter subscribed on customer registration
44
+ *
45
+ * @Params
46
+ * $observer - contains customer details on registration
47
+ */
48
+ protected function _customerRegistrationNewsletterSubscribe(Varien_Event_Observer $observer)
49
+ {
50
+ if(Mage::helper('emailmarketing')->isEnabled())
51
+ {
52
+ $isIninboxSendSubscriberEnabled = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_settings', $field = 'send_subscriber');
53
+ $ininboxSubscriberGroupList = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_settings', $field = 'subscriber_group_list');
54
+
55
+ $ininboxResubscriber = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_misc_settings', $field = 'update_subscriber') ? true : false;
56
+ $ininboxSendConfirmationEmail = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_misc_settings', $field = 'confirm_email') ? true : false;
57
+ $ininboxAddContactToAutoresponderCycle = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_misc_settings', $field = 'send_autoresponder') ? true : false;
58
+
59
+ if($isIninboxSendSubscriberEnabled && !is_null($ininboxSubscriberGroupList))
60
+ {
61
+ $currentCustomer = $observer->getCustomer();
62
+
63
+ $newsletterSubscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($currentCustomer->getEmail());
64
+ if($newsletterSubscriber->getId())
65
+ {
66
+ $ininboxContactId = $currentCustomer->getIninboxContactId();
67
+
68
+ if(isset($ininboxContactId) && !is_null($ininboxContactId))
69
+ $this->updateIninboxContactGroup($currentCustomer->getEmail(), $ininboxSubscriberGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle);
70
+ else
71
+ $this->createIninboxContact($currentCustomer, $ininboxCustomerGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle);
72
+ }
73
+ }
74
+ }
75
+ }
76
+
77
+ /**
78
+ * event listener on new newsletter subscribe
79
+ *
80
+ * @Params
81
+ * $observer - contains email subscribed for newsletter
82
+ */
83
+ public function newsletterSubscribeAfterObserver(Varien_Event_Observer $observer)
84
+ {
85
+ if(Mage::helper('emailmarketing')->isEnabled())
86
+ {
87
+ $isIninboxSendSubscriberEnabled = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_settings', $field = 'send_subscriber');
88
+ $ininboxSubscriberGroupList = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_settings', $field = 'subscriber_group_list');
89
+
90
+ $ininboxResubscriber = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_misc_settings', $field = 'update_subscriber') ? true : false;
91
+ $ininboxSendConfirmationEmail = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_misc_settings', $field = 'confirm_email') ? true : false;
92
+ $ininboxAddContactToAutoresponderCycle = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_misc_settings', $field = 'send_autoresponder') ? true : false;
93
+
94
+ if($isIninboxSendSubscriberEnabled && !is_null($ininboxSubscriberGroupList))
95
+ {
96
+ $subscribeEmail = $observer->getEmail();
97
+ $this->updateIninboxContactGroup($subscribeEmail, $ininboxSubscriberGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle);
98
+ }
99
+ }
100
+ }
101
+
102
+ /**
103
+ * event listener on sales order place when customer place new order.
104
+ *
105
+ * @Params
106
+ * $observer - contains order details
107
+ */
108
+ public function salesOrderPlaceAfterObserver(Varien_Event_Observer $observer)
109
+ {
110
+ if(Mage::helper('emailmarketing')->isEnabled())
111
+ {
112
+ $isIninboxSendOrderEnabled = Mage::helper('emailmarketing')->getConfig($group = 'order_settings', $field = 'send_order');
113
+ $ininboxOrderGroupList = Mage::helper('emailmarketing')->getConfig($group = 'order_settings', $field = 'order_group_list');
114
+
115
+ $ininboxResubscriber = Mage::helper('emailmarketing')->getConfig($group = 'order_misc_settings', $field = 'update_subscriber') ? true : false;
116
+ $ininboxSendConfirmationEmail = Mage::helper('emailmarketing')->getConfig($group = 'order_misc_settings', $field = 'confirm_email') ? true : false;
117
+ $ininboxAddContactToAutoresponderCycle = Mage::helper('emailmarketing')->getConfig($group = 'order_misc_settings', $field = 'send_autoresponder') ? true : false;
118
+
119
+ if($isIninboxSendOrderEnabled && !is_null($ininboxOrderGroupList))
120
+ {
121
+ $this->createIninboxContactForSales($observer->getEvent()->getOrder(), $ininboxOrderGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle);
122
+ }
123
+ }
124
+
125
+ $quote_id = $observer->getEvent()->getOrder()->getQuoteId();
126
+ $quote = Mage::getModel('sales/quote')->load($quote_id);
127
+ $method = $quote->getCheckoutMethod(true);
128
+
129
+ if($method == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER)
130
+ {
131
+ if(Mage::helper('emailmarketing')->isEnabled())
132
+ {
133
+ $isIninboxSendCustomerEnabled = Mage::helper('emailmarketing')->getConfig($group = 'customer_settings', $field = 'send_customer');
134
+ $ininboxCustomerGroupList = Mage::helper('emailmarketing')->getConfig($group = 'customer_settings', $field = 'customer_group_list');
135
+
136
+ $ininboxResubscriber = Mage::helper('emailmarketing')->getConfig($group = 'customer_misc_settings', $field = 'update_subscriber') ? true : false;
137
+ $ininboxSendConfirmationEmail = Mage::helper('emailmarketing')->getConfig($group = 'customer_misc_settings', $field = 'confirm_email') ? true : false;
138
+ $ininboxAddContactToAutoresponderCycle = Mage::helper('emailmarketing')->getConfig($group = 'customer_misc_settings', $field = 'send_autoresponder') ? true : false;
139
+
140
+ if($isIninboxSendCustomerEnabled && !is_null($ininboxCustomerGroupList))
141
+ {
142
+ /*$currentCustomer = Mage::getModel('customer/customer')->load($observer->getEvent()->getOrder()->getCustomerId());*/
143
+ $currentCustomer = $observer->getEvent()->getOrder()->getBillingAddress();
144
+ //die($observer->getEvent()->getOrder()->custome());
145
+ //die(json_encode($currentCustomer));
146
+ $this->createIninboxContact($currentCustomer, $ininboxCustomerGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle);
147
+ }
148
+ }
149
+ }
150
+ }
151
+
152
+ /**
153
+ * event listener on customer account edit.
154
+ *
155
+ * @Params
156
+ * $observer - contains customer details
157
+ */
158
+ public function customerAccountEditAfterObserver(Varien_Event_Observer $observer)
159
+ {
160
+ if(Mage::helper('emailmarketing')->isEnabled())
161
+ {
162
+ $isIninboxSendCustomerEnabled = Mage::helper('emailmarketing')->getConfig($group = 'customer_settings', $field = 'send_customer');
163
+ $ininboxCustomerGroupList = Mage::helper('emailmarketing')->getConfig($group = 'customer_settings', $field = 'customer_group_list');
164
+
165
+ $ininboxResubscriber = Mage::helper('emailmarketing')->getConfig($group = 'customer_misc_settings', $field = 'update_subscriber') ? true : false;
166
+ $ininboxSendConfirmationEmail = Mage::helper('emailmarketing')->getConfig($group = 'customer_misc_settings', $field = 'confirm_email') ? true : false;
167
+ $ininboxAddContactToAutoresponderCycle = Mage::helper('emailmarketing')->getConfig($group = 'customer_misc_settings', $field = 'send_autoresponder') ? true : false;
168
+
169
+ if($isIninboxSendCustomerEnabled && !is_null($ininboxCustomerGroupList))
170
+ {
171
+ $currentCustomer = $observer->getCustomer();
172
+ $this->createIninboxContact($currentCustomer, $ininboxCustomerGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle);
173
+ }
174
+ }
175
+ }
176
+
177
+ /**
178
+ * event listener for newsletter group list on newsletter subscriber mass action
179
+ *
180
+ * @Params
181
+ * $observer - contains customer ids which are subscribed for newsletters.
182
+ */
183
+ public function customerNewsletterSubscribeAfterObserver(Varien_Event_Observer $observer)
184
+ {
185
+ if(Mage::helper('emailmarketing')->isEnabled())
186
+ {
187
+ $isIninboxSendSubscriberEnabled = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_settings', $field = 'send_subscriber');
188
+ $ininboxSubscriberGroupList = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_settings', $field = 'subscriber_group_list');
189
+
190
+ $ininboxResubscriber = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_massaction_settings', $field = 'update_subscriber') ? true : false;
191
+ $ininboxSendConfirmationEmail = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_massaction_settings', $field = 'confirm_email') ? true : false;
192
+ $ininboxAddContactToAutoresponderCycle = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_massaction_settings', $field = 'send_autoresponder') ? true : false;
193
+
194
+ if($isIninboxSendSubscriberEnabled && !is_null($ininboxSubscriberGroupList))
195
+ {
196
+ $customersIds = $observer->getCustomersIds();
197
+ foreach ($customersIds as $customerId) {
198
+ $currentCustomer = Mage::getModel('customer/customer')->load($customerId);
199
+ $this->createIninboxContact($currentCustomer, $ininboxSubscriberGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle);
200
+ }
201
+ }
202
+ }
203
+ }
204
+
205
+ /**
206
+ * Use to update list on new customer register
207
+ * Here boolean variables varies based on massaction or on single action.
208
+ *
209
+ * @Params
210
+ * $currentCustomer - customer object for customer details
211
+ * $ininboxGroupList - group id for which we need to subscribe
212
+ * $ininboxResubscriber - true or false on resubscribe or not
213
+ * $ininboxSendConfirmationEmail - true or false on send confirmation or not
214
+ * $ininboxAddContactToAutoresponderCycle - true or false on add contact to autorespnder cycle or not
215
+ */
216
+ public function createIninboxContact($currentCustomer, $ininboxGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle)
217
+ {
218
+ try
219
+ {
220
+ $ininboxPredefinedCustomFields = Mage::getModel('emailmarketing/system_config_source_field_list')->getPredefinedCustomList();
221
+ $ininboxMappedCustomFields = unserialize(Mage::helper('emailmarketing')->getConfig($group = 'field_mapping', $field = 'field'));
222
+
223
+ foreach($ininboxMappedCustomFields as $mappedField)
224
+ {
225
+ $customerAttribute = $mappedField['customer_attributes'];
226
+ $ininboxCustomField = $mappedField['ininbox_custom_fields'];
227
+ if(array_key_exists($ininboxCustomField, $ininboxPredefinedCustomFields))
228
+ $params['params'][$ininboxCustomField] = $currentCustomer->getData($customerAttribute);
229
+ else
230
+ $params['params']['CustomFields'][] = array('Key' => $ininboxCustomField, 'Value' => $currentCustomer->getData($customerAttribute));
231
+ }
232
+
233
+ $params['params']['Resubscribe'] = $ininboxResubscriber;
234
+ $params['params']['SendConfirmationEmail'] = $ininboxSendConfirmationEmail;
235
+ $params['params']['AddContactToAutoresponderCycle'] = $ininboxAddContactToAutoresponderCycle;
236
+ $params['params']['ListIDs'] = array(intval($ininboxGroupList));
237
+
238
+ $result = Mage::getModel('emailmarketing/ininbox_contact')->add($params);
239
+
240
+ $currentCustomer->setIninboxContactId($result['ContactID']);
241
+ $currentCustomer->save();
242
+ }
243
+ catch (Exception $e) {
244
+ echo 'Caught exception: ' . $e->getMessage();
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Use to update list on new order place
250
+ * Here boolean variables varies based on massaction or on single action.
251
+ *
252
+ * @Params
253
+ * $currentOrder - Current order for which you need to subscribe on INinbox
254
+ * $ininboxGroupList - group id for which we need to subscribe
255
+ * $ininboxResubscriber - true or false on resubscribe or not
256
+ * $ininboxSendConfirmationEmail - true or false on send confirmation or not
257
+ * $ininboxAddContactToAutoresponderCycle - true or false on add contact to autorespnder cycle or not
258
+ */
259
+ public function createIninboxContactForSales($currentOrder, $ininboxGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle)
260
+ {
261
+ try
262
+ {
263
+ $ininboxPredefinedCustomFields = Mage::getModel('emailmarketing/system_config_source_field_list')->getPredefinedCustomList();
264
+ $ininboxMappedCustomFields = unserialize(Mage::helper('emailmarketing')->getConfig($group = 'field_mapping', $field = 'field'));
265
+
266
+ $currentCustomer = $currentOrder->getBillingAddress();
267
+
268
+ foreach($ininboxMappedCustomFields as $mappedField)
269
+ {
270
+ $customerAttribute = $mappedField['customer_attributes'];
271
+ if($customerAttribute == 'default_shipping')
272
+ {
273
+ $currentCustomer = $currentOrder->getShippingAddress();
274
+ break;
275
+ }
276
+ }
277
+
278
+ foreach($ininboxMappedCustomFields as $mappedField)
279
+ {
280
+ $customerAttribute = $mappedField['customer_attributes'];
281
+ $ininboxCustomField = $mappedField['ininbox_custom_fields'];
282
+ if($customerAttribute == 'default_billing' || $customerAttribute == 'default_shipping')
283
+ {
284
+ if($ininboxCustomField == 'Address')
285
+ {
286
+ $params['params']['Address'] = $currentCustomer->getStreet1() . ' ' . $currentCustomer->getStreet2();
287
+ $params['params']['CountryCode'] = $currentCustomer->getCountryId();
288
+ $params['params']['City'] = $currentCustomer->getCity();
289
+ $params['params']['Zip'] = $currentCustomer->getPostcode();
290
+ $params['params']['MobilePhone'] = $currentCustomer->getTelephone();
291
+ $params['params']['Fax'] = $currentCustomer->getFax();
292
+ }
293
+ else
294
+ {
295
+ if(array_key_exists($ininboxCustomField, $ininboxPredefinedCustomFields))
296
+ $params['params'][$ininboxCustomField] = $currentCustomer->getStreet1() . ' ' . $currentCustomer->getStreet2();
297
+ else
298
+ $params['params']['CustomFields'][] = array('Key' => $ininboxCustomField, 'Value' => ($currentCustomer->getStreet1() . ' ' . $currentCustomer->getStreet2()));
299
+ }
300
+ }
301
+ else
302
+ {
303
+ if(array_key_exists($ininboxCustomField, $ininboxPredefinedCustomFields))
304
+ $params['params'][$ininboxCustomField] = $currentCustomer->getData($customerAttribute);
305
+ else
306
+ $params['params']['CustomFields'][] = array('Key' => $ininboxCustomField, 'Value' => $currentCustomer->getData($customerAttribute));
307
+ }
308
+ }
309
+
310
+ $params['params']['Resubscribe'] = $ininboxResubscriber;
311
+ $params['params']['SendConfirmationEmail'] = $ininboxSendConfirmationEmail;
312
+ $params['params']['AddContactToAutoresponderCycle'] = $ininboxAddContactToAutoresponderCycle;
313
+ $params['params']['ListIDs'] = array(intval($ininboxGroupList));
314
+
315
+ $result = Mage::getModel('emailmarketing/ininbox_contact')->add($params);
316
+
317
+ $currentCustomer->setIninboxContactId($result['ContactID']);
318
+ $currentCustomer->save();
319
+ }
320
+ catch (Exception $e) {
321
+ echo 'Caught exception: ' . $e->getMessage();
322
+ }
323
+ }
324
+
325
+ /**
326
+ * Use to update list on customer email
327
+ * Here boolean variables varies based on massaction or on single action.
328
+ *
329
+ * @Params
330
+ * $ininboxCustomerEmail - customer email for subscribtion
331
+ * $ininboxGroupList - group id for which we need to subscribe
332
+ * $ininboxResubscriber - true or false on resubscribe or not
333
+ * $ininboxSendConfirmationEmail - true or false on send confirmation or not
334
+ * $ininboxAddContactToAutoresponderCycle - true or false on add contact to autorespnder cycle or not
335
+ */
336
+ public function updateIninboxContactGroup($ininboxCustomerEmail, $ininboxGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle)
337
+ {
338
+ try
339
+ {
340
+ $params['params']['Email'] = $ininboxCustomerEmail;
341
+ $params['params']['Resubscribe'] = $ininboxResubscriber;
342
+ $params['params']['SendConfirmationEmail'] = $ininboxSendConfirmationEmail;
343
+ $params['params']['AddContactToAutoresponderCycle'] = $ininboxAddContactToAutoresponderCycle;
344
+ $params['params']['ListIDs'] = array(intval($ininboxGroupList));
345
+ $result = Mage::getModel('emailmarketing/ininbox_contact')->add($params);
346
+ }
347
+ catch (Exception $e) {
348
+ echo 'Caught exception: ' . $e->getMessage();
349
+ }
350
+ }
351
+ }
352
+ ?>
app/code/local/Ininbox/Emailmarketing/Model/System/Config/Source/Customer/Attribute.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Model_System_Config_Source_Customer_Attribute
8
+ {
9
+ protected function _construct() {
10
+
11
+ $this->_init('emailmarketing/system_config_source_customer_attribute');
12
+
13
+ }
14
+
15
+ /**
16
+ * use to get the list of attributes for customer
17
+ *
18
+ * @return list of customer attributes
19
+ */
20
+ public function toOptionArray()
21
+ {
22
+ /*
23
+ $attributes = Mage::getSingleton('customer/convert_parser_customer')->getExternalAttributes();
24
+
25
+ $result = $attributes;
26
+ */
27
+
28
+ $attributes = Mage::getModel('customer/entity_attribute_collection');
29
+
30
+ $result = array();
31
+
32
+ foreach ($attributes as $attribute) {
33
+
34
+ if (($label = $attribute->getFrontendLabel()))
35
+ $result[$attribute->getAttributeCode()] = $label;
36
+
37
+ }
38
+
39
+ return $result;
40
+ }
41
+ }
42
+ ?>
app/code/local/Ininbox/Emailmarketing/Model/System/Config/Source/Field/List.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Model_System_Config_Source_Field_List
8
+ {
9
+ protected $_predefinedCustomFields = array
10
+ (
11
+ 'FirstName' => 'first_name',
12
+ 'LastName' => 'last_name',
13
+ 'Email' => 'email',
14
+ 'Gender' => 'gender',
15
+ 'Company' => 'company',
16
+ 'Address' => 'address'
17
+ /*'CountryCode' => 'country',
18
+ 'StateCode' => 'state',
19
+ 'City' => 'city',
20
+ 'Zip' => 'zip_code',
21
+ 'HomePhone' => 'home_phone',
22
+ 'MobilePhone' => 'mobile_phone',
23
+ 'WorkPhone' => 'work_phone',
24
+ 'Fax' => 'fax'*/
25
+ );
26
+
27
+ /**
28
+ * use to get the list of custome fields
29
+ *
30
+ * @return list of custom fields
31
+ */
32
+ public function toOptionArray()
33
+ {
34
+ $result = $this->_predefinedCustomFields;
35
+
36
+ $data = Mage::getModel('emailmarketing/ininbox_customfield')->getList();
37
+
38
+ if(!is_null($data))
39
+ {
40
+ foreach($data['Results'] as $row)
41
+ {
42
+ $result[$row['FieldName']]= $row['FieldName'];
43
+ }
44
+ }
45
+
46
+ return $result;
47
+ }
48
+
49
+ /**
50
+ * use to get the list of predefined custom fields
51
+ *
52
+ * @return list of predefined custom fields
53
+ */
54
+ public function getPredefinedCustomList()
55
+ {
56
+ return $this->_predefinedCustomFields;
57
+ }
58
+ }
59
+
60
+ ?>
app/code/local/Ininbox/Emailmarketing/Model/System/Config/Source/Group/List.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Model_System_Config_Source_Group_List
8
+ {
9
+ /**
10
+ * use to get the list of lists from ininbox
11
+ *
12
+ * @return list of contact
13
+ */
14
+ public function toOptionArray()
15
+ {
16
+ $result = array();
17
+
18
+ $data = Mage::getModel('emailmarketing/ininbox_group')->getList();
19
+
20
+ if(!is_null($data))
21
+ {
22
+ foreach($data['Results'] as $row)
23
+ {
24
+ $result[$row['ListID']] = $row['Title'];
25
+ }
26
+ }
27
+
28
+ return $result;
29
+ }
30
+ }
31
+
32
+ ?>
app/code/local/Ininbox/Emailmarketing/controllers/AccountController.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+
8
+ require_once Mage::getModuleDir('controllers', 'Mage_Customer').DS.'AccountController.php';
9
+
10
+ class Ininbox_Emailmarketing_AccountController extends Mage_Customer_AccountController
11
+ {
12
+ /**
13
+ * Change customer password action
14
+ */
15
+ public function editPostAction()
16
+ {
17
+ if (!$this->_validateFormKey()) {
18
+ return $this->_redirect('*/*/edit');
19
+ }
20
+
21
+ if ($this->getRequest()->isPost()) {
22
+ /** @var $customer Mage_Customer_Model_Customer */
23
+ $customer = $this->_getSession()->getCustomer();
24
+
25
+ /** @var $customerForm Mage_Customer_Model_Form */
26
+ $customerForm = Mage::getModel('customer/form');
27
+ $customerForm->setFormCode('customer_account_edit')
28
+ ->setEntity($customer);
29
+
30
+ $customerData = $customerForm->extractData($this->getRequest());
31
+
32
+ $errors = array();
33
+ $customerErrors = $customerForm->validateData($customerData);
34
+ if ($customerErrors !== true) {
35
+ $errors = array_merge($customerErrors, $errors);
36
+ } else {
37
+ $customerForm->compactData($customerData);
38
+ $errors = array();
39
+
40
+ // If password change was requested then add it to common validation scheme
41
+ if ($this->getRequest()->getParam('change_password')) {
42
+ $currPass = $this->getRequest()->getPost('current_password');
43
+ $newPass = $this->getRequest()->getPost('password');
44
+ $confPass = $this->getRequest()->getPost('confirmation');
45
+
46
+ $oldPass = $this->_getSession()->getCustomer()->getPasswordHash();
47
+ if (Mage::helper('core/string')->strpos($oldPass, ':')) {
48
+ list($_salt, $salt) = explode(':', $oldPass);
49
+ } else {
50
+ $salt = false;
51
+ }
52
+
53
+ if ($customer->hashPassword($currPass, $salt) == $oldPass) {
54
+ if (strlen($newPass)) {
55
+ /**
56
+ * Set entered password and its confirmation - they
57
+ * will be validated later to match each other and be of right length
58
+ */
59
+ $customer->setPassword($newPass);
60
+ $customer->setConfirmation($confPass);
61
+ } else {
62
+ $errors[] = $this->__('New password field cannot be empty.');
63
+ }
64
+ } else {
65
+ $errors[] = $this->__('Invalid current password');
66
+ }
67
+ }
68
+
69
+ // Validate account and compose list of errors if any
70
+ $customerErrors = $customer->validate();
71
+ if (is_array($customerErrors)) {
72
+ $errors = array_merge($errors, $customerErrors);
73
+ }
74
+ }
75
+
76
+ if (!empty($errors)) {
77
+ $this->_getSession()->setCustomerFormData($this->getRequest()->getPost());
78
+ foreach ($errors as $message) {
79
+ $this->_getSession()->addError($message);
80
+ }
81
+ $this->_redirect('*/*/edit');
82
+ return $this;
83
+ }
84
+
85
+ try {
86
+ $customer->setConfirmation(null);
87
+ $customer->save();
88
+ $this->_getSession()->setCustomer($customer)
89
+ ->addSuccess($this->__('The account information has been saved.'));
90
+
91
+ // add event dispatcher to raise event after customer edit
92
+ // this change is made to manage INinbox.com Contacts/List
93
+ $data = array('customer' => Mage::getSingleton('customer/session')->getCustomer());
94
+ Mage::dispatchEvent('customer_account_edit_after', $data);
95
+
96
+ $this->_redirect('customer/account');
97
+ return;
98
+ } catch (Mage_Core_Exception $e) {
99
+ $this->_getSession()->setCustomerFormData($this->getRequest()->getPost())
100
+ ->addError($e->getMessage());
101
+ } catch (Exception $e) {
102
+ $this->_getSession()->setCustomerFormData($this->getRequest()->getPost())
103
+ ->addException($e, $this->__('Cannot save the customer.'));
104
+ }
105
+ }
106
+
107
+ $this->_redirect('*/*/edit');
108
+ }
109
+ }
app/code/local/Ininbox/Emailmarketing/controllers/Adminhtml/CustomerController.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+
8
+ require_once Mage::getModuleDir('controllers', 'Mage_Adminhtml').DS.'CustomerController.php';
9
+
10
+ class Ininbox_Emailmarketing_Adminhtml_CustomerController extends Mage_Adminhtml_CustomerController
11
+ {
12
+ /**
13
+ * Use to raise event on mass action subscribe.
14
+ */
15
+ public function massSubscribeAction()
16
+ {
17
+ $customersIds = $this->getRequest()->getParam('customer');
18
+ if(!is_array($customersIds)) {
19
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select customer(s).'));
20
+
21
+ } else {
22
+ try {
23
+ foreach ($customersIds as $customerId) {
24
+ $customer = Mage::getModel('customer/customer')->load($customerId);
25
+ $customer->setIsSubscribed(true);
26
+ $customer->save();
27
+ }
28
+
29
+ // add event dispatcher to raise event after newsletter subscribe
30
+ // this change is made to manage INinbox.com Contacts/List
31
+ $data = array('customers_ids' => $customersIds);
32
+ Mage::dispatchEvent('customer_newsletter_subscribe_after', $data);
33
+
34
+ Mage::getSingleton('adminhtml/session')->addSuccess(
35
+ Mage::helper('adminhtml')->__('Total of %d record(s) were updated.', count($customersIds))
36
+ );
37
+ } catch (Exception $e) {
38
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
39
+ }
40
+ }
41
+ $this->_redirect('*/*/index');
42
+ }
43
+ }
44
+
45
+ ?>
app/code/local/Ininbox/Emailmarketing/controllers/Adminhtml/MassactionController.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ class Ininbox_Emailmarketing_Adminhtml_MassactionController extends Mage_Adminhtml_Controller_Action {
8
+
9
+ /**
10
+ * Action on mass action for customer to Add in INinbox list
11
+ */
12
+ public function customerAction()
13
+ {
14
+ $customersIds = $this->getRequest()->getParam('customer');
15
+ // check weather customerids is array or not
16
+ if(!is_array($customersIds)) {
17
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select customer(s).'));
18
+ } else {
19
+ try {
20
+ // Check weather extension is enabled or not.
21
+ if(Mage::helper('emailmarketing')->isEnabled())
22
+ {
23
+ // Check weather feature is enabled or not and get the INinbox list id for edit.
24
+ $isIninboxSendCustomerEnabled = Mage::helper('emailmarketing')->getConfig($group = 'customer_settings', $field = 'send_customer');
25
+ $ininboxCustomerGroupList = Mage::helper('emailmarketing')->getConfig($group = 'customer_settings', $field = 'customer_group_list');
26
+
27
+ // get the settings for mass action miscellaneous section to add customer on mass action
28
+ $ininboxResubscriber = Mage::helper('emailmarketing')->getConfig($group = 'customer_massaction_settings', $field = 'update_subscriber') ? true : false;
29
+ $ininboxSendConfirmationEmail = Mage::helper('emailmarketing')->getConfig($group = 'customer_massaction_settings', $field = 'confirm_email') ? true : false;
30
+ $ininboxAddContactToAutoresponderCycle = Mage::helper('emailmarketing')->getConfig($group = 'customer_massaction_settings', $field = 'send_autoresponder') ? true : false;
31
+
32
+ if($isIninboxSendCustomerEnabled && !is_null($ininboxCustomerGroupList))
33
+ {
34
+ foreach ($customersIds as $customerId) {
35
+ $currentCustomer = Mage::getModel('customer/customer')->load($customerId);
36
+ Mage::getModel('emailmarketing/observer')->createIninboxContact($currentCustomer, $ininboxCustomerGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle);
37
+ }
38
+ Mage::getSingleton('adminhtml/session')->addSuccess(
39
+ Mage::helper('adminhtml')->__('Total of %d record(s) were added.', count($customersIds))
40
+ );
41
+ }
42
+ }
43
+ } catch (Exception $e) {
44
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
45
+ }
46
+ }
47
+ $this->_redirect('adminhtml/customer/index/');
48
+ return;
49
+ }
50
+
51
+ /**
52
+ * Action on mass action in newsletter group to add customer to INinbox list
53
+ */
54
+ public function newsletterAction()
55
+ {
56
+ $subscribersIds = $this->getRequest()->getParam('subscriber');
57
+ if (!is_array($subscribersIds)) {
58
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('newsletter')->__('Please select subscriber(s)'));
59
+ }
60
+ else {
61
+ try {
62
+ if(Mage::helper('emailmarketing')->isEnabled())
63
+ {
64
+ $isIninboxSendSubscriberEnabled = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_settings', $field = 'send_subscriber');
65
+ $ininboxSubscriberGroupList = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_settings', $field = 'subscriber_group_list');
66
+
67
+ $ininboxResubscriber = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_massaction_settings', $field = 'update_subscriber') ? true : false;
68
+ $ininboxSendConfirmationEmail = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_massaction_settings', $field = 'confirm_email') ? true : false;
69
+ $ininboxAddContactToAutoresponderCycle = Mage::helper('emailmarketing')->getConfig($group = 'newsletter_massaction_settings', $field = 'send_autoresponder') ? true : false;
70
+
71
+ if($isIninboxSendSubscriberEnabled && !is_null($ininboxSubscriberGroupList))
72
+ {
73
+ foreach ($subscribersIds as $subscriberId) {
74
+ $subscriber = Mage::getModel('newsletter/subscriber')->load($subscriberId);
75
+ $subscribeEmail = $subscriber->getData('subscriber_email');
76
+ Mage::getModel('emailmarketing/observer')->updateIninboxContactGroup($subscribeEmail, $ininboxSubscriberGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle);
77
+ }
78
+ Mage::getSingleton('adminhtml/session')->addSuccess(
79
+ Mage::helper('adminhtml')->__('Total of %d record(s) were added.', count($subscribersIds))
80
+ );
81
+ }
82
+ }
83
+ } catch (Exception $e) {
84
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
85
+ }
86
+ }
87
+ $this->_redirect('adminhtml/newsletter_subscriber/index/');
88
+ return;
89
+ }
90
+
91
+ /**
92
+ * Action on mass action in sales order to add customer to INinbox list
93
+ */
94
+ public function salesorderAction()
95
+ {
96
+ $orderIds = $this->getRequest()->getPost('order_ids', array());
97
+ if (!is_array($orderIds)) {
98
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('newsletter')->__('Please select order(s)'));
99
+ }
100
+ else {
101
+ try {
102
+ if(Mage::helper('emailmarketing')->isEnabled())
103
+ {
104
+ $isIninboxSendOrderEnabled = Mage::helper('emailmarketing')->getConfig($group = 'order_settings', $field = 'send_order');
105
+ $ininboxOrderGroupList = Mage::helper('emailmarketing')->getConfig($group = 'order_settings', $field = 'order_group_list');
106
+
107
+ $ininboxResubscriber = Mage::helper('emailmarketing')->getConfig($group = 'order_massaction_settings', $field = 'update_subscriber') ? true : false;
108
+ $ininboxSendConfirmationEmail = Mage::helper('emailmarketing')->getConfig($group = 'order_massaction_settings', $field = 'confirm_email') ? true : false;
109
+ $ininboxAddContactToAutoresponderCycle = Mage::helper('emailmarketing')->getConfig($group = 'order_massaction_settings', $field = 'send_autoresponder') ? true : false;
110
+
111
+ if($isIninboxSendOrderEnabled && !is_null($ininboxOrderGroupList))
112
+ {
113
+ foreach ($orderIds as $orderId) {
114
+ $order = Mage::getModel('sales/order')->load($orderId);
115
+ Mage::getModel('emailmarketing/observer')->createIninboxContactForSales($order, $ininboxOrderGroupList, $ininboxResubscriber, $ininboxSendConfirmationEmail, $ininboxAddContactToAutoresponderCycle);
116
+ }
117
+ Mage::getSingleton('adminhtml/session')->addSuccess(
118
+ Mage::helper('adminhtml')->__('Total of %d record(s) were added.', count($orderIds))
119
+ );
120
+ }
121
+ }
122
+ } catch (Exception $e) {
123
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
124
+ }
125
+ }
126
+
127
+ $this->_redirect('adminhtml/sales_order/index/');
128
+ return;
129
+ }
130
+ }
131
+
132
+ ?>
app/code/local/Ininbox/Emailmarketing/controllers/ManageController.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ require_once Mage::getModuleDir('controllers', 'Mage_Newsletter').DS.'ManageController.php';
8
+
9
+ class Ininbox_Emailmarketing_ManageController extends Mage_Newsletter_ManageController
10
+ {
11
+ public function saveAction()
12
+ {
13
+ if (!$this->_validateFormKey()) {
14
+ return $this->_redirect('customer/account/');
15
+ }
16
+ try {
17
+ Mage::getSingleton('customer/session')->getCustomer()
18
+ ->setStoreId(Mage::app()->getStore()->getId())
19
+ ->setIsSubscribed((boolean)$this->getRequest()->getParam('is_subscribed', false))
20
+ ->save();
21
+ if ((boolean)$this->getRequest()->getParam('is_subscribed', false)) {
22
+ Mage::getSingleton('customer/session')->addSuccess($this->__('The subscription has been saved.'));
23
+
24
+ // add event dispatcher to raise event after news letter subscribe
25
+ // this change is made to manage INinbox.com Contacts/List
26
+ $data = array('email' => Mage::getSingleton('customer/session')->getCustomer()->getEmail());
27
+ Mage::dispatchEvent('newsletter_subscribe_after', $data);
28
+
29
+ } else {
30
+ Mage::getSingleton('customer/session')->addSuccess($this->__('The subscription has been removed.'));
31
+ }
32
+ }
33
+ catch (Exception $e) {
34
+ Mage::getSingleton('customer/session')->addError($this->__('An error occurred while saving your subscription.'));
35
+ }
36
+ $this->_redirect('customer/account/');
37
+ }
38
+ }
app/code/local/Ininbox/Emailmarketing/controllers/SubscriberController.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+
8
+ require_once Mage::getModuleDir('controllers', 'Mage_Newsletter').DS.'SubscriberController.php';
9
+
10
+ class Ininbox_Emailmarketing_SubscriberController extends Mage_Newsletter_SubscriberController
11
+ {
12
+ public function newAction()
13
+ {
14
+ if ($this->getRequest()->isPost() && $this->getRequest()->getPost('email')) {
15
+ $session = Mage::getSingleton('core/session');
16
+ $customerSession = Mage::getSingleton('customer/session');
17
+ $email = (string) $this->getRequest()->getPost('email');
18
+
19
+ try {
20
+ if (!Zend_Validate::is($email, 'EmailAddress')) {
21
+ Mage::throwException($this->__('Please enter a valid email address.'));
22
+ }
23
+
24
+ if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 &&
25
+ !$customerSession->isLoggedIn()) {
26
+ Mage::throwException($this->__('Sorry, but administrator denied subscription for guests. Please <a href="%s">register</a>.', Mage::helper('customer')->getRegisterUrl()));
27
+ }
28
+
29
+ $ownerId = Mage::getModel('customer/customer')
30
+ ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
31
+ ->loadByEmail($email)
32
+ ->getId();
33
+ if ($ownerId !== null && $ownerId != $customerSession->getId()) {
34
+ Mage::throwException($this->__('This email address is already assigned to another user.'));
35
+ }
36
+
37
+ $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
38
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
39
+ $session->addSuccess($this->__('Confirmation request has been sent.'));
40
+ }
41
+ else {
42
+ $session->addSuccess($this->__('Thank you for your subscription.'));
43
+
44
+ // add event dispatcher to raise event after news letter subscribe
45
+ // this change is made to manage INinbox.com Contacts/List
46
+ $data = array('email' => $email);
47
+ Mage::dispatchEvent('newsletter_subscribe_after', $data);
48
+ }
49
+ }
50
+ catch (Mage_Core_Exception $e) {
51
+ $session->addException($e, $this->__('There was a problem with the subscription: %s', $e->getMessage()));
52
+ }
53
+ catch (Exception $e) {
54
+ $session->addException($e, $this->__('There was a problem with the subscription.'));
55
+ }
56
+ }
57
+ $this->_redirectReferer();
58
+ }
59
+ }
app/code/local/Ininbox/Emailmarketing/etc/config.xml ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <modules>
4
+ <Ininbox_Emailmarketing>
5
+ <version>1.2.0</version>
6
+ </Ininbox_Emailmarketing>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <emailmarketing>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Ininbox_Emailmarketing</module>
14
+ <frontName>emailmarketing</frontName>
15
+ </args>
16
+ </emailmarketing>
17
+ <newsletter>
18
+ <args>
19
+ <modules>
20
+ <ininbox_emailmarketing before="Mage_Newsletter_SubscriberController">Ininbox_Emailmarketing</ininbox_emailmarketing>
21
+ <ininbox_emailmarketing before="Mage_Newsletter_ManageController">Ininbox_Emailmarketing</ininbox_emailmarketing>
22
+ </modules>
23
+ </args>
24
+ </newsletter>
25
+ <customer>
26
+ <args>
27
+ <modules>
28
+ <ininbox_emailmarketing before="Mage_Customer_AccountController">Ininbox_Emailmarketing</ininbox_emailmarketing>
29
+ </modules>
30
+ </args>
31
+ </customer>
32
+ </routers>
33
+ </frontend>
34
+ <admin>
35
+ <routers>
36
+ <emailmarketing>
37
+ <use>admin</use>
38
+ <args>
39
+ <module>Ininbox_Emailmarketing</module>
40
+ <frontName>admin_emailmarketing</frontName>
41
+ </args>
42
+ </emailmarketing>
43
+ <adminhtml>
44
+ <args>
45
+ <modules>
46
+ <ininbox_emailmarketing_adminhtml before="Mage_Adminhtml_CustomerController">Ininbox_Emailmarketing_Adminhtml</ininbox_emailmarketing_adminhtml>
47
+ </modules>
48
+ </args>
49
+ </adminhtml>
50
+ </routers>
51
+ </admin>
52
+ <global>
53
+ <models>
54
+ <emailmarketing>
55
+ <class>Ininbox_Emailmarketing_Model</class>
56
+ </emailmarketing>
57
+ </models>
58
+ <resources>
59
+ <emailmarketing_setup>
60
+ <setup>
61
+ <module>Ininbox_Emailmarketing</module>
62
+ </setup>
63
+ <connection>
64
+ <use>core_setup</use>
65
+ </connection>
66
+ </emailmarketing_setup>
67
+ <emailmarketing_write>
68
+ <connection>
69
+ <use>core_write</use>
70
+ </connection>
71
+ </emailmarketing_write>
72
+ <emailmarketing_read>
73
+ <connection>
74
+ <use>core_read</use>
75
+ </connection>
76
+ </emailmarketing_read>
77
+ </resources>
78
+ <blocks>
79
+ <emailmarketing>
80
+ <class>Ininbox_Emailmarketing_Block</class>
81
+ </emailmarketing>
82
+ <adminhtml>
83
+ <rewrite>
84
+ <customer_grid>Ininbox_Emailmarketing_Block_Adminhtml_Customer_Grid</customer_grid>
85
+ <newsletter_subscriber_grid>Ininbox_Emailmarketing_Block_Adminhtml_Newsletter_Subscriber_Grid</newsletter_subscriber_grid>
86
+ <sales_order_grid>Ininbox_Emailmarketing_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
87
+ <page_menu>Ininbox_Emailmarketing_Block_Adminhtml_Menu</page_menu>
88
+ </rewrite>
89
+ </adminhtml>
90
+ </blocks>
91
+ <helpers>
92
+ <emailmarketing>
93
+ <class>Ininbox_Emailmarketing_Helper</class>
94
+ </emailmarketing>
95
+ </helpers>
96
+ <events>
97
+ <customer_register_success><!-- Default Event -->
98
+ <observers>
99
+ <Ininbox_Emailmarketing_Model_Observer>
100
+ <type>singleton</type>
101
+ <class>Ininbox_Emailmarketing_Model_Observer</class>
102
+ <method>customerSaveObserver</method>
103
+ </Ininbox_Emailmarketing_Model_Observer>
104
+ </observers>
105
+ </customer_register_success>
106
+ <adminhtml_customer_save_after><!-- Default Event -->
107
+ <observers>
108
+ <Ininbox_Emailmarketing_Model_Observer>
109
+ <type>singleton</type>
110
+ <class>Ininbox_Emailmarketing_Model_Observer</class>
111
+ <method>customerSaveObserver</method>
112
+ </Ininbox_Emailmarketing_Model_Observer>
113
+ </observers>
114
+ </adminhtml_customer_save_after>
115
+ <sales_order_place_after><!-- Default Event -->
116
+ <observers>
117
+ <Ininbox_Emailmarketing_Model_Observer>
118
+ <type>singleton</type>
119
+ <class>Ininbox_Emailmarketing_Model_Observer</class>
120
+ <method>salesOrderPlaceAfterObserver</method>
121
+ </Ininbox_Emailmarketing_Model_Observer>
122
+ </observers>
123
+ </sales_order_place_after>
124
+ <sales_order_save_after><!-- Default Event -->
125
+ <observers>
126
+ <Ininbox_Emailmarketing_Model_Observer>
127
+ <type>singleton</type>
128
+ <class>Ininbox_Emailmarketing_Model_Observer</class>
129
+ <method>salesOrderPlaceAfterObserver</method>
130
+ </Ininbox_Emailmarketing_Model_Observer>
131
+ </observers>
132
+ </sales_order_save_after>
133
+ <newsletter_subscribe_after>
134
+ <observers>
135
+ <Ininbox_Emailmarketing_Model_Observer>
136
+ <type>singleton</type>
137
+ <class>Ininbox_Emailmarketing_Model_Observer</class>
138
+ <method>newsletterSubscribeAfterObserver</method>
139
+ </Ininbox_Emailmarketing_Model_Observer>
140
+ </observers>
141
+ </newsletter_subscribe_after>
142
+ <customer_account_edit_after>
143
+ <observers>
144
+ <Ininbox_Emailmarketing_Model_Observer>
145
+ <type>singleton</type>
146
+ <class>Ininbox_Emailmarketing_Model_Observer</class>
147
+ <method>customerAccountEditAfterObserver</method>
148
+ </Ininbox_Emailmarketing_Model_Observer>
149
+ </observers>
150
+ </customer_account_edit_after>
151
+ <customer_newsletter_subscribe_after>
152
+ <observers>
153
+ <Ininbox_Emailmarketing_Model_Observer>
154
+ <type>singleton</type>
155
+ <class>Ininbox_Emailmarketing_Model_Observer</class>
156
+ <method>customerNewsletterSubscribeAfterObserver</method>
157
+ </Ininbox_Emailmarketing_Model_Observer>
158
+ </observers>
159
+ </customer_newsletter_subscribe_after>
160
+ </events>
161
+ </global>
162
+ <adminhtml>
163
+ <menu>
164
+ <ininbox translate="title" module="adminhtml">
165
+ <title>INinbox</title>
166
+ <sort_order>90</sort_order>
167
+ <children>
168
+ <emailmarketing>
169
+ <title>Email Marketing Settings</title>
170
+ <action>adminhtml/system_config/edit/section/emailmarketing_options</action>
171
+ </emailmarketing>
172
+ <ininboxlogin>
173
+ <title>INinbox Login</title>
174
+ </ininboxlogin>
175
+ <inspiredsupport>
176
+ <title>INspired Support</title>
177
+ </inspiredsupport>
178
+ </children>
179
+ </ininbox>
180
+ </menu>
181
+ <acl>
182
+ <resources>
183
+ <admin>
184
+ <children>
185
+ <system>
186
+ <children>
187
+ <config>
188
+ <children>
189
+ <emailmarketing_options>
190
+ <title>Email Marketing Module Section</title>
191
+ </emailmarketing_options>
192
+ </children>
193
+ </config>
194
+ </children>
195
+ </system>
196
+ </children>
197
+ </admin>
198
+ </resources>
199
+ </acl>
200
+ </adminhtml>
201
+ <default>
202
+ <emailmarketing_options>
203
+ <general>
204
+ <url>http://api.ininbox.com/v1/</url>
205
+ </general>
206
+ </emailmarketing_options>
207
+ </default>
208
+ </config>
app/code/local/Ininbox/Emailmarketing/etc/system.xml ADDED
@@ -0,0 +1,404 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <emailmarketing_options translate="label" module="emailmarketing">
5
+ <class>separator-top</class>
6
+ <tab>customer</tab>
7
+ <label><![CDATA[<span id="ininbox_tab_options">Email Marketing</span><script>if($('ininbox_tab_options').up().hasClassName('active')) $('ininbox_tab_options').up().setStyle('background:#666;color:#fff;'); else $('ininbox_tab_options').up().setStyle('background:#333;color:#fff;'); $('ininbox_tab_options').setStyle('background-image: url("' + SKIN_URL + 'images/ininbox/ininbox.png"); padding: 1px 0px 0px 68px; background-color: transparent; background-size:62px 14px; background-position: 0px 2px; background-repeat: no-repeat no-repeat;');</script>]]></label>
8
+ <sort_order>700</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <groups>
12
+ <general translate="label">
13
+ <label>General information</label>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>1</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <fields>
19
+ <enabled translate="label">
20
+ <label>Enabled: </label>
21
+ <comment>
22
+ Select 'YES' will enable this extension for this Magento Store.
23
+ <![CDATA[
24
+ <script type="text/javascript">
25
+ checkGeneralConfig = function() {
26
+ var emailmarketing_enabled = $('emailmarketing_options_general_enabled').getValue();
27
+ var emailmarketing_url = $('emailmarketing_options_general_url').getValue();
28
+ var emailmarketing_key = $('emailmarketing_options_general_key').getValue();
29
+ if(emailmarketing_enabled == 0 || emailmarketing_url == '' || emailmarketing_key == '')
30
+ {
31
+ $('emailmarketing_options_list').up().hide();
32
+ $('emailmarketing_options_miscellaneous').up().hide();
33
+ $('emailmarketing_options_field_mapping').up().hide();
34
+ }
35
+ }
36
+ Event.observe(window, 'load', function() {
37
+ checkGeneralConfig();
38
+ })
39
+ </script>
40
+ ]]>
41
+ </comment>
42
+ <frontend_type>select</frontend_type>
43
+ <sort_order>1</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <source_model>adminhtml/system_config_source_yesno</source_model>
47
+ </enabled>
48
+ <url translate="label">
49
+ <label>INinbox API Url: </label>
50
+ <comment>This url will help extension to connect to INinbox
51
+ API.</comment>
52
+ <frontend_type>text</frontend_type>
53
+ <sort_order>2</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <depends>
57
+ <enabled>1</enabled>
58
+ </depends>
59
+ </url>
60
+ <key translate="label">
61
+ <label>INinbox Key: </label>
62
+ <comment>This key will help the extension to connect to your INinbox account. You can get this key from INinbox.com >> Account settings >> API</comment>
63
+ <frontend_type>text</frontend_type>
64
+ <sort_order>3</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <depends>
68
+ <enabled>1</enabled>
69
+ </depends>
70
+ </key>
71
+ </fields>
72
+ </general>
73
+ <customer_settings translate="label">
74
+ <label>Customer Settings</label>
75
+ <frontend_type>text</frontend_type>
76
+ <sort_order>2</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <fields>
80
+ <send_customer translate="label">
81
+ <label>Send Customer: </label>
82
+ <comment>Select 'YES' will add new customer accounts to a list of choice.</comment>
83
+ <frontend_type>select</frontend_type>
84
+ <sort_order>1</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <source_model>adminhtml/system_config_source_yesno</source_model>
88
+ </send_customer>
89
+ <customer_group_list translate="label">
90
+ <label>Customer Group List: </label>
91
+ <comment>Select the list where you want to add new customer account contacts.</comment>
92
+ <frontend_type>select</frontend_type>
93
+ <sort_order>2</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <source_model>emailmarketing/system_config_source_group_list
97
+ </source_model>
98
+ <depends>
99
+ <send_customer>1</send_customer>
100
+ </depends>
101
+ </customer_group_list>
102
+ </fields>
103
+ </customer_settings>
104
+ <customer_misc_settings translate="label">
105
+ <label>Customer Miscellaneous Settings</label>
106
+ <frontend_type>text</frontend_type>
107
+ <sort_order>3</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>1</show_in_website>
110
+ <fields>
111
+ <confirm_email translate="label">
112
+ <label>Confirmation Email (for double optin lists): </label>
113
+ <comment>Select 'YES' will send the confirmation email when the list is set to double optin. For single optin no mail will be send.</comment>
114
+ <frontend_type>select</frontend_type>
115
+ <sort_order>1</sort_order>
116
+ <show_in_default>1</show_in_default>
117
+ <show_in_website>1</show_in_website>
118
+ <source_model>adminhtml/system_config_source_yesno</source_model>
119
+ </confirm_email>
120
+ <update_subscriber translate="label">
121
+ <label>Update existing subscriber: </label>
122
+ <comment>Select 'YES' will allow to update existing subscriber.</comment>
123
+ <frontend_type>select</frontend_type>
124
+ <sort_order>2</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <source_model>adminhtml/system_config_source_yesno</source_model>
128
+ </update_subscriber>
129
+ <send_autoresponder translate="label">
130
+ <label>Send Autoresponders: </label>
131
+ <comment>Select 'YES' will add contacts to the autoresponder cycle.</comment>
132
+ <frontend_type>select</frontend_type>
133
+ <sort_order>3</sort_order>
134
+ <show_in_default>1</show_in_default>
135
+ <show_in_website>1</show_in_website>
136
+ <source_model>adminhtml/system_config_source_yesno</source_model>
137
+ </send_autoresponder>
138
+ </fields>
139
+ </customer_misc_settings>
140
+ <customer_massaction_settings translate="label">
141
+ <label>Customer Miscellaneous Massaction Settings</label>
142
+ <frontend_type>text</frontend_type>
143
+ <sort_order>4</sort_order>
144
+ <show_in_default>1</show_in_default>
145
+ <show_in_website>1</show_in_website>
146
+ <fields>
147
+ <confirm_email translate="label">
148
+ <label>Confirmation Email (for double optin lists): </label>
149
+ <comment>Select 'YES' will send the confirmation email when the list is set to double optin. For single optin no mail will be send.</comment>
150
+ <frontend_type>select</frontend_type>
151
+ <sort_order>1</sort_order>
152
+ <show_in_default>1</show_in_default>
153
+ <show_in_website>1</show_in_website>
154
+ <source_model>adminhtml/system_config_source_yesno</source_model>
155
+ </confirm_email>
156
+ <update_subscriber translate="label">
157
+ <label>Update existing subscriber: </label>
158
+ <comment>Select 'YES' will allow to update existing subscriber.</comment>
159
+ <frontend_type>select</frontend_type>
160
+ <sort_order>2</sort_order>
161
+ <show_in_default>1</show_in_default>
162
+ <show_in_website>1</show_in_website>
163
+ <source_model>adminhtml/system_config_source_yesno</source_model>
164
+ </update_subscriber>
165
+ <send_autoresponder translate="label">
166
+ <label>Send Autoresponders: </label>
167
+ <comment>Select 'YES' will add contacts to the autoresponder cycle.</comment>
168
+ <frontend_type>select</frontend_type>
169
+ <sort_order>3</sort_order>
170
+ <show_in_default>1</show_in_default>
171
+ <show_in_website>1</show_in_website>
172
+ <source_model>adminhtml/system_config_source_yesno</source_model>
173
+ </send_autoresponder>
174
+ </fields>
175
+ </customer_massaction_settings>
176
+ <order_settings translate="label">
177
+ <label>Order Settings</label>
178
+ <frontend_type>text</frontend_type>
179
+ <sort_order>5</sort_order>
180
+ <show_in_default>1</show_in_default>
181
+ <show_in_website>1</show_in_website>
182
+ <fields>
183
+ <send_order translate="label">
184
+ <label>Send Order: </label>
185
+ <comment>Select 'YES' will add new orders to a list of choice.</comment>
186
+ <frontend_type>select</frontend_type>
187
+ <sort_order>1</sort_order>
188
+ <show_in_default>1</show_in_default>
189
+ <show_in_website>1</show_in_website>
190
+ <source_model>adminhtml/system_config_source_yesno</source_model>
191
+ </send_order>
192
+ <order_group_list translate="label">
193
+ <label>Order Group List: </label>
194
+ <comment>Select the list where you want to add contacts that order.</comment>
195
+ <frontend_type>select</frontend_type>
196
+ <sort_order>2</sort_order>
197
+ <show_in_default>1</show_in_default>
198
+ <show_in_website>1</show_in_website>
199
+ <source_model>emailmarketing/system_config_source_group_list
200
+ </source_model>
201
+ <depends>
202
+ <send_order>1</send_order>
203
+ </depends>
204
+ </order_group_list>
205
+ </fields>
206
+ </order_settings>
207
+ <order_misc_settings translate="label">
208
+ <label>Order Miscellaneous Settings</label>
209
+ <frontend_type>text</frontend_type>
210
+ <sort_order>6</sort_order>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>1</show_in_website>
213
+ <fields>
214
+ <confirm_email translate="label">
215
+ <label>Confirmation Email (for double optin lists): </label>
216
+ <comment>Select 'YES' will send the confirmation email when the list is set to double optin. For single optin no mail will be send.</comment>
217
+ <frontend_type>select</frontend_type>
218
+ <sort_order>1</sort_order>
219
+ <show_in_default>1</show_in_default>
220
+ <show_in_website>1</show_in_website>
221
+ <source_model>adminhtml/system_config_source_yesno</source_model>
222
+ </confirm_email>
223
+ <update_subscriber translate="label">
224
+ <label>Update existing subscriber: </label>
225
+ <comment>Select 'YES' will allow to update existing subscriber.</comment>
226
+ <frontend_type>select</frontend_type>
227
+ <sort_order>2</sort_order>
228
+ <show_in_default>1</show_in_default>
229
+ <show_in_website>1</show_in_website>
230
+ <source_model>adminhtml/system_config_source_yesno</source_model>
231
+ </update_subscriber>
232
+ <send_autoresponder translate="label">
233
+ <label>Send Autoresponders: </label>
234
+ <comment>Select 'YES' will add contacts to the autoresponder cycle.</comment>
235
+ <frontend_type>select</frontend_type>
236
+ <sort_order>3</sort_order>
237
+ <show_in_default>1</show_in_default>
238
+ <show_in_website>1</show_in_website>
239
+ <source_model>adminhtml/system_config_source_yesno</source_model>
240
+ </send_autoresponder>
241
+ </fields>
242
+ </order_misc_settings>
243
+ <order_massaction_settings translate="label">
244
+ <label>Order Miscellaneous Massaction Settings</label>
245
+ <frontend_type>text</frontend_type>
246
+ <sort_order>7</sort_order>
247
+ <show_in_default>1</show_in_default>
248
+ <show_in_website>1</show_in_website>
249
+ <fields>
250
+ <confirm_email translate="label">
251
+ <label>Confirmation Email (for double optin lists): </label>
252
+ <comment>Select 'YES' will send the confirmation email when the list is set to double optin. For single optin no mail will be send.</comment>
253
+ <frontend_type>select</frontend_type>
254
+ <sort_order>1</sort_order>
255
+ <show_in_default>1</show_in_default>
256
+ <show_in_website>1</show_in_website>
257
+ <source_model>adminhtml/system_config_source_yesno</source_model>
258
+ </confirm_email>
259
+ <update_subscriber translate="label">
260
+ <label>Update existing subscriber: </label>
261
+ <comment>Select 'YES' will allow to update existing subscriber.</comment>
262
+ <frontend_type>select</frontend_type>
263
+ <sort_order>2</sort_order>
264
+ <show_in_default>1</show_in_default>
265
+ <show_in_website>1</show_in_website>
266
+ <source_model>adminhtml/system_config_source_yesno</source_model>
267
+ </update_subscriber>
268
+ <send_autoresponder translate="label">
269
+ <label>Send Autoresponders: </label>
270
+ <comment>Select 'YES' will add contacts to the autoresponder cycle.</comment>
271
+ <frontend_type>select</frontend_type>
272
+ <sort_order>3</sort_order>
273
+ <show_in_default>1</show_in_default>
274
+ <show_in_website>1</show_in_website>
275
+ <source_model>adminhtml/system_config_source_yesno</source_model>
276
+ </send_autoresponder>
277
+ </fields>
278
+ </order_massaction_settings>
279
+ <newsletter_settings translate="label">
280
+ <label>Newsletter Settings</label>
281
+ <frontend_type>text</frontend_type>
282
+ <sort_order>8</sort_order>
283
+ <show_in_default>1</show_in_default>
284
+ <show_in_website>1</show_in_website>
285
+ <fields>
286
+ <send_subscriber translate="label">
287
+ <label>Send Newsletter Subscriber: </label>
288
+ <comment>Select 'YES' will add new subscribers to a list of choice.</comment>
289
+ <frontend_type>select</frontend_type>
290
+ <sort_order>1</sort_order>
291
+ <show_in_default>1</show_in_default>
292
+ <show_in_website>1</show_in_website>
293
+ <source_model>adminhtml/system_config_source_yesno</source_model>
294
+ </send_subscriber>
295
+ <subscriber_group_list translate="label">
296
+ <label>Newsletter Subscriber Group List: </label>
297
+ <comment>Select the list where you want to add new subscribers.</comment>
298
+ <frontend_type>select</frontend_type>
299
+ <sort_order>2</sort_order>
300
+ <show_in_default>1</show_in_default>
301
+ <show_in_website>1</show_in_website>
302
+ <source_model>emailmarketing/system_config_source_group_list
303
+ </source_model>
304
+ <depends>
305
+ <send_subscriber>1</send_subscriber>
306
+ </depends>
307
+ </subscriber_group_list>
308
+ </fields>
309
+ </newsletter_settings>
310
+ <newsletter_misc_settings translate="label">
311
+ <label>Newsletter Miscellaneous Settings</label>
312
+ <frontend_type>text</frontend_type>
313
+ <sort_order>9</sort_order>
314
+ <show_in_default>1</show_in_default>
315
+ <show_in_website>1</show_in_website>
316
+ <fields>
317
+ <confirm_email translate="label">
318
+ <label>Confirmation Email (for double optin lists): </label>
319
+ <comment>Select 'YES' will send the confirmation email when the list is set to double optin. For single optin no mail will be send.</comment>
320
+ <frontend_type>select</frontend_type>
321
+ <sort_order>1</sort_order>
322
+ <show_in_default>1</show_in_default>
323
+ <show_in_website>1</show_in_website>
324
+ <source_model>adminhtml/system_config_source_yesno</source_model>
325
+ </confirm_email>
326
+ <update_subscriber translate="label">
327
+ <label>Update existing subscriber: </label>
328
+ <comment>Select 'YES' will allow to update existing subscriber.</comment>
329
+ <frontend_type>select</frontend_type>
330
+ <sort_order>2</sort_order>
331
+ <show_in_default>1</show_in_default>
332
+ <show_in_website>1</show_in_website>
333
+ <source_model>adminhtml/system_config_source_yesno</source_model>
334
+ </update_subscriber>
335
+ <send_autoresponder translate="label">
336
+ <label>Send Autoresponders: </label>
337
+ <comment>Select 'YES' will add contacts to the autoresponder cycle.</comment>
338
+ <frontend_type>select</frontend_type>
339
+ <sort_order>3</sort_order>
340
+ <show_in_default>1</show_in_default>
341
+ <show_in_website>1</show_in_website>
342
+ <source_model>adminhtml/system_config_source_yesno</source_model>
343
+ </send_autoresponder>
344
+ </fields>
345
+ </newsletter_misc_settings>
346
+ <newsletter_massaction_settings translate="label">
347
+ <label>Newsletter Miscellaneous Massaction Settings</label>
348
+ <frontend_type>text</frontend_type>
349
+ <sort_order>10</sort_order>
350
+ <show_in_default>1</show_in_default>
351
+ <show_in_website>1</show_in_website>
352
+ <fields>
353
+ <confirm_email translate="label">
354
+ <label>Confirmation Email (for double optin lists): </label>
355
+ <comment>Select 'YES' will send the confirmation email when the list is set to double optin. For single optin no mail will be send.</comment>
356
+ <frontend_type>select</frontend_type>
357
+ <sort_order>1</sort_order>
358
+ <show_in_default>1</show_in_default>
359
+ <show_in_website>1</show_in_website>
360
+ <source_model>adminhtml/system_config_source_yesno</source_model>
361
+ </confirm_email>
362
+ <update_subscriber translate="label">
363
+ <label>Update existing subscriber: </label>
364
+ <comment>Select 'YES' will allow to update existing subscriber.</comment>
365
+ <frontend_type>select</frontend_type>
366
+ <sort_order>2</sort_order>
367
+ <show_in_default>1</show_in_default>
368
+ <show_in_website>1</show_in_website>
369
+ <source_model>adminhtml/system_config_source_yesno</source_model>
370
+ </update_subscriber>
371
+ <send_autoresponder translate="label">
372
+ <label>Send Autoresponders: </label>
373
+ <comment>Select 'YES' will add contacts to the autoresponder cycle.</comment>
374
+ <frontend_type>select</frontend_type>
375
+ <sort_order>3</sort_order>
376
+ <show_in_default>1</show_in_default>
377
+ <show_in_website>1</show_in_website>
378
+ <source_model>adminhtml/system_config_source_yesno</source_model>
379
+ </send_autoresponder>
380
+ </fields>
381
+ </newsletter_massaction_settings>
382
+ <field_mapping translate="label">
383
+ <label>Field Mapping</label>
384
+ <frontend_type>text</frontend_type>
385
+ <sort_order>11</sort_order>
386
+ <show_in_default>1</show_in_default>
387
+ <show_in_website>1</show_in_website>
388
+ <fields>
389
+                         <field translate="label">
390
+                             <label>Fields</label>
391
+ <comment>In INinbox the "email" field is a mandatory field. For all other fields it's your choice whether you want to send them to INInbox as well. Set up proper fieldmapping to tell INinbox which fields contain which values.</comment>
392
+ <frontend_model>emailmarketing/field</frontend_model>
393
+                             <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
394
+                             <source_model>emailmarketing/system_config_source_field_list</source_model>
395
+                             <sort_order>1</sort_order>
396
+                             <show_in_default>1</show_in_default>
397
+                             <show_in_website>1</show_in_website>
398
+                         </field>
399
+                     </fields>
400
+ </field_mapping>
401
+ </groups>
402
+ </emailmarketing_options>
403
+ </sections>
404
+ </config>
app/code/local/Ininbox/Emailmarketing/sql/emailmarketing_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * INinbox Email Marketing
4
+ * @category INinbox
5
+ * @package INinbox_Emailmarketing
6
+ **/
7
+ $installer = $this;
8
+ $installer->startSetup();
9
+
10
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
11
+
12
+ $entityTypeId = $setup->getEntityTypeId('customer');
13
+ $attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
14
+ $attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
15
+
16
+ $setup->addAttribute('customer', 'ininbox_contact_id', array(
17
+ 'input' => 'text',
18
+ 'type' => 'varchar',
19
+ 'label' => 'INinbox Contact ID',
20
+ 'visible' => 0,
21
+ 'required' => 0,
22
+ 'user_defined' => 1,
23
+ ));
24
+
25
+ $setup->addAttributeToGroup(
26
+ $entityTypeId,
27
+ $attributeSetId,
28
+ $attributeGroupId,
29
+ 'ininbox_contact_id',
30
+ '999' //sort_order
31
+ );
32
+
33
+ $oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'ininbox_contact_id');
34
+ $oAttribute->setData('used_in_forms', array('customer_account_create','customer_account_edit'));
35
+ $oAttribute->save();
36
+
37
+ $installer->endSetup();
38
+ ?>
app/etc/modules/Ininbox_Emailmarketing.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <modules>
4
+ <Ininbox_Emailmarketing>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Ininbox_Emailmarketing>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>INinbox_Emailmarketing</name>
4
+ <version>1.2.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Easily send beautiful newsletters, Upload your contacts and access them whenever you are ready to mail!</summary>
10
+ <description> &#xD;
11
+ &lt;p&gt;Nearly every business depends on email marketing, but most software is complex. That's why we created a platform that makes email marketing EASY!&lt;/p&gt;&#xD;
12
+ &#xD;
13
+ &lt;p&gt;Check our advanced email marketing features made easy, so you can save time, save money, and run your business.&lt;/p&gt;&#xD;
14
+ &#xD;
15
+ &#xD;
16
+ &lt;a href="http://www.ininbox.com/feature-email-marketing.html" title="Learn More About Email Marketing Features"&gt;Check All The Email Marketing Features &gt;&gt;&lt;/a&gt;&#xD;
17
+ &#xD;
18
+ &#xD;
19
+ </description>
20
+ <notes>First Preview Release</notes>
21
+ <authors><author><name>INinbox.com</name><user>ininbox</user><email>support@ininbox.com</email></author></authors>
22
+ <date>2014-03-11</date>
23
+ <time>07:06:33</time>
24
+ <contents><target name="magelocal"><dir name="Ininbox"><dir name="Emailmarketing"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><file name="Grid.php" hash="86d1a54eae6be39062ba283dded1fc74"/></dir><file name="Menu.php" hash="d4392133285bca70425219a11ca073e0"/><dir name="Newsletter"><dir name="Subscriber"><file name="Grid.php" hash="181d4c1264cec1046c3fce78959fd170"/></dir></dir><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="26bb2b0670797ad9f00313efd3a40c6d"/></dir></dir></dir><file name="Field.php" hash="beed8fad3c2700554d81d56b06f2b84f"/><file name="Select.php" hash="d116f5d18322d15def9f41416c489cc9"/></dir><dir name="Helper"><file name="Data.php" hash="55b7012b702983c517697253179913d6"/></dir><dir name="Model"><dir name="Ininbox"><file name="Base.php" hash="6c86ed40cc1ed97995b79e6a78fecd3a"/><file name="Contact.php" hash="31080fd8673982c563c67c6265947fb8"/><file name="Customfield.php" hash="4d17ba0bd7750bc80c3b7fee71838d15"/><file name="Group.php" hash="901d6a5a34c3ef49b7ab518eb276d0bd"/></dir><file name="Observer.php" hash="1bf0907f2bd1c4fc963ecc9afcf4ba4c"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Customer"><file name="Attribute.php" hash="b087317b0ec0479bb06b6f5492ec2ea3"/></dir><dir name="Field"><file name="List.php" hash="cc8841df42c51ccfa5167d718635683b"/></dir><dir name="Group"><file name="List.php" hash="ecbc9d7c8ead7301616570025761957f"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="AccountController.php" hash="7ef76d434c3f9a29724ec53176ac06f4"/><dir name="Adminhtml"><file name="CustomerController.php" hash="f55eda498c79e532f931b2b6a25f2c1f"/><file name="MassactionController.php" hash="d69f16f0e3fbab11b3ad1169a2a0e26f"/></dir><file name="ManageController.php" hash="a1afb00c33151ca164ce6a69d08d276f"/><file name="SubscriberController.php" hash="c1ccc8f3c75be9de1f3b2e26a7f730c8"/></dir><dir name="etc"><file name="config.xml" hash="e3c1b48e062e052e341cebabbcb538dc"/><file name="system.xml" hash="fa79b74b507b7ac496aedae1456e5710"/></dir><dir name="sql"><dir name="emailmarketing_setup"><file name="mysql4-install-0.1.0.php" hash="90441bd504fcde8f0a292e53385ccd53"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ininbox_Emailmarketing.xml" hash="ad90bc3dde0b7f34463702f9e8e8041d"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="ininbox"><file name="ininbox.png" hash="ad2cecd7c657e4bd2c6d9f99f60389d2"/></dir></dir></dir></dir></dir></target></contents>
25
+ <compatible/>
26
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
27
+ </package>
skin/adminhtml/default/default/images/ininbox/ininbox.png ADDED
Binary file