From b7d3c6ff4debd07bccb7ed290189c62a44852d3c Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Wed, 20 Jul 2022 17:42:04 +0200 Subject: [PATCH 1/5] IBX-3265: Disabled User account form during translation --- .../Mapper/UserAccountFieldValueFormMapper.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php b/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php index 628e1da8..010c1cce 100644 --- a/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php +++ b/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php @@ -10,6 +10,7 @@ use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition; use eZ\Publish\Core\FieldType\User\Value as ApiUserValue; +use EzSystems\EzPlatformContentForms\Data\Content\ContentUpdateData; use EzSystems\EzPlatformContentForms\Data\Content\FieldData; use EzSystems\EzPlatformContentForms\Data\ContentTranslationData; use EzSystems\EzPlatformContentForms\Data\User\UserAccountFieldData; @@ -46,7 +47,12 @@ public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data) $formConfig = $fieldForm->getConfig(); $rootForm = $fieldForm->getRoot()->getRoot(); $formIntent = $rootForm->getConfig()->getOption('intent'); - $isTranslation = $rootForm->getData() instanceof ContentTranslationData; + $formData = $rootForm->getData(); + $isTranslation = $formData instanceof ContentUpdateData; + if ($isTranslation) { + return; + } + $formBuilder = $formConfig->getFormFactory()->createBuilder() ->create('value', UserAccountFieldType::class, [ 'required' => true, @@ -57,11 +63,7 @@ public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data) ], ]); - if ($isTranslation) { - $formBuilder->addModelTransformer($this->getModelTransformerForTranslation($fieldDefinition)); - } else { - $formBuilder->addModelTransformer($this->getModelTransformer()); - } + $formBuilder->addModelTransformer($this->getModelTransformer()); $formBuilder->setAutoInitialize(false); From 309228ad40fa2639f90725b7b17f95bb74356500 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Wed, 20 Jul 2022 17:45:17 +0200 Subject: [PATCH 2/5] IBX-3265: CS --- src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php b/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php index 010c1cce..64cf593c 100644 --- a/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php +++ b/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php @@ -12,7 +12,6 @@ use eZ\Publish\Core\FieldType\User\Value as ApiUserValue; use EzSystems\EzPlatformContentForms\Data\Content\ContentUpdateData; use EzSystems\EzPlatformContentForms\Data\Content\FieldData; -use EzSystems\EzPlatformContentForms\Data\ContentTranslationData; use EzSystems\EzPlatformContentForms\Data\User\UserAccountFieldData; use EzSystems\EzPlatformContentForms\FieldType\FieldValueFormMapperInterface; use EzSystems\EzPlatformContentForms\Form\Type\FieldType\UserAccountFieldType; From fcf7635220c12f2cf7ce8965e5ec82fcc952d84d Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Wed, 20 Jul 2022 17:46:22 +0200 Subject: [PATCH 3/5] IBX-3265: CS --- src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php b/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php index 64cf593c..d39c5767 100644 --- a/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php +++ b/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php @@ -58,7 +58,7 @@ public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data) 'label' => $fieldDefinition->getName(), 'intent' => $formIntent, 'constraints' => [ - new UserAccountPassword(['contentType' => $rootForm->getData()->contentType]), + new UserAccountPassword(['contentType' => $formData->contentType]), ], ]); From dc9ed1c6829f4cd29cd45bf2421d816eafcdffdc Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Thu, 21 Jul 2022 11:43:07 +0200 Subject: [PATCH 4/5] IBX-3265: CS --- src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php b/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php index d39c5767..1ad1b496 100644 --- a/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php +++ b/src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php @@ -47,8 +47,7 @@ public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data) $rootForm = $fieldForm->getRoot()->getRoot(); $formIntent = $rootForm->getConfig()->getOption('intent'); $formData = $rootForm->getData(); - $isTranslation = $formData instanceof ContentUpdateData; - if ($isTranslation) { + if ($formData instanceof ContentUpdateData) { return; } From 06ac50cd8a7d1af19b046277b37a075e8a4468c5 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Fri, 22 Jul 2022 10:38:08 +0200 Subject: [PATCH 5/5] IBX-3265: Load User Content with proper language --- src/bundle/Controller/UserController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bundle/Controller/UserController.php b/src/bundle/Controller/UserController.php index d3f806d2..278a8b5f 100644 --- a/src/bundle/Controller/UserController.php +++ b/src/bundle/Controller/UserController.php @@ -170,7 +170,7 @@ public function editAction( string $language, Request $request ) { - $user = $this->userService->loadUser($contentId); + $user = $this->userService->loadUser($contentId, [$language]); if (!$this->permissionResolver->canUser('content', 'edit', $user)) { throw new CoreUnauthorizedException('content', 'edit', ['userId' => $contentId]); }