ltsecurityinc安防产品在线商城代码
This commit is contained in:
+97
@@ -0,0 +1,97 @@
|
||||
<?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\Block\Adminhtml\Buttons\ActionsLog;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\LogEntryRepositoryInterface;
|
||||
use Amasty\AdminActionsLog\Model\ConfigProvider;
|
||||
use Amasty\AdminActionsLog\Restoring\RestoreValidator;
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
use Magento\Framework\Escaper;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
class RestoreButton implements ButtonProviderInterface
|
||||
{
|
||||
/**
|
||||
* @var ConfigProvider
|
||||
*/
|
||||
private $configProvider;
|
||||
|
||||
/**
|
||||
* @var LogEntryRepositoryInterface
|
||||
*/
|
||||
private $logEntryRepository;
|
||||
|
||||
/**
|
||||
* @var RestoreValidator
|
||||
*/
|
||||
private $restoreValidator;
|
||||
|
||||
/**
|
||||
* @var Escaper
|
||||
*/
|
||||
private $escaper;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\App\RequestInterface
|
||||
*/
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\UrlInterface
|
||||
*/
|
||||
private $urlBuilder;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
ConfigProvider $configProvider,
|
||||
LogEntryRepositoryInterface $logEntryRepository,
|
||||
RestoreValidator $restoreValidator,
|
||||
Escaper $escaper
|
||||
) {
|
||||
$this->configProvider = $configProvider;
|
||||
$this->logEntryRepository = $logEntryRepository;
|
||||
$this->restoreValidator = $restoreValidator;
|
||||
$this->escaper = $escaper;
|
||||
$this->request = $context->getRequest();
|
||||
$this->urlBuilder = $context->getUrlBuilder();
|
||||
}
|
||||
|
||||
public function getButtonData()
|
||||
{
|
||||
$id = (int)$this->request->getParam('id');
|
||||
try {
|
||||
$logEntry = $this->logEntryRepository->getById($id);
|
||||
} catch (\Exception $e) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if ($this->restoreValidator->isValid($logEntry)) {
|
||||
return [
|
||||
'label' => __('Restore Changes'),
|
||||
'class' => 'restore_changes',
|
||||
'on_click' => $this->getClickAction($id),
|
||||
'sort_order' => 20
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getClickAction(int $id): string
|
||||
{
|
||||
return sprintf(
|
||||
'confirmSetLocation("%s", "%s")',
|
||||
$this->escaper->escapeJs($this->configProvider->getRestoreSettingsText()),
|
||||
$this->urlBuilder->getUrl('amaudit/actionslog/restore', ['id' => $id])
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?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\Block\Adminhtml\Buttons;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Magento\Framework\AuthorizationInterface;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
class GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
/**
|
||||
* @var UrlInterface
|
||||
*/
|
||||
protected $urlBuilder;
|
||||
|
||||
/**
|
||||
* @var RequestInterface
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var AuthorizationInterface
|
||||
*/
|
||||
protected $authorization;
|
||||
|
||||
public function __construct(
|
||||
Context $context
|
||||
) {
|
||||
$this->urlBuilder = $context->getUrlBuilder();
|
||||
$this->request = $context->getRequest();
|
||||
$this->authorization = $context->getAuthorization();
|
||||
}
|
||||
|
||||
public function getUrl($route = '', $params = []): string
|
||||
{
|
||||
return $this->urlBuilder->getUrl($route, $params);
|
||||
}
|
||||
|
||||
public function getButtonData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?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\Block\Adminhtml\Buttons\Grid;
|
||||
|
||||
use Amasty\AdminActionsLog\Block\Adminhtml\Buttons\GenericButton;
|
||||
|
||||
class ClearLogging extends GenericButton
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Amasty_AdminActionsLog::clear_logging';
|
||||
|
||||
public function getButtonData(): array
|
||||
{
|
||||
if ($this->authorization->isAllowed(self::ADMIN_RESOURCE)) {
|
||||
$alertMessage = __('Are you sure you want to do this?');
|
||||
$onClick = sprintf(
|
||||
'deleteConfirm("%s", "%s")',
|
||||
$alertMessage,
|
||||
$this->getClearLogUrl()
|
||||
);
|
||||
|
||||
return [
|
||||
'label' => __('Clear Log'),
|
||||
'class' => 'primary',
|
||||
'on_click' => $onClick,
|
||||
'sort_order' => 10,
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getClearLogUrl(): string
|
||||
{
|
||||
return $this->getUrl('*/*/clear');
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?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\Block\Adminhtml\Buttons\Grid;
|
||||
|
||||
use Amasty\AdminActionsLog\Block\Adminhtml\Buttons\GenericButton;
|
||||
|
||||
class TerminateAllSessions extends GenericButton
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Amasty_AdminActionsLog::active_sessions';
|
||||
|
||||
public function getButtonData(): array
|
||||
{
|
||||
if ($this->authorization->isAllowed(self::ADMIN_RESOURCE)) {
|
||||
$alertMessage = __('Are you sure you want to terminate all sessions?'
|
||||
. ' Your current session will also be terminated.');
|
||||
$onClick = sprintf(
|
||||
'deleteConfirm("%s", "%s")',
|
||||
$alertMessage,
|
||||
$this->getClearLogUrl()
|
||||
);
|
||||
|
||||
return [
|
||||
'label' => __('Terminate All Sessions'),
|
||||
'class' => 'primary',
|
||||
'on_click' => $onClick,
|
||||
'sort_order' => 10,
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getClearLogUrl(): string
|
||||
{
|
||||
return $this->getUrl('*/*/clear');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user