ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,81 @@
<?php
/**
* @package Plumrocket_CookieConsentPro
* @copyright Copyright (c) 2025 Plumrocket Inc.
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsentPro\Model\Config\Backend\GlobalPrivacyControl;
use Magento\Framework\App\Config\Value;
/**
* @since 1.0.1
*/
class CookieCategoriesToDecline extends Value
{
/**
* @var \Plumrocket\CookieConsentPro\Model\Config\Source\CookieCategories
*/
private $cookieCategories;
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
* @param \Plumrocket\CookieConsentPro\Model\Config\Source\CookieCategories $cookieCategories
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
\Plumrocket\CookieConsentPro\Model\Config\Source\CookieCategories $cookieCategories,
?\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
?\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
parent::__construct(
$context,
$registry,
$config,
$cacheTypeList,
$resource,
$resourceCollection,
$data
);
$this->cookieCategories = $cookieCategories;
}
/**
* Remove essential cookie categories from value before save
*
* @return $this
*/
public function beforeSave()
{
$value = $this->getValue();
if (! is_array($value)) {
$value = explode(',', (string)$value);
}
$disabledCategories = [];
foreach ($this->cookieCategories->toOptionArray() as $option) {
if ($option['isEssential']) {
$disabledCategories[] = $option['value'];
}
}
// Remove essential categories from the value
$value = array_diff($value, $disabledCategories);
$this->setValue($value);
return parent::beforeSave();
}
}
@@ -0,0 +1,32 @@
<?php
/**
* @package Plumrocket_CookieConsentPro
* @copyright Copyright (c) 2025 Plumrocket Inc.
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsentPro\Model\Config\Source;
use Plumrocket\Base\Model\OptionSource\AbstractSource;
/**
* @since 1.0.1
*/
class ConsentInitiator extends AbstractSource
{
public const INITIATOR_CUSTOMER = 'customer';
public const INITIATOR_GPC = 'gpc';
/**
* @return array
*/
public function toOptionHash(): array
{
return [
self::INITIATOR_CUSTOMER => __('Customer'),
self::INITIATOR_GPC => __('GPC Signal'),
];
}
}
@@ -0,0 +1,63 @@
<?php
/**
* @package Plumrocket_CookieConsentPro
* @copyright Copyright (c) 2025 Plumrocket Inc.
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsentPro\Model\Config\Source;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Data\OptionSourceInterface;
use Plumrocket\CookieConsent\Model\CategoryRepository;
/**
* @since 1.0.1
*/
class CookieCategories implements OptionSourceInterface
{
/**
* @var \Magento\Framework\Api\SearchCriteriaBuilder
*/
private $searchCriteriaBuilder;
/**
* @var \Plumrocket\CookieConsent\Model\CategoryRepository
*/
private $cookieCategoryRepository;
/**
* @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
* @param \Plumrocket\CookieConsent\Model\CategoryRepository $cookieCategoryRepository
*/
public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
CategoryRepository $cookieCategoryRepository
) {
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->cookieCategoryRepository = $cookieCategoryRepository;
}
/**
* @return array
*/
public function toOptionArray(): array
{
$options = [];
$categories = $this->cookieCategoryRepository
->getList($this->searchCriteriaBuilder->create())
->getItems();
foreach ($categories as $category) {
$options[] = [
'value' => $category->getKey(),
'label' => $category->getName(),
'isEssential' => $category->getIsEssential()
];
}
return $options;
}
}
@@ -0,0 +1,32 @@
<?php
/**
* @package Plumrocket_CookieConsentPro
* @copyright Copyright (c) 2025 Plumrocket Inc.
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsentPro\Model\Config\Source\GlobalPrivacyControl;
use Plumrocket\Base\Model\OptionSource\AbstractSource;
/**
* @since 1.0.1
*/
class CookieConsentBehavior extends AbstractSource
{
public const DECLINE_ALL_CATEGORIES = 'decline_all';
public const DECLINE_SPECIFIC_CATEGORIES = 'decline_specific';
/**
* @return array
*/
public function toOptionHash(): array
{
return [
self::DECLINE_ALL_CATEGORIES => __('Decline All Non-Essential Cookies'),
self::DECLINE_SPECIFIC_CATEGORIES => __('Decline Specific Cookie Categories'),
];
}
}
@@ -0,0 +1,50 @@
<?php
/**
* @package Plumrocket_CookieConsentPro
* @copyright Copyright (c) 2025 Plumrocket Inc.
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsentPro\Model\Consent;
use Magento\Framework\Model\AbstractModel;
use Plumrocket\CookieConsentPro\Api\Data\ConsentLogInterface;
/**
* @since 1.0.1
*/
class Log extends \Plumrocket\CookieConsent\Model\Consent\Log implements ConsentLogInterface
{
/**
* @inheritDoc
*/
public function getInitiatedBy()
{
return $this->getData(self::INITIATED_BY);
}
/**
* @inheritDoc
*/
public function setInitiatedBy(string $initiatedBy)
{
$this->setData(self::INITIATED_BY, $initiatedBy);
return $this;
}
/**
* @return AbstractModel
*/
public function beforeSave()
{
$initiatedBy = $this->getInitiatedBy();
if (empty($initiatedBy)) {
$this->setInitiatedBy('Сustomer');
}
return parent::beforeSave();
}
}
@@ -0,0 +1,93 @@
<?php
/**
* @package Plumrocket_CookieConsentPro
* @copyright Copyright (c) 2025 Plumrocket Inc.
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsentPro\Model\Consent;
use Magento\Customer\Helper\Session\CurrentCustomer;
use Magento\Framework\App\Response\RedirectInterface;
use Magento\Framework\HTTP\Header;
use Magento\Framework\HTTP\PhpEnvironment\RemoteAddress;
use Magento\Framework\Stdlib\DateTime\DateTime;
use Magento\Store\Model\StoreManagerInterface;
use Plumrocket\CookieConsent\Api\Data\ConsentLogInterface;
use Plumrocket\CookieConsent\Api\Data\ConsentLogInterfaceFactory;
use Plumrocket\CookieConsent\Model\ResourceModel\ConsentLog as ConsentLogResource;
use Plumrocket\CookieConsentPro\Api\Data\ConsentLogInterface as ProConsentLogInterface;
use Plumrocket\CookieConsentPro\Model\Config\Source\ConsentInitiator;
use Plumrocket\GlobalPrivacyControl\Api\IsGpcSignalHandledInterface;
/**
* @since 1.0.1
*/
class Logger extends \Plumrocket\CookieConsent\Model\Consent\Logger
{
/**
* @var \Plumrocket\CookieConsent\Model\ResourceModel\ConsentLog
*/
private $consentLogResource;
/**
* @var \Plumrocket\GlobalPrivacyControl\Api\IsGpcSignalHandledInterface
*/
private $isGpcSignalHandled;
/**
* @param \Plumrocket\CookieConsent\Api\Data\ConsentLogInterfaceFactory $consentLogFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
* @param \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer
* @param \Plumrocket\CookieConsent\Model\ResourceModel\ConsentLog $consentLogResource
* @param \Magento\Framework\HTTP\Header $httpHeader
* @param \Magento\Framework\App\Response\RedirectInterface $redirect
* @param \Plumrocket\GlobalPrivacyControl\Api\IsGpcSignalHandledInterface $isGpcSignalHandled
*/
public function __construct(
ConsentLogInterfaceFactory $consentLogFactory,
StoreManagerInterface $storeManager,
RemoteAddress $remoteAddress,
DateTime $dateTime,
CurrentCustomer $currentCustomer,
ConsentLogResource $consentLogResource,
Header $httpHeader,
RedirectInterface $redirect,
IsGpcSignalHandledInterface $isGpcSignalHandled
) {
parent::__construct(
$consentLogFactory,
$storeManager,
$remoteAddress,
$dateTime,
$currentCustomer,
$consentLogResource,
$httpHeader,
$redirect
);
$this->consentLogResource = $consentLogResource;
$this->isGpcSignalHandled = $isGpcSignalHandled;
}
/**
* @param array $settings
* @return \Plumrocket\CookieConsent\Api\Data\ConsentLogInterface
* @throws \Magento\Framework\Exception\AlreadyExistsException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function log(array $settings): ConsentLogInterface
{
$consentLog = parent::log($settings);
if ($this->isGpcSignalHandled->execute()) {
$consentLog->setData(ProConsentLogInterface::INITIATED_BY, ConsentInitiator::INITIATOR_GPC);
$this->consentLogResource->save($consentLog);
}
return $consentLog;
}
}
@@ -0,0 +1,113 @@
<?php
/**
* @package Plumrocket_CookieConsentPro
* @copyright Copyright (c) 2025 Plumrocket Inc.
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsentPro\Model\Integration;
use Plumrocket\Base\Api\ConfigUtilsInterface;
use Plumrocket\CookieConsent\Helper\Config;
use Plumrocket\GlobalPrivacyControl\Helper\Config as GlobalPrivacyControlConfig;
use Plumrocket\CookieConsentPro\Model\Config\Source\CookieCategories;
use \Plumrocket\CookieConsentPro\Model\Config\Source\GlobalPrivacyControl\CookieConsentBehavior;
/**
* @since 1.0.1
*/
class GlobalPrivacyControl
{
public const XML_PATH_COOKIE_CONSENT_BEHAVIOR = 'pr_gpc/cookie_consent_management/behavior';
public const XML_PATH_COOKIE_CATEGORIES_TO_DECLINE = 'pr_gpc/cookie_consent_management/categories_to_decline';
/**
* @var \Plumrocket\CookieConsent\Helper\Config
*/
private $config;
/**
* @var \Plumrocket\CookieConsentPro\Model\Config\Source\CookieCategories
*/
private $cookieCategories;
/**
* @var \Plumrocket\GlobalPrivacyControl\Helper\Config
*/
private $globalPrivacyControlConfig;
/**
* @var \Plumrocket\Base\Api\ConfigUtilsInterface
*/
private $configUtils;
/**
* @param \Plumrocket\CookieConsent\Helper\Config $config
* @param \Plumrocket\CookieConsentPro\Model\Config\Source\CookieCategories $cookieCategories
* @param \Plumrocket\GlobalPrivacyControl\Helper\Config $globalPrivacyControlConfig
* @param \Plumrocket\Base\Api\ConfigUtilsInterface $configUtils
*/
public function __construct(
Config $config,
CookieCategories $cookieCategories,
GlobalPrivacyControlConfig $globalPrivacyControlConfig,
ConfigUtilsInterface $configUtils
) {
$this->config = $config;
$this->cookieCategories = $cookieCategories;
$this->globalPrivacyControlConfig = $globalPrivacyControlConfig;
$this->configUtils = $configUtils;
}
/**
* @return bool
*/
public function isEnabled(): bool
{
if (! $this->config->isModuleEnabled()) {
return false;
}
if (! $this->globalPrivacyControlConfig->isModuleEnabled())
{
return false;
}
return true;
}
/**
* @param $store
* @return bool
*/
public function shouldDeclineAllCategories($store = null): bool
{
return CookieConsentBehavior::DECLINE_ALL_CATEGORIES === $this->configUtils->getStoreConfig(self::XML_PATH_COOKIE_CONSENT_BEHAVIOR, $store);
}
/**
* Get non-essential cookie categories to decline
*
* @param null $store
* @return array
*/
public function getCategoriesToDecline($store = null): array
{
$categoriesToDecline = $this->shouldDeclineAllCategories()
? array_keys($this->cookieCategories->toOptionHash())
: $this->configUtils->prepareMultiselectValue(
$this->configUtils->getStoreConfig(self::XML_PATH_COOKIE_CATEGORIES_TO_DECLINE, $store)
);
$essentialCategories = [];
foreach ($this->cookieCategories->toOptionArray() as $option) {
if ($option['isEssential']) {
$essentialCategories[] = $option['value'];
}
}
return array_diff($categoriesToDecline, $essentialCategories);
}
}
@@ -0,0 +1,97 @@
<?php
/**
* @package Plumrocket_CookieConsentPro
* @copyright Copyright (c) 2025 Plumrocket Inc.
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsentPro\Model\Integration;
use Magento\Framework\Serialize\SerializerInterface;
use Plumrocket\Base\Api\ConfigUtilsInterface;
use Plumrocket\CookieConsent\Helper\Config;
/**
* @since 1.0.0
*/
class MicrosoftAds
{
public const XML_PATH_ENABLED = 'pr_cookie/integrations/microsoft_ads/enabled';
public const XML_PATH_CONSENT_TYPES = 'pr_cookie/integrations/microsoft_ads/consent_types';
/**
* @var \Plumrocket\CookieConsent\Helper\Config
*/
private $config;
/**
* @var \Plumrocket\Base\Api\ConfigUtilsInterface
*/
private $configUtils;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/**
* @param \Plumrocket\CookieConsent\Helper\Config $config
* @param \Plumrocket\Base\Api\ConfigUtilsInterface $configUtils
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/
public function __construct(
Config $config,
ConfigUtilsInterface $configUtils,
SerializerInterface $serializer
) {
$this->config = $config;
$this->configUtils = $configUtils;
$this->serializer = $serializer;
}
/**
* @return bool
*/
public function isEnabled(): bool
{
if (! $this->config->isModuleEnabled()) {
return false;
}
if (! $this->configUtils->isSetFlag(self::XML_PATH_ENABLED)) {
return false;
}
if (! $this->getConsentTypesConfig()) {
return false;
}
return true;
}
/**
* @param $store
* @return array[]
*/
public function getConsentTypesConfig($store = null): array
{
$config = $this->configUtils->getStoreConfig(self::XML_PATH_CONSENT_TYPES, $store);
if (is_string($config)) {
$config = $this->serializer->unserialize($config);
}
$result = [];
foreach ($config as $item) {
$consentType = $item['consent_type'];
$result[$consentType] = [
'cookie_category' => $item['cookie_category'],
'default_status' => $item['status'],
];
}
return $result;
}
}
@@ -0,0 +1,99 @@
<?php
/**
* @package Plumrocket_CookieConsentPro
* @copyright Copyright (c) 2025 Plumrocket Inc.
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsentPro\Model\Integration;
use Magento\Framework\Serialize\SerializerInterface;
use Plumrocket\Base\Api\ConfigUtilsInterface;
use Plumrocket\CookieConsent\Helper\Config;
/**
* @since 1.0.0
*/
class MicrosoftClarity
{
public const XML_PATH_ENABLED = 'pr_cookie/integrations/microsoft_clarity/enabled';
public const XML_PATH_CONSENT_TYPES = 'pr_cookie/integrations/microsoft_clarity/consent_types';
/**
* @var \Plumrocket\CookieConsent\Helper\Config
*/
private $config;
/**
* @var \Plumrocket\Base\Api\ConfigUtilsInterface
*/
private $configUtils;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/**
* @param \Plumrocket\CookieConsent\Helper\Config $config
* @param \Plumrocket\Base\Api\ConfigUtilsInterface $configUtils
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/
public function __construct(
Config $config,
ConfigUtilsInterface $configUtils,
SerializerInterface $serializer
) {
$this->config = $config;
$this->configUtils = $configUtils;
$this->serializer = $serializer;
}
/**
* @return bool
*/
public function isEnabled(): bool
{
if (! $this->config->isModuleEnabled()) {
return false;
}
if (! $this->configUtils->isSetFlag(self::XML_PATH_ENABLED)) {
return false;
}
if (! $this->getConsentTypesConfig()) {
return false;
}
return true;
}
/**
* Get consent types config.
*
* @param mixed $store
* @return array
*/
public function getConsentTypesConfig($store = null): array
{
$config = $this->configUtils->getStoreConfig(self::XML_PATH_CONSENT_TYPES, $store);
if (is_string($config)) {
$config = $this->serializer->unserialize($config);
}
$result = [];
foreach ($config as $item) {
$consentType = $item['consent_type'];
$result[$consentType] = [
'cookie_category' => $item['cookie_category'],
'default_status' => $item['status'],
];
}
return $result;
}
}