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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?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\Edit\Tab;
|
||||
|
||||
use Amasty\AdminActionsLog\Controller\Adminhtml\AbstractActionsLog;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Framework\View\Element\Text\ListText;
|
||||
|
||||
class History extends ListText implements TabInterface
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\AuthorizationInterface
|
||||
*/
|
||||
protected $authorization;
|
||||
|
||||
public function __construct(
|
||||
\Magento\Framework\View\Element\Context $context,
|
||||
\Magento\Framework\AuthorizationInterface $authorization,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $data);
|
||||
$this->authorization = $authorization;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Tab label
|
||||
*
|
||||
* @return \Magento\Framework\Phrase
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('History of Changes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Tab title
|
||||
*
|
||||
* @return \Magento\Framework\Phrase
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return __('History of Changes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Can show tab in tabs
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return $this->authorization->isAllowed(AbstractActionsLog::ADMIN_RESOURCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab is hidden
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isAjaxLoaded()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?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\System\Config\Form;
|
||||
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
|
||||
class Email extends \Magento\Config\Block\System\Config\Form\Field
|
||||
{
|
||||
/**
|
||||
* @param AbstractElement $element
|
||||
*
|
||||
* @return string
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
protected function _getElementHtml(AbstractElement $element)
|
||||
{
|
||||
$js = '<script type="text/javascript">
|
||||
require([
|
||||
"Magento_Ui/js/lib/view/utils/async",
|
||||
"Amasty_AdminActionsLog/js/form/tag-it"
|
||||
], function ($) {
|
||||
"use strict";
|
||||
|
||||
var input = "#' . $element->getHtmlId() . '";
|
||||
$.async(input, (function() {
|
||||
$(input).tagit();
|
||||
}));
|
||||
});
|
||||
</script>';
|
||||
$element->setAfterElementJs($js);
|
||||
$element->setData('class', "amactionslog-input");
|
||||
|
||||
return parent::_getElementHtml($element);
|
||||
}
|
||||
}
|
||||
+53
@@ -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\System\Config\Form;
|
||||
|
||||
use Amasty\Geoip\Helper\Data as GeoipHelper;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
use Magento\Framework\Module\Manager as ModuleManager;
|
||||
|
||||
class Geolocation extends \Magento\Config\Block\System\Config\Form\Field
|
||||
{
|
||||
/**
|
||||
* @var ModuleManager
|
||||
*/
|
||||
private $moduleManager;
|
||||
|
||||
/**
|
||||
* @var GeoIpHelper
|
||||
*/
|
||||
private $geoipHelper;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
ModuleManager $moduleManager,
|
||||
GeoipHelper $geoipHelper,
|
||||
array $data = []
|
||||
) {
|
||||
$this->moduleManager = $moduleManager;
|
||||
$this->geoipHelper = $geoipHelper;
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
protected function _getElementHtml(AbstractElement $element)
|
||||
{
|
||||
$element->setDisabled(true);
|
||||
|
||||
if ($this->moduleManager->isEnabled('Amasty_Geoip')
|
||||
&& $this->geoipHelper->isDone(false)
|
||||
) {
|
||||
$element->setDisabled(false);
|
||||
}
|
||||
|
||||
return parent::_getElementHtml($element);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user