Skip to content

Commit d83192f

Browse files
committed
Add install / remove functions, send information to Smartsupp:
- partner key - platform via PHP API - platform via JS API
1 parent 400c333 commit d83192f

10 files changed

Lines changed: 91 additions & 44 deletions

File tree

smartsupp.ocmod/upload/admin/controller/extension/module/smartsupp.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
class ControllerExtensionModuleSmartsupp extends Controller
99
{
10+
/**
11+
* Smartsupp partner key for Magento platform
12+
*/
13+
const PARNER_KEY = 'j29hnc919y';
1014

1115
const SETTING_NAME = 'smartsupp';
1216

@@ -32,8 +36,10 @@ public function index()
3236
'email' => $_POST['email'],
3337
'password' => $_POST['password'],
3438
'consentTerms' => 1,
39+
'platform' => 'Opencart ' . $this->getOpenCartVersion(),
40+
'partnerKey' => self::PARNER_KEY,
3541
);
36-
$result = $_GET['action'] === 'register' ? $api->create($data + array('lang' => $this->language->get('code'))) : $api->login($data + array('partnerKey' => 'j29hnc919y'));
42+
$result = $_GET['action'] === 'register' ? $api->create($data + array('lang' => $this->language->get('code'))) : $api->login($data);
3743
if (isset($result['error'])) {
3844
$message = $result['message'];
3945
$formAction = $_GET['action'];
@@ -103,6 +109,20 @@ public function index()
103109
$this->response->setOutput($this->load->view('extension/module/smartsupp', $data));
104110
}
105111

112+
private function getOpenCartVersion()
113+
{
114+
return defined('VERSION') ? VERSION : '???';
115+
}
116+
117+
public function install() {
118+
$this->load->model('setting/setting');
119+
$this->model_setting_setting->editSetting('module_smartsupp', ['module_smartsupp_status'=>1]);
120+
}
121+
122+
public function uninstall() {
123+
$this->load->model('setting/setting');
124+
$this->model_setting_setting->deleteSetting('module_smartsupp_status');
125+
}
106126
}
107127

108128
class SmartsuppModuleExtensionTranslator

smartsupp.ocmod/upload/catalog/controller/extension/module/smartsupp.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ public function index()
3030
$chat->setName($this->customer->getFirstName() . ' ' . $this->customer->getLastName());
3131
$chat->setEmail($this->customer->getEmail());
3232
}
33+
$chat->setPlatform('Opencart ' . $this->getOpenCartVersion());
3334
$data['chat'] = $chat->render();
3435
$data['customCode'] = isset($settings[self::SETTING_NAME . 'customCode']) ? $settings[self::SETTING_NAME . 'customCode'] : NULL;
3536
}
3637

3738
return $this->load->view('extension/module/smartsupp', $data);
3839
}
3940

41+
private function getOpenCartVersion()
42+
{
43+
return defined('VERSION') ? VERSION : '???';
44+
}
4045
}

smartsupp.ocmod/upload/system/library/smartsupp/composer.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

smartsupp.ocmod/upload/system/library/smartsupp/vendor/composer/ClassLoader.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class ClassLoader
5353

5454
private $useIncludePath = false;
5555
private $classMap = array();
56-
5756
private $classMapAuthoritative = false;
57+
private $missingClasses = array();
5858

5959
public function getPrefixes()
6060
{
@@ -322,20 +322,20 @@ public function findFile($class)
322322
if (isset($this->classMap[$class])) {
323323
return $this->classMap[$class];
324324
}
325-
if ($this->classMapAuthoritative) {
325+
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
326326
return false;
327327
}
328328

329329
$file = $this->findFileWithExtension($class, '.php');
330330

331331
// Search for Hack files if we are running on HHVM
332-
if ($file === null && defined('HHVM_VERSION')) {
332+
if (false === $file && defined('HHVM_VERSION')) {
333333
$file = $this->findFileWithExtension($class, '.hh');
334334
}
335335

336-
if ($file === null) {
336+
if (false === $file) {
337337
// Remember that this class does not exist.
338-
return $this->classMap[$class] = false;
338+
$this->missingClasses[$class] = true;
339339
}
340340

341341
return $file;
@@ -399,6 +399,8 @@ private function findFileWithExtension($class, $ext)
399399
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
400400
return $file;
401401
}
402+
403+
return false;
402404
}
403405
}
404406

smartsupp.ocmod/upload/system/library/smartsupp/vendor/composer/autoload_namespaces.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
$baseDir = dirname($vendorDir);
77

