Version Notes
For any queries, please contact support@interakt.co
Download this release
Release Info
Developer | Peeyush Singhla |
Extension | Interakt_App |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
- app/code/community/Interakt/App/Block/Adminhtml/System/Config/Form/Button.php +22 -0
- app/code/community/Interakt/App/Helper/Data.php +18 -0
- app/code/community/Interakt/App/Model/Observer.php +19 -0
- app/code/community/Interakt/App/Model/SyncUserData.php +87 -0
- app/code/community/Interakt/App/controllers/Adminhtml/AppController.php +25 -0
- app/code/community/Interakt/App/etc/adminhtml.xml +22 -0
- app/code/community/Interakt/App/etc/config.xml +66 -0
- app/code/community/Interakt/App/etc/system.xml +56 -0
- app/etc/modules/Interakt_App.xml +9 -0
- package.xml +3 -3
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/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
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Interakt_App</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license>Massachusetts Institute of Technology License (MITL)</license>
|
7 |
<channel>community</channel>
|
@@ -42,8 +42,8 @@ Route customer queries to our simplified helpdesk and collect valuable feedback
|
|
42 |
<notes>For any queries, please contact support@interakt.co</notes>
|
43 |
<authors><author><name>Peeyush Singhla</name><user>peeyush</user><email>peeyush@interakt.co</email></author></authors>
|
44 |
<date>2015-11-20</date>
|
45 |
-
<time>
|
46 |
-
<contents><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=""/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Interakt_App.xml" hash=""/></dir></dir></target></contents>
|
47 |
<compatible/>
|
48 |
<dependencies><required><php><min>5.3.0</min><max>5.6.4</max></php></required></dependencies>
|
49 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Interakt_App</name>
|
4 |
+
<version>1.0.2</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>Massachusetts Institute of Technology License (MITL)</license>
|
7 |
<channel>community</channel>
|
42 |
<notes>For any queries, please contact support@interakt.co</notes>
|
43 |
<authors><author><name>Peeyush Singhla</name><user>peeyush</user><email>peeyush@interakt.co</email></author></authors>
|
44 |
<date>2015-11-20</date>
|
45 |
+
<time>08:01:15</time>
|
46 |
+
<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="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="interakt_app"><file name="button.phtml" hash=""/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Interakt_App.xml" hash="c4bdf884ff2016bc6e319309f3b773ba"/></dir></dir></target></contents>
|
47 |
<compatible/>
|
48 |
<dependencies><required><php><min>5.3.0</min><max>5.6.4</max></php></required></dependencies>
|
49 |
</package>
|