Commit e8715659 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #4893 first go at fixing copy/paste for new save workflow

Showing with 19 additions and 18 deletions
+19 -18
...@@ -258,11 +258,18 @@ class CopyPasteHandler ...@@ -258,11 +258,18 @@ class CopyPasteHandler
if (count($this->clean_objects)) { if (count($this->clean_objects)) {
$this->save_object(); $this->save_object();
foreach ($this->clean_objects as $key => $entry) { foreach ($this->clean_objects as $key => $entry) {
/* Remove from queue -> avoid saving twice */ $this->current = $entry;
unset($this->queue[$key]); $dn = $this->current['object']->dn;
unset($this->clean_objects[$key]); $errors = $this->current['object']->save();
$this->save_current($entry); if (empty($errors)) {
$this->current_saved($dn);
/* Remove from queue -> avoid saving twice */
unset($this->queue[$key]);
} else {
$this->objects_to_fix[$key] = $entry;
}
unset($this->clean_objects[$key]);
} }
} }
...@@ -273,14 +280,13 @@ class CopyPasteHandler ...@@ -273,14 +280,13 @@ class CopyPasteHandler
/* Save current object if edition is finished */ /* Save current object if edition is finished */
if (isset($_POST['edit_finish']) && $this->current) { if (isset($_POST['edit_finish']) && $this->current) {
$msgs = $this->current['object']->check(); $dn = $this->current['object']->dn;
$errors = $this->current['object']->save();
if (!count($msgs)) { if (empty($errors)) {
$this->save_current(); $this->current_saved($dn);
} else { } else {
foreach ($msgs as $msg) { msg_dialog::displayChecks($errors);
msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
}
} }
} }
...@@ -315,18 +321,13 @@ class CopyPasteHandler ...@@ -315,18 +321,13 @@ class CopyPasteHandler
return ""; return "";
} }
private function save_current($object = NULL) private function current_saved($dn)
{ {
if ($object !== NULL) { $this->lastdn = $dn;
$this->current = $object;
}
$this->lastdn = $this->current['object']->dn;
$this->current['object']->save();
$this->handleReferences(); $this->handleReferences();
$this->current = FALSE; $this->current = FALSE;
} }
/*! /*!
* \brief Get the last endited entry * \brief Get the last endited entry
* *
......
  • bmortier @bmortier

    mentioned in issue #1549

    By Côme Chilliet on 2017-09-02T15:30:17 (imported from GitLab)

    ·

    mentioned in issue #1549

    By Côme Chilliet on 2017-09-02T15:30:17 (imported from GitLab)

    Toggle commit list
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment