Skip to content

Commit 03f51c2

Browse files
committed
Initial commit
0 parents  commit 03f51c2

File tree

14 files changed

+516
-0
lines changed

14 files changed

+516
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
/**
3+
* SOZO Design Ltd
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the SOZO Proprietary EULA
8+
* that is bundled with this package in the file LICENSE.
9+
* It is also available through the world-wide-web at this URL:
10+
* http://opensource.org/licenses/osl-3.0.php
11+
*
12+
* @category SOZO Design Ltd
13+
* @package Sozo_ZendeskChat
14+
* @copyright Copyright (c) 2020 SOZO Design Ltd (https://sozodesign.co.uk)
15+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16+
*/
17+
18+
namespace Sozo\ZendeskChat\Block\System\Config\Form\Fieldset;
19+
20+
use Magento\Backend\Block\Template;
21+
use Magento\Backend\Block\Template\Context;
22+
use Magento\Framework\Data\Form\Element\AbstractElement;
23+
use Magento\Framework\Data\Form\Element\Renderer\RendererInterface;
24+
use Sozo\ZendeskChat\Helper\Data;
25+
26+
/**
27+
* Class Details
28+
* @package Sozo\ZendeskChat\Block\System\Config\Form\Fieldset
29+
*/
30+
class Details extends Template implements RendererInterface
31+
{
32+
33+
/**
34+
* @var Data
35+
*/
36+
protected $helper;
37+
38+
/**
39+
* @var string
40+
*/
41+
protected $_template = 'Sozo_ZendeskChat::system/config/fieldset/details.phtml';
42+
43+
/**
44+
* Details constructor.
45+
* @param Context $context
46+
* @param Data $helper
47+
* @param array $data
48+
*/
49+
public function __construct(
50+
Context $context,
51+
Data $helper,
52+
array $data = []
53+
) {
54+
parent::__construct($context, $data);
55+
$this->helper = $helper;
56+
}
57+
58+
/**
59+
* @param AbstractElement $element
60+
* @return string
61+
*/
62+
public function render(AbstractElement $element)
63+
{
64+
return $this->toHtml();
65+
}
66+
67+
/**
68+
* @return mixed
69+
*/
70+
public function getVersion()
71+
{
72+
return $this->helper->getExtensionVersion();
73+
}
74+
75+
}

