Skip to content

Commit

Permalink
fix(target_actor): groups duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Mar 12, 2024
1 parent 2681eca commit dbfcc79
Showing 1 changed file with 35 additions and 34 deletions.
69 changes: 35 additions & 34 deletions inc/target_actor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,41 +267,42 @@ public function export(bool $remove_uuid = false) : array {
$idToRemove = 'id';
if ($remove_uuid) {
$idToRemove = 'uuid';
} else {
// Convert IDs into UUIDs or names
switch ($target_actor['actor_type']) {
case self::ACTOR_TYPE_QUESTION_PERSON:
case self::ACTOR_TYPE_QUESTION_GROUP:
case self::ACTOR_TYPE_QUESTION_SUPPLIER:
case self::ACTOR_TYPE_QUESTION_ACTORS:
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'];
}
break;
case self::ACTOR_TYPE_PERSON:
case self::ACTOR_TYPE_AUTHORS_SUPERVISOR:
$user = new User;
if ($user->getFromDB($target_actor['actor_value'])) {
$target_actor['actor_value'] = $user->fields['name'];
}
break;
case self::ACTOR_TYPE_GROUP:
$group = new Group;
if ($group->getFromDB($target_actor['actor_value'])) {
$target_actor['actor_value'] = $group->fields['completename'];
}
break;
case self::ACTOR_TYPE_SUPPLIER:
$supplier = new Supplier;
if ($supplier->getFromDB($target_actor['actor_value'])) {
$target_actor['actor_value'] = $supplier->fields['name'];
}
break;
}
}

// Convert IDs into UUIDs or names
switch ($target_actor['actor_type']) {
case self::ACTOR_TYPE_QUESTION_PERSON:
case self::ACTOR_TYPE_QUESTION_GROUP:
case self::ACTOR_TYPE_QUESTION_SUPPLIER:
case self::ACTOR_TYPE_QUESTION_ACTORS:
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'];
}
break;
case self::ACTOR_TYPE_PERSON:
case self::ACTOR_TYPE_AUTHORS_SUPERVISOR:
$user = new User;
if ($user->getFromDB($target_actor['actor_value'])) {
$target_actor['actor_value'] = $user->fields['name'];
}
break;
case self::ACTOR_TYPE_GROUP:
$group = new Group;
if ($group->getFromDB($target_actor['actor_value'])) {
$target_actor['actor_value'] = $group->fields['completename'];
}
break;
case self::ACTOR_TYPE_SUPPLIER:
$supplier = new Supplier;
if ($supplier->getFromDB($target_actor['actor_value'])) {
$target_actor['actor_value'] = $supplier->fields['name'];
}
break;
}

unset($target_actor[$idToRemove]);

return $target_actor;
Expand Down

0 comments on commit dbfcc79

Please sign in to comment.