document export bugfixes: getting content from db in Documents.php, correctly return data in Dokumente.php, passing temp folder in DocumentExportLib, path fix in DocumentLib, correct parameters in Archiv.php getByPersonId call, Archiv.js: check if array is returned, different controller for download (dokumente instead of akte)

This commit is contained in:
Alexei Karpenko
2026-02-09 14:22:39 +01:00
parent 0b797cfdb1
commit f4d8a396f5
7 changed files with 65 additions and 126 deletions
+6 -5
View File
@@ -403,17 +403,18 @@ class DocumentExportLib
clearstatcache();
$temp_filename = $temp_folder . '/out.' . $outputformat;
switch ($outputformat) {
case 'pdf':
case 'doc':
$converResult = $this->documentlib->convert($tempname_zip, $temp_filename, $outputformat);
$converResult = $this->_ci->documentlib->convert($tempname_zip, $temp_filename, $outputformat);
if (isError($converResult))
return error($this->_ci->DocumentExportPhrases->t('document_export', 'error_conv_timeout'));
break;
case 'odt':
default:
$temp_filename = $tempname_zip;
//~ default:
//~ $temp_filename = $tempname_zip;
}
return success($temp_filename);
@@ -435,13 +436,13 @@ class DocumentExportLib
{
if ($outputformat != 'pdf') return error($this->_ci->DocumentExportPhrases->t('document_export', 'error_sign_pdf'));
$signed_filename = $this->_ci->signaturelib->sign($temp_filename, $user, $profile);
$signed_filename = $this->_ci->signaturelib->sign($temp_folder, $temp_filename, $user, $profile);
// If fine then return it
if (isSuccess($signed_filename)) return $signed_filename;
// Otherwise it is an error
return error($this->_ci->DocumentExportPhrases->t('global', 'unknown_error', ['error' => $result]));
return error($this->_ci->DocumentExportPhrases->t('global', 'unknown_error', ['error' => getError($signed_filename)]));
}
/**
+1 -1
View File
@@ -144,7 +144,7 @@ class DocumentLib
// If it is set to use docsbox
if (defined('DOCSBOX_ENABLED') && DOCSBOX_ENABLED === true)
{
require_once(dirname(__FILE__).'/../application/libraries/DocsboxLib.php');
require_once(dirname(__FILE__).'/DocsboxLib.php');
$ret = DocsboxLib::convert($inFile, $outFile, $format);
}
+45 -44
View File
@@ -76,64 +76,65 @@ class SignatureLib
}
/**
*
*
*/
public static function sign($inputFileName, $user, $profile)
public function sign($temp_folder, $inputFileName, $user, $profile)
{
// Load the File
$file_data = file_get_contents($inputFileName);
$file_data = file_get_contents($inputFileName);
$data = new stdClass();
$data->document = base64_encode($file_data);
$data = new stdClass();
$data->document = base64_encode($file_data);
// Signatur Profil
if (!is_null($profile))
$data->profile = $profile;
else
$data->profile = SIGNATUR_DEFAULT_PROFILE;
// Signatur Profil
if (!is_null($profile))
$data->profile = $profile;
else
$data->profile = SIGNATUR_DEFAULT_PROFILE;
// Username des Endusers der die Signatur angefordert hat
$data->user = $user;
// Username des Endusers der die Signatur angefordert hat
$data->user = $user;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, SIGNATUR_URL . '/' . SIGNATUR_SIGN_API);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 7);
curl_setopt($ch, CURLOPT_USERAGENT, "FH-Complete");
$ch = curl_init();
// SSL Zertifikatsprüfung deaktivieren
// Besser ist es das Zertifikat am Server zu installieren!
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, SIGNATUR_URL . '/' . SIGNATUR_SIGN_API);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 7);
curl_setopt($ch, CURLOPT_USERAGENT, "FH-Complete");
$data_string = json_encode($data, JSON_FORCE_OBJECT);
// SSL Zertifikatsprüfung deaktivieren
// Besser ist es das Zertifikat am Server zu installieren!
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Content-Length:' . mb_strlen($data_string),
'Authorization: Basic ' . base64_encode(SIGNATUR_USER . ':' . SIGNATUR_PASSWORD)
]);
$data_string = json_encode($data, JSON_FORCE_OBJECT);
$result = curl_exec($ch);
if (curl_errno($ch)) {
curl_close($ch);
return $this->_returnObject(1, 1, 'CURL error');
}
curl_close($ch);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Content-Length:' . mb_strlen($data_string),
'Authorization: Basic ' . base64_encode(SIGNATUR_USER . ':' . SIGNATUR_PASSWORD)
]);
$result = curl_exec($ch);
if (curl_errno($ch)) {
curl_close($ch);
return $this->_returnObject(1, 1, 'CURL error');
}
curl_close($ch);
$resultdata = json_decode($result);
// If it is success
if (isset($resultdata->error) && $resultdata->error == 0) {
$signed_filename = $temp_folder . '/signed.pdf';
file_put_contents($signed_filename, base64_decode($resultdata->retval));
return $this->_returnObject(0, 0, $signed_filename);
}
if (isset($resultdata->error) && $resultdata->error == 0)
{
$signed_filename = $temp_folder . '/signed.pdf';
file_put_contents($signed_filename, base64_decode($resultdata->retval));
return $this->_returnObject(0, 0, $signed_filename);
}
// Otherwise it is an error
return $this->_returnObject(1, 1, 'Error while signing the given document');
// Otherwise it is an error
return $this->_returnObject(1, 1, 'Error while signing the given document');
}
/**
@@ -145,7 +146,7 @@ class SignatureLib
$returnObject->code = $code;
$returnObject->error = $error;
$returnObject->retval = $retval;
return $returnObject;
}
}