- DmsLib:

- Removed deprecated methods from the DMSLib, these were the "problematic" types of methods:
		- Methods that would perform an upload/download of the file (should be performed by a controller)
		- Methods that were returning a base64 representation of the file (what if the file is a 1Gb?)
		- Methods that were performing operation on the akte (should be done in the AkteLib)
	- The first two types have been removed and added new utility method to read a file (wrapper of the DMSFSModel)
	- The last type of methods has been removed and same functionalities already exists in the AkteLib
	- Minor fixes
- AkteLib:
	- Added new methods to get an akte with relative content (even from the DMS) with different parameters (akte_id, person_id, dokument_kurzbz, signiert, stud_selfservice)
- AkteModel:
	- Removed the getArchiv method
- Replaced the usage of the AkteModel with the AkteLib as much as possible. AkteModel is used mainly to quickly check if an akte exists or not, otherwise the AkteLib is used for read/write operations
- Replaced the DmsLib usage with the AkteLib usage where the old deprecated DmsLib methods, that were working with the akte too, were used
This commit is contained in:
Paolo
2025-09-09 13:28:56 +02:00
parent 5889bdb6ea
commit 2ee0c95467
6 changed files with 235 additions and 614 deletions
@@ -46,6 +46,9 @@ class Archiv extends FHCAPI_Controller
$this->load->model('crm/Akte_model', 'AkteModel');
$this->load->model('system/Vorlage_model', 'VorlageModel');
// Load libraries
$this->load->library('AkteLib');
// Load language phrases
$this->loadPhrases([
'archiv'
@@ -74,7 +77,10 @@ class Archiv extends FHCAPI_Controller
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$result = $this->AkteModel->getArchiv($person_id);
$result = $this->aktelib->getByPersonId(
$person_id,
true // archiv
);
$data = $this->getDataOrTerminateWithError($result);
@@ -105,53 +111,55 @@ class Archiv extends FHCAPI_Controller
if (!is_numeric($akte_id)) $this->terminateWithError('akte Id missing');
$result = $this->AkteModel->load($akte_id);
$result = $this->aktelib->getByAkteId($akte_id);
if (!hasData($result)) $this->terminateWithError('Akte not found');
$data = $this->getDataOrTerminateWithError($result);
$data = $this->getDataOrTerminateWithError($result)[0];
$data = getData($result)[0];
//$this->addMeta("daa", $data->inhalt);
$fileObj = new stdClass();
if (isset($data->inhalt) && $data->inhalt != '')
// If the file content is from the akte table or from the DMS
if (!isEmptyString($data->inhalt) || !isEmptyString($data->filename))
{
// Define handle to output stream
$tmpFilePointer = fopen("php://output", 'w');
$tmpFilePointer = fopen("php://output", 'w');
$meta_data = stream_get_meta_data($tmpFilePointer);
$filename = $meta_data["uri"];
fwrite($tmpFilePointer, $data->inhalt);
// File content from akte...
if (!isEmptyString($data->inhalt))
{
// Writes into the output buffer
fwrite($tmpFilePointer, $data->inhalt);
}
else //...or from DMS
{
$this->load->model('content/DmsFS_model', 'DmsFSModel');
$fileHandleResult = $this->DmsFSModel->openRead($data->filename);
if (isError($fileHandleResult) || !hasData($fileHandleResult)) $this->terminateWithError('DMS is not able to load this file');
// Read blocks from the file and writes them into the output buffer
while (hasData($fileData = readBlock($fileHandleResult)))
{
fwrite($tmpFilePointer, $fileData);
}
}
fclose($tmpFilePointer);
header('Content-Description: File Transfer');
header('Content-Type: '. $data->mimetype);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
//header('Content-Length: ' . filesize($fileObj->file));
//header("Content-type: $data->mimetype");
header('Content-Disposition: attachment; filename="'.$data->titel.'"');
readfile($filename);
//echo base64_decode($data->inhalt);
die();
//~ $fileObj->file = $data->inhalt;
//~ $fileObj->name = $data->titel;
//~ $fileObj->mimetype = $data->mimetype;
//~ $fileObj->disposition = 'attachment';
}
else
{
$this->load->library('AkteLib');
$result = $this->aktelib->get($akte_id);
$this->terminateWithError('This file content is not available');
}
/* $fileObj->filename
* $fileObj->file
* $fileObj->name
* $fileObj->mimetype
* $fileObj->disposition*/
}
/**