diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 1df5c06f51f..4eeb87a5b61 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -422,7 +422,9 @@ if ($action == 'update') $object->fetch($id); $object->fetch_optionals(); - $object->fetch_userassigned(); + $object->fetch_userassigned(); + $object->oldcopy = clone $object; + $datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); @@ -610,6 +612,8 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') { $object->fetch($id); $object->fetch_optionals(); + $object->fetch_userassigned(); + $object->oldcopy = clone $object; if ($user->rights->agenda->myactions->delete || $user->rights->agenda->allactions->delete) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 7e8bd88e5bc..12926f9b360 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -772,7 +772,6 @@ class ActionComm extends CommonObject $error=0; $this->db->begin(); - $this->oldcopy = clone $this; $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm"; $sql.= " WHERE id=".$this->id; diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 833f97b3b6b..53d0ad61b90 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -237,6 +237,11 @@ class AgendaEvents extends DolibarrApi } $result = $this->actioncomm->fetch($id); + if ($result) { + $this->actioncomm->fetch_optionals(); + $this->actioncomm->fetch_userassigned(); + $this->actioncomm->oldcopy = clone $this->actioncomm; + } if ( ! $result ) { throw new RestException(404, 'actioncomm not found'); } @@ -269,7 +274,12 @@ class AgendaEvents extends DolibarrApi throw new RestException(401, "Insuffisant rights to delete your Agenda Event"); } - $result = $this->actioncomm->fetch($id); + $result = $this->actioncomm->fetch($id); + if ($result) { + $this->actioncomm->fetch_optionals(); + $this->actioncomm->fetch_userassigned(); + $this->actioncomm->oldcopy = clone $this->actioncomm; + } if(! DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { throw new RestException(401, "Insuffisant rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);