Block/Widget.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* SOZO Design Ltd
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the SOZO Proprietary EULA
8+
* that is bundled with this package in the file LICENSE.
9+
* It is also available through the world-wide-web at this URL:
10+
* http://opensource.org/licenses/osl-3.0.php
11+
*
12+
* @category SOZO Design Ltd
13+
* @package Sozo_ZendeskChat
14+
* @copyright Copyright (c) 2020 SOZO Design Ltd (https://sozodesign.co.uk)
15+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16+
*/
17+
18+
namespace Sozo\ZendeskChat\Block;
19+
20+
21+
use Magento\Framework\View\Element\Template;
22+
use Magento\Framework\View\Element\Template\Context;
23+
use Sozo\ZendeskChat\Helper\Data;
24+
25+
class Widget extends Template
26+
{
27+
28+
protected $helper;
29+
30+
public function __construct(
31+
Context $context,
32+
Data $helper,
33+
array $data = []
34+
){
35+
$this->helper = $helper;
36+
parent::__construct($context, $data);
37+
}
38+
39+
public function getWidgetId()
40+
{
41+
return $this->helper->getWidgetId();
42+
}
43+
44+
}

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Sozo Zendesk Chat Module Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7+
8+
Given a version number MAJOR.MINOR.PATCH, increment the:
9+
10+
* MAJOR version when you make incompatible API changes,
11+
* MINOR version when you add functionality in a backwards-compatible manner, and
12+
* PATCH version when you make backwards-compatible bug fixes.
13+
14+
##### Types of changes
15+
* [Added] for new features.
16+
* [Changed] for changes in existing functionality.
17+
* [Deprecated] for soon-to-be removed features.
18+
* [Removed] for now removed features.
19+
* [Fixed] for any bug fixes.
20+
* [Security] in case of vulnerabilities.
21+
22+
### [Unreleased]
23+
- Initial Release
24+

Helper/Data.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* SOZO Design Ltd
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the SOZO Proprietary EULA
8+
* that is bundled with this package in the file LICENSE.
9+
* It is also available through the world-wide-web at this URL:
10+
* http://opensource.org/licenses/osl-3.0.php
11+
*
12+
* @category SOZO Design Ltd
13+
* @package Sozo_ZendeskChat
14+
* @copyright Copyright (c) 2020 SOZO Design Ltd (https://sozodesign.co.uk)
15+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16+
*/
17+
18+
namespace Sozo\ZendeskChat\Helper;
19+
20+
21+
use Magento\Framework\App\Helper\AbstractHelper;
22+
use Magento\Framework\App\Helper\Context;
23+
use Magento\Framework\Module\ModuleListInterface;
24+
use Magento\Store\Model\ScopeInterface;
25+
26+
/**
27+
* Class Data
28+
* @package Sozo\ZendeskChat\Helper
29+
*/
30+
class Data extends AbstractHelper
31+
{
32+
33+
const SZ_ZENDESKCHAT_ENABLED = 'sozo_zendeskchat/general/enabled';
34+
const SZ_ZENDESKCHAT_WIDGET_ID = 'sozo_zendeskchat/general/widget_id';
35+
36+
/**
37+
* @var ModuleListInterface
38+
*/
39+
protected $moduleList;
40+
41+
/**
42+
* Data constructor.
43+
* @param Context $context
44+
* @param ModuleListInterface $moduleList
45+
*/
46+
public function __construct(
47+
Context $context,
48+
ModuleListInterface $moduleList
49+
){
50+
$this->moduleList = $moduleList;
51+
parent::__construct($context);
52+
}
53+
54+
/**
55+
* @return bool
56+
*/
57+
public function isEnabled()
58+
{
59+
return $this->scopeConfig->isSetFlag(self::SZ_ZENDESKCHAT_ENABLED, ScopeInterface::SCOPE_STORE);
60+
}
61+
62+
/**
63+
* @return mixed
64+
*/
65+
public function getWidgetId()
66+
{
67+
return $this->scopeConfig->getValue(self::SZ_ZENDESKCHAT_WIDGET_ID, ScopeInterface::SCOPE_STORE);
68+
}
69+
70+
/**
71+
* @return mixed
72+
*/
73+
public function getExtensionVersion()
74+
{
75+
$moduleCode = 'Sozo_ZendeskChat';
76+
$moduleInfo = $this->moduleList->getOne($moduleCode);
77+
return $moduleInfo['setup_version'];
78+
}
79+
80+
}

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Sozo Zendesk Chat Module Magento 2
2+
3+
## About
4+
5+
A plugin for Magento 2 that outputs the Zendesk Chat javascript code into the website
6+
7+
8+

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "sozodesign/magento2-module-sozo-zendeskchat",
3+
"description": "SOZO Magento 2 module for Zendesk Chat",
4+
"config": {
5+
"sort-packages": true
6+
},
7+
"authors": [
8+
{
9+
"name": "Becky Doggett",
10+
"email": "[email protected]",
11+
"homepage": "https://sozodesign.co.uk",
12+
"role": "Developer"
13+
}
14+
15+
],
16+
"require": {
17+
"magento/framework": "102.0.*"
18+
},
19+
"type": "magento2-module",
20+
"license": "Proprietary",
21+
"autoload": {
22+
"files": [
23+
"registration.php"
24+
],
25+
"psr-4": {
26+
"Sozo\\ZendeskChat\\": ""
27+
}
28+
}
29+
}

etc/acl.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ SOZO Design
4+
~
5+
~ NOTICE OF LICENSE
6+
~
7+
~ This source file is subject to the Open Software License (OSL 3.0)
8+
~ that is bundled with this package in the file LICENSE.
9+
~ It is also available through the world-wide-web at this URL:
10+
~ http://opensource.org/licenses/osl-3.0.php
11+
~
12+
~ @category SOZO Design
13+
~ @package Sozo_ZendeskChat
14+
~ @copyright Copyright (c) 2020 SOZO Design Ltd (https://sozodesign.co.uk)
15+
~ @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16+
~
17+
-->
18+
19+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
20+
<acl>
21+
<resources>
22+
<resource id="Magento_Backend::admin">
23+
<resource id="Magento_Backend::stores">
24+
<resource id="Magento_Backend::stores_settings">
25+
<resource id="Magento_Config::config">
26+
<resource id="Sozo_Zendeskchat::config" title="ZendeskChat" sortOrder="120"/>
27+
</resource>
28+
</resource>
29+
</resource>
30+
</resource>
31+
</resources>
32+
</acl>
33+
</config>

etc/adminhtml/system.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ SOZO Design
4+
~
5+
~ NOTICE OF LICENSE
6+
~
7+
~ This source file is subject to the Open Software License (OSL 3.0)
8+
~ that is bundled with this package in the file LICENSE.
9+
~ It is also available through the world-wide-web at this URL:
10+
~ http://opensource.org/licenses/osl-3.0.php
11+
~
12+
~ @category SOZO Design
13+
~ @package Sozo_ZendeskChat
14+
~ @copyright Copyright (c) 2020 SOZO Design Ltd (https://sozodesign.co.uk)
15+
~ @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16+
~
17+
-->
18+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
19+
<system>
20+
<tab id="sozodesign" translate="label" sortOrder="100001" class="sozodesign-tab">
21+
<label>SOZO Design Extensions</label>
22+
</tab>
23+
<section id="sozo_zendeskchat" translate="label" sortOrder="100" showInDefault="1" showInWebsite="1"
24+
showInStore="1">
25+
<class>separator-top</class>
26+
<label><![CDATA[Zendesk Chat]]></label>
27+
<tab>sozodesign</tab>
28+
<resource>Sozo_ZendeskChat::config</resource>
29+
<group id="details" translate="label" type="text" sortOrder="0" showInDefault="1" showInWebsite="1"
30+
showInStore="1">
31+
<frontend_model>Sozo\ZendeskChat\Block\System\Config\Form\Fieldset\Details</frontend_model>
32+
</group>
33+
<group id="general" translate="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
34+
<label>General</label>
35+
<attribute type="expanded">1</attribute>
36+
<field id="enabled" type="select" translate="label" sortOrder="10" showInDefault="1" showInStore="1"
37+
showInWebsite="1">
38+
<label>Enabled</label>
39+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
40+
</field>
41+
42+
<field id="widget_id" translate="label comment" type="text" sortOrder="30" showInDefault="1"
43+
showInStore="1" showInWebsite="1">
44+
<label>Widget ID</label>
45+
<comment>Enter the Widget ID from your script.</comment>
46+
<depends>
47+
<field id="enabled">1</field>
48+
</depends>
49+
</field>
50+
</group>
51+
</section>
52+
</system>
53+
</config>

etc/config.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ SOZO Design
4+
~
5+
~ NOTICE OF LICENSE
6+
~
7+
~ This source file is subject to the Open Software License (OSL 3.0)
8+
~ that is bundled with this package in the file LICENSE.
9+
~ It is also available through the world-wide-web at this URL:
10+
~ http://opensource.org/licenses/osl-3.0.php
11+
~
12+
~ @category SOZO Design
13+
~ @package Sozo_ZendeskChat
14+
~ @copyright Copyright (c) 2020 SOZO Design Ltd (https://sozodesign.co.uk)
15+
~ @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16+
~
17+
-->
18+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
19+
<default>
20+
<sozo_zendeskchat>
21+
<general>
22+
<enabled>0</enabled>
23+
<widget_id></widget_id>
24+
</general>
25+
</sozo_zendeskchat>
26+
</default>
27+
</config>

0 commit comments

Comments
 (0)