Skip to content

Commit

Permalink
FR #2
Browse files Browse the repository at this point in the history
  • Loading branch information
matfish3 committed Oct 10, 2022
1 parent 786c962 commit 44199b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Activity Log

## 1.1.2 - 2022-10-10
### Added
- Added `requestFilter` setting [#2]((https://github.com/matfish2/craft-activity-log/issues/2))

## 1.1.1 - 2022-10-10
### Fixed
- Fix createdAt null [#1](https://github.com/matfish2/craft-activity-log/issues/1)
Expand Down
5 changes: 5 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ private function shouldRecord(): bool
$isCp = $request->isCpRequest;
$isAjax = $this->isAjax($request);
$settings = self::getInstance()->getSettings();

$true = $settings->recordOnlyActions ? $request->isActionRequest : true;

if ($settings->requestFilter) {
$true = $true && $settings->requestFilter->call($request);
}

if ($isCp) {
if ($isAjax && ($settings->recordCpAjaxRequests || $this->isLoginRequest($request))) {
return $true;
Expand Down
4 changes: 3 additions & 1 deletion src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ class Settings extends Model
public bool $recordCpAjaxRequests = false;

public bool $recordOnlyActions = false;
public ?\Closure $requestFilter = null;

public function rules() : array
{
return [
[['recordSitePageRequests','recordSiteAjaxRequests','recordCpPageRequests','recordCpAjaxRequests','recordOnlyActions'], 'boolean']
[['recordSitePageRequests','recordSiteAjaxRequests','recordCpPageRequests','recordCpAjaxRequests','recordOnlyActions'], 'boolean'],
[['callback'],'function']
];
}
}

0 comments on commit 44199b6

Please sign in to comment.