Skip to content

Commit 1bd6a2a

Browse files
committed
fix: duplicate key when updating a profile
1 parent 1269edd commit 1bd6a2a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

hook.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,11 +732,18 @@ function plugin_formcreator_hook_update_profile(CommonDBTM $item) {
732732
}
733733
$dashboardRight = new DashboardRight();
734734
if ($item->fields['interface'] == 'helpdesk') {
735-
$dashboardRight->add([
735+
$dashboardRight->getFromDBByCrit([
736736
'dashboards_dashboards_id' => $dashboard->fields['id'],
737737
'itemtype' => Profile::getType(),
738738
'items_id' => $item->getID(),
739739
]);
740+
if ($dashboardRight->isNewItem()) {
741+
$dashboardRight->add([
742+
'dashboards_dashboards_id' => $dashboard->fields['id'],
743+
'itemtype' => Profile::getType(),
744+
'items_id' => $item->getID(),
745+
]);
746+
}
740747
} else {
741748
$dashboardRight->delete([
742749
'dashboards_dashboards_id' => $dashboard->fields['id'],

0 commit comments

Comments
 (0)