Skip to content

Commit

Permalink
Merge pull request #215 from tony13tv/patch-1
Browse files Browse the repository at this point in the history
UPDATE: Fluent.FilterAdmin is now taken from config
  • Loading branch information
Damian Mooyman authored Jun 30, 2016
2 parents bcf69cf + 67d03e2 commit a36ac85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions _config/fluent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Fluent:
# www.example.co.nz:
# locales:
# - en_NZ
# Turn this on to enable admin filtering
filter_admin: false
---
Name: fluenti18nconfig
---
Expand Down
5 changes: 3 additions & 2 deletions code/extensions/FluentFilteredExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ public function updateCMSFields(FieldList $fields)
}

/**
* Amend freshly created DataQuery objects with the current locale and frontend status
* Amend freshly created DataQuery objects with the "should filter admin?" option, current locale and frontend status
*
* @param SQLQuery
* @param DataQuery
*/
public function augmentDataQueryCreation(SQLQuery $query, DataQuery $dataQuery)
{
$dataQuery->setQueryParam('Fluent.FilterAdmin', Fluent::config()->filter_admin);
$dataQuery->setQueryParam('Fluent.Locale', Fluent::current_locale());
$dataQuery->setQueryParam('Fluent.IsFrontend', Fluent::is_frontend());
}
Expand All @@ -127,7 +128,7 @@ public function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null)
}

// Skip filter in the CMS, unless filtering is explicitly turned on
$filterAdmin = $dataQuery->getQueryParam(self::FILTER_ADMIN);
$filterAdmin = $dataQuery->getQueryParam('Fluent.FilterAdmin');
if (!$filterAdmin) {
$isFrontend = $dataQuery->getQueryParam('Fluent.IsFrontend');
if ($isFrontend === null) {
Expand Down

0 comments on commit a36ac85

Please sign in to comment.