Justuno_Social - Version 1.0.1

Version Notes

Stable release. Add auto logging in user via API

Download this release

Release Info

Developer Justuno
Extension Justuno_Social
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

app/code/community/Justuno/Social/Block/Dashboard.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Justuno_Social_Block_Dashboard extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
5
+ {
6
+ $email = Mage::getStoreConfig('advanced/account/email');
7
+ $domain = Mage::getStoreConfig('advanced/account/domain');
8
+ $jusdata = Mage::getStoreConfig('advanced/account/embed');
9
+ if ($email && $jusdata) {
10
+ $jusdata = json_decode($jusdata);
11
+ include_once realpath(dirname(__FILE__) . '/../Model/JustunoAccess.php');
12
+ $jAccess = new JustunoAccess(array('apiKey'=>JUSTUNO_KEY,'email'=>$email, 'guid'=>$jusdata->guid, 'domain'=>$domain));
13
+ $url = $jAccess->getDashboardLink();
14
+ }
15
+ else {
16
+ $url = 'https://www.justuno.com/dashboard.html?loggedin=true';
17
+ }
18
+ return '<button title="Justuno Dashboard" class="scalable" onClick="window.open(\'' . $url . '\',\'_blank\'); return false;">Justuno Dashboard</button>';
19
+ }
20
+ }
app/code/community/Justuno/Social/Block/Domain.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Justuno_Social_Block_Domain extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
5
+ {
6
+ return '<input id="advanced_account_domain" class=" input-text" type="text" value="' . $_SERVER['HTTP_HOST'] . '" name="groups[account][fields][domain][value]" readonly="true"></input>';
7
+ }
8
+ }
app/code/community/Justuno/Social/Block/Widget.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Justuno_Social_Block_Widget extends Mage_Core_Block_Template
3
+ {
4
+ public function getEmbed()
5
+ {
6
+ $jusdata = Mage::getStoreConfig('advanced/account/embed');
7
+ if ($jusdata) {
8
+ $jusdata = json_decode($jusdata);
9
+ }
10
+ return $jusdata->embed;
11
+ }
12
+ }
app/code/community/Justuno/Social/Model/Embed.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Justuno_Social_Model_Embed extends Mage_Core_Model_Config_Data
3
+ {
4
+ public function save()
5
+ {
6
+ $fdata = array();
7
+ foreach ($this->groups['account']['fields'] as $name=>$field) {
8
+ $fdata[$name] = $field['value'];
9
+ }
10
+ if ($fdata['embed']) {
11
+ $obj = json_decode($fdata['embed']);
12
+ $fdata['embed'] = $obj->embed;
13
+ $fdata['guid'] = $obj->guid;
14
+ }
15
+ include_once dirname(__FILE__) . '/JustunoAccess.php';
16
+ $params = array('apiKey'=>JUSTUNO_KEY,'email'=>$fdata['email'],'domain'=>$fdata['domain'],'guid'=>$fdata['guid']);
17
+ if($fdata['password'])
18
+ $params['password'] = $fdata['password'];
19
+ $jAccess = new JustunoAccess($params);
20
+ try {
21
+ $justuno = $jAccess->getWidgetConfig();
22
+ $jusdata = array();
23
+ $jusdata['dashboard'] = (string)$jAccess->getDashboardLink();
24
+ $jusdata['guid'] = (string)$justuno['guid'];
25
+ $jusdata['embed'] = (string)$justuno['embed'];
26
+ $this->setValue((string)json_encode($jusdata));
27
+ }
28
+ catch(JustunoAccessException $e) {
29
+ Mage::throwException($e->getMessage());
30
+ }
31
+ return parent::save();
32
+ }
33
+ }
app/code/community/Justuno/Social/Model/JustunoAccess.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ define('JUSTUNO_KEY', '467cd758-5745-4385-906b-6c76271c343a');
3
+ /**
4
+ * @file
5
+ * Class to perform operations with Justuno server.
6
+ *
7
+ * @version 13-08-2013
8
+ */
9
+
10
+ class JustunoAccess {
11
+ protected $apiKey;
12
+ protected $domain;
13
+ protected $email;
14
+ protected $apiEndpointUrl;
15
+ protected $guid;
16
+ protected $password;
17
+
18
+ /**
19
+ * Set initial data in constructor.
20
+ */
21
+ public function __construct($settings) {
22
+ $this->apiKey = $settings['apiKey'];
23
+ $this->domain = $settings['domain'];
24
+ $this->email = $settings['email'];
25
+ $this->guid = isset($settings['guid']) ? $settings['guid'] : NULL;
26
+ $this->password = isset($settings['password']) ? $settings['password'] : NULL;
27
+ $this->apiEndpointUrl = 'https://www.justuno.com/api/endpoint.html';
28
+ }
29
+
30
+ /**
31
+ * Retreives Justuno widget data.
32
+ */
33
+ public function getWidgetConfig() {
34
+ if (!extension_loaded("curl")) {
35
+ throw new JustunoAccessException('Plug-in requires php `curl` extension which seems to be not activated on this server. Please activate it.');
36
+ }
37
+ $params = array(
38
+ 'key' => $this->apiKey,
39
+ 'email' => $this->email,
40
+ 'domain' => $this->domain,
41
+ 'action' => 'install',
42
+ );
43
+ if (isset($this->password)) {
44
+ $params['password'] = $this->password;
45
+ }
46
+ $query = http_build_query($params);
47
+ $tucurl = curl_init();
48
+ curl_setopt($tucurl, CURLOPT_URL, "{$this->apiEndpointUrl}?$query");
49
+ curl_setopt($tucurl, CURLOPT_SSL_VERIFYPEER, FALSE);
50
+ curl_setopt($tucurl, CURLOPT_RETURNTRANSFER, 1);
51
+ $tudata = curl_exec($tucurl);
52
+ try {
53
+ if (curl_errno($tucurl)) {
54
+ throw new Exception(curl_error($tucurl));
55
+ }
56
+ $dom = new DOMDocument();
57
+ $dom->loadXML($tudata);
58
+ $nodes = $dom->getElementsByTagName('result');
59
+ if (!$nodes || ($nodes->length == 0)) {
60
+ throw new Exception('Incorrect response from remote server');
61
+ }
62
+
63
+ if ($nodes->item(0)->nodeValue == 0) {
64
+ $nodes = $dom->getElementsByTagName('error');
65
+ throw new Exception($nodes->item(0)->nodeValue);
66
+ }
67
+ $justuno_conf = array();
68
+ $nodes = $dom->getElementsByTagName('guid');
69
+ if ($nodes && $nodes->length !== 0) {
70
+ $this->guid = $justuno_conf['guid'] = $nodes->item(0)->nodeValue;
71
+ }
72
+ $nodes = $dom->getElementsByTagName('embed');
73
+ if ($nodes && $nodes->length !== 0) {
74
+ $justuno_conf['embed'] = $nodes->item(0)->nodeValue;
75
+ }
76
+ $nodes = $dom->getElementsByTagName('conversion');
77
+ if ($nodes && $nodes->length !== 0) {
78
+ $justuno_conf['conversion'] = $nodes->item(0)->nodeValue;
79
+ }
80
+ curl_close($tucurl);
81
+ return $justuno_conf;
82
+ }
83
+ catch (Exception $e) {
84
+ curl_close($tucurl);
85
+ throw new JustunoAccessException('Request error: ' . $e->getMessage());
86
+ }
87
+
88
+ }
89
+
90
+ /**
91
+ * Get link to Jutsuno dashbord link using API
92
+ */
93
+ public function getDashboardLink() {
94
+ $params = array(
95
+ 'key'=>$this->apiKey,
96
+ 'email'=>$this->email,
97
+ 'domain'=>$this->domain,
98
+ 'action'=>'login',
99
+ 'guid'=>$this->guid
100
+ );
101
+
102
+ if(isset($this->password)){
103
+ $params['password'] = $this->password;
104
+ }
105
+ $query = http_build_query($params);
106
+ $tuCurl = curl_init();
107
+ curl_setopt($tuCurl, CURLOPT_URL, "{$this->apiEndpointUrl}?$query");
108
+ curl_setopt($tuCurl,CURLOPT_SSL_VERIFYPEER,false);
109
+ curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, 1);
110
+ $tuData = curl_exec($tuCurl);
111
+ try{
112
+ if(curl_errno($tuCurl)){
113
+ throw new Exception(curl_error($tuCurl));
114
+ }
115
+ $dom = new DOMDocument;
116
+ $dom->loadXML($tuData);
117
+ $nodes = $dom->getElementsByTagName('result');
118
+ if(!$nodes || $nodes->length == 0)
119
+ throw new Exception('Incorrect response from remote server');
120
+
121
+ if($nodes->item(0)->nodeValue == 0){
122
+ $nodes = $dom->getElementsByTagName('error');
123
+ throw new Exception($nodes->item(0)->nodeValue);
124
+ }
125
+ $nodes = $dom->getElementsByTagName('secure_login_url');
126
+ if($nodes && $nodes->length !== 0){
127
+ $secureLoginUrl = $nodes->item(0)->nodeValue;
128
+ }
129
+ curl_close($tuCurl);
130
+ return $secureLoginUrl;
131
+ }
132
+ catch(Exception $e){
133
+ curl_close($tuCurl);
134
+ throw new JustunoAccessException('Request error: '.$e->getMessage());
135
+ }
136
+ }
137
+ }
138
+
139
+
140
+ /**
141
+ * Exception child to throw.
142
+ */
143
+ class JustunoAccessException extends Exception {
144
+
145
+ }
app/code/community/Justuno/Social/etc/adminhtml.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <justuno translate="title" module="social">
12
+ <title>Justuno Social</title>
13
+ <sort_order>0</sort_order>
14
+ </justuno>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/community/Justuno/Social/etc/config.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Justuno_Social>
5
+ <version>1.0.0</version>
6
+ </Justuno_Social>
7
+ </modules>
8
+ <tabs>
9
+ <social module="social" translate="label">
10
+ <label>Justuno Social</label>
11
+ <sort_order>100</sort_order>
12
+ </social>
13
+ </tabs>
14
+ <global>
15
+ <models>
16
+ <social>
17
+ <class>Justuno_Social_Model</class>
18
+ <resourceModel>social_embed</resourceModel>
19
+ </social>
20
+ <social_embed>
21
+ <class>Justuno_Social_Model_Embed</class>
22
+ </social_embed>
23
+ </models>
24
+ <blocks>
25
+ <social>
26
+ <class>Justuno_Social_Block</class>
27
+ </social>
28
+ <social_domain>
29
+ <class>Justuno_Social_Block_Domain</class>
30
+ </social_domain>
31
+ <social_dashboard>
32
+ <class>Justuno_Social_Block_Dashboard</class>
33
+ </social_dashboard>
34
+ </blocks>
35
+ </global>
36
+ <frontend>
37
+ <layout>
38
+ <updates>
39
+ <social>
40
+ <file>justuno_social.xml</file>
41
+ </social>
42
+ </updates>
43
+ </layout>
44
+ </frontend>
45
+ </config>
app/code/community/Justuno/Social/etc/system.xml ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <advanced translate="label" module="social">
5
+ <label>Justuno Social</label>
6
+ <tab>advanced</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>0</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <account translate="label">
14
+ <label>Create or Connect Existing Justuno Account</label>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>0</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <fields>
21
+ <email translate="label">
22
+ <label>E-Mail</label>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>0</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ <comment></comment>
29
+ </email>
30
+ <password translate="label">
31
+ <label>Password</label>
32
+ <frontend_type>password</frontend_type>
33
+ <sort_order>1</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ <comment></comment>
38
+ </password>
39
+ <domain translate="label">
40
+ <label>Domain</label>
41
+ <frontend_type>text</frontend_type>
42
+ <frontend_model>social/domain</frontend_model>
43
+ <sort_order>2</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ <comment></comment>
48
+ </domain>
49
+ <embed translate="label">
50
+ <label></label>
51
+ <frontend_type>hidden</frontend_type>
52
+ <backend_model>social/embed</backend_model>
53
+ <sort_order>3</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>1</show_in_store>
57
+ <comment></comment>
58
+ </embed>
59
+ </fields>
60
+ </account>
61
+
62
+ <dashboard translate="label">
63
+ <label>Set Up or Manage Account</label>
64
+ <frontend_type>text</frontend_type>
65
+ <sort_order>1</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ <fields>
70
+ <dashboard translate="label">
71
+ <frontend_type>hidden</frontend_type>
72
+ <frontend_model>social/dashboard</frontend_model>
73
+ <sort_order>0</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ <comment></comment>
78
+ </dashboard>
79
+ </fields>
80
+ </dashboard>
81
+ </groups>
82
+ </advanced>
83
+ </sections>
84
+ </config>
app/design/frontend/base/default/layout/justuno_social.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout>
3
+ <default>
4
+ <reference name="after_body_start">
5
+ <block type="social/widget" name="justuno_social" as="justuno_social" template="justuno_social/widget.phtml" />
6
+ </reference>
7
+ </default>
8
+ </layout>
app/design/frontend/base/default/template/justuno_social/widget.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Justuno Social plugin for Magento
4
+ *
5
+ * @category design
6
+ * @package base_default
7
+ * @author Justuno (http://www.justuno.com/)
8
+ * @copyright Copyright (c) 2013 Justuno (http://www.justuno.com/)
9
+ * @license Open Software License
10
+ */
11
+ ?>
12
+ <script>
13
+ <?php echo $this->getEmbed(); ?>
14
+
15
+ </script>
app/etc/modules/Justuno_Social.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @package Justuno_Social
5
+ */
6
+ -->
7
+ <config>
8
+ <modules>
9
+ <Justuno_Social>
10
+ <active>true</active>
11
+ <codePool>community</codePool>
12
+ <version>0.1.0</version>
13
+ </Justuno_Social>
14
+ </modules>
15
+ </config>
package.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Justuno_Social</name>
4
+ <version>1.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Convert website visitors into high quality fans, followers &amp; email subscribers with Justuno social offers.</summary>
10
+ <description>Justuno is the premier social marketing tool to convert website visitors to social and email leads via a simple instant offer widget on your site. In exchange for a coupon code, customers must either Facebook Like, Twitter Follow, Google+1, Join your mailing list or other available options all without ever having to leave your website. &#xD;
11
+ &lt;br /&gt;&lt;br /&gt;&#xD;
12
+ &lt;strong&gt;Key Features:&lt;/strong&gt;&lt;br /&gt;&#xD;
13
+ -Present instant offers in exchange for a social or email lead capture &lt;br /&gt;&#xD;
14
+ -Convert up to 3% of your daily website traffic&lt;br /&gt;&#xD;
15
+ -Easy to set-up and manage. No technical skills needed.&lt;br /&gt;&#xD;
16
+ -Available in any language&lt;br /&gt;&#xD;
17
+ &#xD;
18
+ &#xD;
19
+ To understand how Justuno works it&#x2019;s best to just see him in action ;) Please visit </description>
20
+ <notes>Stable release. Add auto logging in user via API</notes>
21
+ <authors><author><name>Justuno</name><user>Justuno</user><email>erik@justuno.com</email></author></authors>
22
+ <date>2013-10-16</date>
23
+ <time>13:49:14</time>
24
+ <contents><target name="magecommunity"><dir name="Justuno"><dir name="Social"><dir name="Block"><file name="Dashboard.php" hash="65c748c957380488645c75cbb292267a"/><file name="Domain.php" hash="d9375f0f7b4e9198793959a86e96d4de"/><file name="Widget.php" hash="5d61c43647ed55827acfd0bd3baed473"/></dir><dir name="Model"><file name="Embed.php" hash="c5a033a067c424ef17bcab29c192424c"/><file name="JustunoAccess.php" hash="092c586e980c5840c3db6775e260e93b"/></dir><dir name="etc"><file name="adminhtml.xml" hash="798e1cb0f2843594e7b45d3601dfc6c4"/><file name="config.xml" hash="e82b6ecab3d744cb15a64e7170fb662c"/><file name="system.xml" hash="137c952fe96f7093a73e8144716107d5"/></dir></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="justuno_social.xml" hash="d098f0a90ce0f311d0f233d416646183"/></dir><dir name="template"><dir name="justuno_social"><file name="widget.phtml" hash="7c6cbd4fe1df046562bc7bcc654f84d1"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Justuno_Social.xml" hash="936992f02fadf29a8de2af307d4c2dd0"/></dir></dir></target></contents>
25
+ <compatible/>
26
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><extension><name>curl</name><min></min><max></max></extension></required></dependencies>
27
+ </package>