Skip to content

Commit 894f1b1

Browse files
committed
[FEATURE] #13 Exclude configured admin users from logging
1 parent 1b6db55 commit 894f1b1

3 files changed

Lines changed: 61 additions & 2 deletions

File tree

src/app/code/community/FireGento/AdminMonitoring/Helper/Data.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,30 @@ class FireGento_AdminMonitoring_Helper_Data extends Mage_Core_Helper_Abstract
4242
const ACTION_INSERT = 1;
4343
const ACTION_UPDATE = 2;
4444
const ACTION_DELETE = 3;
45-
const ACTION_LOGIN = 4;
45+
const ACTION_LOGIN = 4;
4646

4747
/**
4848
* STATUS
4949
*/
5050
const STATUS_SUCCESS = 1;
5151
const STATUS_FAILURE = 2;
5252

53+
/**
54+
* Checks if the given admin user id is excluded
55+
*
56+
* @param int $userId User ID
57+
* @return bool
58+
*/
59+
public function isAdminUserIdExcluded($userId)
60+
{
61+
$excludedUserIds = explode(',', Mage::getStoreConfig('admin/firegento_adminmonitoring/exclude_admin_users'));
62+
if (in_array($userId, $excludedUserIds)) {
63+
return true;
64+
}
65+
66+
return false;
67+
}
68+
5369
/**
5470
* Retrieve the attribute type by provided class name
5571
*
@@ -113,7 +129,7 @@ public function getRowUrl(FireGento_AdminMonitoring_Model_History $row)
113129
* @param string $separator Separator
114130
* @return string
115131
*/
116-
public function getFullActionName($separator='_')
132+
public function getFullActionName($separator = '_')
117133
{
118134
$request = array(
119135
Mage::app()->getRequest()->getModuleName(),

src/app/code/community/FireGento/AdminMonitoring/Model/History.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
*/
3737
class FireGento_AdminMonitoring_Model_History extends Mage_Core_Model_Abstract
3838
{
39+
/**
40+
* @var bool
41+
*/
42+
protected $_forcedLogging = false;
43+
3944
/**
4045
* Inits the resource model and resource collection model
4146
*/
@@ -44,6 +49,35 @@ protected function _construct()
4449
$this->_init('firegento_adminmonitoring/history');
4550
}
4651

52+
/**
53+
* Processing object before save data
54+
*
55+
* @return FireGento_AdminMonitoring_Model_History
56+
*/
57+
protected function _beforeSave()
58+
{
59+
if (Mage::helper('firegento_adminmonitoring')->isAdminUserIdExcluded($this->getData('user_id'))
60+
&& !$this->_forcedLogging
61+
) {
62+
$this->_dataSaveAllowed = false;
63+
}
64+
65+
return parent::_beforeSave();
66+
}
67+
68+
/**
69+
* Set the forced logging value
70+
*
71+
* @param bool $flag Flag
72+
* @return FireGento_AdminMonitoring_Model_History
73+
*/
74+
public function setForcedLogging($flag)
75+
{
76+
$this->_forcedLogging = $flag;
77+
78+
return $this;
79+
}
80+
4781
/**
4882
* Retrieve the original model
4983
*

src/app/code/community/FireGento/AdminMonitoring/etc/system.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@
6969
<show_in_website>0</show_in_website>
7070
<show_in_store>0</show_in_store>
7171
</product_mass_update_logging>
72+
<exclude_admin_users translate="label">
73+
<label>Exclude admin users</label>
74+
<frontend_type>multiselect</frontend_type>
75+
<source_model>firegento_adminmonitoring/system_config_source_admin_user</source_model>
76+
<sort_order>50</sort_order>
77+
<show_in_default>1</show_in_default>
78+
<show_in_website>0</show_in_website>
79+
<show_in_store>0</show_in_store>
80+
</exclude_admin_users>
7281
</fields>
7382
</firegento_adminmonitoring>
7483
</groups>

0 commit comments

Comments
 (0)