88
return array(
9-
'Smartsupp' => array($vendorDir . '/smartsupp/chat-code-generator/src', $vendorDir . '/smartsupp/php-partner-client/src'),
9+
'Smartsupp' => array($vendorDir . '/smartsupp/php-partner-client/src', $vendorDir . '/smartsupp/chat-code-generator/src'),
1010
);

smartsupp.ocmod/upload/system/library/smartsupp/vendor/composer/autoload_static.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class ComposerStaticInit8a11ce1759d170e1c7e2501b752e3653
1111
array (
1212
'Smartsupp' =>
1313
array (
14-
0 => __DIR__ . '/..' . '/smartsupp/chat-code-generator/src',
15-
1 => __DIR__ . '/..' . '/smartsupp/php-partner-client/src',
14+
0 => __DIR__ . '/..' . '/smartsupp/php-partner-client/src',
15+
1 => __DIR__ . '/..' . '/smartsupp/chat-code-generator/src',
1616
),
1717
),
1818
);

smartsupp.ocmod/upload/system/library/smartsupp/vendor/composer/installed.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
[
22
{
3-
"name": "smartsupp/chat-code-generator",
3+
"name": "smartsupp/php-partner-client",
44
"version": "1.0",
55
"version_normalized": "1.0.0.0",
66
"source": {
77
"type": "git",
8-
"url": "https://github.com/smartsupp/chat-code-generator.git",
9-
"reference": "1659eaa267318039dc65c63a8588944c69a5803c"
8+
"url": "https://github.com/smartsupp/php-auth-client.git",
9+
"reference": "29f19b60b1c4609fd1d3a6da346b6c69dbc0a4b5"
1010
},
1111
"dist": {
1212
"type": "zip",
13-
"url": "https://api.github.com/repos/smartsupp/chat-code-generator/zipball/1659eaa267318039dc65c63a8588944c69a5803c",
14-
"reference": "1659eaa267318039dc65c63a8588944c69a5803c",
13+
"url": "https://api.github.com/repos/smartsupp/php-auth-client/zipball/29f19b60b1c4609fd1d3a6da346b6c69dbc0a4b5",
14+
"reference": "29f19b60b1c4609fd1d3a6da346b6c69dbc0a4b5",
1515
"shasum": ""
1616
},
1717
"require": {
1818
"php": ">=5.3.2"
1919
},
2020
"require-dev": {
21-
"phpunit/phpunit": "4.7.*"
21+
"phpunit/phpunit": "4.8.*"
2222
},
23-
"time": "2015-12-01 14:49:12",
23+
"time": "2016-06-28 09:23:17",
2424
"type": "library",
25-
"extra": {
26-
"branch-alias": {
27-
"dev-master": "1.0.x-dev"
28-
}
29-
},
3025
"installation-source": "dist",
3126
"autoload": {
3227
"psr-0": {
@@ -40,35 +35,40 @@
4035
"role": "lead"
4136
}
4237
],
43-
"description": "This simple PHP class allows you to easily generate Smartsupp.com JS chat code.",
38+
"description": "API client allows to register and login (obtain API key) from Smartsupp partner API.",
4439
"homepage": "https://www.smartsupp.com/",
4540
"keywords": [
4641
"chat"
4742
]
4843
},
4944
{
50-
"name": "smartsupp/php-partner-client",
51-
"version": "1.0",
52-
"version_normalized": "1.0.0.0",
45+
"name": "smartsupp/chat-code-generator",
46+
"version": "1.0.1",
47+
"version_normalized": "1.0.1.0",
5348
"source": {
5449
"type": "git",
55-
"url": "https://github.com/smartsupp/php-auth-client.git",
56-
"reference": "29f19b60b1c4609fd1d3a6da346b6c69dbc0a4b5"
50+
"url": "https://github.com/smartsupp/chat-code-generator.git",
51+
"reference": "1f63b44aeb90a1cd9e37b260a35b0ccb3377feea"
5752
},
5853
"dist": {
5954
"type": "zip",
60-
"url": "https://api.github.com/repos/smartsupp/php-auth-client/zipball/29f19b60b1c4609fd1d3a6da346b6c69dbc0a4b5",
61-
"reference": "29f19b60b1c4609fd1d3a6da346b6c69dbc0a4b5",
55+
"url": "https://api.github.com/repos/smartsupp/chat-code-generator/zipball/1f63b44aeb90a1cd9e37b260a35b0ccb3377feea",
56+
"reference": "1f63b44aeb90a1cd9e37b260a35b0ccb3377feea",
6257
"shasum": ""
6358
},
6459
"require": {
6560
"php": ">=5.3.2"
6661
},
6762
"require-dev": {
68-
"phpunit/phpunit": "4.8.*"
63+
"phpunit/phpunit": "4.7.*"
6964
},
70-
"time": "2016-06-28 09:23:17",
65+
"time": "2018-11-08 15:36:32",
7166
"type": "library",
67+
"extra": {
68+
"branch-alias": {
69+
"dev-master": "1.0.x-dev"
70+
}
71+
},
7272
"installation-source": "dist",
7373
"autoload": {
7474
"psr-0": {
@@ -82,7 +82,7 @@
8282
"role": "lead"
8383
}
8484
],
85-
"description": "API client allows to register and login (obtain API key) from Smartsupp partner API.",
85+
"description": "This simple PHP class allows you to easily generate Smartsupp.com JS chat code.",
8686
"homepage": "https://www.smartsupp.com/",
8787
"keywords": [
8888
"chat"

smartsupp.ocmod/upload/system/library/smartsupp/vendor/smartsupp/chat-code-generator/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
[![Build Status](https://travis-ci.org/smartsupp/chat-code-generator.svg)](https://travis-ci.org/smartsupp/chat-code-generator)
22
[![Coverage Status](https://coveralls.io/repos/smartsupp/chat-code-generator/badge.svg?branch=master&service=github)](https://coveralls.io/github/smartsupp/chat-code-generator?branch=master)
33

4-
smartsupp/chat-code-generator
5-
===============
4+
# Smartsupp chat code generator
65

7-
## Introduction
8-
9-
This is simple PHP class for SmartSupp.com chat API which helps you to generate chat JavaScript code.
6+
This is simple PHP class for Smartsupp chat API which helps you to generate chat JavaScript code.
107

8+
* https://www.smartsupp.com/
119
* [More info about Smartsupp CHAT API](https://developers.smartsupp.com/chat/configuration) This is "Get started" doc for chat API.
1210
* [More info about Smartsupp CHAT API - Overview](https://developers.smartsupp.com/chat/overview) This is full documentation for chat API. Note, that not all properties are possible to be set using this class.
1311

@@ -29,3 +27,7 @@ Here is an example on how to use it:
2927
$chat->setGoogleAnalytics('UA-123456');
3028
$data = $chat->render();
3129
```
30+
31+
## Copyright
32+
33+
Copyright (c) 2016 Smartsupp.com, s.r.o.

smartsupp.ocmod/upload/system/library/smartsupp/vendor/smartsupp/chat-code-generator/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"chat"
77
],
88
"homepage": "https://www.smartsupp.com/",
9-
"license": "",
109
"authors": [
1110
{
1211
"name": "Marek Gach",

smartsupp.ocmod/upload/system/library/smartsupp/vendor/smartsupp/chat-code-generator/src/Smartsupp/ChatGenerator.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,26 @@ class ChatGenerator
131131
*/
132132
protected $hide_widget = false;
133133

134+
/**
135+
* @var null|string plugin platform
136+
*/
137+
protected $platform = null;
138+
134139
public function __construct($key = null)
135140
{
136141
$this->key = $key;
137142
}
138143

144+
/**
145+
* Set platform - serves as internal information for Smartsupp to identify which CMS and version is used.
146+
*
147+
* @param string $platform
148+
*/
149+
public function setPlatform($platform)
150+
{
151+
$this->platform = $platform;
152+
}
153+
139154
/**
140155
* Set chat language. Also is checking if language is one of allowed values.
141156
*
@@ -305,7 +320,7 @@ public function setWidget($widget = 'widget')
305320
* @param $ga_key Google analytics key.
306321
* @param array|null $ga_options Additional gaOptions.
307322
*/
308-
public function setGoogleAnalytics($ga_key, Array $ga_options = null)
323+
public function setGoogleAnalytics($ga_key, array $ga_options = null)
309324
{
310325
$this->ga_key = $ga_key;
311326
$this->ga_options = $ga_options;
@@ -387,6 +402,10 @@ public function render($print_out = false)
387402
$params[] = "_smartsupp.offsetY = " . (int)$this->offset_y . "; // offset from top, default 100";
388403
}
389404

405+
if ($this->platform) {
406+
$params[] = "_smartsupp.sitePlatform = '" . self::javascriptEscape($this->platform) . "';";
407+
}
408+
390409
// set detailed visitor's info
391410
// basic info
392411
if ($this->email) {

0 commit comments

Comments
 (0)