33/**
44 * This file is part of MetaModels/attribute_checkbox.
55 *
6- * (c) 2012-2019 The MetaModels team.
6+ * (c) 2012-2020 The MetaModels team.
77 *
88 * For the full copyright and license information, please view the LICENSE
99 * file that was distributed with this source code.
1515 * @author Andreas Isaak <info@andreas-isaak.de>
1616 * @author Sven Baumann <baumann.sv@gmail.com>
1717 * @author David Molineus <david.molineus@netzmacht.de>
18- * @copyright 2012-2019 The MetaModels team.
18+ * @author Richard Henkenjohann <richardhenkenjohann@googlemail.com>
19+ * @copyright 2012-2020 The MetaModels team.
1920 * @license https://github.com/MetaModels/attribute_checkbox/blob/master/LICENSE LGPL-3.0-or-later
2021 * @filesource
2122 */
2223
2324namespace MetaModels \AttributeCheckboxBundle \FilterSetting ;
2425
26+ use Contao \CoreBundle \Security \Authentication \Token \TokenChecker ;
2527use Contao \System ;
2628use Doctrine \DBAL \Connection ;
2729use MetaModels \Filter \FilterUrlBuilder ;
@@ -44,6 +46,13 @@ class Published extends Simple
4446 */
4547 private $ connection ;
4648
49+ /**
50+ * The token checker.
51+ *
52+ * @var TokenChecker
53+ */
54+ private $ tokenChecker ;
55+
4756 /**
4857 * Constructor - initialize the object and store the parameters.
4958 *
@@ -52,13 +61,15 @@ class Published extends Simple
5261 * @param Connection $connection The database connection.
5362 * @param EventDispatcherInterface|null $dispatcher The event dispatcher.
5463 * @param FilterUrlBuilder|null $filterUrlBuilder The filter URL builder.
64+ * @param TokenChecker|null $tokenChecker The token checker.
5565 */
5666 public function __construct (
5767 ICollection $ collection ,
5868 array $ data ,
5969 Connection $ connection = null ,
6070 EventDispatcherInterface $ dispatcher = null ,
61- FilterUrlBuilder $ filterUrlBuilder = null
71+ FilterUrlBuilder $ filterUrlBuilder = null ,
72+ TokenChecker $ tokenChecker = null
6273 ) {
6374 parent ::__construct ($ collection , $ data , $ dispatcher , $ filterUrlBuilder );
6475
@@ -73,7 +84,8 @@ public function __construct(
7384 $ connection = System::getContainer ()->get ('database_connection ' );
7485 }
7586
76- $ this ->connection = $ connection ;
87+ $ this ->connection = $ connection ;
88+ $ this ->tokenChecker = $ tokenChecker ;
7789 }
7890
7991 /**
@@ -86,7 +98,7 @@ public function prepareRules(IFilter $objFilter, $arrFilterUrl)
8698 }
8799
88100 // Skip filter when in front end preview.
89- if ($ this ->get ('check_allowpreview ' ) && BE_USER_LOGGED_IN ) {
101+ if ($ this ->get ('check_allowpreview ' ) && ( $ this -> tokenChecker && $ this -> tokenChecker -> isPreviewMode ()) ) {
90102 return ;
91103 }
92104
0 commit comments