From 164bef19249cce13197ea4fdec194f50084c5182 Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Wed, 17 Apr 2024 15:48:17 +0200 Subject: [PATCH] fix(target_actor): duplication fails for some types --- inc/target_actor.class.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/inc/target_actor.class.php b/inc/target_actor.class.php index ebf8b853e..bfe3e7400 100644 --- a/inc/target_actor.class.php +++ b/inc/target_actor.class.php @@ -191,8 +191,11 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con $input['actor_value'] = $question->getID(); break; - case self::ACTOR_TYPE_PERSON: case self::ACTOR_TYPE_AUTHORS_SUPERVISOR: + $input['actor_value'] = 0; + break; + + case self::ACTOR_TYPE_PERSON: $user = new User; $field = $idKey == 'id' ? 'id' : 'name'; $users_id = plugin_formcreator_getFromDBByField($user, $field, $input['actor_value']); @@ -278,12 +281,18 @@ public function export(bool $remove_uuid = false) : array { case self::ACTOR_TYPE_GROUP_FROM_OBJECT: case self::ACTOR_TYPE_TECH_GROUP_FROM_OBJECT : $question = new PluginFormcreatorQuestion; - if ($question->getFromDB($target_actor['actor_value'])) { - $target_actor['actor_value'] = $question->fields['uuid']; + $field = $idToRemove == 'uuid' ? 'id' : 'uuid'; + $question->getFromDBByCrit([ + $field => $target_actor['actor_value'] + ]); + if (!$question->isNewItem()) { + $target_actor['actor_value'] = $idToRemove == 'uuid' ? $question->getID() : $question->fields['uuid']; } break; - case self::ACTOR_TYPE_PERSON: case self::ACTOR_TYPE_AUTHORS_SUPERVISOR: + $target_actor['actor_value'] = 0; + break; + case self::ACTOR_TYPE_PERSON: $user = new User; $field = $idToRemove == 'uuid' ? 'id' : 'completename'; if ($user->getFromDB($target_actor['actor_value'])) {