ltsecurityinc安防产品在线商城代码
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
<?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;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
|
||||
abstract class AbstractActionsLog extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Amasty_AdminActionsLog::actions_log';
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?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;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
|
||||
abstract class AbstractActiveSessions extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Amasty_AdminActionsLog::active_sessions';
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?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;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
|
||||
abstract class AbstractLoginAttempts extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Amasty_AdminActionsLog::login_attempts';
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?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;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
|
||||
abstract class AbstractVisitHistory extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Amasty_AdminActionsLog::page_visit_history';
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
+134
@@ -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');
|
||||
}
|
||||
}
|
||||
+64
@@ -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;
|
||||
}
|
||||
}
|
||||
+66
@@ -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();
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<?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\ActiveSessions;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\ActiveSessionManagerInterface;
|
||||
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractActiveSessions;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
|
||||
class Clear extends AbstractActiveSessions
|
||||
{
|
||||
/**
|
||||
* @var ActiveSessionManagerInterface
|
||||
*/
|
||||
private $activeSessionManager;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
ActiveSessionManagerInterface $loginAttemptManager
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->activeSessionManager = $loginAttemptManager;
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$this->activeSessionManager->terminateAll();
|
||||
|
||||
return $this->resultRedirectFactory->create()->setRefererUrl();
|
||||
}
|
||||
}
|
||||
+28
@@ -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\ActiveSessions;
|
||||
|
||||
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractActiveSessions;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
|
||||
class Index extends AbstractActiveSessions
|
||||
{
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
|
||||
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
|
||||
$resultPage->setActiveMenu('Amasty_AdminActionsLog::active_sessions');
|
||||
$resultPage->addBreadcrumb(__('Active Sessions'), __('Active Sessions'));
|
||||
$resultPage->getConfig()->getTitle()->prepend(__('Active Sessions'));
|
||||
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?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\ActiveSessions;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\ActiveSessionManagerInterface;
|
||||
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractActiveSessions;
|
||||
use Amasty\AdminActionsLog\Model\ActiveSession\ActiveSession;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
|
||||
class Terminate extends AbstractActiveSessions
|
||||
{
|
||||
/**
|
||||
* @var ActiveSessionManagerInterface
|
||||
*/
|
||||
private $activeSessionManager;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
ActiveSessionManagerInterface $activeSessionManager
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->activeSessionManager = $activeSessionManager;
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
if ($sessionId = $this->getRequest()->getParam(ActiveSession::SESSION_ID)) {
|
||||
$this->activeSessionManager->terminate($sessionId);
|
||||
$this->messageManager->addSuccessMessage('Session has been successfully terminated.');
|
||||
}
|
||||
|
||||
return $this->resultRedirectFactory->create()->setRefererUrl();
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?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\LoginAttempts;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\LoginAttemptManagerInterface;
|
||||
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractLoginAttempts;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
|
||||
class Clear extends AbstractLoginAttempts
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Amasty_AdminActionsLog::clear_logging';
|
||||
|
||||
/**
|
||||
* @var LoginAttemptManagerInterface
|
||||
*/
|
||||
private $loginAttemptManager;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
LoginAttemptManagerInterface $loginAttemptManager
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->loginAttemptManager = $loginAttemptManager;
|
||||
}
|
||||
public function execute()
|
||||
{
|
||||
$this->loginAttemptManager->clear();
|
||||
$this->messageManager->addSuccessMessage(__('Login Attempts Log has been successfully cleared.'));
|
||||
|
||||
return $this->resultRedirectFactory->create()->setRefererUrl();
|
||||
}
|
||||
}
|
||||
+28
@@ -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\LoginAttempts;
|
||||
|
||||
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractLoginAttempts;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
|
||||
class Index extends AbstractLoginAttempts
|
||||
{
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
|
||||
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
|
||||
$resultPage->setActiveMenu('Amasty_AdminActionsLog::login_attempts');
|
||||
$resultPage->addBreadcrumb(__('Login Attempts'), __('Login Attempts'));
|
||||
$resultPage->getConfig()->getTitle()->prepend(__('Login Attempts'));
|
||||
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?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\VisitHistory;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\VisitHistoryManagerInterface;
|
||||
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractVisitHistory;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
|
||||
class Clear extends AbstractVisitHistory
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Amasty_AdminActionsLog::clear_logging';
|
||||
|
||||
/**
|
||||
* @var VisitHistoryManagerInterface
|
||||
*/
|
||||
private $visitHistoryManager;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
VisitHistoryManagerInterface $visitHistoryManager
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->visitHistoryManager = $visitHistoryManager;
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$this->visitHistoryManager->clear();
|
||||
$this->messageManager->addSuccessMessage(__('Page History Log has been successfully cleared.'));
|
||||
|
||||
return $this->resultRedirectFactory->create()->setRefererUrl();
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
<?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\VisitHistory;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\VisitHistoryEntryRepositoryInterface;
|
||||
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractVisitHistory;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
|
||||
|
||||
class GetDetails extends AbstractVisitHistory
|
||||
{
|
||||
/**
|
||||
* @var VisitHistoryEntryRepositoryInterface
|
||||
*/
|
||||
private $visitHistoryEntryRepository;
|
||||
|
||||
/**
|
||||
* @var TimezoneInterface
|
||||
*/
|
||||
private $localeDate;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
VisitHistoryEntryRepositoryInterface $visitHistoryEntryRepository,
|
||||
TimezoneInterface $localeDate
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->visitHistoryEntryRepository = $visitHistoryEntryRepository;
|
||||
$this->localeDate = $localeDate;
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$result = [];
|
||||
if ($id = (int)$this->getRequest()->getParam('id')) {
|
||||
$visitHistoryEntry = $this->visitHistoryEntryRepository->getById($id);
|
||||
$details = [];
|
||||
|
||||
foreach ($visitHistoryEntry->getVisitHistoryDetails() as $detail) {
|
||||
$details[] = $detail->getData();
|
||||
}
|
||||
|
||||
$sessionStart = $this->localeDate->formatDateTime(
|
||||
$visitHistoryEntry->getSessionStart() ?? '',
|
||||
\IntlDateFormatter::MEDIUM,
|
||||
\IntlDateFormatter::MEDIUM
|
||||
);
|
||||
$sessionEnd = $this->localeDate->formatDateTime(
|
||||
$visitHistoryEntry->getSessionEnd() ?? '',
|
||||
\IntlDateFormatter::MEDIUM,
|
||||
\IntlDateFormatter::MEDIUM
|
||||
);
|
||||
$result = $visitHistoryEntry->setVisitHistoryDetails($details)
|
||||
->setSessionStart($sessionStart)
|
||||
->setSessionEnd($sessionEnd)
|
||||
->getData();
|
||||
}
|
||||
|
||||
/** @var \Magento\Framework\Controller\Result\Json $resultPage */
|
||||
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
|
||||
$resultJson->setData($result);
|
||||
|
||||
return $resultJson;
|
||||
}
|
||||
}
|
||||
+28
@@ -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\VisitHistory;
|
||||
|
||||
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractVisitHistory;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
|
||||
class Index extends AbstractVisitHistory
|
||||
{
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
|
||||
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
|
||||
$resultPage->setActiveMenu('Amasty_AdminActionsLog::page_visit_history');
|
||||
$resultPage->addBreadcrumb(__('Visit History'), __('Visit History'));
|
||||
$resultPage->getConfig()->getTitle()->prepend(__('Visit History'));
|
||||
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user