Initial commit

This commit is contained in:
2020-10-07 10:37:15 +02:00
commit ce5f440392
28157 changed files with 4429172 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class APIFAQ
{
/**
* @param string $module_key
* @param mixed $version
*
* @return object|false
*/
public function getData($module_key, $version)
{
if (function_exists('curl_init') == false) {
return false;
}
$context = Context::getContext();
$iso_code = Language::getIsoById($context->language->id);
$url = 'http://api.addons.prestashop.com/request/faq/' . $module_key . '/' . $version . '/' . $iso_code;
$options = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
];
$CURL = curl_init();
curl_setopt_array($CURL, $options);
$content = curl_exec($CURL);
curl_close($CURL);
if (!$content) {
return false;
}
/** @var object $content */
$content = Tools::jsonDecode($content, true);
if (empty($content->categories)) {
return false;
}
return $content->categories;
}
}

View File

@@ -0,0 +1,152 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class GDPRConsent extends ObjectModel
{
/**
* @var int
*/
public $id_module;
/**
* @var bool
*/
public $active;
/**
* @var bool
*/
public $error;
/**
* @var string
*/
public $error_message;
/**
* @var string|string[] Translated field
*/
public $message;
/**
* @var string
*/
public $date_add;
/**
* @var string
*/
public $date_upd;
/**
* @see ObjectModel::$definition
*/
public static $definition = [
'table' => 'psgdpr_consent',
'primary' => 'id_gdpr_consent',
'multilang' => true,
'multilang_shop' => true,
'fields' => [
// Config fields
'id_module' => ['type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true],
'active' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true],
'error' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => false],
'error_message' => ['type' => self::TYPE_HTML, 'validate' => 'isCleanHtml', 'required' => false],
// Lang fields
'message' => ['type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 4000],
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
'date_upd' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
],
];
/**
* Return the list of all the modules registered on our hook and active
*
* @return array who contains id_module, message
*/
public static function getAllRegisteredModules()
{
$modules = Db::getInstance()->executeS('
SELECT psgdpr.id_gdpr_consent, psgdpr.id_module
FROM `' . _DB_PREFIX_ . 'psgdpr_consent` psgdpr
INNER JOIN `' . _DB_PREFIX_ . 'module` module ON (module.id_module = psgdpr.id_module)'
);
if (empty($modules)) {
return [];
}
return $modules;
}
/**
* Return the Consent Message registered for a specificed module in the right language
*
* @param int $id_module id of the specified module
* @param int $id_lang id of the language used
*
* @return string the Consent Message
*/
public static function getConsentMessage($id_module, $id_lang)
{
$message = Db::getInstance()->getValue('
SELECT psgdprl.message FROM `' . _DB_PREFIX_ . 'psgdpr_consent` psgdpr
LEFT JOIN ' . _DB_PREFIX_ . 'psgdpr_consent_lang psgdprl ON (psgdpr.id_gdpr_consent = psgdprl.id_gdpr_consent)
WHERE psgdpr.id_module = ' . (int) $id_module . ' AND psgdprl.id_lang =' . (int) $id_lang
);
if (empty($message)) {
return '';
}
return $message;
}
/**
* Return the Consent module active
*
* @param int $id_module id of the specified module
*
* @return bool if the module consent is enable or not
*/
public static function getConsentActive($id_module)
{
return (bool) Db::getInstance()->getValue('
SELECT psgdpr.active FROM `' . _DB_PREFIX_ . 'psgdpr_consent` psgdpr
WHERE psgdpr.id_module = ' . (int) $id_module
);
}
/**
* Allow to know if the module has been already added in the database
*
* @param int $id_module id of the module
* @param int $id_shop id of the current shop
*
* @return bool true if the module already exist or false if not
*/
public static function checkIfExist($id_module, $id_shop)
{
return (bool) Db::getInstance()->getValue('
SELECT id_module FROM `' . _DB_PREFIX_ . 'psgdpr_consent` psgdpr
LEFT JOIN ' . _DB_PREFIX_ . 'psgdpr_consent_lang psgdprl ON (psgdpr.id_gdpr_consent = psgdprl.id_gdpr_consent)
WHERE psgdpr.id_module = ' . (int) $id_module . ' AND psgdprl.id_shop =' . (int) $id_shop
);
}
}

