Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwi-commerce committed Jun 1, 2018
1 parent e6a3528 commit 7a9fdc7
Show file tree
Hide file tree
Showing 97 changed files with 11,563 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Api/Activity/ModelInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* KiwiCommerce
*
* Do not edit or add to this file if you wish to upgrade to newer versions in the future.
* If you wish to customize this module for your needs.
* Please contact us https://kiwicommerce.co.uk/contacts.
*
* @category KiwiCommerce
* @package KiwiCommerce_AdminActivity
* @copyright Copyright (C) 2018 Kiwi Commerce Ltd (https://kiwicommerce.co.uk/)
* @license https://kiwicommerce.co.uk/magento2-extension-license/
*/
namespace KiwiCommerce\AdminActivity\Api\Activity;

/**
* Interface ModelInterface
* @package KiwiCommerce\AdminActivity\Api\Activity
*/
interface ModelInterface
{
/**
* Get old data
* @param $model
* @return mixed
*/
public function getOldData($model);

/**
* Get edit data
* @param $model
* @return mixed
*/
public function getEditData($model, $fieldArray);
}
89 changes: 89 additions & 0 deletions Api/ActivityRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php
/**
* KiwiCommerce
*
* Do not edit or add to this file if you wish to upgrade to newer versions in the future.
* If you wish to customize this module for your needs.
* Please contact us https://kiwicommerce.co.uk/contacts.
*
* @category KiwiCommerce
* @package KiwiCommerce_AdminActivity
* @copyright Copyright (C) 2018 Kiwi Commerce Ltd (https://kiwicommerce.co.uk/)
* @license https://kiwicommerce.co.uk/magento2-extension-license/
*/
namespace KiwiCommerce\AdminActivity\Api;

/**
* Interface ActivityRepositoryInterface
* @package KiwiCommerce\AdminActivity\Api
*/
interface ActivityRepositoryInterface
{
/**
* Array of protected fields
* @return mixed
*/
public function protectedFields();

/**
* Get collection of admin activity
* @return mixed
*/
public function getList();

/**
* Get all admin activity data before date
* @param $endDate
* @return mixed
*/
public function getListBeforeDate($endDate);

/**
* Remove activity log entry
* @param $activityId
* @return mixed
*/
public function deleteActivityById($activityId);

/**
* Get all admin activity detail by activity id
* @param $activityId
* @return mixed
*/
public function getActivityDetail($activityId);

/**
* Get all admin activity log by activity id
* @param $activityId
* @return mixed
*/
public function getActivityLog($activityId);

/**
* Revert last changes made in module
* @param $activity
* @return mixed
*/
public function revertActivity($activity);

/**
* Get old data for system config module
* @param $model
* @return mixed
*/
public function getOldData($model);

/**
* Get admin activity by id
* @param $activityId
* @return mixed
*/
public function getActivityById($activityId);

/**
* Check field is protected or not
* @param $fieldName
* @return mixed
*/
public function isFieldProtected($fieldName);
}
23 changes: 23 additions & 0 deletions Api/Data/ActivityInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* KiwiCommerce
*
* Do not edit or add to this file if you wish to upgrade to newer versions in the future.
* If you wish to customize this module for your needs.
* Please contact us https://kiwicommerce.co.uk/contacts.
*
* @category KiwiCommerce
* @package KiwiCommerce_AdminActivity
* @copyright Copyright (C) 2018 Kiwi Commerce Ltd (https://kiwicommerce.co.uk/)
* @license https://kiwicommerce.co.uk/magento2-extension-license/
*/
namespace KiwiCommerce\AdminActivity\Api\Data;

/**
* Interface ActivityInterface
* @package KiwiCommerce\AdminActivity\Api\Data
*/
interface ActivityInterface
{

}
36 changes: 36 additions & 0 deletions Api/Data/ActivitySearchResultsInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* KiwiCommerce
*
* Do not edit or add to this file if you wish to upgrade to newer versions in the future.
* If you wish to customize this module for your needs.
* Please contact us https://kiwicommerce.co.uk/contacts.
*
* @category KiwiCommerce
* @package KiwiCommerce_AdminActivity
* @copyright Copyright (C) 2018 Kiwi Commerce Ltd (https://kiwicommerce.co.uk/)
* @license https://kiwicommerce.co.uk/magento2-extension-license/
*/
namespace KiwiCommerce\AdminActivity\Api\Data;

/**
* Interface LogSearchResultsInterface
* @package KiwiCommerce\EnhancedSMTP\Api\Data
*/
interface ActivitySearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface
{
/**
* Get admin activity list.
* @api
* @return \KiwiCommerce\AdminActivity\Model\Activity[]
*/
public function getItems();

/**
* Set admin activity list.
* @api
* @param \KiwiCommerce\AdminActivity\Model\Activity[] $items
* @return $this
*/
public function setItems(array $items);
}
43 changes: 43 additions & 0 deletions Api/LoginRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* KiwiCommerce
*
* Do not edit or add to this file if you wish to upgrade to newer versions in the future.
* If you wish to customize this module for your needs.
* Please contact us https://kiwicommerce.co.uk/contacts.
*
* @category KiwiCommerce
* @package KiwiCommerce_AdminActivity
* @copyright Copyright (C) 2018 Kiwi Commerce Ltd (https://kiwicommerce.co.uk/)
* @license https://kiwicommerce.co.uk/magento2-extension-license/
*/
namespace KiwiCommerce\AdminActivity\Api;

/**
* Interface LoginRepositoryInterface
* @package KiwiCommerce\AdminActivity\Api
*/
interface LoginRepositoryInterface
{
/**
* Set login data
* @param $status
* @param $type
* @return mixed
*/
public function addLog($status, $type);

/**
* Get all admin activity data before date
* @param $endDate
* @return mixed
*/
public function getListBeforeDate($endDate);

/**
* Set login user
* @param $user
* @return mixed
*/
public function setUser($user);
}
91 changes: 91 additions & 0 deletions Block/Adminhtml/ActivityLogListing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
/**
* KiwiCommerce
*
* Do not edit or add to this file if you wish to upgrade to newer versions in the future.
* If you wish to customize this module for your needs.
* Please contact us https://kiwicommerce.co.uk/contacts.
*
* @category KiwiCommerce
* @package KiwiCommerce_AdminActivity
* @copyright Copyright (C) 2018 Kiwi Commerce Ltd (https://kiwicommerce.co.uk/)
* @license https://kiwicommerce.co.uk/magento2-extension-license/
*/
namespace KiwiCommerce\AdminActivity\Block\Adminhtml;

use Magento\Backend\Block\Template;
use KiwiCommerce\AdminActivity\Api\ActivityRepositoryInterface;
use KiwiCommerce\AdminActivity\Helper\Browser;

/**
* Class ActivityLogListing
* @package KiwiCommerce\AdminActivity\Block\Adminhtml
*/
class ActivityLogListing extends Template
{
/**
* @var ActivityRepositoryInterface
*/
public $activityRepository;

/**
* @var Browser
*/
public $browser;

/**
* Path to template file in theme.
* @var string
*/
public $_template = 'KiwiCommerce_AdminActivity::log_listing.phtml';

/**
* ActivityLogListing constructor.
* @param Template\Context $context
* @param ActivityRepositoryInterface $activityRepository
* @param Browser $browser
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
ActivityRepositoryInterface $activityRepository,
Browser $browser
) {
$this->activityRepository = $activityRepository;
$this->browser = $browser;
parent::__construct($context);
}

/**
* Get admin activity log listing
* @return array
*/
public function getLogListing()
{
$id = $this->getRequest()->getParam('id');
$data = $this->activityRepository->getActivityLog($id);
return $data->getData();
}

/**
* Get admin activity details
* @return array
*/
public function getAdminDetails()
{
$id = $this->getRequest()->getParam('id');
$activity = $this->activityRepository->getActivityById($id);

$this->browser->reset();
$this->browser->setUserAgent($activity->getUserAgent());
$browser = $this->browser->__toString();

$logData = [];
$logData['username'] = $activity->getUsername();
$logData['module'] = $activity->getModule();
$logData['name'] = $activity->getName();
$logData['fullaction'] = $activity->getFullaction();
$logData['browser'] = $browser;
$logData['date'] = $activity->getUpdatedAt();
return $logData;
}
}
30 changes: 30 additions & 0 deletions Block/Adminhtml/Selector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* KiwiCommerce
*
* Do not edit or add to this file if you wish to upgrade to newer versions in the future.
* If you wish to customize this module for your needs.
* Please contact us https://kiwicommerce.co.uk/contacts.
*
* @category KiwiCommerce
* @package KiwiCommerce_AdminActivity
* @copyright Copyright (C) 2018 Kiwi Commerce Ltd (https://kiwicommerce.co.uk/)
* @license https://kiwicommerce.co.uk/magento2-extension-license/
*/
namespace KiwiCommerce\AdminActivity\Block\Adminhtml;

/**
* Class Selector
* @package KiwiCommerce\AdminActivity\Block\Adminhtml
*/
class Selector extends \Magento\Backend\Block\Template
{
/**
* Revert Activity Log action URL
* @return string
*/
public function getRevertUrl()
{
return $this->getUrl('adminactivity/activity/revert');
}
}
Loading

0 comments on commit 7a9fdc7

Please sign in to comment.