Skip to content
This repository has been archived by the owner on Apr 5, 2018. It is now read-only.

Commit

Permalink
Fixed criteria attributes not fully working
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Olde Hampsink committed Nov 10, 2015
1 parent 03dd9d2 commit 7001de3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Changelog
=================
###0.6.2###
- Fixed a bug where the date range didn't fully work
- Fixed criteria attributes not fully working

###0.6.1###
- Added a registerAuditLogSources hook to provide custom sources/criteria
Expand Down
32 changes: 32 additions & 0 deletions elementtypes/AuditLogElementType.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ public function defineCriteriaAttributes()
'userId' => AttributeType::Number,
'origin' => AttributeType::String,
'modified' => AttributeType::DateTime,
'before' => AttributeType::String,
'after' => AttributeType::String,
'status' => AttributeType::String,
'from' => AttributeType::DateTime,
'to' => AttributeType::DateTime,
Expand Down Expand Up @@ -173,6 +175,36 @@ public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $crit
$query->andWhere(DbHelper::parseParam('auditlog.id', $criteria->id, $query->params));
}

// Check type
if (!empty($criteria->type)) {
$query->andWhere(DbHelper::parseParam('auditlog.type', $criteria->type, $query->params));
}

// Check user id
if (!empty($criteria->userId)) {
$query->andWhere(DbHelper::parseParam('auditlog.userId', $criteria->userId, $query->params));
}

// Check origin
if (!empty($criteria->origin)) {
$query->andWhere(DbHelper::parseParam('auditlog.origin', $criteria->origin, $query->params));
}

// Check for date modified
if (!empty($criteria->modified)) {
$query->andWhere(DbHelper::parseDateParam('auditlog.dateUpdated', $criteria->modified, $query->params));
}

// Check before
if (!empty($criteria->before)) {
$query->andWhere(DbHelper::parseParam('auditlog.before', $criteria->before, $query->params));
}

// Check after
if (!empty($criteria->after)) {
$query->andWhere(DbHelper::parseParam('auditlog.after', $criteria->after, $query->params));
}

// Check for date from
if (!empty($criteria->from)) {
$query->andWhere(DbHelper::parseDateParam('auditlog.dateUpdated', '>= '.DateTimeHelper::formatTimeForDb($criteria->from), $query->params));
Expand Down

0 comments on commit 7001de3

Please sign in to comment.