Skip to content

Commit f968c06

Browse files
committed
fix(target_actor): duplication fails for some types
1 parent 2d5ad80 commit f968c06

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

inc/target_actor.class.php

+16-4
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,11 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
191191
$input['actor_value'] = $question->getID();
192192
break;
193193

194-
case self::ACTOR_TYPE_PERSON:
195194
case self::ACTOR_TYPE_AUTHORS_SUPERVISOR:
195+
$input['actor_value'] = 0;
196+
break;
197+
198+
case self::ACTOR_TYPE_PERSON:
196199
$user = new User;
197200
$field = $idKey == 'id' ? 'id' : 'name';
198201
$users_id = plugin_formcreator_getFromDBByField($user, $field, $input['actor_value']);
@@ -278,12 +281,21 @@ public function export(bool $remove_uuid = false) : array {
278281
case self::ACTOR_TYPE_GROUP_FROM_OBJECT:
279282
case self::ACTOR_TYPE_TECH_GROUP_FROM_OBJECT :
280283
$question = new PluginFormcreatorQuestion;
281-
if ($question->getFromDB($target_actor['actor_value'])) {
282-
$target_actor['actor_value'] = $question->fields['uuid'];
284+
$field = $idToRemove == 'uuid' ? 'id' : 'uuid';
285+
$question->getFromDBByCrit([
286+
$field => $target_actor['actor_value']
287+
]);
288+
if (!$question->isNewItem()) {
289+
$target_actor['actor_value'] = $idToRemove == 'uuid' ? $question->getID() : $question->fields['uuid'];
283290
}
291+
// if ($question->getFromDB($target_actor['actor_value'])) {
292+
// $target_actor['actor_value'] = $question->fields['uuid'];
293+
// }
284294
break;
285-
case self::ACTOR_TYPE_PERSON:
286295
case self::ACTOR_TYPE_AUTHORS_SUPERVISOR:
296+
$target_actor['actor_value'] = 0;
297+
break;
298+
case self::ACTOR_TYPE_PERSON:
287299
$user = new User;
288300
$field = $idToRemove == 'uuid' ? 'id' : 'completename';
289301
if ($user->getFromDB($target_actor['actor_value'])) {

0 commit comments

Comments
 (0)