chat_tidio - Version 1.0.1

Version Notes

Notes

Download this release

Release Info

Developer Tytus Gołas
Extension chat_tidio
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/code/local/Tidio/Chat/Block/Adminhtml/Menu.php CHANGED
@@ -2,37 +2,63 @@
2
 
3
  class Tidio_Chat_Block_Adminhtml_Menu extends Mage_Adminhtml_Block_Page_Menu
4
  {
 
 
 
5
  const XML_PATH_EXTENSION_PRIVATE_KEY = 'chat_section/chat_group/privatekey';
 
6
  public function getMenuArray()
7
  {
8
  //Load standard menu
9
  $parentArr = parent::getMenuArray();
 
 
10
  $privateKey = Mage::getStoreConfig(self::XML_PATH_EXTENSION_PRIVATE_KEY);
11
 
 
 
 
 
 
 
 
 
 
12
 
13
- $chatUrl = "'http://external.tidiochat.com/access?privateKey=$privateKey'";
14
- $parentArr['tidio_chat'] = array(
15
- 'label' => 'Tidio Chat',
16
- 'active' => false,
17
- 'sort_order' => 16,
18
- 'click' => 'return false;',
19
- 'url'=> '#' ,
20
- 'level'=> 0,
21
- 'last'=> true,
22
- 'children' => array(
23
- array(
24
- 'label' => 'Tidio Chat',
25
- 'active' => false,
26
- 'sort_order' => 1,
27
- 'click' => "window.open($chatUrl)",
28
- 'url'=> '#' ,
29
- 'level'=> 0,
30
- 'last'=> true,
31
- )
32
- )
33
- );
34
 
35
  return $parentArr;
36
  }
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
2
 
3
  class Tidio_Chat_Block_Adminhtml_Menu extends Mage_Adminhtml_Block_Page_Menu
4
  {
5
+ // paths to configuration
6
+ const XML_PATH_EXTENSION_ENABLED = 'chat_section/chat_group/tidio_enable';
7
+ const XML_PATH_EXTENSION_PUBLIC_KEY = 'chat_section/chat_group/publickey';
8
  const XML_PATH_EXTENSION_PRIVATE_KEY = 'chat_section/chat_group/privatekey';
9
+
10
  public function getMenuArray()
11
  {
12
  //Load standard menu
13
  $parentArr = parent::getMenuArray();
14
+
15
+ $publicKey = Mage::getStoreConfig(self::XML_PATH_EXTENSION_PUBLIC_KEY);
16
  $privateKey = Mage::getStoreConfig(self::XML_PATH_EXTENSION_PRIVATE_KEY);
17
 
18
+ if ((trim($publicKey) == '') || (trim($privateKey) == '')) {
19
+ $keys = $this->_getKeys();
20
+ $publicKey = $keys['public_key'];
21
+ $privateKey = $keys['private_key'];
22
+
23
+ $config = new Mage_Core_Model_Config();
24
+ $config->saveConfig(self::XML_PATH_EXTENSION_PUBLIC_KEY, $publicKey);
25
+ $config->saveConfig(self::XML_PATH_EXTENSION_PRIVATE_KEY, $privateKey);
26
+ }
27
 
28
+ $extEnabled = (int) Mage::getStoreConfig(self::XML_PATH_EXTENSION_ENABLED);
29
+ if ($extEnabled && ($privateKey != '')) {
30
+ $chatUrl = "'http://external.tidiochat.com/access?privateKey=$privateKey'";
31
+ $parentArr['tidio_chat'] = array(
32
+ 'label' => 'Tidio Chat',
33
+ 'active' => false,
34
+ 'sort_order' => 16,
35
+ 'click' => "window.open($chatUrl)",
36
+ 'url'=> '#' ,
37
+ 'level'=> 0,
38
+ 'last'=> true,
39
+ );
40
+ }
 
 
 
 
 
 
 
 
41
 
42
  return $parentArr;
43
  }
44
 
45
+ private function _getKeys()
46
+ {
47
+ $domainName = $_SERVER['HTTP_HOST'];
48
+ $adminEmail = Mage::getStoreConfig('trans_email/ident_general/email');
49
+ $remoteAddr = $_SERVER['REMOTE_ADDR'];
50
+
51
+ $ch = curl_init();
52
+
53
+ curl_setopt($ch,CURLOPT_URL, "http://www.tidiochat.com/access/create?url=" . urlencode($domainName) . "&platform=magento&email=$adminEmail&_ip=$remoteAddr");
54
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
55
+
56
+ curl_setopt($ch, CURLOPT_HEADER, 0);
57
+ $output = curl_exec($ch);
58
+ curl_close($ch);
59
+
60
+ $json = json_decode($output);
61
+
62
+ return array('public_key' => $json->value->public_key, 'private_key' => $json->value->private_key);
63
+ }
64
  }
app/code/local/Tidio/Chat/Model/Observer.php DELETED
@@ -1,81 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Observer class file.
5
- *
6
- * @category TB
7
- * @package Tidio_Chat
8
- * @author tb
9
- * @copyright Copyright (c) 2014
10
- */
11
-
12
- class Tidio_Chat_Model_Observer extends Mage_Core_Model_Abstract
13
- {
14
- // paths to configuration
15
- const XML_PATH_EXTENSION_ENABLED = 'chat_section/chat_group/tidio_enable';
16
- const XML_PATH_EXTENSION_PUBLIC_KEY = 'chat_section/chat_group/publickey';
17
- const XML_PATH_EXTENSION_PRIVATE_KEY = 'chat_section/chat_group/privatekey';
18
-
19
- private $extEnabled = null;
20
- /**
21
- * Constructor
22
- *
23
- */
24
- public function __construct()
25
- {
26
- $this->extEnabled = (int) Mage::getStoreConfig(self::XML_PATH_EXTENSION_ENABLED);
27
-
28
- // if extension not enabled, then return
29
- if (!$this->extEnabled) {
30
- return;
31
- }
32
-
33
- try {
34
- } catch (Exception $e) {
35
- }
36
- }
37
- /**
38
- * Event dispatched after backoffice loaded
39
- *
40
- * @param array $observer
41
- *
42
- */
43
- public function hookToAdminLoad($observer)
44
- {
45
- if ($this->extEnabled) {
46
- $publicKey = Mage::getStoreConfig(self::XML_PATH_EXTENSION_PUBLIC_KEY);
47
- $privateKey = Mage::getStoreConfig(self::XML_PATH_EXTENSION_PUBLIC_KEY);
48
- if ((trim($publicKey) == '') || (trim($privateKey) == '')) {
49
- $keys = $this->_getKeys();
50
-
51
- $config = new Mage_Core_Model_Config();
52
- $config->saveConfig(self::XML_PATH_EXTENSION_PUBLIC_KEY, $keys['public_key']);
53
- $config->saveConfig(self::XML_PATH_EXTENSION_PRIVATE_KEY, $keys['private_key']);
54
- }
55
- }
56
- }
57
-
58
- private function _getKeys()
59
- {
60
- $domainName = $_SERVER['HTTP_HOST'];
61
- $adminEmail = Mage::getStoreConfig('trans_email/ident_general/email');
62
- $remoteAddr = $_SERVER['REMOTE_ADDR'];
63
-
64
- $ch = curl_init();
65
-
66
- curl_setopt($ch,CURLOPT_URL, "http://www.tidiochat.com/access/create?url=" . urlencode($domainName) . "&platform=magento&email=$adminEmail&_ip=$remoteAddr");
67
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
68
-
69
- curl_setopt($ch, CURLOPT_HEADER, 0);
70
- $output = curl_exec($ch);
71
- curl_close($ch);
72
-
73
- $json = json_decode($output);
74
-
75
- return array('public_key' => $json->value->public_key, 'private_key' => $json->value->private_key);
76
- }
77
-
78
-
79
-
80
-
81
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Tidio/Chat/etc/config.xml CHANGED
@@ -69,15 +69,6 @@
69
  </blocks>
70
 
71
  <events>
72
- <adminhtml_block_html_before>
73
- <observers>
74
- <tidio_chat_load_model_observer>
75
- <type>singleton</type>
76
- <class>Tidio_Chat_Model_Observer</class>
77
- <method>hookToAdminLoad</method>
78
- </tidio_chat_load_model_observer>
79
- </observers>
80
- </adminhtml_block_html_before>
81
 
82
  </events>
83
 
69
  </blocks>
70
 
71
  <events>
 
 
 
 
 
 
 
 
 
72
 
73
  </events>
74
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>chat_tidio</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license>GNU G eneral Public License ( GPL )</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Description </description>
11
  <notes>Notes </notes>
12
  <authors><author><name>Tytus Go&#x142;as</name><user>tytustytus</user><email>tytus@tidio.net</email></author></authors>
13
- <date>2014-08-26</date>
14
- <time>09:48:01</time>
15
- <contents><target name="magelocal"><dir name="Tidio"><dir name="Chat"><dir name="Block"><dir name="Adminhtml"><file name="Menu.php" hash="a36eeb7b9240eb4cae2b52d817883acb"/></dir><file name="Script.php" hash="4807b8dcd76f35a5b9d59aa8a7521d26"/></dir><dir name="Helper"><file name="Data.php" hash="4c45ffbb6ea2d5a043f7203842e2c079"/></dir><dir name="Model"><file name="Observer.php" hash="1452f7189bc873b4cbbb0dc15409a78e"/></dir><dir name="etc"><file name="config.xml" hash="3dc148206920cd8198644097705188ed"/><file name="system.xml" hash="ae343f9c2378f7e99252f8fb57b5f6a0"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Tidio_Chat.xml" hash="9788abdf12bd16ab9f6a83a908a05d31"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="tidio_chat.xml" hash="d969c4490a190e2127fd8e7caa5bf294"/></dir><dir name="template"><dir name="tidiochat"><file name="script.phtml" hash="b02b8e0f7bd476473eee0a0453f3491b"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>chat_tidio</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license>GNU G eneral Public License ( GPL )</license>
7
  <channel>community</channel>
10
  <description>Description </description>
11
  <notes>Notes </notes>
12
  <authors><author><name>Tytus Go&#x142;as</name><user>tytustytus</user><email>tytus@tidio.net</email></author></authors>
13
+ <date>2014-09-05</date>
14
+ <time>15:55:21</time>
15
+ <contents><target name="magelocal"><dir name="Tidio"><dir name="Chat"><dir name="Block"><dir name="Adminhtml"><file name="Menu.php" hash="9159a048d458c20aa22a256231949a7b"/></dir><file name="Script.php" hash="4807b8dcd76f35a5b9d59aa8a7521d26"/></dir><dir name="Helper"><file name="Data.php" hash="4c45ffbb6ea2d5a043f7203842e2c079"/></dir><dir name="etc"><file name="config.xml" hash="6565d22bb62b4af5b903004907a5a1f3"/><file name="system.xml" hash="ae343f9c2378f7e99252f8fb57b5f6a0"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Tidio_Chat.xml" hash="9788abdf12bd16ab9f6a83a908a05d31"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="tidio_chat.xml" hash="d969c4490a190e2127fd8e7caa5bf294"/></dir><dir name="template"><dir name="tidiochat"><file name="script.phtml" hash="b02b8e0f7bd476473eee0a0453f3491b"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>