From 5d63ae5dec872b693d08d512d318375c6fbb5936 Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Mon, 2 Oct 2023 16:56:16 +0200 Subject: [PATCH 1/4] Permission compatibility with Contao 5 --- src/Group/Group.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Group/Group.php b/src/Group/Group.php index 4d31338..8b57070 100644 --- a/src/Group/Group.php +++ b/src/Group/Group.php @@ -90,6 +90,9 @@ public function __construct(Environment $twig, string $table, int $rowId, string throw new \InvalidArgumentException("Invalid definition for group '$name': Field '$field' does not exist."); } + // Make sure those fields can never be managed via user permissions (Contao 5 compatibility) + $fieldDefinition['exclude'] = false; + $this->fields[$field] = $fieldDefinition; } From 15a42e0a661a2c2551d9a73f90b882bba2d29eaf Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Mon, 2 Oct 2023 17:02:55 +0200 Subject: [PATCH 2/4] Also apply to wrapper elements --- src/Group/Group.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Group/Group.php b/src/Group/Group.php index 8b57070..8d48272 100644 --- a/src/Group/Group.php +++ b/src/Group/Group.php @@ -441,6 +441,7 @@ private function addGroupField(bool $start): string 'htmlAttributes' => $this->htmlAttributes, ] ), + 'exclude' => false, // Do not apply user permissions ] ); @@ -463,6 +464,7 @@ private function addGroupElementField(bool $start, int $id): string 'id' => $id, ] ), + 'exclude' => false, // Do not apply user permissions ] ); From 602a3ac9666ec214d1632838c4f21b58603f0ce4 Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Wed, 4 Oct 2023 09:47:06 +0200 Subject: [PATCH 3/4] Move the logic to the correct place --- src/Group/Group.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Group/Group.php b/src/Group/Group.php index 8d48272..5c43ac0 100644 --- a/src/Group/Group.php +++ b/src/Group/Group.php @@ -89,9 +89,6 @@ public function __construct(Environment $twig, string $table, int $rowId, string if (null === ($fieldDefinition = $fields[$field] ?? $getReferencedDefinition($field))) { throw new \InvalidArgumentException("Invalid definition for group '$name': Field '$field' does not exist."); } - - // Make sure those fields can never be managed via user permissions (Contao 5 compatibility) - $fieldDefinition['exclude'] = false; $this->fields[$field] = $fieldDefinition; } @@ -481,6 +478,7 @@ private function addVirtualField(string $name, array $definition, int $id): stri 'eval' => [ 'doNotSaveEmpty' => true, ], + 'exclude' => false, // Do not apply user permissions 'sql' => null, ] ); From 6bf0325a013746595f0c41d1e497ab7c3ffc2b85 Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Wed, 4 Oct 2023 09:47:36 +0200 Subject: [PATCH 4/4] CS --- src/Group/Group.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Group/Group.php b/src/Group/Group.php index 5c43ac0..978202b 100644 --- a/src/Group/Group.php +++ b/src/Group/Group.php @@ -89,7 +89,7 @@ public function __construct(Environment $twig, string $table, int $rowId, string if (null === ($fieldDefinition = $fields[$field] ?? $getReferencedDefinition($field))) { throw new \InvalidArgumentException("Invalid definition for group '$name': Field '$field' does not exist."); } - + $this->fields[$field] = $fieldDefinition; }