Message_Mate_by_OL - Version 1.0.0

Version Notes

Stable release

Download this release

Release Info

Developer Niv Caner
Extension Message_Mate_by_OL
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Ownerlistens/Messagemate/Block/MessagemateJs.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Ownerlistens_Messagemate_Block_MessagemateJs extends Mage_Core_Block_Template
3
+ {
4
+ /**/
5
+ }
app/code/community/Ownerlistens/Messagemate/Helper/Data.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php class Ownerlistens_Messagemate_Helper_Data extends Mage_Core_Helper_Abstract { }
app/code/community/Ownerlistens/Messagemate/controllers/Adminhtml/OwnerlistensmessagemateController.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ownerlistens_Messagemate_Adminhtml_OwnerlistensmessagemateController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ public function indexAction()
6
+ {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('ownerlistens')
9
+ ->_title($this->__('Index Action'));
10
+
11
+ $mag_id = Mage::getStoreConfig('ownerlistens/config/mag_id');
12
+ $mag_url = Mage::getBaseUrl();
13
+ $mail = '';
14
+ try {
15
+ $mail = Mage::getStoreConfig('trans_email/ident_general/email');
16
+ } catch (Exception $e) {
17
+ // do nothing
18
+ }
19
+ $phone = '';
20
+ try {
21
+ $phone = Mage::getStoreConfig('general/store_information/phone');
22
+ } catch (Exception $e) {
23
+ // do nothing
24
+ }
25
+ $iframe_src = "//ownerlistens.com/magento/message_mate/";
26
+ $iframe_src_params = "$iframe_src?mag_id=$mag_id&mag_url=$mag_url";
27
+ if ($mail) $iframe_src_params .= "&em=$mail";
28
+ if ($phone) $iframe_src_params .= "&ph=$phone";
29
+ $html = "
30
+ <script type='text/javascript'>
31
+ var ol_handshake = setInterval(function () {
32
+ var message = 'magento_message_mate_' + window.location.href;
33
+ console.log('OwnerListens Message Mate: sending message: ' + message); //for debugging
34
+ var target_url = /^https/.test(document.getElementById('ol_message_mate').src) ?
35
+ 'https://ownerlistens.com/magento/message_mate' : 'http://ownerlistens.com/magento/message_mate';
36
+ var iframe = document.getElementById('ol_message_mate').contentWindow;
37
+ iframe.postMessage(message, target_url); //send the message and target URI
38
+ }, 2000);
39
+
40
+ window.addEventListener('message',function(ev) {
41
+ if (
42
+ ev.origin !== 'http://demo.ownerlistens.com' && ev.origin !== 'http://ownerlistens.com' &&
43
+ ev.origin !== 'https://demo.ownerlistens.com' && ev.origin !== 'https://ownerlistens.com'
44
+ ) return;
45
+ console.log('Received msg from OwnerListens: ' + ev.data);
46
+ if(ev.data === 'magento handshake successful'){
47
+ clearInterval(ol_handshake);
48
+ return;
49
+ }
50
+ // ev.data is the script tag you should inject into the magento store
51
+ var url = '" . Mage::helper('adminhtml')->getUrl('/ownerlistensmessagemate/savescript') . "';
52
+ ajax(url, function(text, transport) {
53
+ var response = transport.responseText || 'result=failed&msg=Unexpected error';
54
+ var resp = parseQstr(response);
55
+ if (resp['result'] == 'success') {
56
+ var target_url = /^https/.test(document.getElementById('ol_message_mate').src) ?
57
+ 'https://ownerlistens.com/magento/message_mate' : 'http://ownerlistens.com/magento/message_mate';
58
+ var iframe = document.getElementById('ol_message_mate').contentWindow;
59
+ iframe.postMessage('magento_message_mate success', target_url);
60
+ } else {
61
+ alert('Failed to save due to some server-side problem: ' + resp['msg']);
62
+ }
63
+ }, 'mage_mate=' + encodeURIComponent(ev.data) + '&form_key=" . Mage::getSingleton("core/session")->getFormKey() . "', null);
64
+ });
65
+ function parseQstr(qstr) {
66
+ var obj = {};
67
+ var arr = qstr.split('&');
68
+ for (var i = 0; i <= arr.length; ++i) {
69
+ try {
70
+ arr[i] = arr[i].split('=');
71
+ obj[arr[i][0]] = arr[i][1];
72
+ } catch (e) {
73
+ // do nothing
74
+ }
75
+ }
76
+ return obj;
77
+ }
78
+ function ajax(url, callback, data, x) {
79
+ try {
80
+ x = new(this.XMLHttpRequest || ActiveXObject)('MSXML2.XMLHTTP.3.0');
81
+ x.open(data ? 'POST' : 'GET', url, 1);
82
+ x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
83
+ x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
84
+ x.onreadystatechange = function () {
85
+ x.readyState > 3 && callback && callback(x.responseText, x);
86
+ };
87
+ x.send(data)
88
+ } catch (e) {
89
+ window.console && console.log(e);
90
+ }
91
+ };
92
+ </script>
93
+ <iframe id='ol_message_mate' style='width:100%;height:80vh;border:none;' src='$iframe_src_params'></iframe>
94
+ ";
95
+
96
+ $block = $this->getLayout()
97
+ ->createBlock('core/text')
98
+ ->setText($html);
99
+ $this->_addContent($block);
100
+
101
+ $this->renderLayout();
102
+ }
103
+
104
+ public function saveScriptAction()
105
+ {
106
+ error_log('Save called!');
107
+ $this->getResponse()->setHeader('Content-type', 'text/plain');
108
+ $mate = $this->getRequest()->getParam('mage_mate');
109
+ try {
110
+ error_log('Trying to update: ' . $mate);
111
+ $resource = new Mage_Core_Model_Config();
112
+ $resource->saveConfig('ownerlistens/config/message_mate', $mate, 'default', 0);
113
+ Mage::app()->cleanCache();
114
+ $this->getResponse()->setBody('result=success');
115
+ } catch (Exception $e) {
116
+ error_log('Exception thrown!');
117
+ $this->getResponse()->setBody('result=fail&msg=' . $e->getMessage());
118
+ }
119
+ }
120
+ }
app/code/community/Ownerlistens/Messagemate/etc/adminhtml.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <menu>
4
+ <ownerlistens module="ownerlistens_messagemate" translate="title">
5
+ <title>Message Mate by OL</title>
6
+ <sort_order>100</sort_order>
7
+ <children>
8
+ <index module="ownerlistens_messagemate" translate="title">
9
+ <title>My Message Mate</title>
10
+ <sort_order>1</sort_order>
11
+ <action>adminhtml/ownerlistensmessagemate</action>
12
+ </index>
13
+ </children>
14
+ </ownerlistens>
15
+ </menu>
16
+ <acl>
17
+ <resources>
18
+ <admin>
19
+ <children>
20
+ <ownerlistensmessagemate translate="title" module="ownerlistens_messagemate">
21
+ <title>Message Mate by OL</title>
22
+ <sort_order>-100</sort_order>
23
+ <children>
24
+ <index translate="title">
25
+ <title>My Message Mate</title>
26
+ <sort_order>1</sort_order>
27
+ </index>
28
+ </children>
29
+ </ownerlistensmessagemate>
30
+ </children>
31
+ </admin>
32
+ </resources>
33
+ </acl>
34
+ </config>
app/code/community/Ownerlistens/Messagemate/etc/config.xml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <config>
3
+ <modules>
4
+ <Ownerlistens_Messagemate>
5
+ <version>1.0.0</version>
6
+ </Ownerlistens_Messagemate>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <ownerlistens_messagemate>
11
+ <class>Ownerlistens_Messagemate_Model</class>
12
+ </ownerlistens_messagemate>
13
+ </models>
14
+ <helpers>
15
+ <ownerlistens_messagemate>
16
+ <class>Ownerlistens_Messagemate_Helper</class>
17
+ </ownerlistens_messagemate>
18
+ </helpers>
19
+ <blocks>
20
+ <ownerlistens_messagemate>
21
+ <class>Ownerlistens_Messagemate_Block</class>
22
+ </ownerlistens_messagemate>
23
+ </blocks>
24
+ <resources>
25
+ <ownerlistens_messagemate_setup>
26
+ <setup>
27
+ <module>Ownerlistens_Messagemate</module>
28
+ </setup>
29
+ <connection>
30
+ <use>core_setup</use>
31
+ </connection>
32
+ </ownerlistens_messagemate_setup>
33
+ <ownerlistens_messagemate_write>
34
+ <connection>
35
+ <use>core_write</use>
36
+ </connection>
37
+ </ownerlistens_messagemate_write>
38
+ <ownerlistens_messagemate_read>
39
+ <connection>
40
+ <use>core_read</use>
41
+ </connection>
42
+ </ownerlistens_messagemate_read>
43
+ </resources>
44
+ </global>
45
+
46
+ <admin>
47
+ <routers>
48
+ <adminhtml>
49
+ <args>
50
+ <modules>
51
+ <ownerlistens_messagemate before="Mage_Adminhtml">Ownerlistens_Messagemate_Adminhtml</ownerlistens_messagemate>
52
+ </modules>
53
+ </args>
54
+ </adminhtml>
55
+ </routers>
56
+ </admin>
57
+
58
+ <adminhtml>
59
+ <acl>
60
+ <resources>
61
+ <admin>
62
+ <children>
63
+ <system>
64
+ <children>
65
+ <config>
66
+ <children>
67
+ <ownerlistens translate="label" module="ownerlistens_messagemate">
68
+ <title>Ownerlistens</title>
69
+ </ownerlistens>
70
+ </children>
71
+ </config>
72
+ </children>
73
+ </system>
74
+ </children>
75
+ </admin>
76
+ </resources>
77
+ </acl>
78
+ </adminhtml>
79
+
80
+ <default>
81
+ <ownerlistens>
82
+ <config>
83
+ <enabled>1</enabled>
84
+ </config>
85
+ </ownerlistens>
86
+ </default>
87
+
88
+ <frontend>
89
+ <layout>
90
+ <updates>
91
+ <messagemate_layout module="ownerlistens_messagemate">
92
+ <file>ownerlistens_messagemate.xml</file>
93
+ </messagemate_layout>
94
+ </updates>
95
+ </layout>
96
+ </frontend>
97
+ </config>
app/code/community/Ownerlistens/Messagemate/etc/system.xml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <ownerlistens_messagemate translate="label" module="ownerlistens_messagemate">
5
+ <label>Ownerlistens</label>
6
+ <sort_order>195</sort_order>
7
+ </ownerlistens_messagemate>
8
+ </tabs>
9
+ <sections>
10
+ <ownerlistens translate="label" module="ownerlistens_messagemate">
11
+ <label>Message Mate by OL</label>
12
+ <tab>ownerlistens_messagemate</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>99999</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <config translate="label">
20
+ <label>General Settings</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <enabled translate="label">
28
+ <label>Enable Ownerlistens</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>1</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </enabled>
36
+ <mag_id>
37
+ <label>Client id</label>
38
+ <frontend_type>label</frontend_type>
39
+ <sort_order>2</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>0</show_in_store>
43
+ </mag_id>
44
+ <message_mate>
45
+ <label>Message Mate</label>
46
+ <frontend_type>label</frontend_type>
47
+ <sort_order>3</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ </message_mate>
52
+ </fields>
53
+ </config>
54
+ </groups>
55
+ </ownerlistens>
56
+ </sections>
57
+ </config>
app/code/community/Ownerlistens/Messagemate/sql/ownerlistens_messagemate_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+ $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
7
+ $charactersLength = strlen($characters);
8
+ $randomString = '';
9
+ for ($i = 0; $i < 15; $i++) {
10
+ $randomString .= $characters[rand(0, $charactersLength - 1)];
11
+ }
12
+
13
+ $setup = new Mage_Core_Model_Config();
14
+ Mage::getModel('core/config')->saveConfig('ownerlistens/config/mag_id', $randomString );
15
+
16
+ $installer->endSetup();
app/design/frontend/base/default/layout/ownerlistens_messagemate.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <default>
4
+ <reference name="before_body_end">
5
+ <block type="core/template" name="ownerlistens_messagemate_messagematejs" template="ownerlistens/messagemate/messagematejs.phtml"/>
6
+ </reference>
7
+ </default>
8
+ </layout>
app/design/frontend/base/default/template/ownerlistens/messagemate/messagematejs.phtml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ try {
3
+ $enabled = Mage::getStoreConfig('ownerlistens/config/enabled');
4
+ if ($enabled) {
5
+ echo Mage::getStoreConfig('ownerlistens/config/message_mate');
6
+ } else {
7
+ // nothing to do..
8
+ }
9
+ } catch (Exception $e) {
10
+ // do nothing..
11
+ }
app/etc/modules/Ownerlistens_Messagemate.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Ownerlistens_Messagemate>
4
+ <active>true</active>
5
+ <codePool>community</codePool>
6
+ </Ownerlistens_Messagemate>
7
+ </modules>
8
+ </config>
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Message_Mate_by_OL</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="https://ownerlistens.com/legal/">OwnerListens Custom License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Message Mate, by OwnerListens, adds a secure and simple texting solution to your website</summary>
10
+ <description>Texting is preferred by customers because they can take the conversation with them anywhere, and continue it at anytime. Message Mate allows shop owners to text with customers to answer questions, assist with the sales process and address complaints.&#xD;
11
+ &#xD;
12
+ With the Secure plan, all parties' personal mobile numbers &#x2013; yours, your employees&#x2019;, and your customers&#x2019; &#x2013; remain hidden. Up to three users can receive and respond to incoming messages via SMS, email, and a web dashboard.&#xD;
13
+ &#xD;
14
+ Choose any US area code (subject to availability), and get your first 30 days for free. </description>
15
+ <notes>Stable release</notes>
16
+ <authors><author><name>Niv Caner</name><user>nivcaner</user><email>niv@ownerlistens.com</email></author></authors>
17
+ <date>2015-11-30</date>
18
+ <time>16:02:17</time>
19
+ <contents><target name="magecommunity"><dir name="Ownerlistens"><dir name="Messagemate"><dir name="Block"><file name="MessagemateJs.php" hash="baca2ed58e6fd33a028ae649580a5c71"/></dir><dir name="Helper"><file name="Data.php" hash="3d47c8addddeb5049f9303c392322160"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="OwnerlistensmessagemateController.php" hash="b8cdbbbbe2e0d420c6c7521732dfb899"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="7f18997e52a7b72c04e3c2b312d32793"/><file name="config.xml" hash="5f64fbd53270399f781a3799dfca82d8"/><file name="system.xml" hash="b9ba9d062aef776b61c5407535e61502"/></dir><dir name="sql"><dir name="ownerlistens_messagemate_setup"><file name="mysql4-install-1.0.0.php" hash="8e984702dc6ad0add07568ab6de260bf"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ownerlistens_Messagemate.xml" hash="ce0ab194ce0ac1822493380f0da636e9"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="ownerlistens"><dir name="messagemate"><file name="messagematejs.phtml" hash="406e56f39b6877d2de7445b4df1e2c10"/></dir></dir></dir><dir name="layout"><file name="ownerlistens_messagemate.xml" hash="21d23cc50d6702adff0bc232b0fbe392"/></dir></dir></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies>
22
+ </package>