mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-19 07:52:16 +00:00
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:
@@ -458,9 +458,11 @@ class Documents extends FHCAPI_Controller
|
||||
$result = $this->documentexportlib->getDataURL($xml, $params);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->documentexportlib->addArchiveToData($data);
|
||||
$contentResult = $this->documentexportlib->getContent($vorlage, $data, $xsl_oe_kurzbz, $version, $outputformat, $sign_user);
|
||||
|
||||
$content = $this->getDataOrTerminateWithError($result);
|
||||
$content = $this->getDataOrTerminateWithError($contentResult);
|
||||
$akteData['titel'] .= '.pdf';
|
||||
$akteData['inhalt'] = base64_encode($content);
|
||||
|
||||
return [
|
||||
'akteData' => $akteData,
|
||||
|
||||
@@ -60,7 +60,7 @@ class Archiv extends FHCAPI_Controller
|
||||
|
||||
/**
|
||||
* Get archive documents for a person
|
||||
|
||||
|
||||
* @return void
|
||||
*/
|
||||
public function getArchiv()
|
||||
@@ -79,6 +79,7 @@ class Archiv extends FHCAPI_Controller
|
||||
|
||||
$result = $this->aktelib->getByPersonId(
|
||||
$person_id,
|
||||
null, // dokument_kurzbz
|
||||
true // archiv
|
||||
);
|
||||
|
||||
@@ -100,68 +101,6 @@ class Archiv extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param
|
||||
* @return object success or error
|
||||
*/
|
||||
public function download()
|
||||
{
|
||||
$akte_id = $this->input->get('akte_id');
|
||||
|
||||
if (!is_numeric($akte_id)) $this->terminateWithError('akte Id missing');
|
||||
|
||||
$result = $this->aktelib->getByAkteId($akte_id);
|
||||
|
||||
if (!hasData($result)) $this->terminateWithError('Akte not found');
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result)[0];
|
||||
|
||||
// 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');
|
||||
$meta_data = stream_get_meta_data($tmpFilePointer);
|
||||
$filename = $meta_data["uri"];
|
||||
|
||||
// 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-Disposition: attachment; filename="'.$data->titel.'"');
|
||||
readfile($filename);
|
||||
die();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithError('This file content is not available');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updating an Akte
|
||||
* @return void
|
||||
@@ -216,7 +155,7 @@ class Archiv extends FHCAPI_Controller
|
||||
$this->addMeta('content', base64_encode($content));
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach ($allowed as $field)
|
||||
if ($this->input->post($field) !== null)
|
||||
$data[$field] = $this->input->post($field);
|
||||
@@ -271,7 +210,7 @@ class Archiv extends FHCAPI_Controller
|
||||
'akte_id' => $akte_id
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
$result = $this->AkteModel->delete($akte_id);
|
||||
if (isError($result)) $this->terminateWithError(getError($result));
|
||||
|
||||
|
||||
@@ -755,9 +755,7 @@ class Dokumente extends FHCAPI_Controller
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$student = current($data);
|
||||
|
||||
return $student->student_uid;
|
||||
return hasData($data) ? getData($data)[0]->student_uid : null;
|
||||
}
|
||||
|
||||
private function _loadPrestudentFromUid($studentUid)
|
||||
@@ -769,10 +767,7 @@ class Dokumente extends FHCAPI_Controller
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$student = current($data);
|
||||
|
||||
|
||||
return $student->prestudent_id;
|
||||
return hasData($data) ? getData($data)[0]->prestudent_id : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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)]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,14 +202,14 @@ export default {
|
||||
{
|
||||
return [this.modelValue.uid];
|
||||
}
|
||||
return this.modelValue.map(e => e.uid);
|
||||
return Array.isArray(this.modelValue) ? this.modelValue.map(e => e.uid) : [];
|
||||
},
|
||||
studentKzs(){
|
||||
if (this.modelValue.uid)
|
||||
{
|
||||
return [this.modelValue.studiengang_kz];
|
||||
}
|
||||
return this.modelValue.map(e => e.studiengang_kz);
|
||||
return Array.isArray(this.modelValue) ? this.modelValue.map(e => e.studiengang_kz) : [];
|
||||
},
|
||||
stg_kz(){
|
||||
return this.studentKzs[0];
|
||||
@@ -282,7 +282,8 @@ export default {
|
||||
actionDownload(akte_id) {
|
||||
window.open(
|
||||
FHC_JS_DATA_STORAGE_OBJECT.app_root
|
||||
+ FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/api/frontend/v1/stv/akte/download?akte_id=' + encodeURIComponent(akte_id),
|
||||
//+ FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/api/frontend/v1/stv/akte/download?akte_id=' + encodeURIComponent(akte_id),
|
||||
+ FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/api/frontend/v1/stv/dokumente/download?akte_id=' + encodeURIComponent(akte_id),
|
||||
'_blank'
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user