Skip to content

Commit e5b9ed1

Browse files
authored
Merge pull request #1531 from MetaModels/hotfix/fix_rights_for_non_admins_2
Fix rights check for non-admin user
2 parents e5698b1 + c8c0845 commit e5b9ed1

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/CoreBundle/Contao/Hooks/ContentElementCallback.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
namespace MetaModels\CoreBundle\Contao\Hooks;
2424

25+
use Contao\CoreBundle\Exception\AccessDeniedException;
2526
use Contao\DC_Table;
2627

2728
/**
@@ -45,10 +46,15 @@ class ContentElementCallback extends AbstractContentElementAndModuleCallback
4546
*/
4647
public function buildFilterParameterList(DC_Table $dataContainer)
4748
{
48-
if (
49-
null === ($currentRecord = $dataContainer->getCurrentRecord())
50-
|| $currentRecord['type'] !== 'metamodel_content'
51-
) {
49+
try {
50+
if (
51+
null === ($currentRecord = $dataContainer->getCurrentRecord())
52+
|| $currentRecord['type'] !== 'metamodel_content'
53+
) {
54+
return;
55+
}
56+
} catch (AccessDeniedException $exception) {
57+
// If the access is denied, we don't want to build filter parameters.
5258
return;
5359
}
5460

src/CoreBundle/Contao/Hooks/FilterContentElementCallback.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
namespace MetaModels\CoreBundle\Contao\Hooks;
2121

22+
use Contao\CoreBundle\Exception\AccessDeniedException;
2223
use Contao\DC_Table;
2324

2425
/**
@@ -36,13 +37,17 @@ final class FilterContentElementCallback extends AbstractContentElementAndModule
3637
/** Called from tl_content.onload_callback. */
3738
public function buildFilterParameterList(DC_Table $dataContainer): void
3839
{
39-
if (
40-
null === ($currentRecord = $dataContainer->getCurrentRecord())
41-
|| $currentRecord['type'] !== 'metamodels_frontendfilter'
42-
) {
40+
try {
41+
if (
42+
null === ($currentRecord = $dataContainer->getCurrentRecord())
43+
|| $currentRecord['type'] !== 'metamodels_frontendfilter'
44+
) {
45+
return;
46+
}
47+
} catch (AccessDeniedException $exception) {
48+
// If the access is denied, we don't want to build filter parameters.
4349
return;
4450
}
45-
4651
$this->buildFilterParamsFor($dataContainer, 'metamodels_frontendfilter');
4752
}
4853
}

0 commit comments

Comments
 (0)