View File

@@ -0,0 +1,192 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class GDPRLog extends ObjectModel
{
/**
* @var int
*/
public $id_customer;
/**
* @var int
*/
public $id_guest;
/**
* @var string
*/
public $client_name;
/**
* @var int
*/
public $id_module;
/**
* @var string
*/
public $request_type;
/**
* @var string
*/
public $data_add;
/**
* @var string
*/
public $data_upd;
/**
* @see ObjectModel::$definition
*/
public static $definition = [
'table' => 'psgdpr_log',
'primary' => 'id_gdpr_log',
'multishop' => true,
'fields' => [
// Config fields
'id_gdpr_log' => ['type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => false],
'id_customer' => ['type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => false],
'id_guest' => ['type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => false],
'client_name' => ['type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => false],
'id_module' => ['type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => false],
'request_type' => ['type' => self::TYPE_BOOL, 'validate' => 'isInt', 'required' => true],
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
'date_upd' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
],
];
/**
* log consent
*
* @param int $id_customer Customer identifier
* @param string $request_type
* @param int $id_module Module identifier
* @param int $id_guest Guest identifier
* @param mixed $value
*
* @return bool
*
* @throws PrestaShopDatabaseException
*/
public static function addLog($id_customer, $request_type, $id_module, $id_guest = 0, $value = null)
{
/** @var Psgdpr|false $psgdpr */
$psgdpr = Module::getInstanceByName('psgdpr');
$client_name = '';
if ($id_customer && $psgdpr) {
$client_name = $psgdpr->getCustomerNameById((int) $id_customer);
$id_guest = 0;
} elseif ($value) {
$client_name = $value;
} elseif ($psgdpr) {
$client_name = $psgdpr->l('Guest client : ID') . $id_guest;
}
switch ($request_type) {
case 'consent':
$request_type = 1;
break;
case 'exportPdf':
$request_type = 2;
break;
case 'exportCsv':
$request_type = 3;
break;
case 'delete':
$request_type = 4;
break;
}
$exist = (bool) Db::getInstance()->getValue('
SELECT 1 FROM `' . _DB_PREFIX_ . 'psgdpr_log`
WHERE date_add = NOW()
AND date_upd = NOW()
AND id_customer = ' . (int) $id_customer . '
AND id_guest = ' . (int) $id_guest . '
AND client_name = "' . pSQL($client_name) . '"
AND id_module = ' . (int) $id_module . '
AND request_type = ' . (int) $request_type
);
if ($exist) {
return true;
}
$now = date('Y-m-d H:i:s');
return Db::getInstance()->insert(
'psgdpr_log',
[
'id_customer' => (int) $id_customer,
'id_guest' => (int) $id_guest,
'client_name' => pSQL($client_name),
'id_module' => (int) $id_module,
'request_type' => (int) $request_type,
'date_add' => $now,
'date_upd' => $now,
]
);
}
/**
* @return array
*
* @throws PrestaShopDatabaseException
*/
public static function getLogs()
{
$logs = Db::getInstance()->executeS('
SELECT *
FROM `' . _DB_PREFIX_ . 'psgdpr_log`'
);
if (empty($logs)) {
return [];
}
$result = [];
foreach ($logs as $log) {
$module_name = '';
if (!empty($log['id_module'])) {
/** @var Psgdpr|false $module */
$module = Module::getInstanceById($log['id_module']);
if ($module) {
$module_name = $module->displayName;
}
}
$result[] = [
'id_gdpr_log' => $log['id_gdpr_log'],
'id_customer' => $log['id_customer'],
'id_guest' => $log['id_guest'],
'client_name' => $log['client_name'],
'module_name' => $module_name,
'id_module' => $log['id_module'],
'request_type' => $log['request_type'],
'date_add' => $log['date_add'],
];
unset($module);
}
return $result;
}
}

View File

@@ -0,0 +1,149 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
// require _PS_MODULE_DIR_.'psgdpr/psgdpr.php';
class HTMLTemplatePSGDPRModule extends HTMLTemplate
{
/**
* @var array
*/
public $personalData;
/**
* @var bool
*/
public $available_in_your_account = false;
/**
* @var Context
*/
public $context;
/**
* @param array $personalData
* @param Smarty $smarty
*
* @throws PrestaShopException
*/
public function __construct($personalData, Smarty $smarty)
{
$this->personalData = $personalData;
$this->smarty = $smarty;
$this->context = Context::getContext();
$firstname = $this->personalData['prestashopData']['customerInfo']['firstname'];
$lastname = $this->personalData['prestashopData']['customerInfo']['lastname'];
$this->title = $firstname . ' ' . $lastname;
$this->date = Tools::displayDate(date('Y-m-d H:i:s'));
$this->shop = new Shop((int) Context::getContext()->shop->id);
}
/**
* Returns the template's HTML footer
*
* @return string HTML footer
*
* @throws SmartyException
*/
public function getFooter()
{
$shop_address = $this->getShopAddress();
$this->smarty->assign([
'available_in_your_account' => $this->available_in_your_account,
'shop_address' => $shop_address,
'shop_fax' => Configuration::get('PS_SHOP_FAX'),
'shop_phone' => Configuration::get('PS_SHOP_PHONE'),
'shop_details' => Configuration::get('PS_SHOP_DETAILS'),
'free_text' => '',
]);
return $this->smarty->fetch($this->getTemplate('footer'));
}
/**
* Returns the template's HTML content
*
* @return string HTML content
*
* @throws SmartyException
*/
public function getContent()
{
// Generate smarty data
$this->smarty->assign([
'customerInfo' => $this->personalData['prestashopData']['customerInfo'],
'addresses' => $this->personalData['prestashopData']['addresses'],
'orders' => $this->personalData['prestashopData']['orders'],
'carts' => $this->personalData['prestashopData']['carts'],
'messages' => $this->personalData['prestashopData']['messages'],
'connections' => $this->personalData['prestashopData']['connections'],
'modules' => $this->personalData['modulesData'],
]);
// Generate templates after, to be able to reuse data above
$this->smarty->assign([
'style_tab' => $this->smarty->fetch($this->getGDPRTemplate('personalData.style-tab')),
'generalInfo_tab' => $this->smarty->fetch($this->getGDPRTemplate('personalData.generalInfo-tab')),
'orders_tab' => $this->smarty->fetch($this->getGDPRTemplate('personalData.orders-tab')),
'carts_tab' => $this->smarty->fetch($this->getGDPRTemplate('personalData.carts-tab')),
'addresses_tab' => $this->smarty->fetch($this->getGDPRTemplate('personalData.addresses-tab')),
'messages_tab' => $this->smarty->fetch($this->getGDPRTemplate('personalData.messages-tab')),
'connections_tab' => $this->smarty->fetch($this->getGDPRTemplate('personalData.connections-tab')),
'modules_tab' => $this->smarty->fetch($this->getGDPRTemplate('personalData.modules-tab')),
]);
return $this->smarty->fetch($this->getGDPRTemplate('personalData'));
}
/**
* Returns the template filename
*
* @return string filename
*/
public function getFilename()
{
return 'personalData-' . date('Y-m-d') . '.pdf';
}
/**
* Returns the template filename
*
* @return string filename
*/
public function getBulkFilename()
{
return 'personalData-' . date('Y-m-d') . '.pdf';
}
/**
* If the template is not present in the theme directory, it will return the default template
* in _PS_PDF_DIR_ directory
*
* @param string $template_name
*
* @return string
*/
protected function getGDPRTemplate($template_name)
{
return _PS_MODULE_DIR_ . 'psgdpr/views/templates/front/pdf/' . $template_name . '.tpl';
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;