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,64 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Controller\Adminhtml\ActionsLog;
use Amasty\AdminActionsLog\Api\LogEntryRepositoryInterface;
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractActionsLog;
use Magento\Backend\App\Action\Context;
use Magento\Backend\Model\Auth\Session;
class Clear extends AbstractActionsLog
{
/**
* @var LogEntryRepositoryInterface
*/
private $logEntryRepository;
/**
* @var Session
*/
private $backendSession;
public function __construct(
Context $context,
LogEntryRepositoryInterface $logEntryRepository,
Session $backendSession
) {
parent::__construct($context);
$this->logEntryRepository = $logEntryRepository;
$this->backendSession = $backendSession;
}
public function execute()
{
if ($storeIds = $this->getAvailableStoreIds()) {
$this->logEntryRepository->cleanByStoreIds($storeIds);
} else {
$this->logEntryRepository->clean();
}
$this->messageManager->addSuccessMessage(__('Actions Log has been successfully cleared.'));
return $this->resultRedirectFactory->create()->setRefererUrl();
}
private function getAvailableStoreIds(): array
{
$userRole = $this->backendSession->getUser()->getRole();
if ($userRole->getData('gws_is_all')) {
return [];
}
if ($userRole->getData('gws_stores')) {
return $userRole->getData('gws_stores');
}
return [];
}
}
@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Controller\Adminhtml\ActionsLog;
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractActionsLog;
use Magento\Framework\Controller\ResultFactory;
class Edit extends AbstractActionsLog
{
public function execute()
{
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$resultPage->setActiveMenu('Amasty_AdminActionsLog::amaudit');
$resultPage->addBreadcrumb(__('Admin Actions Log'), __('Actions Log'));
$resultPage->getConfig()->getTitle()->prepend(__('Actions Log'));
return $resultPage;
}
}
@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Controller\Adminhtml\ActionsLog;
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractActionsLog;
use Magento\Framework\Controller\ResultFactory;
class Index extends AbstractActionsLog
{
public function execute()
{
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$resultPage->setActiveMenu('Amasty_AdminActionsLog::amaudit');
$resultPage->addBreadcrumb(__('Admin Actions Log'), __('Actions Log'));
$resultPage->getConfig()->getTitle()->prepend(__('Actions Log'));
return $resultPage;
}
}
@@ -0,0 +1,134 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Controller\Adminhtml\ActionsLog;
use Amasty\AdminActionsLog\Api\Data\LogEntryInterfaceFactory;
use Amasty\AdminActionsLog\Api\LogEntryRepositoryInterface;
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractActionsLog;
use Amasty\AdminActionsLog\Model\LogEntry\ResourceModel\Grid\CollectionFactory;
use Amasty\AdminActionsLog\Restoring\RestoreProcessor;
use Amasty\AdminActionsLog\Restoring\RestoreValidator;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Indexer\SaveHandler\Batch;
use Magento\Ui\Component\MassAction\Filter;
use Psr\Log\LoggerInterface;
class MassRestore extends AbstractActionsLog
{
/**
* @var RestoreProcessor
*/
private $restoreProcessor;
/**
* @var RestoreValidator
*/
private $restoreValidator;
/**
* @var Filter
*/
private $filter;
/**
* @var Batch
*/
private $batch;
/**
* @var CollectionFactory
*/
private $collectionFactory;
/**
* @var LogEntryInterfaceFactory
*/
private $logEntryFactory;
/**
* @var LogEntryRepositoryInterface
*/
private $entryRepository;
/**
* @var LoggerInterface
*/
private $logger;
public function __construct(
Context $context,
RestoreProcessor $restoreProcessor,
RestoreValidator $restoreValidator,
CollectionFactory $collectionFactory,
LogEntryInterfaceFactory $logEntryFactory,
LogEntryRepositoryInterface $entryRepository,
Filter $filter,
Batch $batch,
LoggerInterface $logger
) {
parent::__construct($context);
$this->restoreProcessor = $restoreProcessor;
$this->restoreValidator = $restoreValidator;
$this->filter = $filter;
$this->batch = $batch;
$this->collectionFactory = $collectionFactory;
$this->logEntryFactory = $logEntryFactory;
$this->entryRepository = $entryRepository;
$this->logger = $logger;
}
public function execute()
{
$this->filter->applySelectionOnTargetProvider();
$collection = $this->filter->getCollection($this->collectionFactory->create());
$successRestore = $skippedRestore = $failedRestore = [];
/** @var \Magento\Framework\Api\Search\DocumentInterface $logEntryDocument */
foreach ($this->batch->getItems($collection, 10) as $batch) {
foreach ($batch as $logEntryDocument) {
$logEntry = $this->entryRepository->getById((int)$logEntryDocument->getId());
if ($this->restoreValidator->isValid($logEntry)) {
try {
$this->restoreProcessor->restoreChanges($logEntry);
$successRestore[] = $logEntry->getId();
} catch (LocalizedException $e) {
$failedRestore[] = $logEntry->getId();
} catch (\Exception $e) {
$failedRestore[] = $logEntry->getId();
$this->logger->critical($e);
}
} else {
$skippedRestore[] = $logEntry->getId();
}
}
}
if (!empty($successRestore)) {
$this->messageManager->addSuccessMessage(
__('A total of %1 record(s) have been restored.', count($successRestore))
);
}
if (!empty($skippedRestore)) {
$this->messageManager->addWarningMessage(
__('The restoring of records (%1) is not allowed.', implode(', ', $skippedRestore))
);
}
if (!empty($failedRestore)) {
$this->messageManager->addErrorMessage(
__('Failed to restore the records (%1).', implode(', ', $failedRestore))
);
}
return $this->resultRedirectFactory->create()->setPath('*/*/index');
}
}
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Controller\Adminhtml\ActionsLog;
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractActionsLog;
use Amasty\AdminActionsLog\Model\LogEntry\Frontend\LogDetailsFormatter;
use Amasty\Base\Model\Serializer;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Controller\ResultFactory;
class Preview extends AbstractActionsLog
{
/**
* @var LogDetailsFormatter
*/
private $detailsFormatter;
/**
* @var Serializer
*/
private $jsonSerializer;
public function __construct(
Context $context,
LogDetailsFormatter $detailsFormatter,
Serializer $jsonSerializer
) {
parent::__construct($context);
$this->detailsFormatter = $detailsFormatter;
$this->jsonSerializer = $jsonSerializer;
}
public function execute()
{
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
if ($logEntryId = (int)$this->getRequest()->getParam('element_id')) {
try {
$data = $this->detailsFormatter->format($logEntryId);
$result = [
'isError' => false,
'data' => $data
];
} catch (\RuntimeException $e) {
$result = [
'isError' => true,
'message' => $e->getMessage()
];
} finally {
$resultJson->setData($result);
}
}
return $resultJson;
}
}
@@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Controller\Adminhtml\ActionsLog;
use Amasty\AdminActionsLog\Api\Data\LogEntryInterface;
use Amasty\AdminActionsLog\Api\LogEntryRepositoryInterface;
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractActionsLog;
use Amasty\AdminActionsLog\Restoring\RestoreProcessor;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Exception\LocalizedException;
use Psr\Log\LoggerInterface;
class Restore extends AbstractActionsLog
{
/**
* @var LogEntryRepositoryInterface
*/
private $logEntryRepository;
/**
* @var RestoreProcessor
*/
private $restoreProcessor;
/**
* @var LoggerInterface
*/
private $logger;
public function __construct(
Context $context,
LogEntryRepositoryInterface $logEntryRepository,
RestoreProcessor $restoreProcessor,
LoggerInterface $logger
) {
parent::__construct($context);
$this->logEntryRepository = $logEntryRepository;
$this->restoreProcessor = $restoreProcessor;
$this->logger = $logger;
}
public function execute()
{
try {
/** @var LogEntryInterface $logEntry */
$logEntry = $this->logEntryRepository->getById((int)$this->getRequest()->getParam('id'));
$this->restoreProcessor->restoreChanges($logEntry);
$this->messageManager->addSuccessMessage(__('Changes have been successfully restored.'));
} catch (LocalizedException $e) {
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addErrorMessage(__('Something went wrong.'));
$this->logger->critical($e);
}
return $this->resultRedirectFactory->create()->setRefererUrl();
}
}