-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c932a8d
Showing
30 changed files
with
1,362 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* Magenizr AdminUser | ||
* | ||
* @category Magenizr | ||
* @package Magenizr_AdminUser | ||
* @copyright Copyright (c) 2021 Magenizr (https://agency.magenizr.com) | ||
* @license https://www.magenizr.com/license Magenizr EULA | ||
*/ | ||
|
||
namespace Magenizr\AdminUser\Controller\Adminhtml; | ||
|
||
/** | ||
* Class Activity | ||
* | ||
* @package Magenizr\AdminUser\Controller\Adminhtml | ||
*/ | ||
abstract class Activity extends \Magento\Backend\App\Action | ||
{ | ||
const ADMIN_RESOURCE = 'Magenizr_AdminUser::activity'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/** | ||
* Magenizr AdminUser | ||
* | ||
* @category Magenizr | ||
* @package Magenizr_AdminUser | ||
* @copyright Copyright (c) 2021 Magenizr (https://agency.magenizr.com) | ||
* @license https://www.magenizr.com/license Magenizr EULA | ||
*/ | ||
|
||
namespace Magenizr\AdminUser\Controller\Adminhtml\Activity; | ||
|
||
/** | ||
* Class Index | ||
* | ||
* @package Magenizr\AdminUser\Controller\Adminhtml\Activity | ||
*/ | ||
class Index extends \Magenizr\AdminUser\Controller\Adminhtml\Activity | ||
{ | ||
/** | ||
* @var bool|\Magento\Framework\View\Result\PageFactory | ||
*/ | ||
private $resultPageFactory = false; | ||
|
||
/** | ||
* Index constructor. | ||
* | ||
* @param \Magento\Backend\App\Action\Context $context | ||
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\App\Action\Context $context, | ||
\Magento\Framework\View\Result\PageFactory $resultPageFactory | ||
) { | ||
|
||
parent::__construct($context); | ||
$this->resultPageFactory = $resultPageFactory; | ||
} | ||
|
||
public function execute() | ||
{ | ||
$resultPage = $this->resultPageFactory->create(); | ||
$resultPage->getConfig()->getTitle()->prepend((__('User Activity'))); | ||
|
||
return $resultPage; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/** | ||
* Magenizr AdminUser | ||
* | ||
* @category Magenizr | ||
* @package Magenizr_AdminUser | ||
* @copyright Copyright (c) 2021 Magenizr (https://agency.magenizr.com) | ||
* @license https://www.magenizr.com/license Magenizr EULA | ||
*/ | ||
|
||
namespace Magenizr\AdminUser\Controller\Adminhtml\Activity; | ||
|
||
use Magento\Framework\Controller\ResultFactory; | ||
|
||
/** | ||
* Class MassDisable | ||
* | ||
* @package Magenizr\AdminUser\Controller\Adminhtml\Activity | ||
*/ | ||
class MassDisable extends \Magenizr\AdminUser\Controller\Adminhtml\Activity | ||
{ | ||
/** | ||
* @var \Magenizr\AdminUser\Model\ResourceModel\Activity | ||
*/ | ||
private $activityModel; | ||
|
||
/** | ||
* MassDisable constructor. | ||
* | ||
* @param \Magento\Backend\App\Action\Context $context | ||
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory | ||
* @param \Magenizr\AdminUser\Model\ResourceModel\Activity $activityModel | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\App\Action\Context $context, | ||
\Magento\Framework\View\Result\PageFactory $resultPageFactory, | ||
\Magenizr\AdminUser\Model\ResourceModel\Activity $activityModel | ||
) { | ||
$this->resultPageFactory = $resultPageFactory; | ||
$this->activityModel = $activityModel; | ||
|
||
parent::__construct($context); | ||
} | ||
|
||
public function execute() | ||
{ | ||
try { | ||
$userIds = $this->getRequest()->getPost('selected'); | ||
|
||
if (is_array($userIds)) { | ||
$this->activityModel->updateUserStatus($userIds, 0); | ||
|
||
$this->messageManager->addSuccess( | ||
__( | ||
'Disabled <strong>%1</strong> user(s).', | ||
count($userIds) | ||
) | ||
); | ||
} | ||
} catch (\Exception $e) { | ||
$this->messageManager->addError($e->getMessage()); | ||
} | ||
|
||
$this->_redirect('*/*/index'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/** | ||
* Magenizr AdminUser | ||
* | ||
* @category Magenizr | ||
* @package Magenizr_AdminUser | ||
* @copyright Copyright (c) 2021 Magenizr (https://agency.magenizr.com) | ||
* @license https://www.magenizr.com/license Magenizr EULA | ||
*/ | ||
|
||
namespace Magenizr\AdminUser\Controller\Adminhtml\Activity; | ||
|
||
use Magento\Framework\Controller\ResultFactory; | ||
|
||
/** | ||
* Class MassEnable | ||
* | ||
* @package Magenizr\AdminUser\Controller\Adminhtml\Activity | ||
*/ | ||
class MassEnable extends \Magenizr\AdminUser\Controller\Adminhtml\Activity | ||
{ | ||
/** | ||
* @var \Magenizr\AdminUser\Model\ResourceModel\Activity | ||
*/ | ||
private $activityModel; | ||
|
||
/** | ||
* MassEnable constructor. | ||
* | ||
* @param \Magento\Backend\App\Action\Context $context | ||
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory | ||
* @param \Magenizr\AdminUser\Model\ResourceModel\Activity $activityModel | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\App\Action\Context $context, | ||
\Magento\Framework\View\Result\PageFactory $resultPageFactory, | ||
\Magenizr\AdminUser\Model\ResourceModel\Activity $activityModel | ||
) { | ||
$this->resultPageFactory = $resultPageFactory; | ||
$this->activityModel = $activityModel; | ||
|
||
parent::__construct($context); | ||
} | ||
|
||
public function execute() | ||
{ | ||
try { | ||
$userIds = $this->getRequest()->getPost('selected'); | ||
|
||
if (is_array($userIds)) { | ||
$this->activityModel->updateUserStatus($userIds, 1); | ||
|
||
$this->messageManager->addSuccess( | ||
__( | ||
'Enabled <strong>%1</strong> user(s).', | ||
count($userIds) | ||
) | ||
); | ||
} | ||
} catch (\Exception $e) { | ||
$this->messageManager->addError($e->getMessage()); | ||
} | ||
|
||
$this->_redirect('*/*/index'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* Magenizr AdminUser | ||
* | ||
* @category Magenizr | ||
* @package Magenizr_AdminUser | ||
* @copyright Copyright (c) 2021 Magenizr (https://agency.magenizr.com) | ||
* @license https://www.magenizr.com/license Magenizr EULA | ||
*/ | ||
|
||
namespace Magenizr\AdminUser\Helper; | ||
|
||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
|
||
/** | ||
* Class Data | ||
* | ||
* @package Magenizr\AdminUser\Helper | ||
*/ | ||
class Data extends \Magento\Framework\App\Helper\AbstractHelper | ||
{ | ||
const TABLE_USER = 'admin_user'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $tab = 'admin/magenizr_adminuser'; | ||
|
||
/** | ||
* Get current date based on date settings. | ||
* | ||
* @return false|int | ||
*/ | ||
public function getNow() | ||
{ | ||
return $this->dateFactory->create()->gmtDate(); | ||
} | ||
|
||
/** | ||
* Get difference between two dates. Return the number of days. | ||
* | ||
* @param string $dateFrom | ||
* @param $dateTo | ||
* @return float | ||
*/ | ||
public function getDateDiff($dateTo, $dateFrom = 'now') | ||
{ | ||
if ($dateFrom == 'now') { | ||
$dateFrom = $this->getNow(); | ||
} | ||
|
||
return round(abs(strtotime($dateFrom) - strtotime($dateTo))/86400); | ||
} | ||
|
||
/** | ||
* Get module configuration values from core_config_data | ||
* | ||
* @param $setting | ||
* @return mixed | ||
*/ | ||
public function getConfig($setting) | ||
{ | ||
return $this->scopeConfig->getValue( | ||
$this->tab . '/' . $setting, | ||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
/** | ||
* Magenizr AdminUser | ||
* | ||
* @category Magenizr | ||
* @package Magenizr_AdminUser | ||
* @copyright Copyright (c) 2021 Magenizr (https://agency.magenizr.com) | ||
* @license https://www.magenizr.com/license Magenizr EULA | ||
*/ | ||
|
||
namespace Magenizr\AdminUser\Model; | ||
|
||
/** | ||
* Class Activity | ||
* | ||
* @package Magenizr\AdminUser\Model | ||
*/ | ||
class Activity extends \Magento\Framework\Model\AbstractModel | ||
{ | ||
// @codingStandardsIgnoreStart | ||
protected function _construct() | ||
{ | ||
$this->_init(\Magenizr\AdminUser\Model\ResourceModel\Activity::class); | ||
} | ||
// @codingStandardsIgnoreEnd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/** | ||
* Magenizr AdminUser | ||
* | ||
* @category Magenizr | ||
* @package Magenizr_AdminUser | ||
* @copyright Copyright (c) 2021 Magenizr (https://agency.magenizr.com) | ||
* @license https://www.magenizr.com/license Magenizr EULA | ||
*/ | ||
|
||
namespace Magenizr\AdminUser\Model\ResourceModel; | ||
|
||
use Magenizr\AdminUser\Helper\Data as Helper; | ||
|
||
/** | ||
* Class Style | ||
* | ||
* @package Magenizr\Notification\Model\ResourceModel | ||
*/ | ||
class Activity extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb | ||
{ | ||
// @codingStandardsIgnoreStart | ||
protected function _construct() { | ||
$this->_init(Helper::TABLE_USER, 'user_id'); | ||
} | ||
// @codingStandardsIgnoreEnd | ||
|
||
/** | ||
* Update the user status | ||
* | ||
* @param $userIds | ||
* @param $status | ||
* @return mixed | ||
*/ | ||
public function updateUserStatus($userIds, $status) | ||
{ | ||
if (!is_array($userIds)) { | ||
$userIds = [$userIds]; | ||
} | ||
|
||
return $this->getConnection()->update( | ||
$this->getMainTable(), | ||
['is_active' => $status], | ||
$this->getIdFieldName() . ' IN (' . $this->getConnection()->quote($userIds) . ')' | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
/** | ||
* Magenizr AdminUser | ||
* | ||
* @category Magenizr | ||
* @package Magenizr_AdminUser | ||
* @copyright Copyright (c) 2021 Magenizr (https://agency.magenizr.com) | ||
* @license https://www.magenizr.com/license Magenizr EULA | ||
*/ | ||
|
||
namespace Magenizr\AdminUser\Model\ResourceModel\Activity; | ||
|
||
/** | ||
* Class Collection | ||
* | ||
* @package Magenizr\Notification\Model\ResourceModel\Activity | ||
*/ | ||
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection | ||
{ | ||
// @codingStandardsIgnoreStart | ||
protected function _construct() | ||
{ | ||
$this->_init(\Magenizr\AdminUser\Model\Activity::class, \Magenizr\AdminUser\Model\ResourceModel\Activity::class); | ||
} | ||
// @codingStandardsIgnoreEnd | ||
} |
Oops, something went wrong.