From 59c8af3bfddd4ebc2919f63913a928907130ab94 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come.chilliet@fusiondirectory.org>
Date: Tue, 8 Sep 2020 10:44:53 +0200
Subject: [PATCH] :ambulance: fix(management) Fix copy paste

There was a logic problem when calling readPost/update closes the
 dialog, the edit_finish POST value was read twice - by the opened
 dialog and by the copypasting logic.

issue #6072
---
 include/class_CopyPasteHandler.inc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/class_CopyPasteHandler.inc b/include/class_CopyPasteHandler.inc
index 503242fe5..7a4019955 100644
--- a/include/class_CopyPasteHandler.inc
+++ b/include/class_CopyPasteHandler.inc
@@ -222,10 +222,11 @@ class CopyPasteHandler implements FusionDirectoryDialog
 
     /* Save edited entry and force loading new one */
     if (isset($this->current['object'])) {
+      $dialogWasOpened = $this->current['object']->dialogOpened();
       $this->current['object']->readPost();
       $this->current['object']->update();
       /* Save current object if edition is finished */
-      if (!$this->current['object']->dialogOpened() && isset($_POST['edit_finish'])) {
+      if (!$dialogWasOpened && !$this->current['object']->dialogOpened() && isset($_POST['edit_finish'])) {
         $errors = $this->current['object']->save();
 
         if (empty($errors)) {
-- 
GitLab