diff --git a/README.md b/README.md index 66960e0..474832e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/elementtypes/AuditLogElementType.php b/elementtypes/AuditLogElementType.php index 2fdbc8a..8b99802 100644 --- a/elementtypes/AuditLogElementType.php +++ b/elementtypes/AuditLogElementType.php @@ -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, @@ -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));