Skip to content

Commit c5167c1

Browse files
committed
fix(target_actor): actors ID not converted when duplicating a form
1 parent 4da93e3 commit c5167c1

File tree

1 file changed

+43
-42
lines changed

1 file changed

+43
-42
lines changed

inc/target_actor.class.php

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -172,51 +172,52 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
172172
'uuid',
173173
$input['uuid']
174174
);
175-
// Convert UUIDs or names into IDs
176-
switch ($input['actor_type']) {
177-
case self::ACTOR_TYPE_QUESTION_PERSON :
178-
case self::ACTOR_TYPE_QUESTION_GROUP :
179-
case self::ACTOR_TYPE_QUESTION_SUPPLIER :
180-
case self::ACTOR_TYPE_QUESTION_ACTORS :
181-
case self::ACTOR_TYPE_GROUP_FROM_OBJECT :
182-
case self::ACTOR_TYPE_TECH_GROUP_FROM_OBJECT :
183-
/** @var PluginFormcreatorQuestion $question */
184-
$question = $linker->getObject($input['actor_value'], PluginFormcreatorQuestion::class);
185-
if ($question === false) {
186-
$linker->postpone($input[$idKey], $item->getType(), $input, $containerId);
187-
return false;
188-
}
189-
$input['actor_value'] = $question->getID();
190-
break;
175+
}
191176

192-
case self::ACTOR_TYPE_PERSON:
193-
case self::ACTOR_TYPE_AUTHORS_SUPERVISOR:
194-
$user = new User;
195-
$users_id = plugin_formcreator_getFromDBByField($user, 'name', $input['actor_value']);
196-
if ($users_id === false) {
197-
throw new ImportFailureException(sprintf(__('Failed to find a user: %1$s'), $input['actor_value']));
198-
}
199-
$input['actor_value'] = $users_id;
200-
break;
177+
// Convert UUIDs or names into IDs
178+
switch ($input['actor_type']) {
179+
case self::ACTOR_TYPE_QUESTION_PERSON :
180+
case self::ACTOR_TYPE_QUESTION_GROUP :
181+
case self::ACTOR_TYPE_QUESTION_SUPPLIER :
182+
case self::ACTOR_TYPE_QUESTION_ACTORS :
183+
case self::ACTOR_TYPE_GROUP_FROM_OBJECT :
184+
case self::ACTOR_TYPE_TECH_GROUP_FROM_OBJECT :
185+
/** @var PluginFormcreatorQuestion $question */
186+
$question = $linker->getObject($input['actor_value'], PluginFormcreatorQuestion::class);
187+
if ($question === false) {
188+
$linker->postpone($input[$idKey], $item->getType(), $input, $containerId);
189+
return false;
190+
}
191+
$input['actor_value'] = $question->getID();
192+
break;
201193

202-
case self::ACTOR_TYPE_GROUP:
203-
$group = new Group;
204-
$groups_id = plugin_formcreator_getFromDBByField($group, 'completename', $input['actor_value']);
205-
if ($groups_id === false) {
206-
throw new ImportFailureException(sprintf(__('Failed to find a group: %1$s'), $input['actor_value']));
207-
}
208-
$input['actor_value'] = $groups_id;
209-
break;
194+
case self::ACTOR_TYPE_PERSON:
195+
case self::ACTOR_TYPE_AUTHORS_SUPERVISOR:
196+
$user = new User;
197+
$users_id = plugin_formcreator_getFromDBByField($user, 'name', $input['actor_value']);
198+
if ($users_id === false) {
199+
throw new ImportFailureException(sprintf(__('Failed to find a user: %1$s'), $input['actor_value']));
200+
}
201+
$input['actor_value'] = $users_id;
202+
break;
210203

211-
case self::ACTOR_TYPE_SUPPLIER:
212-
$supplier = new Supplier;
213-
$suppliers_id = plugin_formcreator_getFromDBByField($supplier, 'name', $input['actor_value']);
214-
if ($suppliers_id === false) {
215-
throw new ImportFailureException(sprintf(__('Failed to find a supplier: %1$s'), $input['actor_value']));
216-
}
217-
$input['actor_value'] = $suppliers_id;
218-
break;
219-
}
204+
case self::ACTOR_TYPE_GROUP:
205+
$group = new Group;
206+
$groups_id = plugin_formcreator_getFromDBByField($group, 'completename', $input['actor_value']);
207+
if ($groups_id === false) {
208+
throw new ImportFailureException(sprintf(__('Failed to find a group: %1$s'), $input['actor_value']));
209+
}
210+
$input['actor_value'] = $groups_id;
211+
break;
212+
213+
case self::ACTOR_TYPE_SUPPLIER:
214+
$supplier = new Supplier;
215+
$suppliers_id = plugin_formcreator_getFromDBByField($supplier, 'name', $input['actor_value']);
216+
if ($suppliers_id === false) {
217+
throw new ImportFailureException(sprintf(__('Failed to find a supplier: %1$s'), $input['actor_value']));
218+
}
219+
$input['actor_value'] = $suppliers_id;
220+
break;
220221
}
221222

222223
$originalId = $input[$idKey];

0 commit comments

Comments
 (0)