Interakt_App - Version 1.0.0

Version Notes

In case of any bugg found, please contact support@interakt.co

Download this release

Release Info

Developer Peeyush Singhla
Extension Interakt_App
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Interakt/App/Block/Adminhtml/System/Config/Form/Button.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class Interakt_App_Block_Adminhtml_System_Config_Form_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
6
+ {
7
+
8
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
9
+ {
10
+ $this->setElement($element);
11
+ //$url = $this->getUrl('catalog/product'); //
12
+
13
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')
14
+ ->setId('sync_btn')
15
+ ->setType('button')
16
+ ->setClass('scalable')
17
+ ->setLabel($this->helper('adminhtml')->__('Sync User'))
18
+ ->toHtml();
19
+
20
+ return $html;
21
+ }
22
+ }
app/code/community/Interakt/App/Helper/Data.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class Interakt_App_Helper_Data extends Mage_Core_Helper_Abstract
6
+ {
7
+ const XML_PATH_APP_ID = 'interakt_app/settings/app_id';
8
+ const XML_PATH_API_KEY = 'interakt_app/settings/api_key';
9
+ public function getAppId($store=null)
10
+ {
11
+ return Mage::getStoreConfig(self::XML_PATH_APP_ID,$store);
12
+ }
13
+ public function getApiKey($store=null)
14
+ {
15
+ return Mage::getStoreConfig(self::XML_PATH_API_KEY,$store);
16
+ }
17
+ }
18
+ ?>
app/code/community/Interakt/App/Model/Observer.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Interakt_App_Model_Observer
3
+ {
4
+ public function addInteraktJs($observer)
5
+ {
6
+ $product=Mage::getModel('Interakt_App_Model_SyncUserData');
7
+ $product->getInteraktJs();
8
+ }
9
+ public function addCustomJs($observer)
10
+ {
11
+ $controller = $observer->getAction();
12
+ $layout = $controller->getLayout();
13
+ $block = $layout->createBlock('adminhtml/template');
14
+ $block->setTemplate('interakt_app/button.phtml');
15
+ $layout->getBlock('js')->append($block);
16
+
17
+ }
18
+ }
19
+ ?>
app/code/community/Interakt/App/Model/SyncUserData.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class Interakt_App_Model_SyncUserData
6
+ {
7
+ private $interakt_app_id;
8
+ private $interakt_api_key;
9
+ private $user_data=array();
10
+ private $total_synced=0;
11
+ public function getInteraktJs()
12
+ {
13
+ $this->interakt_app_id=Mage::helper('interakt_app')->getAppId();
14
+ echo "<script>
15
+ (function() {
16
+ var interakt = document.createElement('script');
17
+ interakt.type = 'text/javascript'; interakt.async = true;
18
+ interakt.src = 'http://cdn.interakt.co/interakt/$this->interakt_app_id.js'
19
+ var scrpt = document.getElementsByTagName('script')[0];
20
+ scrpt.parentNode.insertBefore(interakt, scrpt);
21
+ })()
22
+ </script>";
23
+ //verify if the user is logged in to the backend
24
+ if(Mage::getSingleton('customer/session')->isLoggedIn()){
25
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
26
+ $user_name=$customer->getName();
27
+ $email=$customer->getEmail();
28
+ $created_at=$customer->getCreatedAt();
29
+ echo "<script>
30
+ window.mySettings = {
31
+ email: '$email',
32
+ name: '$user_name',
33
+ created_at: '$created_at',
34
+ app_id: '$this->interakt_app_id'
35
+ };
36
+ </script>";
37
+ }
38
+ }
39
+ public function syncData($offset=1)
40
+ {
41
+ $customerData = mage::getResourceModel('customer/customer_collection')->addAttributeToSelect('firstname')
42
+ ->addAttributeToSelect('lastname')
43
+ ->addAttributeToSelect('email')->setPage($offset,30);
44
+ foreach($customerData as $data)
45
+ {
46
+ $email=$data->getEmail();
47
+ $createdAt=$data->getCreatedAt();
48
+ $name=$data->getName();
49
+ $this->user_data=array('email'=>$email,'name'=>$name,'created_at'=>$createdAt);
50
+ $response=$this->sendData();
51
+ if($response=='error')
52
+ {
53
+ return 'error';
54
+ }
55
+ $this->total_synced++;
56
+ }
57
+ unset($customerData);
58
+ return $this->total_synced;
59
+ }
60
+ public function userCount()
61
+ {
62
+ $userCount = mage::getResourceModel('customer/customer_collection')->count();
63
+ return $userCount;
64
+ }
65
+ public function sendData()
66
+ {
67
+ $this->interakt_app_id=Mage::helper('interakt_app')->getAppId();
68
+ $this->interakt_api_key=Mage::helper('interakt_app')->getApiKey();
69
+ $this->user_data=json_encode($this->user_data);
70
+ $url='http://4c6978af.ngrok.io/api/v1/members';
71
+ $curl = curl_init();
72
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
73
+ curl_setopt($curl, CURLOPT_POST, true);
74
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
75
+ curl_setopt($curl,CURLOPT_URL, $url);
76
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
77
+ curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
78
+ curl_setopt($curl, CURLOPT_USERPWD, $this->interakt_app_id.':'.$this->interakt_api_key);
79
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $this->user_data);
80
+ $curl_response = curl_exec($curl);
81
+ curl_close($curl);
82
+ $curl_response=json_decode($curl_response,true);
83
+ return $curl_response;
84
+ }
85
+
86
+ }
87
+ ?>
app/code/community/Interakt/App/controllers/Adminhtml/AppController.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Interakt_App_Adminhtml_AppController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ /**
5
+ * Return some checking result
6
+ *
7
+ * @return void
8
+ */
9
+
10
+ public function indexAction()
11
+ {
12
+ $sync_users=Mage::getModel('Interakt_App_Model_SyncUserData');
13
+ $count=$sync_users->userCount();
14
+ echo $count;
15
+ }
16
+ public function syncdataAction()
17
+ {
18
+ $offset=isset($_GET['offset'])?$_GET['offset']:"";
19
+ $sync_users=Mage::getModel('Interakt_App_Model_SyncUserData');
20
+ $data=$sync_users->syncData($offset);
21
+ echo $data;
22
+ }
23
+
24
+ }
25
+ ?>
app/code/community/Interakt/App/etc/adminhtml.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <interakt_app module="interakt_app">
12
+ <title>InteraktApp</title>
13
+ </interakt_app>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ </config>
app/code/community/Interakt/App/etc/config.xml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Interakt_App>
5
+ <version>0.2.2</version>
6
+ </Interakt_App>
7
+ </modules>
8
+ <global>
9
+ <modules>
10
+ <interakt_app>
11
+ <class>
12
+ Interakt_App_Model
13
+ </class>
14
+ </interakt_app>
15
+ </modules>
16
+ <helpers>
17
+ <interakt_app>
18
+ <class>
19
+ Interakt_App_Helper
20
+ </class>
21
+ </interakt_app>
22
+ </helpers>
23
+ <blocks>
24
+ <interakt_app>
25
+ <class>Interakt_App_Block</class>
26
+ </interakt_app>
27
+ </blocks>
28
+ </global>
29
+ <admin>
30
+ <routers>
31
+ <interakt_app>
32
+ <use>admin</use>
33
+ <args>
34
+ <module>Interakt_App</module>
35
+ <frontName>interakt_app</frontName>
36
+ </args>
37
+ </interakt_app>
38
+ </routers>
39
+ </admin>
40
+ <frontend>
41
+ <events>
42
+ <controller_action_layout_generate_blocks_after>
43
+ <observers>
44
+ <interakt_app>
45
+ <type>model</type>
46
+ <class>Interakt_App_Model_Observer</class>
47
+ <method>addInteraktJs</method>
48
+ </interakt_app>
49
+ </observers>
50
+ </controller_action_layout_generate_blocks_after>
51
+ </events>
52
+ </frontend>
53
+ <adminhtml>
54
+ <events>
55
+ <controller_action_layout_generate_blocks_after>
56
+ <observers>
57
+ <interakt_app>
58
+ <type>model</type>
59
+ <class>Interakt_App_Model_Observer</class>
60
+ <method>addCustomJs</method>
61
+ </interakt_app>
62
+ </observers>
63
+ </controller_action_layout_generate_blocks_after>
64
+ </events>
65
+ </adminhtml>
66
+ </config>
app/code/community/Interakt/App/etc/system.xml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <interakt module="interakt_app">
5
+ <label>Interakt</label>
6
+ <sort_order>10</sort_order>
7
+ </interakt>
8
+ </tabs>
9
+ <sections>
10
+ <interakt_app module="interakt_app">
11
+ <label>InteraktApp</label>
12
+ <tab>interakt</tab>
13
+ <sort_order>10</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <groups>
18
+ <settings>
19
+ <label> Settings</label>
20
+ <sort_order>10</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <fields>
25
+ <app_id translate="label">
26
+ <label>App Id</label>
27
+ <frontend_type>text</frontend_type>
28
+ <sort_order>20</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>1</show_in_store>
32
+ </app_id>
33
+ <api_key translate="label">
34
+ <label>Api Key</label>
35
+ <frontend_type>text</frontend_type>
36
+ <sort_order>40</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>1</show_in_store>
40
+ </api_key>
41
+ <sync_btn translate="label">
42
+ <label>Sync User</label>
43
+ <frontend_type>button</frontend_type>
44
+ <frontend_model>interakt_app/adminhtml_system_config_form_button</frontend_model>
45
+ <sort_order>80</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ </sync_btn>
50
+
51
+ </fields>
52
+ </settings>
53
+ </groups>
54
+ </interakt_app>
55
+ </sections>
56
+ </config>
app/design/adminhtml/default/default/template/interakt_app/button.phtml ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
2
+
3
+ <script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.3.0/prototype.js"></script>
4
+ <script src="https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js"></script>
5
+ <script type="text/javascript">
6
+ ( function($) {
7
+ // we can now rely on $ within the safety of our "bodyguard" function
8
+ $(document).ready( function() {
9
+ var offset=0;
10
+ var totalUsers=0;
11
+ var from=1;
12
+ var to=0;
13
+ $('#sync_btn').on('click',function(){
14
+ count();
15
+ })
16
+ function sync()
17
+ {
18
+ if(parseInt(offset)<=parseInt(totalUsers/2))
19
+ {
20
+
21
+ new Ajax.Request("<?php echo $this->getUrl('interakt_app/adminhtml_app/syncdata');?>",{
22
+ method:'get',
23
+ parameters:"count="+count+"&offset="+offset,
24
+ onSuccess: function(transport){
25
+ if(transport.responseText)
26
+ {
27
+ if(transport.responseText=='error')
28
+ {
29
+ $('#total_users').text('Invalid app key or api key, Please check your app key or api key, Further you have any proble please <a href="mailto:support@interakt.co?Subject=Need help for Interakt Integration with WordPress site" target="_top">Drop us an Email');
30
+ }
31
+ else
32
+ {
33
+ to=from+2;
34
+ $('#total_users').text('Users synced from'+from+' to '+to);
35
+ from+=2;
36
+ offset=offset+29;
37
+ sync();
38
+ }
39
+
40
+ }
41
+ }
42
+ });
43
+ }
44
+ else
45
+ {
46
+ $('#total_users').text('All data has been sent.');
47
+ }
48
+ }
49
+ function count() {
50
+ if(parseInt(offset)>parseInt(totalUsers/2))
51
+ {
52
+ alert('Users already synced');
53
+ }
54
+ else
55
+ {
56
+ offset=1;
57
+ new Ajax.Request("<?php echo $this->getUrl('interakt_app/adminhtml_app/');?>",{
58
+ method:'get',
59
+ onSuccess: function(transport){
60
+ if (transport.responseText){
61
+ //alert(transport.responseText);
62
+ totalUsers=transport.responseText;
63
+ $('#interakt_app_settings').append('<span id="total_users" style="text-align:center;font-size:14px;">Total no. of users = '+totalUsers+'</br>Syncing User Data.</span>')
64
+ $('#row_interakt_app_settings_app_id').closest('table').before('<span style="text-align:center;font-size:20px;fon-weight:bold;">Please do not reload page, it will take some time, have patience.</span>');
65
+ sync();
66
+ }
67
+ }
68
+ });
69
+ }
70
+ }
71
+
72
+ } );
73
+ } ) ( jQuery );
74
+ </script>
app/etc/modules/Interakt_App.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Interakt_App>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Interakt_App>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Interakt_App</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>Massachusetts Institute of Technology License (MITL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Interakt will simplify customer data analysis, marketing and support. It is an integrated crm that lets you do email marketing, engage customers through live chat, retain and support your customers, all from one single dashboard.</summary>
10
+ <description>With Interakt you can capture new leads directly from your magento application, connect with the existing users via email &amp; push notifications and answer them through chat &amp; helpdesk.&#xD;
11
+ Capture Leads in every possible way. Import existing leads, divide them in segments and nurture them in realtime.&#xD;
12
+ Capture user sessions, activities &amp; dynamics with rich profiling for every user. Create segments and track their progress.&#xD;
13
+ Customize templates to send automated marketing &amp; transactional emails. Engage users and view email stats.&#xD;
14
+ Installing Interakt Extension on Magento&#xD;
15
+ 1. Click the &#x201C;Install Now&#x201D; button at the top of the page.&#xD;
16
+ 2. Copy the key provided.&#xD;
17
+ 3. Login to your Magento connect manager, paste key and click to install.&#xD;
18
+ 4. Click the Systems Tab to populate the drop down menu Select Cofiguration.&#xD;
19
+ 5. Click on the InteraktApp tab, paste app key and app id which you can get from your Interakt.co account.&#xD;
20
+ 6. Click on sync user button to sync your customer data to Interakt.</description>
21
+ <notes>In case of any bugg found, please contact support@interakt.co</notes>
22
+ <authors><author><name>Peeyush Singhla</name><user>peeyush</user><email>peeyush@interakt.co</email></author></authors>
23
+ <date>2015-11-16</date>
24
+ <time>07:34:01</time>
25
+ <contents><target name="magecommunity"><dir><dir name="Interakt"><dir name="App"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="ab44aad61b65b29bf8e7643d6f2cc57c"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="49d4d9414b044b21cadefb0130b02cd1"/></dir><dir name="Model"><file name="Observer.php" hash="ba370bf6389e84d495ea28daaf5893e7"/><file name="SyncUserData.php" hash="30dff0ea6bd23da30e50884306ba1420"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AppController.php" hash="caf8aec8403946617d218d28369ae8bc"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="1302c629c2abfc004cf2654b19082b7e"/><file name="config.xml" hash="51f4fa966cf64016113580fc6339d7f8"/><file name="system.xml" hash="d711a0961c143b132fe4e9a116d7eeaf"/></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Interakt_App.xml" hash="c4bdf884ff2016bc6e319309f3b773ba"/></dir></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="interakt_app"><file name="button.phtml" hash="4dc3a7c887b83393643ab368184fb847"/></dir></dir></dir></dir></dir></dir></target></contents>
26
+ <compatible/>
27
+ <dependencies><required><php><min>5.3.0</min><max>5.5.0</max></php></required></dependencies>
28
+ </package>