ltsecurityinc安防产品在线商城代码
This commit is contained in:
+87
@@ -0,0 +1,87 @@
|
||||
/.buildpath
|
||||
/.cache
|
||||
/.metadata
|
||||
/.project
|
||||
/.settings
|
||||
/.vscode
|
||||
atlassian*
|
||||
/nbproject
|
||||
/robots.txt
|
||||
/pub/robots.txt
|
||||
/sitemap
|
||||
/sitemap.xml
|
||||
/pub/sitemap
|
||||
/pub/sitemap.xml
|
||||
/.idea
|
||||
/.gitattributes
|
||||
/app/config_sandbox
|
||||
/app/etc/config.php
|
||||
/app/etc/env.php
|
||||
/app/etc/env.php.*
|
||||
/app/code/Magento/TestModule*
|
||||
/lib/internal/flex/uploader/.actionScriptProperties
|
||||
/lib/internal/flex/uploader/.flexProperties
|
||||
/lib/internal/flex/uploader/.project
|
||||
/lib/internal/flex/uploader/.settings
|
||||
/lib/internal/flex/varien/.actionScriptProperties
|
||||
/lib/internal/flex/varien/.flexLibProperties
|
||||
/lib/internal/flex/varien/.project
|
||||
/lib/internal/flex/varien/.settings
|
||||
/node_modules
|
||||
/.grunt
|
||||
/Gruntfile.js
|
||||
/package.json
|
||||
/.php_cs
|
||||
/.php_cs.cache
|
||||
/.php-cs-fixer.php
|
||||
/.php-cs-fixer.cache
|
||||
/grunt-config.json
|
||||
/pub/media/*.*
|
||||
!/pub/media/.htaccess
|
||||
/pub/media/attribute/*
|
||||
!/pub/media/attribute/.htaccess
|
||||
/pub/media/analytics/*
|
||||
/pub/media/catalog/*
|
||||
!/pub/media/catalog/.htaccess
|
||||
/pub/media/customer/*
|
||||
!/pub/media/customer/.htaccess
|
||||
/pub/media/downloadable/*
|
||||
!/pub/media/downloadable/.htaccess
|
||||
/pub/media/favicon/*
|
||||
/pub/media/import/*
|
||||
!/pub/media/import/.htaccess
|
||||
/pub/media/logo/*
|
||||
/pub/media/custom_options/*
|
||||
!/pub/media/custom_options/.htaccess
|
||||
/pub/media/theme/*
|
||||
/pub/media/theme_customization/*
|
||||
!/pub/media/theme_customization/.htaccess
|
||||
/pub/media/wysiwyg/*
|
||||
!/pub/media/wysiwyg/.htaccess
|
||||
/pub/media/tmp/*
|
||||
!/pub/media/tmp/.htaccess
|
||||
/pub/media/captcha/*
|
||||
/pub/media/sitemap/*
|
||||
!/pub/media/sitemap/.htaccess
|
||||
/pub/static/*
|
||||
!/pub/static/.htaccess
|
||||
|
||||
/var/*
|
||||
!/var/.htaccess
|
||||
/vendor/*
|
||||
!/vendor/.htaccess
|
||||
/generated/*
|
||||
!/generated/.htaccess
|
||||
.DS_Store
|
||||
__MACOSX/
|
||||
|
||||
.dockerignore
|
||||
.editorconfig
|
||||
.htaccess
|
||||
.htaccess.sample
|
||||
.php-cs-fixer.dist.php
|
||||
.user.ini
|
||||
design-qa.md
|
||||
docker-compose.yml
|
||||
.docker/*
|
||||
pub/*
|
||||
File diff suppressed because it is too large
Load Diff
+7977
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
||||
Copyright © 2013-present Magento, Inc.
|
||||
|
||||
Each Magento source file included in this distribution is licensed under OSL 3.0 or the Magento Enterprise Edition (MEE) license
|
||||
|
||||
http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
Please see LICENSE.txt for the full text of the OSL 3.0 license or contact license@magentocommerce.com for a copy.
|
||||
|
||||
Subject to Licensee's payment of fees and compliance with the terms and conditions of the MEE License, the MEE License supersedes the OSL 3.0 license for each source file.
|
||||
Please see LICENSE_EE.txt for the full text of the MEE License or visit http://magento.com/legal/terms/enterprise.
|
||||
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
// For performance use one level down: 'name/{,*/}*.js'
|
||||
// If you want to recursively match all subfolders, use: 'name/**/*.js'
|
||||
|
||||
module.exports = function (grunt) {
|
||||
'use strict';
|
||||
|
||||
var _ = require('underscore'),
|
||||
path = require('path'),
|
||||
filesRouter = require('./dev/tools/grunt/tools/files-router'),
|
||||
configDir = './dev/tools/grunt/configs',
|
||||
tasks = grunt.file.expand('./dev/tools/grunt/tasks/*'),
|
||||
themes;
|
||||
|
||||
filesRouter.set('themes', 'dev/tools/grunt/configs/themes');
|
||||
themes = filesRouter.get('themes');
|
||||
|
||||
tasks = _.map(tasks, function (task) {
|
||||
return task.replace('.js', '');
|
||||
});
|
||||
tasks.push('time-grunt');
|
||||
tasks.forEach(function (task) {
|
||||
require(task)(grunt);
|
||||
});
|
||||
|
||||
require('load-grunt-config')(grunt, {
|
||||
configPath: path.join(__dirname, configDir),
|
||||
init: true,
|
||||
jitGrunt: {
|
||||
staticMappings: {
|
||||
usebanner: 'grunt-banner'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
_.each({
|
||||
/**
|
||||
* Assembling tasks.
|
||||
* ToDo: define default tasks.
|
||||
*/
|
||||
default: function () {
|
||||
grunt.log.subhead('I\'m default task and at the moment I\'m empty, sorry :/');
|
||||
},
|
||||
|
||||
/**
|
||||
* Production preparation task.
|
||||
*/
|
||||
prod: function (component) {
|
||||
var tasks = [
|
||||
'less',
|
||||
'cssmin',
|
||||
'usebanner'
|
||||
].map(function (task) {
|
||||
return task + ':' + component;
|
||||
});
|
||||
|
||||
if (typeof component === 'undefined') {
|
||||
grunt.log.subhead('Tip: Please make sure that u specify prod subtask. By default prod task do nothing');
|
||||
} else {
|
||||
grunt.task.run(tasks);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Refresh themes.
|
||||
*/
|
||||
refresh: function () {
|
||||
var tasks = [
|
||||
'clean',
|
||||
'exec:all'
|
||||
];
|
||||
_.each(themes, function (theme, name) {
|
||||
tasks.push('less:' + name);
|
||||
});
|
||||
grunt.task.run(tasks);
|
||||
},
|
||||
|
||||
/**
|
||||
* Documentation
|
||||
*/
|
||||
documentation: [
|
||||
'replace:documentation',
|
||||
'less:documentation',
|
||||
'styledocco:documentation',
|
||||
'usebanner:documentationCss',
|
||||
'usebanner:documentationLess',
|
||||
'usebanner:documentationHtml',
|
||||
'clean:var',
|
||||
'clean:pub'
|
||||
],
|
||||
|
||||
'legacy-build': [
|
||||
'mage-minify:legacy'
|
||||
],
|
||||
|
||||
spec: function (theme) {
|
||||
var runner = require('./dev/tests/js/jasmine/spec_runner');
|
||||
|
||||
runner.init(grunt, { theme: theme });
|
||||
|
||||
grunt.task.run(runner.getTasks());
|
||||
}
|
||||
}, function (task, name) {
|
||||
grunt.registerTask(name, task);
|
||||
});
|
||||
};
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
|
||||
Open Software License ("OSL") v. 3.0
|
||||
|
||||
This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
|
||||
|
||||
Licensed under the Open Software License version 3.0
|
||||
|
||||
1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
|
||||
|
||||
1. to reproduce the Original Work in copies, either alone or as part of a collective work;
|
||||
|
||||
2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
|
||||
|
||||
3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License;
|
||||
|
||||
4. to perform the Original Work publicly; and
|
||||
|
||||
5. to display the Original Work publicly.
|
||||
|
||||
2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
|
||||
|
||||
3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
|
||||
|
||||
4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
|
||||
|
||||
5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
|
||||
|
||||
6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
|
||||
|
||||
7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
|
||||
|
||||
8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
|
||||
|
||||
9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
|
||||
|
||||
10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
|
||||
|
||||
11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
|
||||
|
||||
12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
|
||||
|
||||
13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
|
||||
|
||||
14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
|
||||
|
||||
16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
|
||||
@@ -0,0 +1,48 @@
|
||||
|
||||
Academic Free License ("AFL") v. 3.0
|
||||
|
||||
This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
|
||||
|
||||
Licensed under the Academic Free License version 3.0
|
||||
|
||||
1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
|
||||
|
||||
1. to reproduce the Original Work in copies, either alone or as part of a collective work;
|
||||
|
||||
2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
|
||||
|
||||
3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License;
|
||||
|
||||
4. to perform the Original Work publicly; and
|
||||
|
||||
5. to display the Original Work publicly.
|
||||
|
||||
2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
|
||||
|
||||
3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
|
||||
|
||||
4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
|
||||
|
||||
5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
|
||||
|
||||
6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
|
||||
|
||||
7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
|
||||
|
||||
8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
|
||||
|
||||
9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
|
||||
|
||||
10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
|
||||
|
||||
11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
|
||||
|
||||
12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
|
||||
|
||||
13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
|
||||
|
||||
14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
|
||||
|
||||
16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
|
||||
@@ -0,0 +1,30 @@
|
||||
# LTS Magento Code Base
|
||||
|
||||
## Docker local development
|
||||
|
||||
Requirements: Docker Desktop with at least 4 GB of memory available to Docker.
|
||||
|
||||
Start the local services:
|
||||
|
||||
```shell
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
The storefront is available at <http://localhost:8080>. The default local-only
|
||||
admin account created during initial setup is `admin` / `Admin123!`; obtain the
|
||||
admin path with:
|
||||
|
||||
```shell
|
||||
docker compose exec php php bin/magento info:adminuri
|
||||
```
|
||||
|
||||
Useful commands:
|
||||
|
||||
```shell
|
||||
docker compose exec php php bin/magento cache:flush
|
||||
docker compose logs -f nginx php
|
||||
docker compose stop
|
||||
```
|
||||
|
||||
MySQL and OpenSearch data are stored in named Docker volumes, so `stop` or
|
||||
`down` does not delete the local site data.
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
# Reporting Security Issues
|
||||
|
||||
Magento values the contributions of the security research community, and we look forward to working with you to minimize risk to Magento merchants.
|
||||
|
||||
## Where should I report security issues?
|
||||
|
||||
We strongly encourage you to report all security issues privately via our [bug bounty program](https://hackerone.com/adobe). Please provide us with relevant technical details and repro steps to expedite our investigation. If you prefer not to use HackerOne, email us directly at `psirt@adobe.com` with details and repro steps.
|
||||
|
||||
## Learning More About Security
|
||||
To learn more about securing a Magento store, please visit the [Security Center](https://magento.com/security).
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Register basic autoloader that uses include path
|
||||
*
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Framework\Autoload\AutoloaderRegistry;
|
||||
use Magento\Framework\Autoload\ClassLoaderWrapper;
|
||||
|
||||
/**
|
||||
* Shortcut constant for the root directory
|
||||
*/
|
||||
\define('BP', \dirname(__DIR__));
|
||||
|
||||
\define('VENDOR_PATH', BP . '/app/etc/vendor_path.php');
|
||||
|
||||
if (!\is_readable(VENDOR_PATH)) {
|
||||
throw new \Exception(
|
||||
'We can\'t read some files that are required to run the Magento application. '
|
||||
. 'This usually means file permissions are set incorrectly.'
|
||||
);
|
||||
}
|
||||
|
||||
$vendorAutoload = (
|
||||
static function (): ?string {
|
||||
$vendorDir = require VENDOR_PATH;
|
||||
|
||||
$vendorAutoload = BP . "/{$vendorDir}/autoload.php";
|
||||
if (\is_readable($vendorAutoload)) {
|
||||
return $vendorAutoload;
|
||||
}
|
||||
|
||||
$vendorAutoload = "{$vendorDir}/autoload.php";
|
||||
if (\is_readable($vendorAutoload)) {
|
||||
return $vendorAutoload;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
)();
|
||||
|
||||
if ($vendorAutoload === null) {
|
||||
throw new \Exception(
|
||||
'Vendor autoload is not found. Please run \'composer install\' under application root directory.'
|
||||
);
|
||||
}
|
||||
|
||||
$composerAutoloader = include $vendorAutoload;
|
||||
AutoloaderRegistry::registerAutoloader(new ClassLoaderWrapper($composerAutoloader));
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Environment initialization
|
||||
*/
|
||||
error_reporting(E_ALL);
|
||||
if (in_array('phar', \stream_get_wrappers())) {
|
||||
stream_wrapper_unregister('phar');
|
||||
}
|
||||
#ini_set('display_errors', 1);
|
||||
|
||||
/* PHP version validation */
|
||||
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80100) {
|
||||
if (PHP_SAPI == 'cli') {
|
||||
echo 'Magento supports PHP 8.1.0 or later. ' .
|
||||
'Please read https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements-tech.html';
|
||||
} else {
|
||||
echo <<<HTML
|
||||
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
|
||||
<p>Magento supports PHP 8.1.0 or later. Please read
|
||||
<a target="_blank" href="https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements-tech.html">
|
||||
Magento System Requirements</a>.
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
http_response_code(503);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// PHP 8 compatibility. Define constants that are not present in PHP < 8.0
|
||||
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80000) {
|
||||
if (!defined('T_NAME_QUALIFIED')) {
|
||||
define('T_NAME_QUALIFIED', 24001);
|
||||
}
|
||||
if (!defined('T_NAME_FULLY_QUALIFIED')) {
|
||||
define('T_NAME_FULLY_QUALIFIED', 24002);
|
||||
}
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/autoload.php';
|
||||
// Sets default autoload mappings, may be overridden in Bootstrap::create
|
||||
\Magento\Framework\App\Bootstrap::populateAutoloader(BP, []);
|
||||
|
||||
/* Custom umask value may be provided in optional mage_umask file in root */
|
||||
$umaskFile = BP . '/magento_umask';
|
||||
$mask = file_exists($umaskFile) ? octdec(file_get_contents($umaskFile)) : 002;
|
||||
umask($mask);
|
||||
|
||||
if (empty($_SERVER['ENABLE_IIS_REWRITES']) || ($_SERVER['ENABLE_IIS_REWRITES'] != 1)) {
|
||||
/*
|
||||
* Unset headers used by IIS URL rewrites.
|
||||
*/
|
||||
unset($_SERVER['HTTP_X_REWRITE_URL']);
|
||||
unset($_SERVER['HTTP_X_ORIGINAL_URL']);
|
||||
unset($_SERVER['IIS_WasUrlRewritten']);
|
||||
unset($_SERVER['UNENCODED_URL']);
|
||||
unset($_SERVER['ORIG_PATH_INFO']);
|
||||
}
|
||||
|
||||
if (
|
||||
(!empty($_SERVER['MAGE_PROFILER']) || file_exists(BP . '/var/profiler.flag'))
|
||||
&& isset($_SERVER['HTTP_ACCEPT'])
|
||||
&& strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false
|
||||
) {
|
||||
$profilerConfig = isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER'])
|
||||
? $_SERVER['MAGE_PROFILER']
|
||||
: trim(file_get_contents(BP . '/var/profiler.flag'));
|
||||
|
||||
if ($profilerConfig) {
|
||||
$profilerConfig = json_decode($profilerConfig, true) ?: $profilerConfig;
|
||||
}
|
||||
|
||||
Magento\Framework\Profiler::applyConfig(
|
||||
$profilerConfig,
|
||||
BP,
|
||||
!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
|
||||
);
|
||||
}
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
/* For data consistency between displaying (printing) and serialization a float number */
|
||||
ini_set('precision', 14);
|
||||
ini_set('serialize_precision', 14);
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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\Api;
|
||||
|
||||
interface ActiveSessionManagerInterface
|
||||
{
|
||||
public function initNew(): void;
|
||||
|
||||
public function update(): void;
|
||||
|
||||
public function terminate(string $sessionId = null): void;
|
||||
|
||||
public function getInactiveSessions(): array;
|
||||
|
||||
public function terminateAll(): void;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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\Api;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface;
|
||||
|
||||
interface ActiveSessionRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function getById(int $id): ActiveSessionInterface;
|
||||
|
||||
/**
|
||||
* @param string $sessionId
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function getBySessionId(string $sessionId): ActiveSessionInterface;
|
||||
|
||||
/**
|
||||
* @param \Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface $activeSession
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface
|
||||
* @throws \Magento\Framework\Exception\CouldNotSaveException
|
||||
*/
|
||||
public function save(ActiveSessionInterface $activeSession): ActiveSessionInterface;
|
||||
|
||||
/**
|
||||
* @param \Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface $activeSession
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Magento\Framework\Exception\CouldNotDeleteException
|
||||
*/
|
||||
public function delete(ActiveSessionInterface $activeSession): bool;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\CouldNotDeleteException
|
||||
*/
|
||||
public function deleteById(int $id): bool;
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
interface ActiveSessionInterface
|
||||
{
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* @param int|null $id
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface
|
||||
*/
|
||||
public function setId($id);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSessionId(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $sessionId
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface
|
||||
*/
|
||||
public function setSessionId(string $sessionId): ActiveSessionInterface;
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getAdminSessionInfoId(): ?int;
|
||||
|
||||
/**
|
||||
* @param int|null $adminSessionInfoId
|
||||
* @return ActiveSessionInterface
|
||||
*/
|
||||
public function setAdminSessionInfoId(?int $adminSessionInfoId): ActiveSessionInterface;
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getUserId(): ?int;
|
||||
|
||||
/**
|
||||
* @param int|null $userId
|
||||
* @return ActiveSessionInterface
|
||||
*/
|
||||
public function setUserId(?int $userId): ActiveSessionInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUsername(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface
|
||||
*/
|
||||
public function setUsername(string $username): ActiveSessionInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFullName(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $fullName
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface
|
||||
*/
|
||||
public function setFullName(string $fullName): ActiveSessionInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getIp(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $ip
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface
|
||||
*/
|
||||
public function setIp(string $ip): ActiveSessionInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSessionStart(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $startTime
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface
|
||||
*/
|
||||
public function setSessionStart(string $startTime): ActiveSessionInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRecentActivity(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $activityTime
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface
|
||||
*/
|
||||
public function setRecentActivity(string $activityTime): ActiveSessionInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLocation(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $location
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface
|
||||
*/
|
||||
public function setLocation(string $location): ActiveSessionInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCountryId(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $countryId
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\ActiveSessionInterface
|
||||
*/
|
||||
public function setCountryId(string $countryId): ActiveSessionInterface;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
interface LogDetailInterface
|
||||
{
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* @param int|null $id
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogDetailInterface
|
||||
*/
|
||||
public function setId($id);
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLogId(): ?int;
|
||||
|
||||
/**
|
||||
* @param int $logId
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogDetailInterface
|
||||
*/
|
||||
public function setLogId(int $logId): LogDetailInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getName(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogDetailInterface
|
||||
*/
|
||||
public function setName(string $name): LogDetailInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOldValue(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $oldValue
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogDetailInterface
|
||||
*/
|
||||
public function setOldValue(string $oldValue): LogDetailInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getNewValue(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $newValue
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogDetailInterface
|
||||
*/
|
||||
public function setNewValue(string $newValue): LogDetailInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getModel(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $model
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogDetailInterface
|
||||
*/
|
||||
public function setModel(string $model): LogDetailInterface;
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
interface LogEntryInterface
|
||||
{
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* @param int|null $id
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
*/
|
||||
public function setId($id);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDate(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $date
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
*/
|
||||
public function setDate(string $date): LogEntryInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUsername(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
*/
|
||||
public function setUsername(string $username): LogEntryInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getType(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
*/
|
||||
public function setType(string $type): LogEntryInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCategory(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $category
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
*/
|
||||
public function setCategory(string $category): LogEntryInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCategoryName(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $categoryName
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
*/
|
||||
public function setCategoryName(string $categoryName): LogEntryInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getParameterName(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $parameterName
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
*/
|
||||
public function setParameterName(string $parameterName): LogEntryInterface;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getElementId(): int;
|
||||
|
||||
/**
|
||||
* @param int $elementId
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
*/
|
||||
public function setElementId(int $elementId): LogEntryInterface;
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getViewElementId(): ?int;
|
||||
|
||||
/**
|
||||
* @param int|null $viewElementId
|
||||
*
|
||||
* @return LogEntryInterface
|
||||
*/
|
||||
public function setViewElementId(?int $viewElementId): LogEntryInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getItem(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $item
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
*/
|
||||
public function setItem(string $item): LogEntryInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getIp(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $ipAddress
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
*/
|
||||
public function setIp(string $ipAddress): LogEntryInterface;
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getStoreId(): ?int;
|
||||
|
||||
/**
|
||||
* @param int $storeId
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
*/
|
||||
public function setStoreId(int $storeId): LogEntryInterface;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAdditionalData();
|
||||
|
||||
/**
|
||||
* @param mixed $additionalData
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
*/
|
||||
public function setAdditionalData($additionalData): LogEntryInterface;
|
||||
|
||||
/**
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogDetailInterface[]
|
||||
*/
|
||||
public function getLogDetails(): array;
|
||||
|
||||
/**
|
||||
* @param array $logDetails
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
*/
|
||||
public function setLogDetails(array $logDetails): LogEntryInterface;
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
use Magento\Framework\Api\SearchResultsInterface;
|
||||
|
||||
interface LogEntrySearchResultsInterface extends SearchResultsInterface
|
||||
{
|
||||
/**
|
||||
* Get log entries list.
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* Set log entries list.
|
||||
*
|
||||
* @param \Amasty\AdminActionsLog\Api\Data\LogEntryInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(array $items);
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
interface LoginAttemptInterface
|
||||
{
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* @param int|null $id
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface
|
||||
*/
|
||||
public function setId($id);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDate(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $date
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface
|
||||
*/
|
||||
public function setDate(string $date): LoginAttemptInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUsername(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface
|
||||
*/
|
||||
public function setUsername(string $username): LoginAttemptInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFullName(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $fullName
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface
|
||||
*/
|
||||
public function setFullName(string $fullName): LoginAttemptInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getIp(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $ip
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface
|
||||
*/
|
||||
public function setIp(string $ip): LoginAttemptInterface;
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getStatus(): ?int;
|
||||
|
||||
/**
|
||||
* @param int $status
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface
|
||||
*/
|
||||
public function setStatus(int $status): LoginAttemptInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLocation(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $location
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface
|
||||
*/
|
||||
public function setLocation(string $location): LoginAttemptInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCountryId(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $countryId
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface
|
||||
*/
|
||||
public function setCountryId(string $countryId): LoginAttemptInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUserAgent(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $userAgent
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface
|
||||
*/
|
||||
public function setUserAgent(string $userAgent): LoginAttemptInterface;
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
use Magento\Framework\Api\SearchResultsInterface;
|
||||
|
||||
interface LoginAttemptSearchResultsInterface extends SearchResultsInterface
|
||||
{
|
||||
/**
|
||||
* Get login attempts list.
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* Set login attempts list.
|
||||
*
|
||||
* @param \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(array $items);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
interface VisitHistoryDetailInterface
|
||||
{
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* @param int|null $id
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryDetailInterface
|
||||
*/
|
||||
public function setId($id);
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getVisitId(): ?int;
|
||||
|
||||
/**
|
||||
* @param int $visitId
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryDetailInterface
|
||||
*/
|
||||
public function setVisitId(int $visitId): VisitHistoryDetailInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPageName(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $pageName
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryDetailInterface
|
||||
*/
|
||||
public function setPageName(string $pageName): VisitHistoryDetailInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPageUrl(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $pageUrl
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryDetailInterface
|
||||
*/
|
||||
public function setPageUrl(string $pageUrl): VisitHistoryDetailInterface;
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getStayDuration(): ?int;
|
||||
|
||||
/**
|
||||
* @param int $stayDuration
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryDetailInterface
|
||||
*/
|
||||
public function setStayDuration(int $stayDuration): VisitHistoryDetailInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSessionId(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $sessionId
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryDetailInterface
|
||||
*/
|
||||
public function setSessionId(string $sessionId): VisitHistoryDetailInterface;
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
interface VisitHistoryEntryInterface
|
||||
{
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* @param int|null $id
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface
|
||||
*/
|
||||
public function setId($id);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUsername(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface
|
||||
*/
|
||||
public function setUsername(string $username): VisitHistoryEntryInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFullName(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $fullName
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface
|
||||
*/
|
||||
public function setFullName(string $fullName): VisitHistoryEntryInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSessionStart(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $sessionStart
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface
|
||||
*/
|
||||
public function setSessionStart(string $sessionStart): VisitHistoryEntryInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSessionEnd(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $sessionEnd
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface
|
||||
*/
|
||||
public function setSessionEnd(string $sessionEnd): VisitHistoryEntryInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getIp(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $ip
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface
|
||||
*/
|
||||
public function setIp(string $ip): VisitHistoryEntryInterface;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLocation(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $location
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface
|
||||
*/
|
||||
public function setLocation(string $location): VisitHistoryEntryInterface;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSessionId(): ?string;
|
||||
|
||||
/**
|
||||
* @param string $sessionId
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface
|
||||
*/
|
||||
public function setSessionId(string $sessionId): VisitHistoryEntryInterface;
|
||||
|
||||
/**
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryDetailInterface[]
|
||||
*/
|
||||
public function getVisitHistoryDetails(): array;
|
||||
|
||||
/**
|
||||
* @param array $visitHistoryDetails
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface
|
||||
*/
|
||||
public function setVisitHistoryDetails(array $visitHistoryDetails): VisitHistoryEntryInterface;
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
interface VisitHistoryEntrySearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface
|
||||
{
|
||||
/**
|
||||
* Get visit history list.
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* Set visit history list.
|
||||
*
|
||||
* @param \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(array $items);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?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\Api;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Data\LogEntryInterface;
|
||||
use Amasty\AdminActionsLog\Api\Data\LogEntrySearchResultsInterface;
|
||||
use Magento\Framework\Api\SearchCriteriaInterface;
|
||||
|
||||
interface LogEntryRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function getById(int $id): LogEntryInterface;
|
||||
|
||||
/**
|
||||
* @param \Amasty\AdminActionsLog\Api\Data\LogEntryInterface $logEntry
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntryInterface
|
||||
* @throws \Magento\Framework\Exception\CouldNotSaveException
|
||||
*/
|
||||
public function save(LogEntryInterface $logEntry): LogEntryInterface;
|
||||
|
||||
/**
|
||||
* @param \Amasty\AdminActionsLog\Api\Data\LogEntryInterface $logEntry
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Magento\Framework\Exception\CouldNotDeleteException
|
||||
*/
|
||||
public function delete(LogEntryInterface $logEntry): bool;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\CouldNotDeleteException
|
||||
*/
|
||||
public function deleteById(int $id): bool;
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LogEntrySearchResultsInterface
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function getList(SearchCriteriaInterface $searchCriteria): LogEntrySearchResultsInterface;
|
||||
|
||||
/**
|
||||
* @param int|null $period
|
||||
*
|
||||
* @return void
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\CouldNotSaveException
|
||||
*/
|
||||
public function clean(?int $period = null): void;
|
||||
|
||||
/**
|
||||
* @param array|null $storeIds
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cleanByStoreIds(?array $storeIds = []): void;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Api\Logging;
|
||||
|
||||
interface EntitySaveHandlerInterface
|
||||
{
|
||||
/**
|
||||
* Method returns specific LogEntry's data after object saving/deleting.
|
||||
* @see \Amasty\AdminActionsLog\Logging\ActionType\AfterSave\Entity::prepareLogEntryData
|
||||
*
|
||||
* @param MetadataInterface $metadata
|
||||
* @return array
|
||||
*/
|
||||
public function getLogMetadata(MetadataInterface $metadata): array;
|
||||
|
||||
/**
|
||||
* Method for extracting and generating key => value array with data from concrete object
|
||||
* for LogDetail entity before saving main entity.
|
||||
* @see \Amasty\AdminActionsLog\Logging\ActionType\BeforeSave\Entity::execute
|
||||
*
|
||||
* @param $object
|
||||
* @return array
|
||||
*/
|
||||
public function processBeforeSave($object): array;
|
||||
|
||||
/**
|
||||
* Method for extracting and generating key => value array with data from concrete object
|
||||
* for LogDetail entity after saving main entity.
|
||||
* @see \Amasty\AdminActionsLog\Logging\ActionType\AfterSave\Entity::execute
|
||||
*
|
||||
* @param $object
|
||||
* @return array
|
||||
*/
|
||||
public function processAfterSave($object): array;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Api\Logging;
|
||||
|
||||
interface LoggingActionInterface
|
||||
{
|
||||
/**
|
||||
* Perform logging action i.e. save product changes, save visit history, etc.
|
||||
*/
|
||||
public function execute(): void;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Api\Logging;
|
||||
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
|
||||
interface MetadataInterface
|
||||
{
|
||||
/**
|
||||
* Basic event actions identifiers.
|
||||
*/
|
||||
public const EVENT_DISPATCH = 'dispatch';
|
||||
public const EVENT_SAVE_BEFORE = 'save_before';
|
||||
public const EVENT_SAVE_AFTER = 'save_after';
|
||||
public const EVENT_DELETE = 'delete';
|
||||
public const EVENT_LOGIN = 'login';
|
||||
public const EVENT_LAYOUT_RENDER_BEFORE = 'layout_render_before';
|
||||
|
||||
/**
|
||||
* Current action's request.
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
public function getRequest(): RequestInterface;
|
||||
|
||||
/**
|
||||
* Action's event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEventName(): string;
|
||||
|
||||
/**
|
||||
* Action's logging object.
|
||||
*
|
||||
* @return object|null
|
||||
*/
|
||||
public function getObject(): ?object;
|
||||
|
||||
/**
|
||||
* Object key. It could be set while executing entities by schedule.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getStorageEntityKey(): ?string;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Api\Logging;
|
||||
|
||||
interface ObjectDataStorageInterface
|
||||
{
|
||||
/**
|
||||
* Method to retrieve stored object data.
|
||||
*
|
||||
* @param string $key
|
||||
* @return array|null
|
||||
*/
|
||||
public function get(string $key): ?array;
|
||||
|
||||
/**
|
||||
* Method to store object's data in storage.
|
||||
*
|
||||
* @param string $key
|
||||
* @param array $data
|
||||
*/
|
||||
public function set(string $key, array $data): void;
|
||||
|
||||
/**
|
||||
* Method to remove object's data from storage.
|
||||
*
|
||||
* @param string $key
|
||||
*/
|
||||
public function unset(string $key): void;
|
||||
|
||||
/**
|
||||
* Method to to check is data persists in storage.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function isExists(string $key): bool;
|
||||
}
|
||||
@@ -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\Api;
|
||||
|
||||
interface LoginAttemptManagerInterface
|
||||
{
|
||||
public function saveAttempt(?string $username, int $status): void;
|
||||
|
||||
public function clear(int $period = null): void;
|
||||
}
|
||||
@@ -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\Api;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface;
|
||||
use Amasty\AdminActionsLog\Api\Data\LoginAttemptSearchResultsInterface;
|
||||
use Magento\Framework\Api\SearchCriteriaInterface;
|
||||
|
||||
interface LoginAttemptRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function getById(int $id): LoginAttemptInterface;
|
||||
|
||||
/**
|
||||
* @param \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface $loginAttempt
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface
|
||||
* @throws \Magento\Framework\Exception\CouldNotSaveException
|
||||
*/
|
||||
public function save(LoginAttemptInterface $loginAttempt): LoginAttemptInterface;
|
||||
|
||||
/**
|
||||
* @param \Amasty\AdminActionsLog\Api\Data\LoginAttemptInterface $loginAttempt
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Magento\Framework\Exception\CouldNotDeleteException
|
||||
*/
|
||||
public function delete(LoginAttemptInterface $loginAttempt): bool;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\CouldNotDeleteException
|
||||
*/
|
||||
public function deleteById(int $id): bool;
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\LoginAttemptSearchResultsInterface
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function getList(SearchCriteriaInterface $searchCriteria): LoginAttemptSearchResultsInterface;
|
||||
|
||||
/**
|
||||
* @param int|null $period
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clean(?int $period = null): void;
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Api\Restoring;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Data\LogEntryInterface;
|
||||
|
||||
interface EntityRestoreHandlerInterface
|
||||
{
|
||||
/**
|
||||
* Perform restoring action by action log details
|
||||
*
|
||||
* @param \Amasty\AdminActionsLog\Api\Data\LogEntryInterface $logEntry
|
||||
* @param \Amasty\AdminActionsLog\Api\Data\LogDetailInterface[] $logDetails
|
||||
* @return void
|
||||
*/
|
||||
public function restore(LogEntryInterface $logEntry, array $logDetails): void;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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\Api;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Data\VisitHistoryEntrySearchResultsInterface;
|
||||
use Magento\Framework\Api\SearchCriteriaInterface;
|
||||
|
||||
interface VisitHistoryEntryFinderInterface
|
||||
{
|
||||
/**
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntrySearchResultsInterface
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function getList(SearchCriteriaInterface $searchCriteria): VisitHistoryEntrySearchResultsInterface;
|
||||
}
|
||||
+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\Api;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface;
|
||||
use Amasty\AdminActionsLog\Api\Data\VisitHistoryEntrySearchResultsInterface;
|
||||
use Magento\Framework\Api\SearchCriteriaInterface;
|
||||
|
||||
interface VisitHistoryEntryRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param int $id
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function getById(int $id): VisitHistoryEntryInterface;
|
||||
|
||||
/**
|
||||
* @param string $sessionId
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function getBySessionId(string $sessionId): VisitHistoryEntryInterface;
|
||||
|
||||
/**
|
||||
* @param \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface $logEntry
|
||||
*
|
||||
* @return \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface
|
||||
* @throws \Magento\Framework\Exception\CouldNotSaveException
|
||||
*/
|
||||
public function save(VisitHistoryEntryInterface $logEntry): VisitHistoryEntryInterface;
|
||||
|
||||
/**
|
||||
* @param \Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface $logEntry
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Magento\Framework\Exception\CouldNotDeleteException
|
||||
*/
|
||||
public function delete(VisitHistoryEntryInterface $logEntry): bool;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\CouldNotDeleteException
|
||||
*/
|
||||
public function deleteById(int $id): bool;
|
||||
|
||||
/**
|
||||
* @param int|null $period
|
||||
*
|
||||
* @return void
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\CouldNotSaveException
|
||||
*/
|
||||
public function clean(?int $period = null): void;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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\Api;
|
||||
|
||||
interface VisitHistoryManagerInterface
|
||||
{
|
||||
/**
|
||||
* Initialize Visit History tracking for current admin.
|
||||
*/
|
||||
public function startVisit(): void;
|
||||
|
||||
/**
|
||||
* Track Visit History end time, i.e. admin logout or session destroy.
|
||||
*
|
||||
* @param string|null $sessionId
|
||||
*/
|
||||
public function endVisit(string $sessionId = null): void;
|
||||
|
||||
/**
|
||||
* Clear whole Visit History storage.
|
||||
*
|
||||
* @param int|null $period
|
||||
*/
|
||||
public function clear(int $period = null): void;
|
||||
}
|
||||
+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);
|
||||
}
|
||||
}
|
||||
+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;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?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\Cron;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\LogEntryRepositoryInterface;
|
||||
use Amasty\AdminActionsLog\Api\LoginAttemptRepositoryInterface;
|
||||
use Amasty\AdminActionsLog\Api\VisitHistoryEntryRepositoryInterface;
|
||||
use Amasty\AdminActionsLog\Model\ConfigProvider;
|
||||
|
||||
class LogCleaner
|
||||
{
|
||||
/**
|
||||
* @var ConfigProvider
|
||||
*/
|
||||
private $configProvider;
|
||||
|
||||
/**
|
||||
* @var LogEntryRepositoryInterface
|
||||
*/
|
||||
private $logEntryRepository;
|
||||
|
||||
/**
|
||||
* @var LoginAttemptRepositoryInterface
|
||||
*/
|
||||
private $loginAttemptRepository;
|
||||
|
||||
/**
|
||||
* @var VisitHistoryEntryRepositoryInterface
|
||||
*/
|
||||
private $visitHistoryEntryRepository;
|
||||
|
||||
public function __construct(
|
||||
ConfigProvider $configProvider,
|
||||
LogEntryRepositoryInterface $logEntryRepository,
|
||||
LoginAttemptRepositoryInterface $loginAttemptRepository,
|
||||
VisitHistoryEntryRepositoryInterface $visitHistoryEntryRepository
|
||||
) {
|
||||
$this->configProvider = $configProvider;
|
||||
$this->logEntryRepository = $logEntryRepository;
|
||||
$this->loginAttemptRepository = $loginAttemptRepository;
|
||||
$this->visitHistoryEntryRepository = $visitHistoryEntryRepository;
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
if ($this->configProvider->isNeedCleanActionsLog()) {
|
||||
$this->logEntryRepository->clean($this->configProvider->getActionsLogPeriod());
|
||||
}
|
||||
|
||||
if ($this->configProvider->isNeedCleanLoginAttemptsLog()) {
|
||||
//TODO: replace to LoginAttemptsManager->clear()
|
||||
$this->loginAttemptRepository->clean($this->configProvider->getLoginAttemptsLogPeriod());
|
||||
}
|
||||
|
||||
if ($this->configProvider->isNeedCleanVisitHistoryLog()) {
|
||||
//TODO: replace to VisitHistoryManager->clear()
|
||||
$this->visitHistoryEntryRepository->clean($this->configProvider->getVisitHistoryLogPeriod());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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\Cron;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\ActiveSessionManagerInterface;
|
||||
use Amasty\AdminActionsLog\Api\VisitHistoryManagerInterface;
|
||||
|
||||
class UpdateActiveSessions
|
||||
{
|
||||
/**
|
||||
* @var ActiveSessionManagerInterface
|
||||
*/
|
||||
private $activeSessionManager;
|
||||
|
||||
/**
|
||||
* @var VisitHistoryManagerInterface
|
||||
*/
|
||||
private $visitHistoryManager;
|
||||
|
||||
public function __construct(
|
||||
ActiveSessionManagerInterface $activeSessionManager,
|
||||
VisitHistoryManagerInterface $visitHistoryManager
|
||||
) {
|
||||
$this->activeSessionManager = $activeSessionManager;
|
||||
$this->visitHistoryManager = $visitHistoryManager;
|
||||
}
|
||||
|
||||
public function execute(): void
|
||||
{
|
||||
$inactiveSessions = $this->activeSessionManager->getInactiveSessions();
|
||||
|
||||
foreach ($inactiveSessions as $sessionId) {
|
||||
$this->activeSessionManager->terminate($sessionId);
|
||||
$this->visitHistoryManager->endVisit($sessionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
<?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\Logging;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\LoggingActionInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\ActionType;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
|
||||
class ActionFactory
|
||||
{
|
||||
/**
|
||||
* Handler fetch strategies.
|
||||
*/
|
||||
public const FETCH_ONE = 1;
|
||||
public const FETCH_ANY = 2;
|
||||
|
||||
/**
|
||||
* @var ObjectManagerInterface
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @var ActionType\CompositeFactory
|
||||
*/
|
||||
private $compositeFactory;
|
||||
|
||||
/**
|
||||
* @var ActionType\HandlerResolver
|
||||
*/
|
||||
private $actionHandlerResolver;
|
||||
|
||||
/**
|
||||
* @var ActionType\ValidationCompositeFactory
|
||||
*/
|
||||
private $validationCompositeFactory;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $dummyHandlerClass;
|
||||
|
||||
public function __construct(
|
||||
ObjectManagerInterface $objectManager,
|
||||
ActionType\CompositeFactory $compositeFactory,
|
||||
ActionType\HandlerResolver $actionHandlerResolver,
|
||||
ActionType\ValidationCompositeFactory $validationCompositeFactory,
|
||||
string $dummyHandlerClass = ActionType\Dummy::class
|
||||
) {
|
||||
$this->objectManager = $objectManager;
|
||||
$this->compositeFactory = $compositeFactory;
|
||||
$this->actionHandlerResolver = $actionHandlerResolver;
|
||||
$this->validationCompositeFactory = $validationCompositeFactory;
|
||||
$this->dummyHandlerClass = $dummyHandlerClass;
|
||||
}
|
||||
|
||||
public function create(MetadataInterface $metadata, int $fetchStrategy = self::FETCH_ONE): LoggingActionInterface
|
||||
{
|
||||
$loggingActions = [];
|
||||
$actionName = $metadata->getRequest()->getFullActionName();
|
||||
$handlerClasses = $this->actionHandlerResolver->getHandlers($actionName, $metadata->getEventName());
|
||||
|
||||
switch ($fetchStrategy) {
|
||||
case self::FETCH_ONE:
|
||||
$handlerClasses = [$handlerClasses[0] ?? $this->dummyHandlerClass];
|
||||
break;
|
||||
default:
|
||||
$handlerClasses = !empty($handlerClasses) ? $handlerClasses : [$this->dummyHandlerClass];
|
||||
}
|
||||
|
||||
foreach ($handlerClasses as $handlerClass) {
|
||||
$loggingActions[] = $this->initializeLoggingAction($handlerClass, $metadata);
|
||||
}
|
||||
|
||||
return $this->compositeFactory->create(['actions' => $loggingActions]);
|
||||
}
|
||||
|
||||
private function initializeLoggingAction(string $class, MetadataInterface $metadata): LoggingActionInterface
|
||||
{
|
||||
$action = $this->objectManager->create($class, ['metadata' => $metadata]);
|
||||
$eventName = $metadata->getEventName();
|
||||
$actionName = $metadata->getRequest()->getFullActionName();
|
||||
$validators = $this->actionHandlerResolver->getValidators($actionName, $eventName, $class);
|
||||
|
||||
if ($validators) {
|
||||
return $this->validationCompositeFactory->create([
|
||||
'metadata' => $metadata,
|
||||
'wrappedAction' => $action,
|
||||
'validators' => $validators
|
||||
]);
|
||||
}
|
||||
|
||||
return $action;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?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\Logging\ActionType\AfterSave;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\LogEntryRepositoryInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\LoggingActionInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\ObjectDataStorageInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandlerProvider;
|
||||
use Amasty\AdminActionsLog\Logging\Util\DetailsBuilder;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
use Amasty\AdminActionsLog\Restoring\Entity\RestoreHandler\AbstractHandler;
|
||||
|
||||
class Entity implements LoggingActionInterface
|
||||
{
|
||||
/**
|
||||
* @var MetadataInterface
|
||||
*/
|
||||
private $metadata;
|
||||
|
||||
/**
|
||||
* @var DetailsBuilder
|
||||
*/
|
||||
private $detailsBuilder;
|
||||
|
||||
/**
|
||||
* @var SaveHandlerProvider
|
||||
*/
|
||||
private $entityTypeProvider;
|
||||
|
||||
/**
|
||||
* @var ObjectDataStorageInterface
|
||||
*/
|
||||
private $dataStorage;
|
||||
|
||||
/**
|
||||
* @var LogEntryRepositoryInterface
|
||||
*/
|
||||
private $logEntryRepository;
|
||||
|
||||
/**
|
||||
* @var LogEntry\AdminLogEntryFactory
|
||||
*/
|
||||
private $logEntryFactory;
|
||||
|
||||
public function __construct(
|
||||
MetadataInterface $metadata,
|
||||
DetailsBuilder $detailsBuilder,
|
||||
SaveHandlerProvider $entityTypeProvider,
|
||||
ObjectDataStorageInterface $dataStorage,
|
||||
LogEntryRepositoryInterface $logEntryRepository,
|
||||
LogEntry\AdminLogEntryFactory $logEntryFactory
|
||||
) {
|
||||
$this->metadata = $metadata;
|
||||
$this->detailsBuilder = $detailsBuilder;
|
||||
$this->entityTypeProvider = $entityTypeProvider;
|
||||
$this->dataStorage = $dataStorage;
|
||||
$this->logEntryRepository = $logEntryRepository;
|
||||
$this->logEntryFactory = $logEntryFactory;
|
||||
}
|
||||
|
||||
public function execute(): void
|
||||
{
|
||||
if ($loggingObject = $this->metadata->getObject()) {
|
||||
// storageEntityKey could be set while executing entities by schedule.
|
||||
$storageKey = $this->metadata->getStorageEntityKey() ?? spl_object_id($loggingObject) . '.before';
|
||||
$entityLogType = $this->entityTypeProvider->get(get_class($loggingObject));
|
||||
$beforeData = $this->dataStorage->get($storageKey) ?? [];
|
||||
$afterData = $entityLogType->processAfterSave($loggingObject);
|
||||
$detailsList = $this->detailsBuilder->build(get_class($loggingObject), $beforeData, $afterData);
|
||||
|
||||
if (!empty($detailsList)) {
|
||||
$logEntry = $this->logEntryFactory->create($this->prepareLogEntryData($loggingObject));
|
||||
$logEntry->setLogDetails($detailsList);
|
||||
$this->logEntryRepository->save($logEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function prepareLogEntryData($object): array
|
||||
{
|
||||
$entityLogType = $this->entityTypeProvider->get(get_class($object));
|
||||
$defaultCategory = sprintf(
|
||||
'%s/%s',
|
||||
$this->metadata->getRequest()->getModuleName(),
|
||||
$this->metadata->getRequest()->getControllerName()
|
||||
);
|
||||
|
||||
switch (true) {
|
||||
case (bool)$object->isObjectNew():
|
||||
$actionType = LogEntryTypes::TYPE_NEW;
|
||||
break;
|
||||
default:
|
||||
$actionType = LogEntryTypes::TYPE_EDIT;
|
||||
}
|
||||
|
||||
$logEntryData = array_merge(
|
||||
[
|
||||
LogEntry\LogEntry::TYPE => $actionType,
|
||||
LogEntry\LogEntry::CATEGORY => $defaultCategory,
|
||||
LogEntry\LogEntry::CATEGORY_NAME => $defaultCategory,
|
||||
],
|
||||
$entityLogType->getLogMetadata($this->metadata)
|
||||
);
|
||||
|
||||
$storageKey = spl_object_id($object) . '.' . AbstractHandler::STORAGE_CODE_PREFIX;
|
||||
if ($this->dataStorage->isExists($storageKey)) {
|
||||
$logEntryData[LogEntry\LogEntry::TYPE] = LogEntryTypes::TYPE_RESTORE;
|
||||
}
|
||||
|
||||
return $logEntryData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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\Logging\ActionType\BeforeSave;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\LoggingActionInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\ObjectDataStorageInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandlerProvider;
|
||||
|
||||
class Entity implements LoggingActionInterface
|
||||
{
|
||||
/**
|
||||
* @var MetadataInterface
|
||||
*/
|
||||
private $metadata;
|
||||
|
||||
/**
|
||||
* @var SaveHandlerProvider
|
||||
*/
|
||||
private $entityTypeProvider;
|
||||
|
||||
/**
|
||||
* @var ObjectDataStorageInterface
|
||||
*/
|
||||
private $dataStorage;
|
||||
|
||||
public function __construct(
|
||||
MetadataInterface $metadata,
|
||||
SaveHandlerProvider $entityTypeProvider,
|
||||
ObjectDataStorageInterface $dataStorage
|
||||
) {
|
||||
$this->metadata = $metadata;
|
||||
$this->entityTypeProvider = $entityTypeProvider;
|
||||
$this->dataStorage = $dataStorage;
|
||||
}
|
||||
|
||||
public function execute(): void
|
||||
{
|
||||
if ($loggingObject = $this->metadata->getObject()) {
|
||||
$storageKey = $this->metadata->getStorageEntityKey() ?? spl_object_id($loggingObject) . '.before';
|
||||
if ($this->dataStorage->isExists($storageKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$entityLogType = $this->entityTypeProvider->get(get_class($loggingObject));
|
||||
if ($beforeData = $entityLogType->processBeforeSave($loggingObject)) {
|
||||
$this->dataStorage->set($storageKey, $beforeData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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\Logging\ActionType;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\LoggingActionInterface;
|
||||
use Magento\Framework\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Composite implements LoggingActionInterface
|
||||
{
|
||||
/**
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* @var LoggingActionInterface[]
|
||||
*/
|
||||
private $actions;
|
||||
|
||||
public function __construct(
|
||||
LoggerInterface $logger,
|
||||
array $actions = []
|
||||
) {
|
||||
foreach ($actions as $action) {
|
||||
if (!$action instanceof LoggingActionInterface) {
|
||||
throw new \LogicException(
|
||||
sprintf('Action handler must implement %s', LoggingActionInterface::class)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->logger = $logger;
|
||||
$this->actions = $actions;
|
||||
}
|
||||
|
||||
public function execute(): void
|
||||
{
|
||||
foreach ($this->actions as $action) {
|
||||
try {
|
||||
$actionTimerName = sprintf('__ACTION_LOG_RUN_%s__', get_class($action));
|
||||
Profiler::start($actionTimerName);
|
||||
$action->execute();
|
||||
Profiler::stop($actionTimerName);
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->error(
|
||||
__('An error occurred during Logging Action execution. Error is %1', $e->getMessage())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?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\Logging\ActionType\Delete;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\LoggingActionInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\ObjectDataStorageInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandlerProvider;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
|
||||
class Entity implements LoggingActionInterface
|
||||
{
|
||||
public const DELETE_LOG_ENTRY_POSTFIX = '.delete_log_entry';
|
||||
|
||||
/**
|
||||
* @var MetadataInterface
|
||||
*/
|
||||
private $metadata;
|
||||
|
||||
/**
|
||||
* @var SaveHandlerProvider
|
||||
*/
|
||||
private $entityTypeProvider;
|
||||
|
||||
/**
|
||||
* @var ObjectDataStorageInterface
|
||||
*/
|
||||
private $dataStorage;
|
||||
|
||||
/**
|
||||
* @var LogEntry\AdminLogEntryFactory
|
||||
*/
|
||||
private $logEntryFactory;
|
||||
|
||||
public function __construct(
|
||||
MetadataInterface $metadata,
|
||||
SaveHandlerProvider $entityTypeProvider,
|
||||
ObjectDataStorageInterface $dataStorage,
|
||||
LogEntry\AdminLogEntryFactory $logEntryFactory
|
||||
) {
|
||||
$this->metadata = $metadata;
|
||||
$this->entityTypeProvider = $entityTypeProvider;
|
||||
$this->dataStorage = $dataStorage;
|
||||
$this->logEntryFactory = $logEntryFactory;
|
||||
}
|
||||
|
||||
public function execute(): void
|
||||
{
|
||||
if ($deletedObject = $this->metadata->getObject()) {
|
||||
$entityLogType = $this->entityTypeProvider->get(get_class($deletedObject));
|
||||
$category = sprintf(
|
||||
'%s/%s',
|
||||
$this->metadata->getRequest()->getModuleName(),
|
||||
$this->metadata->getRequest()->getControllerName()
|
||||
);
|
||||
|
||||
$lodEntryData = array_merge(
|
||||
[LogEntry\LogEntry::CATEGORY_NAME => $category],
|
||||
$entityLogType->getLogMetadata($this->metadata),
|
||||
[
|
||||
LogEntry\LogEntry::CATEGORY => $category,
|
||||
LogEntry\LogEntry::TYPE => LogEntryTypes::TYPE_DELETE,
|
||||
LogEntry\LogEntry::STORE_ID => 0
|
||||
]
|
||||
);
|
||||
$logEntry = $this->logEntryFactory->create($lodEntryData);
|
||||
$storageKey = spl_object_id($deletedObject) . self::DELETE_LOG_ENTRY_POSTFIX;
|
||||
$this->dataStorage->set($storageKey, ['log' => $logEntry]);
|
||||
}
|
||||
}
|
||||
}
|
||||
+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\Logging\ActionType\Dispatch;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\ActiveSessionManagerInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\LoggingActionInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Api\LoginAttemptManagerInterface;
|
||||
use Amasty\AdminActionsLog\Api\VisitHistoryManagerInterface;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LoginAttemptStatus;
|
||||
|
||||
class AdminSession implements LoggingActionInterface
|
||||
{
|
||||
public const LOGOUT_ACTION = 'logout';
|
||||
|
||||
/**
|
||||
* @var MetadataInterface
|
||||
*/
|
||||
private $metadata;
|
||||
|
||||
/**
|
||||
* @var ActiveSessionManagerInterface
|
||||
*/
|
||||
private $activeSessionManager;
|
||||
|
||||
/**
|
||||
* @var VisitHistoryManagerInterface
|
||||
*/
|
||||
private $visitHistoryManager;
|
||||
|
||||
/**
|
||||
* @var LoginAttemptManagerInterface
|
||||
*/
|
||||
private $loginAttemptManager;
|
||||
|
||||
public function __construct(
|
||||
MetadataInterface $metadata,
|
||||
ActiveSessionManagerInterface $activeSessionManager,
|
||||
VisitHistoryManagerInterface $visitHistoryManager,
|
||||
LoginAttemptManagerInterface $loginAttemptManager
|
||||
) {
|
||||
$this->metadata = $metadata;
|
||||
$this->activeSessionManager = $activeSessionManager;
|
||||
$this->visitHistoryManager = $visitHistoryManager;
|
||||
$this->loginAttemptManager = $loginAttemptManager;
|
||||
}
|
||||
|
||||
public function execute(): void
|
||||
{
|
||||
if ($this->metadata->getRequest()->getActionName() === self::LOGOUT_ACTION) {
|
||||
$this->activeSessionManager->terminate();
|
||||
$this->visitHistoryManager->endVisit();
|
||||
$this->loginAttemptManager->saveAttempt(null, LoginAttemptStatus::LOGOUT);
|
||||
} elseif (!$this->metadata->getRequest()->isAjax()) {
|
||||
$this->activeSessionManager->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?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\Logging\ActionType\Dispatch;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\LogEntryRepositoryInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\LoggingActionInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
|
||||
class Cache implements LoggingActionInterface
|
||||
{
|
||||
/**
|
||||
* @var MetadataInterface
|
||||
*/
|
||||
private $metadata;
|
||||
|
||||
/**
|
||||
* @var LogEntryRepositoryInterface
|
||||
*/
|
||||
private $logEntryRepository;
|
||||
|
||||
/**
|
||||
* @var LogEntry\AdminLogEntryFactory
|
||||
*/
|
||||
private $logEntryFactory;
|
||||
|
||||
public function __construct(
|
||||
MetadataInterface $metadata,
|
||||
LogEntryRepositoryInterface $logEntryRepository,
|
||||
LogEntry\AdminLogEntryFactory $logEntryFactory
|
||||
) {
|
||||
$this->metadata = $metadata;
|
||||
$this->logEntryRepository = $logEntryRepository;
|
||||
$this->logEntryFactory = $logEntryFactory;
|
||||
}
|
||||
|
||||
public function execute(): void
|
||||
{
|
||||
$logEntry = $this->logEntryFactory->create([
|
||||
LogEntry\LogEntry::TYPE => LogEntryTypes::TYPE_CACHE,
|
||||
LogEntry\LogEntry::CATEGORY => __('Cache'),
|
||||
LogEntry\LogEntry::CATEGORY_NAME => __('Cache'),
|
||||
LogEntry\LogEntry::ITEM => $this->actionName2Label($this->metadata->getRequest()->getActionName()),
|
||||
]);
|
||||
$this->logEntryRepository->save($logEntry);
|
||||
}
|
||||
|
||||
private function actionName2Label(string $actionName): string
|
||||
{
|
||||
$actionLabels = [
|
||||
'cleanImages' => __('Flushed image cache'),
|
||||
'cleanMedia' => __('Flushed JavaScript/CSS cache'),
|
||||
'cleanStaticFiles' => __('Flushed static files cache'),
|
||||
'flushAll' => __('Flushed cache storage'),
|
||||
'flushSystem' => __('Flushed Magento cache storage'),
|
||||
'massDisable' => __('Cache disabled'),
|
||||
'massEnable' => __('Cache enabled'),
|
||||
'massRefresh' => __('Cache refreshed')
|
||||
];
|
||||
|
||||
return isset($actionLabels[$actionName]) ? $actionLabels[$actionName]->render() : $actionName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?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\Logging\ActionType\Dispatch;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\LogEntryRepositoryInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\LoggingActionInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
|
||||
class Export implements LoggingActionInterface
|
||||
{
|
||||
/**
|
||||
* @var MetadataInterface
|
||||
*/
|
||||
private $metadata;
|
||||
|
||||
/**
|
||||
* @var LogEntryRepositoryInterface
|
||||
*/
|
||||
private $logEntryRepository;
|
||||
|
||||
/**
|
||||
* @var LogEntry\AdminLogEntryFactory
|
||||
*/
|
||||
private $logEntryFactory;
|
||||
|
||||
public function __construct(
|
||||
MetadataInterface $metadata,
|
||||
LogEntryRepositoryInterface $logEntryRepository,
|
||||
LogEntry\AdminLogEntryFactory $logEntryFactory
|
||||
) {
|
||||
$this->metadata = $metadata;
|
||||
$this->logEntryRepository = $logEntryRepository;
|
||||
$this->logEntryFactory = $logEntryFactory;
|
||||
}
|
||||
|
||||
public function execute(): void
|
||||
{
|
||||
$category = sprintf(
|
||||
'%s %s',
|
||||
$this->metadata->getRequest()->getModuleName(),
|
||||
$this->metadata->getRequest()->getControllerName()
|
||||
);
|
||||
$logEntry = $this->logEntryFactory->create([
|
||||
LogEntry\LogEntry::TYPE => LogEntryTypes::TYPE_EXPORT,
|
||||
LogEntry\LogEntry::CATEGORY => $category,
|
||||
LogEntry\LogEntry::CATEGORY_NAME => $category,
|
||||
LogEntry\LogEntry::ITEM => __('Data was exported.'),
|
||||
]);
|
||||
$this->logEntryRepository->save($logEntry);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?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\Logging\ActionType;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\LoggingActionInterface;
|
||||
|
||||
class Dummy implements LoggingActionInterface
|
||||
{
|
||||
//phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedFunction
|
||||
public function execute(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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\Logging\ActionType;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\LoggingActionInterface;
|
||||
|
||||
class HandlerResolver
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $handlers;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $matched = [];
|
||||
|
||||
public function __construct(array $handlers = [])
|
||||
{
|
||||
foreach ($handlers as $handlerName => $handlerData) {
|
||||
$handlerClass = $handlerData['handlerClass'] ?? null;
|
||||
$config = $handlerData['config'] ?? null;
|
||||
|
||||
if (!is_subclass_of($handlerClass, LoggingActionInterface::class)) {
|
||||
throw new \LogicException(
|
||||
sprintf('ActionType handler "%s" must implement %s', $handlerName, LoggingActionInterface::class)
|
||||
);
|
||||
}
|
||||
|
||||
if (!$config instanceof TypeConfig) {
|
||||
throw new \LogicException(
|
||||
sprintf('ActionType handler config "%s" must be instance of %s', $handlerName, TypeConfig::class)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
usort($handlers, function ($first, $second) {
|
||||
return $first['config']->getPriority() <=> $second['config']->getPriority();
|
||||
});
|
||||
|
||||
$this->handlers = $handlers;
|
||||
}
|
||||
|
||||
public function getHandlers(string $actionName, string $event): array
|
||||
{
|
||||
$this->matchHandlers($actionName, $event);
|
||||
|
||||
return array_map(function ($handlerData) {
|
||||
return $handlerData['class'];
|
||||
}, $this->matched[$actionName][$event]['handlers'] ?? []);
|
||||
}
|
||||
|
||||
public function getValidators(string $actionName, string $event, string $handlerClass): array
|
||||
{
|
||||
$this->matchHandlers($actionName, $event);
|
||||
|
||||
foreach ($this->matched[$actionName][$event]['handlers'] ?? [] as $handlerData) {
|
||||
if ($handlerData['class'] === $handlerClass) {
|
||||
return $handlerData['validators'];
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
private function matchHandlers(string $actionName, string $event): void
|
||||
{
|
||||
if (isset($this->matched[$actionName][$event]['handlers'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->handlers as $handlerData) {
|
||||
/** @var TypeConfig $config */
|
||||
$config = $handlerData['config'];
|
||||
|
||||
if ($config->getEvent() === $event) {
|
||||
foreach ($config->getActions() as $handlerActionRegExp) {
|
||||
if (preg_match("/$handlerActionRegExp/i", $actionName)) {
|
||||
$this->matched[$actionName][$event]['handlers'][] = [
|
||||
'class' => $handlerData['handlerClass'],
|
||||
'validators' => $config->getValidators()
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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\Logging\ActionType\Login;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\ActiveSessionManagerInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\LoggingActionInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Api\LoginAttemptManagerInterface;
|
||||
use Amasty\AdminActionsLog\Api\VisitHistoryManagerInterface;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LoginAttemptStatus;
|
||||
|
||||
class SucceedLogin implements LoggingActionInterface
|
||||
{
|
||||
/**
|
||||
* @var MetadataInterface
|
||||
*/
|
||||
private $metadata;
|
||||
|
||||
/**
|
||||
* @var ActiveSessionManagerInterface
|
||||
*/
|
||||
private $activeSessionManager;
|
||||
|
||||
/**
|
||||
* @var VisitHistoryManagerInterface
|
||||
*/
|
||||
private $visitHistoryManager;
|
||||
|
||||
/**
|
||||
* @var LoginAttemptManagerInterface
|
||||
*/
|
||||
private $loginAttemptManager;
|
||||
|
||||
public function __construct(
|
||||
MetadataInterface $metadata,
|
||||
ActiveSessionManagerInterface $activeSessionManager,
|
||||
VisitHistoryManagerInterface $visitHistoryManager,
|
||||
LoginAttemptManagerInterface $loginAttemptManager
|
||||
) {
|
||||
$this->metadata = $metadata;
|
||||
$this->activeSessionManager = $activeSessionManager;
|
||||
$this->visitHistoryManager = $visitHistoryManager;
|
||||
$this->loginAttemptManager = $loginAttemptManager;
|
||||
}
|
||||
|
||||
public function execute(): void
|
||||
{
|
||||
$this->activeSessionManager->initNew();
|
||||
$this->visitHistoryManager->startVisit();
|
||||
$this->loginAttemptManager->saveAttempt(null, LoginAttemptStatus::SUCCESS);
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
<?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\Logging\ActionType\RenderBefore;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Data\VisitHistoryDetailInterfaceFactory;
|
||||
use Amasty\AdminActionsLog\Api\Data\VisitHistoryEntryInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\LoggingActionInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\ObjectDataStorageInterface;
|
||||
use Amasty\AdminActionsLog\Model\Admin\SessionUserDataProvider;
|
||||
use Amasty\AdminActionsLog\Api\VisitHistoryEntryRepositoryInterface;
|
||||
use Amasty\AdminActionsLog\Model\VisitHistoryEntry\VisitHistoryDetail;
|
||||
use Amasty\AdminActionsLog\Model\VisitHistoryEntry\VisitHistoryManager;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Stdlib\DateTime\DateTime;
|
||||
|
||||
class Layout implements LoggingActionInterface
|
||||
{
|
||||
/**
|
||||
* @var DateTime
|
||||
*/
|
||||
private $dateTime;
|
||||
|
||||
/**
|
||||
* @var MetadataInterface
|
||||
*/
|
||||
private $metadata;
|
||||
|
||||
/**
|
||||
* @var SessionUserDataProvider
|
||||
*/
|
||||
private $userDataProvider;
|
||||
|
||||
/**
|
||||
* @var ObjectDataStorageInterface
|
||||
*/
|
||||
private $dataStorage;
|
||||
|
||||
/**
|
||||
* @var VisitHistoryDetailInterfaceFactory
|
||||
*/
|
||||
private $detailFactory;
|
||||
|
||||
/**
|
||||
* @var VisitHistoryEntryRepositoryInterface
|
||||
*/
|
||||
private $historyEntryRepository;
|
||||
|
||||
/**
|
||||
* @var VisitHistoryManager
|
||||
*/
|
||||
private $visitHistoryManager;
|
||||
|
||||
public function __construct(
|
||||
DateTime $dateTime,
|
||||
MetadataInterface $metadata,
|
||||
SessionUserDataProvider $userDataProvider,
|
||||
ObjectDataStorageInterface $dataStorage,
|
||||
VisitHistoryDetailInterfaceFactory $detailFactory,
|
||||
VisitHistoryEntryRepositoryInterface $historyEntryRepository,
|
||||
VisitHistoryManager $visitHistoryManager
|
||||
) {
|
||||
$this->dateTime = $dateTime;
|
||||
$this->metadata = $metadata;
|
||||
$this->userDataProvider = $userDataProvider;
|
||||
$this->dataStorage = $dataStorage;
|
||||
$this->detailFactory = $detailFactory;
|
||||
$this->historyEntryRepository = $historyEntryRepository;
|
||||
$this->visitHistoryManager = $visitHistoryManager;
|
||||
}
|
||||
|
||||
public function execute(): void
|
||||
{
|
||||
/** @var \Magento\Framework\View\Element\Template\Context $context */
|
||||
if (!$context = $this->metadata->getObject()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sessionId = $this->userDataProvider->getSessionId();
|
||||
$historyEntry = $this->getHistoryEntry($sessionId);
|
||||
$details = $historyEntry->getVisitHistoryDetails();
|
||||
$lastDetail = end($details) ?: $this->detailFactory->create();
|
||||
|
||||
if ($lastDetail->getPageUrl() !== $context->getUrlBuilder()->getCurrentUrl()) {
|
||||
$storageKey = $this->userDataProvider->getUserName() . 'StayDuration';
|
||||
$currentTimeStamp = $this->dateTime->gmtTimestamp();
|
||||
$lastDetailStayDuration = $this->dataStorage->isExists($storageKey)
|
||||
? $currentTimeStamp - ($this->dataStorage->get($storageKey)['timestamp'] ?? 0)
|
||||
: 0;
|
||||
$lastDetail->setStayDuration((int)$lastDetailStayDuration);
|
||||
$this->dataStorage->set($storageKey, ['timestamp' => $currentTimeStamp]);
|
||||
$details[] = $this->detailFactory->create(['data' => [
|
||||
VisitHistoryDetail::PAGE_NAME => $context->getPageConfig()->getTitle()->get(),
|
||||
VisitHistoryDetail::PAGE_URL => $context->getUrlBuilder()->getCurrentUrl()
|
||||
]]);
|
||||
$historyEntry->setVisitHistoryDetails($details);
|
||||
$this->historyEntryRepository->save($historyEntry);
|
||||
}
|
||||
}
|
||||
|
||||
private function getHistoryEntry(string $sessionId): VisitHistoryEntryInterface
|
||||
{
|
||||
try {
|
||||
$historyEntry = $this->historyEntryRepository->getBySessionId($sessionId);
|
||||
} catch (NoSuchEntityException $e) {
|
||||
$this->visitHistoryManager->startVisit();
|
||||
$historyEntry = $this->historyEntryRepository->getBySessionId($sessionId);
|
||||
}
|
||||
|
||||
return $historyEntry;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?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\Logging\ActionType;
|
||||
|
||||
use Amasty\AdminActionsLog\Logging\ActionType\Validation\ActionValidatorInterface;
|
||||
|
||||
class TypeConfig
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $actionsRegExp;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $validators;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $priority;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $event;
|
||||
|
||||
public function __construct(
|
||||
array $actionsRegExp = [],
|
||||
array $validators = [],
|
||||
string $event = '',
|
||||
int $priority = 0
|
||||
) {
|
||||
foreach ($validators as $validatorName => $validator) {
|
||||
if (!$validator instanceof ActionValidatorInterface) {
|
||||
throw new \LogicException(
|
||||
sprintf(
|
||||
'ActionType validator "%s" must implement %s',
|
||||
$validatorName,
|
||||
ActionValidatorInterface::class
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->actionsRegExp = array_map(function ($action) {
|
||||
return (string)$action;
|
||||
}, $actionsRegExp);
|
||||
$this->validators = $validators;
|
||||
$this->event = $event;
|
||||
$this->priority = $priority;
|
||||
}
|
||||
|
||||
public function getActions(): array
|
||||
{
|
||||
return $this->actionsRegExp;
|
||||
}
|
||||
|
||||
public function getPriority(): int
|
||||
{
|
||||
return $this->priority;
|
||||
}
|
||||
|
||||
public function getEvent(): string
|
||||
{
|
||||
return $this->event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActionValidatorInterface[]
|
||||
*/
|
||||
public function getValidators(): array
|
||||
{
|
||||
return $this->validators;
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?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\Logging\ActionType\Validation;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Magento\Framework\DataObject;
|
||||
|
||||
class ActionValidator implements ActionValidatorInterface
|
||||
{
|
||||
/**
|
||||
* @var DataObject
|
||||
*/
|
||||
private $actionsList;
|
||||
|
||||
public function __construct(DataObject $actionsList)
|
||||
{
|
||||
$this->actionsList = $actionsList;
|
||||
}
|
||||
|
||||
public function isValid(MetadataInterface $metadata): bool
|
||||
{
|
||||
return !in_array($metadata->getRequest()->getFullActionName(), $this->actionsList->getList());
|
||||
}
|
||||
}
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
<?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\Logging\ActionType\Validation;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
|
||||
interface ActionValidatorInterface
|
||||
{
|
||||
/**
|
||||
* Validate Action Metadata.
|
||||
*
|
||||
* @param MetadataInterface $metadata
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(MetadataInterface $metadata): bool;
|
||||
}
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
<?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\Logging\ActionType\Validation;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Model\Admin\IsLoggingAllowed;
|
||||
|
||||
class LoggingAllowedValidator implements ActionValidatorInterface
|
||||
{
|
||||
/**
|
||||
* @var IsLoggingAllowed
|
||||
*/
|
||||
private $isLoggingAllowed;
|
||||
|
||||
public function __construct(IsLoggingAllowed $isLoggingAllowed)
|
||||
{
|
||||
$this->isLoggingAllowed = $isLoggingAllowed;
|
||||
}
|
||||
|
||||
public function isValid(MetadataInterface $metadata): bool
|
||||
{
|
||||
return $this->isLoggingAllowed->execute();
|
||||
}
|
||||
}
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
<?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\Logging\ActionType\Validation;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Model\ConfigProvider;
|
||||
use Magento\Framework\App\HttpRequestInterface;
|
||||
|
||||
class LoggingVisitHistoryValidator implements ActionValidatorInterface
|
||||
{
|
||||
/**
|
||||
* @var ConfigProvider
|
||||
*/
|
||||
private $configProvider;
|
||||
|
||||
/**
|
||||
* @var bool|null
|
||||
*/
|
||||
private $validationResult = null;
|
||||
|
||||
public function __construct(ConfigProvider $configProvider)
|
||||
{
|
||||
$this->configProvider = $configProvider;
|
||||
}
|
||||
|
||||
public function isValid(MetadataInterface $metadata): bool
|
||||
{
|
||||
if ($this->validationResult === null) {
|
||||
$request = $metadata->getRequest();
|
||||
|
||||
$this->validationResult = $this->configProvider->isEnabledLogVisitHistory()
|
||||
&& $request instanceof HttpRequestInterface
|
||||
&& !$request->isAjax();
|
||||
}
|
||||
|
||||
return $this->validationResult;
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?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\Logging\ActionType\Validation;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ClassList;
|
||||
|
||||
class ObjectClassValidator implements ActionValidatorInterface
|
||||
{
|
||||
/**
|
||||
* @var ClassList
|
||||
*/
|
||||
private $classList;
|
||||
|
||||
public function __construct(ClassList $classList)
|
||||
{
|
||||
$this->classList = $classList;
|
||||
}
|
||||
|
||||
public function isValid(MetadataInterface $metadata): bool
|
||||
{
|
||||
if ($object = $metadata->getObject()) {
|
||||
return !$this->classList->isIgnored(get_class($object));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<?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\Logging\ActionType\Validation;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Model\Di\Wrapper as TfaSession;
|
||||
use Magento\Framework\Module\Manager;
|
||||
use Magento\TwoFactorAuth\Api\TfaSessionInterface;
|
||||
|
||||
class TwoFactorGranted implements ActionValidatorInterface
|
||||
{
|
||||
/**
|
||||
* @var Manager
|
||||
*/
|
||||
private $moduleManager;
|
||||
|
||||
/**
|
||||
* @var TfaSessionInterface
|
||||
*/
|
||||
private $tfaSession;
|
||||
|
||||
public function __construct(
|
||||
Manager $moduleManager,
|
||||
TfaSession $tfaSession
|
||||
) {
|
||||
$this->moduleManager = $moduleManager;
|
||||
$this->tfaSession = $tfaSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stateless session validator because TFA access can be changed during request processing.
|
||||
* @see \Magento\TwoFactorAuth\Model\TfaSession::grantAccess
|
||||
*
|
||||
* @param MetadataInterface $metadata
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(MetadataInterface $metadata): bool
|
||||
{
|
||||
return $this->moduleManager->isEnabled('Magento_TwoFactorAuth')
|
||||
? (bool)$this->tfaSession->isGranted()
|
||||
: true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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\Logging\ActionType;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\LoggingActionInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\ActionType\Validation\ActionValidatorInterface;
|
||||
|
||||
class ValidationComposite implements LoggingActionInterface
|
||||
{
|
||||
/**
|
||||
* @var MetadataInterface
|
||||
*/
|
||||
private $metadata;
|
||||
|
||||
/**
|
||||
* @var LoggingActionInterface
|
||||
*/
|
||||
private $wrappedAction;
|
||||
|
||||
/**
|
||||
* @var ActionValidatorInterface[]
|
||||
*/
|
||||
private $validators;
|
||||
|
||||
public function __construct(
|
||||
MetadataInterface $metadata,
|
||||
LoggingActionInterface $wrappedAction,
|
||||
array $validators = []
|
||||
) {
|
||||
$this->metadata = $metadata;
|
||||
$this->wrappedAction = $wrappedAction;
|
||||
$this->validators = $validators;
|
||||
}
|
||||
|
||||
public function execute(): void
|
||||
{
|
||||
foreach ($this->validators as $validator) {
|
||||
if (!$validator->isValid($this->metadata)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->wrappedAction->execute();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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\Logging\DataStorage;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\ObjectDataStorageInterface;
|
||||
use Magento\Backend\Model\Session;
|
||||
|
||||
class BackendSession implements ObjectDataStorageInterface
|
||||
{
|
||||
/**
|
||||
* @var Session
|
||||
*/
|
||||
private $session;
|
||||
|
||||
public function __construct(Session $session)
|
||||
{
|
||||
$this->session = $session;
|
||||
}
|
||||
|
||||
public function get(string $key): ?array
|
||||
{
|
||||
$getterName = 'get' . ucfirst($key);
|
||||
//phpcs:ignore
|
||||
$storedData = call_user_func([$this->session, $getterName]);
|
||||
|
||||
return is_array($storedData) ? $storedData : [$storedData];
|
||||
}
|
||||
|
||||
public function set(string $key, array $data): void
|
||||
{
|
||||
$setterName = 'set' . ucfirst($key);
|
||||
//phpcs:ignore
|
||||
call_user_func_array([$this->session, $setterName], [$data]);
|
||||
}
|
||||
|
||||
public function unset(string $key): void
|
||||
{
|
||||
$unsetterName = 'uns' . ucfirst($key);
|
||||
//phpcs:ignore
|
||||
call_user_func([$this->session, $unsetterName]);
|
||||
}
|
||||
|
||||
public function isExists(string $key): bool
|
||||
{
|
||||
$checkerName = 'has' . ucfirst($key);
|
||||
//phpcs:ignore
|
||||
return call_user_func([$this->session, $checkerName]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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\Logging\DataStorage;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\ObjectDataStorageInterface;
|
||||
use Magento\Framework\FlagManager;
|
||||
|
||||
class FlagTable implements ObjectDataStorageInterface
|
||||
{
|
||||
public const FLAG_CODE_PREFIX = 'amasty_audit_';
|
||||
|
||||
/**
|
||||
* @var FlagManager
|
||||
*/
|
||||
private $flagManager;
|
||||
|
||||
public function __construct(FlagManager $flagManager)
|
||||
{
|
||||
$this->flagManager = $flagManager;
|
||||
}
|
||||
|
||||
public function get(string $key): ?array
|
||||
{
|
||||
$storedData = $this->flagManager->getFlagData(self::FLAG_CODE_PREFIX . $key);
|
||||
|
||||
return is_array($storedData) || $storedData === null ? $storedData : [$storedData];
|
||||
}
|
||||
|
||||
public function set(string $key, array $data): void
|
||||
{
|
||||
$this->flagManager->saveFlag(self::FLAG_CODE_PREFIX . $key, $data);
|
||||
}
|
||||
|
||||
public function unset(string $key): void
|
||||
{
|
||||
$this->flagManager->deleteFlag(self::FLAG_CODE_PREFIX . $key);
|
||||
}
|
||||
|
||||
public function isExists(string $key): bool
|
||||
{
|
||||
return $this->flagManager->getFlagData(self::FLAG_CODE_PREFIX . $key) !== null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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\Logging\DataStorage;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\ObjectDataStorageInterface;
|
||||
|
||||
class InMemory implements ObjectDataStorageInterface
|
||||
{
|
||||
/**
|
||||
* Data storage for entities data.
|
||||
* We are using spl_object_id to correctly identify objects.
|
||||
*
|
||||
* Data structure example:
|
||||
* [objectHashId.postfix] => [...]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $entityDataStorage = [];
|
||||
|
||||
public function get(string $key): ?array
|
||||
{
|
||||
return $this->entityDataStorage[$key] ?? null;
|
||||
}
|
||||
|
||||
public function set(string $key, array $data): void
|
||||
{
|
||||
$this->entityDataStorage[$key] = $data;
|
||||
}
|
||||
|
||||
public function unset(string $key): void
|
||||
{
|
||||
unset($this->entityDataStorage[$key]);
|
||||
}
|
||||
|
||||
public function isExists(string $key): bool
|
||||
{
|
||||
return isset($this->entityDataStorage[$key]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?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\Logging\Entity\SaveHandler\Admin;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\User\Model\UserFactory;
|
||||
|
||||
class User extends Common
|
||||
{
|
||||
/**
|
||||
* @var UserFactory
|
||||
*/
|
||||
private $userFactory;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'reload_acl_flag',
|
||||
'modified'
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
UserFactory $userFactory
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
$this->userFactory = $userFactory;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\User\Model\User $adminUser */
|
||||
$adminUser = $metadata->getObject();
|
||||
|
||||
if (!$adminUser->getUserName()) {
|
||||
$adminUser->load($adminUser->getId());
|
||||
}
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $adminUser->getUserName(),
|
||||
LogEntry::CATEGORY => 'admin/user/edit',
|
||||
LogEntry::CATEGORY_NAME => __('Admin User'),
|
||||
LogEntry::ELEMENT_ID => (int)$adminUser->getId(),
|
||||
LogEntry::PARAMETER_NAME => 'user_id'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\User\Model\User $object
|
||||
* @return array
|
||||
*/
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
if ($role = $object->getRole()) {
|
||||
$object->setOrigData('role_id', $role->getId());
|
||||
}
|
||||
|
||||
return parent::processBeforeSave($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\User\Model\User $object
|
||||
* @return array
|
||||
*/
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
$user = $this->userFactory->create()->load($object->getId());
|
||||
|
||||
if ($role = $user->getRole()) {
|
||||
$user->setRoleId($role->getId());
|
||||
}
|
||||
|
||||
return parent::processAfterSave($user);
|
||||
}
|
||||
}
|
||||
+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\Logging\Entity\SaveHandler\Admin;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
|
||||
class UserExpiration extends Common
|
||||
{
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Security\Model\UserExpiration $expiration */
|
||||
$expiration = $metadata->getObject();
|
||||
$type = $expiration->getOrigData() === [] ? LogEntryTypes::TYPE_NEW : LogEntryTypes::TYPE_EDIT;
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => $type,
|
||||
LogEntry::ITEM => __('Expiration for Admin #%1', $expiration->getUserId()),
|
||||
LogEntry::CATEGORY => 'admin/user/edit',
|
||||
LogEntry::CATEGORY_NAME => __('Admin Expiration'),
|
||||
LogEntry::ELEMENT_ID => (int)$expiration->getUserId(),
|
||||
LogEntry::PARAMETER_NAME => 'user_id'
|
||||
];
|
||||
}
|
||||
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
$object->load($object->getId());
|
||||
|
||||
return parent::processAfterSave($object);
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?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\Logging\Entity\SaveHandler\Admin;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class UserRole extends Common
|
||||
{
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Authorization\Model\Role $role */
|
||||
$role = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $role->getRoleName(),
|
||||
LogEntry::CATEGORY => 'admin/user_role/editrole',
|
||||
LogEntry::CATEGORY_NAME => __('Admin User Role'),
|
||||
LogEntry::ELEMENT_ID => (int)$role->getId(),
|
||||
LogEntry::PARAMETER_NAME => 'rid'
|
||||
];
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
<?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\Logging\Entity\SaveHandler\Adminhtml\Stock;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\CatalogInventory\Api\StockItemRepositoryInterface;
|
||||
use Magento\CatalogInventory\Model\Adminhtml\Stock\Item as StockItem;
|
||||
|
||||
class Item extends Common
|
||||
{
|
||||
public const CATEGORY = 'catalog/product/edit/stock/item';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $stockItems = [];
|
||||
|
||||
/**
|
||||
* @var ProductRepositoryInterface
|
||||
*/
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @var StockItemRepositoryInterface
|
||||
*/
|
||||
private $stockItemRepository;
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
ProductRepositoryInterface $productRepository,
|
||||
StockItemRepositoryInterface $stockItemRepository
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
$this->productRepository = $productRepository;
|
||||
$this->stockItemRepository = $stockItemRepository;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var StockItem $stockItem */
|
||||
$stockItem = $metadata->getObject();
|
||||
$product = $this->productRepository->getById((int)$stockItem->getProductId());
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $product->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Stock Item'),
|
||||
LogEntry::ELEMENT_ID => $stockItem->getId(),
|
||||
LogEntry::VIEW_ELEMENT_ID => $product->getId(),
|
||||
];
|
||||
}
|
||||
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
$stockItem = $this->getStockItem((int)$object->getId());
|
||||
|
||||
return $this->filterObjectData($stockItem->getData());
|
||||
}
|
||||
|
||||
private function getStockItem(int $stockItemId): StockItem
|
||||
{
|
||||
if (!isset($this->stockItems[$stockItemId])) {
|
||||
$this->stockItems[$stockItemId] = $this->stockItemRepository->get($stockItemId);
|
||||
}
|
||||
|
||||
return $this->stockItems[$stockItemId];
|
||||
}
|
||||
}
|
||||
Executable
+68
@@ -0,0 +1,68 @@
|
||||
<?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\Logging\Entity\SaveHandler\Amasty\RequestQuote\Model;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class Quote extends Common
|
||||
{
|
||||
public const CATEGORY = 'amasty_quote/quote/view';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $keysToCheck;
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
array $keysToCheck = []
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
$this->keysToCheck = $keysToCheck;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Amasty\RequestQuote\Model\Quote $quote */
|
||||
$quote = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => __('Request Quote #%1', $quote->getIncrementId()),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Request Quote'),
|
||||
LogEntry::ELEMENT_ID => $quote->getId(),
|
||||
LogEntry::PARAMETER_NAME => 'quote_id'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Amasty\RequestQuote\Model\Quote $object
|
||||
* @return array
|
||||
*/
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
$quote = clone $object;
|
||||
$quote->load($object->getId());
|
||||
|
||||
return $this->filterObjectData((array)$quote->getData());
|
||||
}
|
||||
|
||||
protected function filterObjectData(array $data): array
|
||||
{
|
||||
$data = parent::filterObjectData($data);
|
||||
|
||||
return array_intersect_key($data, array_flip($this->keysToCheck));
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
<?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\Logging\Entity\SaveHandler\Catalog;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class Category extends Common
|
||||
{
|
||||
public const CATEGORY = 'catalog/category/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'form_key',
|
||||
'entity_id',
|
||||
'updated_at',
|
||||
'url_key_create_redirect',
|
||||
'save_rewrites_history',
|
||||
'custom_design_from_is_formated'
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Catalog\Model\Category $category */
|
||||
$category = $metadata->getObject();
|
||||
|
||||
if (!$category->getName()) {
|
||||
$category->load($category->getId()); // Force reload category in cases of mass delete, etc.
|
||||
}
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $category->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Catalog Category'),
|
||||
LogEntry::ELEMENT_ID => (int)$category->getId(),
|
||||
LogEntry::STORE_ID => (int)$category->getStoreId()
|
||||
];
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
<?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\Logging\Entity\SaveHandler\Catalog;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\Catalog\Model\Product\Gallery\LogImages;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
|
||||
class Product extends Common
|
||||
{
|
||||
public const CATEGORY = 'catalog/product/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'current_product_id',
|
||||
'affect_product_custom_options',
|
||||
'current_store_id',
|
||||
'product_has_weight',
|
||||
'is_new',
|
||||
'_edit_mode',
|
||||
'amrolepermissions_owner',
|
||||
'use_config_gift_message_available',
|
||||
'use_config_gift_wrapping_available',
|
||||
'url_key_create_redirect',
|
||||
'use_config_is_returnable',
|
||||
'can_save_custom_options',
|
||||
'save_rewrites_history',
|
||||
'is_custom_option_changed',
|
||||
'special_from_date_is_formated',
|
||||
'custom_design_from_is_formated',
|
||||
'news_from_date_is_formated',
|
||||
'news_to_date_is_formated',
|
||||
'force_reindex_eav_required',
|
||||
'updated_at',
|
||||
'has_options',
|
||||
'required_options',
|
||||
'quantity_and_stock_status'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var LogImages
|
||||
*/
|
||||
private $logImages;
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
?LogImages $logImages = null
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
$this->logImages = $logImages ?? ObjectManager::getInstance()->get(LogImages::class);
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Catalog\Model\Product $product */
|
||||
$product = $metadata->getObject();
|
||||
|
||||
if (!$product->getName()) {
|
||||
$product->load($product->getId()); // Force reload product in cases of mass delete, etc.
|
||||
}
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $product->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Catalog Product'),
|
||||
LogEntry::ELEMENT_ID => (int)$product->getId(),
|
||||
LogEntry::STORE_ID => (int)$product->getStoreId()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Model\AbstractModel $object
|
||||
* @return array
|
||||
*/
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
$this->logImages->processGalleryBeforeSave($object);
|
||||
|
||||
return parent::processBeforeSave($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Model\AbstractModel $object
|
||||
* @return array
|
||||
*/
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
$this->logImages->processGalleryAfterSave($object);
|
||||
|
||||
return parent::processAfterSave($object);
|
||||
}
|
||||
}
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
<?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\Logging\Entity\SaveHandler\Catalog;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class ProductGalleryEntry extends Common
|
||||
{
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
$image = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $image->getFile(),
|
||||
LogEntry::CATEGORY => __('Product Gallery Image'),
|
||||
LogEntry::CATEGORY_NAME => __('Product Gallery Image'),
|
||||
LogEntry::ELEMENT_ID => (int)$image->getId()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Model\AbstractModel $object
|
||||
* @return array
|
||||
*/
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
if ($object->getId()) {
|
||||
return $this->filterObjectData($object->getData());
|
||||
} else {
|
||||
return $this->filterObjectData((array)$object->getOrigData());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Model\AbstractModel $object
|
||||
* @return array
|
||||
*/
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
return $this->filterObjectData($object->getData());
|
||||
}
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
<?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\Logging\Entity\SaveHandler\Catalog;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Logging\Util\ProductIdentifierResolver;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
|
||||
class ProductOption extends Common
|
||||
{
|
||||
public const CATEGORY = 'catalog/product/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'is_use_default',
|
||||
'initialize',
|
||||
'record_id',
|
||||
'product_sku',
|
||||
'store_id'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var ProductRepositoryInterface
|
||||
*/
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @var ProductCustomOptionRepositoryInterface
|
||||
*/
|
||||
private $productCustomOptionRepository;
|
||||
|
||||
/**
|
||||
* @var ProductIdentifierResolver
|
||||
*/
|
||||
private $productIdentifierResolver;
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
ProductRepositoryInterface $productRepository,
|
||||
ProductCustomOptionRepositoryInterface $productCustomOptionRepository,
|
||||
ProductIdentifierResolver $productIdentifierResolver
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
|
||||
$this->productRepository = $productRepository;
|
||||
$this->productCustomOptionRepository = $productCustomOptionRepository;
|
||||
$this->productIdentifierResolver = $productIdentifierResolver;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Catalog\Model\Product\Option $option */
|
||||
$option = $metadata->getObject();
|
||||
$type = $option->isObjectNew() ? LogEntryTypes::TYPE_NEW : LogEntryTypes::TYPE_EDIT;
|
||||
// Workaround because there is no product SKU in the object when deleted
|
||||
$productId = $this->productIdentifierResolver->execute((int)$option->getProductId());
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => $type,
|
||||
LogEntry::ITEM => __('Option "%1"', $option->getTitle()),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Product Customizable Option'),
|
||||
LogEntry::ELEMENT_ID => $productId,
|
||||
LogEntry::STORE_ID => (int)$option->getStoreId(),
|
||||
LogEntry::ADDITIONAL_DATA => [
|
||||
'productId' => $productId,
|
||||
'optionId' => $option->getId() ? (int)$option->getId() : null
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
if ($object->getId()) {
|
||||
$productId = $this->productIdentifierResolver->execute((int)$object->getProductId());
|
||||
$product = $this->productRepository->getById($productId, false, (int)$object->getStoreId());
|
||||
$option = $this->productCustomOptionRepository->getProductOptions($product)
|
||||
[$object->getId()] ?? null;
|
||||
|
||||
return $option ? $this->filterObjectData($option->getData()) : [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
$data = parent::processAfterSave($object);
|
||||
if ($object->hasValues()) {
|
||||
unset($data['price_type']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Executable
+121
@@ -0,0 +1,121 @@
|
||||
<?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\Logging\Entity\SaveHandler\Catalog;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\ObjectDataStorageInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Logging\Util\ProductIdentifierResolver;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
use Amasty\AdminActionsLog\Restoring\Entity\RestoreHandler\AbstractHandler;
|
||||
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
|
||||
class ProductOptionValue extends Common
|
||||
{
|
||||
public const CATEGORY = 'catalog/product/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'is_use_default',
|
||||
'initialize',
|
||||
'record_id',
|
||||
'store_id'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var ProductRepositoryInterface
|
||||
*/
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @var ProductCustomOptionRepositoryInterface
|
||||
*/
|
||||
private $productCustomOptionRepository;
|
||||
|
||||
/**
|
||||
* @var ProductIdentifierResolver
|
||||
*/
|
||||
private $productIdentifierResolver;
|
||||
|
||||
/**
|
||||
* @var ObjectDataStorageInterface
|
||||
*/
|
||||
private $dataStorage;
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
ProductRepositoryInterface $productRepository,
|
||||
ProductCustomOptionRepositoryInterface $productCustomOptionRepository,
|
||||
ProductIdentifierResolver $productIdentifierResolver,
|
||||
ObjectDataStorageInterface $dataStorage
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
|
||||
$this->productRepository = $productRepository;
|
||||
$this->productCustomOptionRepository = $productCustomOptionRepository;
|
||||
$this->productIdentifierResolver = $productIdentifierResolver;
|
||||
$this->dataStorage = $dataStorage;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Catalog\Model\Product\Option\Value $value */
|
||||
$value = $metadata->getObject();
|
||||
// Workaround because there is no product SKU in the object when deleted
|
||||
$productId = $this->productIdentifierResolver->execute((int)$value->getOption()->getProductId());
|
||||
$type = $value->isObjectNew() ? LogEntryTypes::TYPE_NEW : LogEntryTypes::TYPE_EDIT;
|
||||
$storageKey = spl_object_id($value->getOption()) . '.' . AbstractHandler::STORAGE_CODE_PREFIX;
|
||||
if ($this->dataStorage->isExists($storageKey)) {
|
||||
$type = LogEntryTypes::TYPE_RESTORE;
|
||||
}
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => $type,
|
||||
LogEntry::ITEM => __(
|
||||
'Value "%1" of Option "%2"',
|
||||
$value->getTitle(),
|
||||
$value->getOption()->getTitle()
|
||||
),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Product Customizable Option'),
|
||||
LogEntry::ELEMENT_ID => $productId,
|
||||
LogEntry::STORE_ID => (int)$value->getStoreId(),
|
||||
LogEntry::ADDITIONAL_DATA => [
|
||||
'productId' => $productId,
|
||||
'optionId' => $value->getOption()->getId(),
|
||||
'valueId' => $value->getId() ? (int)$value->getId() : null
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
if ($object->getId() && $object->getOption()->getId()) {
|
||||
$productId = $this->productIdentifierResolver->execute(
|
||||
(int)$object->getOption()->getProductId()
|
||||
);
|
||||
$product = $this->productRepository->getById($productId, false, (int)$object->getStoreId());
|
||||
$option = $this->productCustomOptionRepository->getProductOptions($product)
|
||||
[$object->getOption()->getId()] ?? null;
|
||||
$value = $option ? $option->getValues()[$object->getId()] ?? null : null;
|
||||
|
||||
return $value ? $this->filterObjectData($value->getData()) : [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Executable
+69
@@ -0,0 +1,69 @@
|
||||
<?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\Logging\Entity\SaveHandler\CheckoutAgreement;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\CheckoutAgreements\Api\CheckoutAgreementsRepositoryInterface;
|
||||
use Magento\CheckoutAgreements\Model\Agreement as CheckoutAgreement;
|
||||
|
||||
class Agreement extends Common
|
||||
{
|
||||
public const CATEGORY = 'checkout/agreement/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'form_key'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var CheckoutAgreementsRepositoryInterface
|
||||
*/
|
||||
private $checkoutAgreementsRepository;
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter,
|
||||
CheckoutAgreementsRepositoryInterface $checkoutAgreementsRepository
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
|
||||
$this->checkoutAgreementsRepository = $checkoutAgreementsRepository;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var CheckoutAgreement $agreement */
|
||||
$agreement = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $agreement->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Terms and Conditions'),
|
||||
LogEntry::ELEMENT_ID => (int)$agreement->getId(),
|
||||
];
|
||||
}
|
||||
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
if ($object->getId()) {
|
||||
$agreement = $this->checkoutAgreementsRepository->get((int)$object->getId());
|
||||
|
||||
return $this->filterObjectData($agreement->getData());
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -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\Logging\Entity\SaveHandler\Cms;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Store\Model\Store;
|
||||
|
||||
class Block extends Common
|
||||
{
|
||||
public const CATEGORY = 'cms/block/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'_first_store_id',
|
||||
'form_key',
|
||||
];
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Cms\Model\Block $block */
|
||||
$block = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $block->getTitle(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('CMS Block'),
|
||||
LogEntry::ELEMENT_ID => (int)$block->getId(),
|
||||
LogEntry::STORE_ID => Store::DEFAULT_STORE_ID,
|
||||
LogEntry::PARAMETER_NAME => 'block_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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\Logging\Entity\SaveHandler\Cms;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Store\Model\Store;
|
||||
|
||||
class Page extends Common
|
||||
{
|
||||
public const CATEGORY = 'admin/cms_page/edit/';
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Cms\Model\Page $page */
|
||||
$page = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $page->getTitle(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('CMS Page'),
|
||||
LogEntry::ELEMENT_ID => (int)$page->getId(),
|
||||
LogEntry::STORE_ID => Store::DEFAULT_STORE_ID,
|
||||
LogEntry::PARAMETER_NAME => 'page_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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\Logging\Entity\SaveHandler\Cms;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Magento\Store\Model\Store;
|
||||
|
||||
class Widget extends Common
|
||||
{
|
||||
public const CATEGORY = 'admin/widget_instance/edit/';
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Widget\Model\Widget\Instance $widget */
|
||||
$widget = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ITEM => $widget->getTitle(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('CMS Widget'),
|
||||
LogEntry::ELEMENT_ID => (int)$widget->getId(),
|
||||
LogEntry::STORE_ID => Store::DEFAULT_STORE_ID,
|
||||
LogEntry::PARAMETER_NAME => 'instance_id'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?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\Logging\Entity\SaveHandler;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\EntitySaveHandlerInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
|
||||
class Common implements EntitySaveHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @var ArrayFilter\ScalarValueFilter
|
||||
*/
|
||||
private $scalarValueFilter;
|
||||
|
||||
/**
|
||||
* @var ArrayFilter\KeyFilter
|
||||
*/
|
||||
private $keyFilter;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [];
|
||||
|
||||
public function __construct(
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter
|
||||
) {
|
||||
$this->scalarValueFilter = $scalarValueFilter;
|
||||
$this->keyFilter = $keyFilter;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Framework\Model\AbstractModel $object */
|
||||
$object = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::ELEMENT_ID => (int)$object->getId(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Model\AbstractModel $object
|
||||
* @return array
|
||||
*/
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
if (!$object instanceof \Magento\Framework\Model\AbstractModel) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->filterObjectData((array)$object->getOrigData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Model\AbstractModel $object
|
||||
* @return array
|
||||
*/
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
if (!$object instanceof \Magento\Framework\Model\AbstractModel) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->filterObjectData((array)$object->getData());
|
||||
}
|
||||
|
||||
protected function filterObjectData(array $data): array
|
||||
{
|
||||
$data = $this->scalarValueFilter->filter($data);
|
||||
$data = $this->keyFilter->filter($data, $this->dataKeysIgnoreList ?? []);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?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\Logging\Entity\SaveHandler;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\EntitySaveHandlerInterface;
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
use Amasty\Base\Model\Serializer;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Framework\App\Config\Value;
|
||||
use Magento\Store\Model\ScopeInterface;
|
||||
|
||||
class Config implements EntitySaveHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @var ScopeConfigInterface
|
||||
*/
|
||||
private $scopeConfig;
|
||||
|
||||
/**
|
||||
* @var Serializer
|
||||
*/
|
||||
private $serializer;
|
||||
|
||||
public function __construct(
|
||||
ScopeConfigInterface $scopeConfig,
|
||||
Serializer $serializer
|
||||
) {
|
||||
$this->scopeConfig = $scopeConfig;
|
||||
$this->serializer = $serializer;
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var Value $object */
|
||||
$object = $metadata->getObject();
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => LogEntryTypes::TYPE_EDIT,
|
||||
LogEntry::CATEGORY_NAME => __('System Config'),
|
||||
LogEntry::ELEMENT_ID => (int)$object->getId(),
|
||||
LogEntry::STORE_ID => (int)$object->getScopeId(),
|
||||
// save 'scope' in additional data to understand, what we save in 'store_id': website id or store view id.
|
||||
LogEntry::ADDITIONAL_DATA => [
|
||||
'scope' => $object->getScope()
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Value $object
|
||||
* @return array
|
||||
*/
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
$oldValue = $this->scopeConfig->getValue(
|
||||
$object->getPath(),
|
||||
$object->getScope(),
|
||||
(int)$object->getScopeId()
|
||||
);
|
||||
|
||||
if (is_array($oldValue)) {
|
||||
$oldValue = $this->serializer->serialize($oldValue);
|
||||
}
|
||||
|
||||
return [
|
||||
$object->getPath() => $oldValue
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Value $object
|
||||
* @return array
|
||||
*/
|
||||
public function processAfterSave($object): array
|
||||
{
|
||||
return [
|
||||
$object->getPath() => $object->getValue()
|
||||
];
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
<?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\Logging\Entity\SaveHandler\Customer;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Logging\MetadataInterface;
|
||||
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Common;
|
||||
use Amasty\AdminActionsLog\Logging\Util\Ignore\ArrayFilter;
|
||||
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
use Magento\Customer\Api\CustomerRepositoryInterface;
|
||||
use Magento\Eav\Model\ResourceModel\Attribute\Collection;
|
||||
use Magento\Store\Model\Store;
|
||||
|
||||
class Customer extends Common
|
||||
{
|
||||
public const CATEGORY = 'customer/index/edit';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dataKeysIgnoreList = [
|
||||
'assistance_allowed',
|
||||
'entity_id',
|
||||
'rp_token',
|
||||
'rp_token_created_at',
|
||||
'ignore_validation_flag',
|
||||
'password_hash',
|
||||
'failures_num',
|
||||
'dob_is_formated',
|
||||
'updated_at'
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
?CustomerRepositoryInterface $customerRepository, // @deprecated
|
||||
ArrayFilter\ScalarValueFilter $scalarValueFilter,
|
||||
ArrayFilter\KeyFilter $keyFilter
|
||||
) {
|
||||
parent::__construct($scalarValueFilter, $keyFilter);
|
||||
}
|
||||
|
||||
public function getLogMetadata(MetadataInterface $metadata): array
|
||||
{
|
||||
/** @var \Magento\Customer\Model\Backend\Customer $customer */
|
||||
$customer = $metadata->getObject();
|
||||
$type = $customer->hasData(Collection::EAV_CODE_PASSWORD_HASH)
|
||||
? LogEntryTypes::TYPE_EDIT
|
||||
: LogEntryTypes::TYPE_NEW;
|
||||
|
||||
return [
|
||||
LogEntry::TYPE => $type,
|
||||
LogEntry::ITEM => $customer->getName(),
|
||||
LogEntry::CATEGORY => self::CATEGORY,
|
||||
LogEntry::CATEGORY_NAME => __('Customer'),
|
||||
LogEntry::ELEMENT_ID => (int)$customer->getId(),
|
||||
LogEntry::STORE_ID => Store::DEFAULT_STORE_ID,
|
||||
];
|
||||
}
|
||||
|
||||
public function processBeforeSave($object): array
|
||||
{
|
||||
return $this->filterObjectData((array)$object->getOrigData());
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user