Skip to content

Commit

Permalink
fix(target_actor): duplicate failure with gours, supliers or users
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Jan 5, 2024
1 parent 75144be commit d77cde0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions inc/target_actor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
case self::ACTOR_TYPE_PERSON:
case self::ACTOR_TYPE_AUTHORS_SUPERVISOR:
$user = new User;
$users_id = plugin_formcreator_getFromDBByField($user, 'name', $input['actor_value']);
$field = $idKey == 'id' ? 'id' : 'name';
$users_id = plugin_formcreator_getFromDBByField($user, $field, $input['actor_value']);
if ($users_id === false) {
throw new ImportFailureException(sprintf(__('Failed to find a user: %1$s'), $input['actor_value']));
}
Expand All @@ -203,7 +204,8 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con

case self::ACTOR_TYPE_GROUP:
$group = new Group;
$groups_id = plugin_formcreator_getFromDBByField($group, 'completename', $input['actor_value']);
$field = $idKey == 'id' ? 'id' : 'completename';
$groups_id = plugin_formcreator_getFromDBByField($group, $field, $input['actor_value']);
if ($groups_id === false) {
throw new ImportFailureException(sprintf(__('Failed to find a group: %1$s'), $input['actor_value']));
}
Expand All @@ -212,7 +214,8 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con

case self::ACTOR_TYPE_SUPPLIER:
$supplier = new Supplier;
$suppliers_id = plugin_formcreator_getFromDBByField($supplier, 'name', $input['actor_value']);
$field = $idKey == 'id' ? 'id' : 'name';
$suppliers_id = plugin_formcreator_getFromDBByField($supplier, $field, $input['actor_value']);
if ($suppliers_id === false) {
throw new ImportFailureException(sprintf(__('Failed to find a supplier: %1$s'), $input['actor_value']));
}
Expand Down

0 comments on commit d77cde0

Please sign in to comment.