From 909eb0bf5731489fbe8cfda44833f1b7cebcb3e9 Mon Sep 17 00:00:00 2001 From: Paolo Date: Mon, 15 Sep 2025 17:42:40 +0200 Subject: [PATCH] Fixed AkteLib->_remove --- .../api/frontend/v1/stv/Dokumente.php | 2 - application/libraries/AkteLib.php | 48 ++++--------------- 2 files changed, 8 insertions(+), 42 deletions(-) diff --git a/application/controllers/api/frontend/v1/stv/Dokumente.php b/application/controllers/api/frontend/v1/stv/Dokumente.php index 82aadcc52..d1b330d70 100644 --- a/application/controllers/api/frontend/v1/stv/Dokumente.php +++ b/application/controllers/api/frontend/v1/stv/Dokumente.php @@ -261,7 +261,6 @@ class Dokumente extends FHCAPI_Controller $logdata_dms = "Logdata: " . var_export($logdata_dms, true); //delete from dmsLib - $this->load->library('DmsLib'); $person_id = current($dataAkte)->person_id; $result = $this->aktelib->removeByPersonIdAndDmsId($person_id, $dms_id); $this->getDataOrTerminateWithError($result); @@ -321,7 +320,6 @@ class Dokumente extends FHCAPI_Controller public function uploadDokument() { - $this->load->library('DmsLib'); $prestudent_id = $this->input->post('prestudent_id'); $anmerkung_intern = $this->input->post('anmerkung_intern'); $titel_intern = $this->input->post('titel_intern'); diff --git a/application/libraries/AkteLib.php b/application/libraries/AkteLib.php index 2e2813d32..0ac039cdd 100644 --- a/application/libraries/AkteLib.php +++ b/application/libraries/AkteLib.php @@ -332,6 +332,7 @@ class AkteLib private function _remove($akte_id = null, $person_id = null, $dms_id = null) { // Get dms_id for akte + $this->_ci->AkteModel->addSelect('akte_id'); $this->_ci->AkteModel->addSelect('dms_id'); $paramArray = array(); @@ -344,50 +345,17 @@ class AkteLib if (isError($akteResult)) return $akteResult; - if (!hasData($akteResult)) return error("Akte not found"); + if (!hasData($akteResult)) return error('Akte not found'); - $dms_id = getData($akteResult)[0]->dms_id; - $error = null; + // Delete Akte + $deleteResult = $this->_ci->AkteModel->delete(getData($akteResult)[0]->akte_id); - // Start DB transaction to avoid deleting only part of the data - $this->_ci->db->trans_begin(); + if (isError($deleteResult)) return $deleteResult; - // delete Akte - $deleteResult = $this->_ci->AkteModel->delete($akte_id); + // Remove all dms entry for dms of the akte + $removeAllResult = $this->_ci->dmslib->removeAll(getData($akteResult)[0]->dms_id); - if (isError($deleteResult)) - { - $error = $deleteResult; - } - else - { - // remove all dms entry for dms of the akte - $removeAllResult = $this->_ci->dmslib->removeAll($dms_id); - - if (isError($removeAllResult)) $error = $removeAllResult; - } - - // Transaction complete! - $this->_ci->db->trans_complete(); - - // Check if everything went ok during the transaction - if ($this->_ci->db->trans_status() === false || isset($error)) - { - $this->_ci->db->trans_rollback(); - - // return occured error - if (isset($error)) - return $error; - else - return error("Error occured when deleting, rolled back"); - } - else - { - $this->_ci->db->trans_commit(); - - // return removed dms entry data - return $removeAllResult; - } + return $removeAllResult; } }