mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-17 20:19:28 +00:00
- DmsLib->download removed
- DmsLib->upload replaced by uploadFile - Removed who parameter from DmsLib constructor - Added insert by into DmsLib add and addLastVersion - Removed commented code - Replaced self with $this in the Anrechnung classes - Added removeByPersonIdAndDmsId to AkteLib
This commit is contained in:
@@ -233,7 +233,7 @@ class ProfilUpdate extends Auth_Controller
|
||||
) {
|
||||
// Get file to be downloaded from DMS
|
||||
$newFilename = $this->uid . "/document_" . $dms_id;
|
||||
$download = $this->dmslib->download($dms_id);
|
||||
$download = $this->dmslib->getOutputFileInfo($dms_id);
|
||||
if (isError($download))
|
||||
return $download;
|
||||
|
||||
@@ -290,20 +290,26 @@ class ProfilUpdate extends Auth_Controller
|
||||
$_FILES['files']['error'] = $files['error'][$i];
|
||||
$_FILES['files']['size'] = $files['size'][$i];
|
||||
|
||||
$dms = [
|
||||
"kategorie_kurzbz" => "profil_aenderung",
|
||||
"version" => 0,
|
||||
"name" => $_FILES['files']['name'],
|
||||
"mimetype" => $_FILES['files']['type'],
|
||||
"beschreibung" => $this->uid . " Profil Änderung",
|
||||
"insertvon" => $this->uid,
|
||||
"insertamum" => "NOW()",
|
||||
];
|
||||
$uploadDataResult = uploadFile('files', array('jpg', 'png', 'pdf'));
|
||||
|
||||
$tmp_res = $this->dmslib->upload($dms, 'files', array("jpg", "png", "pdf"));
|
||||
if (hasData($uploadDataResult))
|
||||
{
|
||||
// Add file to the DMS (DB + file system)
|
||||
$dms_res = $this->dmslib->add(
|
||||
getData($uploadDataResult)['file_name'],
|
||||
getData($uploadDataResult)['file_type'],
|
||||
fopen(getData($uploadDataResult)['full_path'], 'r'),
|
||||
'profil_aenderung'
|
||||
null, // dokument_kurzbz
|
||||
null, // beschreibung
|
||||
false, // cis_suche
|
||||
null, // schlagworte
|
||||
getAuthUID() // insertvon
|
||||
);
|
||||
|
||||
$tmp_res = hasData($tmp_res) ? getData($tmp_res) : null;
|
||||
array_push($res, $tmp_res);
|
||||
$tmp_res = hasData($dms_res) ? getData($dms_res) : null;
|
||||
array_push($res, $tmp_res);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($res);
|
||||
@@ -811,4 +817,4 @@ class ProfilUpdate extends Auth_Controller
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
$this->uid == $profil_update->uid
|
||||
) {
|
||||
// Get file to be downloaded from DMS
|
||||
$download = $this->dmslib->download($dms_id);
|
||||
$download = $this->dmslib->getOutputFileInfo($dms_id);
|
||||
$download = $this->getDataOrTerminateWithError($download);
|
||||
// Download file
|
||||
$this->outputFile($download);
|
||||
@@ -456,24 +456,28 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
$_FILES['files']['error'] = $files['error'][$i];
|
||||
$_FILES['files']['size'] = $files['size'][$i];
|
||||
|
||||
$dms = [
|
||||
"kategorie_kurzbz" => "profil_aenderung",
|
||||
"version" => 0,
|
||||
"name" => $_FILES['files']['name'],
|
||||
"mimetype" => $_FILES['files']['type'],
|
||||
"beschreibung" => $this->uid . " Profil Änderung",
|
||||
"insertvon" => $this->uid,
|
||||
"insertamum" => "NOW()",
|
||||
];
|
||||
// File upload
|
||||
$uploadDataResult = uploadFile('files', array('jpg', 'png', 'pdf'));
|
||||
if (isError($uploadDataResult)) $this->addError(getError($uploadDataResult));
|
||||
if (!hasData($uploadDataResult)) $this->addError('Upload failed');
|
||||
|
||||
$tmp_res = $this->dmslib->upload($dms, 'files', array("jpg", "png", "pdf"));
|
||||
|
||||
if(isError($tmp_res)){
|
||||
$this->addError(getError($tmp_res));
|
||||
if (hasData($uploadDataResult))
|
||||
{
|
||||
// Add file to the DMS (DB + file system)
|
||||
$dms_res = $this->dmslib->add(
|
||||
getData($uploadDataResult)['file_name'],
|
||||
getData($uploadDataResult)['file_type'],
|
||||
fopen(getData($uploadDataResult)['full_path'], 'r'),
|
||||
'profil_aenderung', // kategorie_kurzbz
|
||||
null, // dokument_kurzbz
|
||||
null, // beschreibung
|
||||
false, // cis_suche
|
||||
null, // schlagworte
|
||||
getAuthUID() // insertvon
|
||||
);
|
||||
$dms_res = $this->getDataOrTerminateWithError($dms_res);
|
||||
array_push($res, $dms_res);
|
||||
}
|
||||
|
||||
$tmp_res = $this->getDataOrTerminateWithError($tmp_res);
|
||||
array_push($res, $tmp_res);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($res);
|
||||
|
||||
@@ -158,19 +158,27 @@ class Unterbrechung extends FHCAPI_Controller
|
||||
if (isset($_FILES['attachment']) && (!isset($_FILES['attachment']['error']) || $_FILES['attachment']['error'] != UPLOAD_ERR_NO_FILE)) {
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
$dms = $this->config->item('unterbrechung_dms');
|
||||
if (!count(array_filter($dms, function ($v) {
|
||||
return $v !== null;
|
||||
})))
|
||||
$dms = ['kategorie_kurzbz' => 'Akte'];
|
||||
$dms['version'] = 0;
|
||||
|
||||
$allowed_filetypes = $this->config->item('unterbrechung_dms_filetypes') ?: ['*'];
|
||||
$result = $this->dmslib->upload($dms, 'attachment', $allowed_filetypes);
|
||||
$uploadDataResult = uploadFile('attachment', $this->config->item('unterbrechung_dms_filetypes') ?: array('*'));
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$dms_id = $data['dms_id'];
|
||||
$data = $this->getDataOrTerminateWithError($uploadDataResult);
|
||||
|
||||
// Add file to the DMS (DB + file system)
|
||||
$dms_res = $this->dmslib->add(
|
||||
getData($uploadDataResult)['file_name'],
|
||||
getData($uploadDataResult)['file_type'],
|
||||
fopen(getData($uploadDataResult)['full_path'], 'r'),
|
||||
'studierendenantrag'
|
||||
null, // dokument_kurzbz
|
||||
null, // beschreibung
|
||||
false, // cis_suche
|
||||
null, // schlagworte
|
||||
getAuthUID() // insertvon
|
||||
);
|
||||
|
||||
$dms_data = $this->getDataOrTerminateWithError($dms_res);
|
||||
|
||||
$dms_id = $dms_data->dms_id;
|
||||
}
|
||||
|
||||
$result = $this->antraglib->createUnterbrechung($prestudent_id, $studiensemester, getAuthUID(), $grund, $datum_wiedereinstieg, $dms_id);
|
||||
|
||||
@@ -24,7 +24,8 @@ class Dokumente extends FHCAPI_Controller
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('form_validation');
|
||||
$this->load->library('DmsLib', array('who' => getAuthUID()));
|
||||
$this->load->library('AkteLib');
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
@@ -187,8 +188,6 @@ class Dokumente extends FHCAPI_Controller
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$uid = getAuthUID();
|
||||
|
||||
$result = $this->AkteModel->update(
|
||||
[
|
||||
'akte_id' => $this->input->post('akte_id'),
|
||||
@@ -199,7 +198,7 @@ class Dokumente extends FHCAPI_Controller
|
||||
'titel_intern' => $this->input->post('titel_intern'),
|
||||
'nachgereicht_am' => $this->input->post('nachgereicht_am'),
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => $uid,
|
||||
'updatevon' => getAuthUID(),
|
||||
]
|
||||
);
|
||||
|
||||
@@ -216,8 +215,6 @@ class Dokumente extends FHCAPI_Controller
|
||||
if(!$dokument_kurzbz)
|
||||
$this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Dokument_kurzbz']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$uid = getAuthUid();
|
||||
|
||||
//check if more than 1 dokumentkurzbz
|
||||
//if()
|
||||
|
||||
@@ -225,10 +222,10 @@ class Dokumente extends FHCAPI_Controller
|
||||
[
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'dokument_kurzbz' => $dokument_kurzbz,
|
||||
'mitarbeiter_uid' => $uid,
|
||||
'mitarbeiter_uid' => getAuthUID(),
|
||||
'datum' => date('c'),
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $uid,
|
||||
'insertvon' => getAuthUID(),
|
||||
]
|
||||
);
|
||||
|
||||
@@ -251,7 +248,6 @@ class Dokumente extends FHCAPI_Controller
|
||||
$nachgereicht = current($dataAkte)->nachgereicht;
|
||||
$inhalt = current($dataAkte)->inhalt;
|
||||
$inhaltVorhanden = $inhalt != '';
|
||||
$uid = getAuthUid();
|
||||
|
||||
$this->db->trans_start();
|
||||
|
||||
@@ -267,14 +263,14 @@ class Dokumente extends FHCAPI_Controller
|
||||
//delete from dmsLib
|
||||
$this->load->library('DmsLib');
|
||||
$person_id = current($dataAkte)->person_id;
|
||||
$result = $this->dmslib->delete($person_id, $dms_id);
|
||||
$result = $this->aktelib->removeByPersonIdAndDmsId($person_id, $dms_id);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
//LOGGING Dms ID
|
||||
$this->load->model('system/Log_model', 'LogModel');
|
||||
$result = $this->LogModel->insert([
|
||||
'executetime' => date('c'),
|
||||
'mitarbeiter_uid' => $uid,
|
||||
'mitarbeiter_uid' => getAuthUID(),
|
||||
'beschreibung' => "Löschen der DMS_ID ". $dms_id,
|
||||
'sql' => $logdata_dms
|
||||
]);
|
||||
@@ -291,7 +287,7 @@ class Dokumente extends FHCAPI_Controller
|
||||
//Logging Deletion Akte
|
||||
$result = $this->LogModel->insert([
|
||||
'executetime' => date('c'),
|
||||
'mitarbeiter_uid' => $uid,
|
||||
'mitarbeiter_uid' => getAuthUID(),
|
||||
'beschreibung' => "Löschen der Akte ". $akte_id,
|
||||
'sql' => "DELETE FROM public.tbl_akte WHERE akte_id=" .$akte_id. " LogData: ". $logdata_akte
|
||||
]);
|
||||
@@ -310,7 +306,7 @@ class Dokumente extends FHCAPI_Controller
|
||||
|
||||
$result = $this->LogModel->insert([
|
||||
'executetime' => date('c'),
|
||||
'mitarbeiter_uid' => $uid,
|
||||
'mitarbeiter_uid' => getAuthUID(),
|
||||
'beschreibung' => "Löschen der Akte ". $akte_id,
|
||||
'sql' => "DELETE FROM public.tbl_akte WHERE akte_id=" .$akte_id. " LogData: ". $logdata_akte
|
||||
]);
|
||||
@@ -348,34 +344,44 @@ class Dokumente extends FHCAPI_Controller
|
||||
}
|
||||
|
||||
$this->db->trans_start();
|
||||
$uid = getAuthUID();
|
||||
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'Akte',
|
||||
'version' => 0,
|
||||
'name' => $_FILES['anhang']['name'],
|
||||
'mimetype' => $_FILES['anhang']['type'],
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $uid
|
||||
);
|
||||
|
||||
$result = $this->dmslib->upload($dms, 'anhang', array("jpg", "png", "pdf"));
|
||||
|
||||
if (isError($result))
|
||||
$uploadDataResult = uploadFile('anhang', array('jpg', 'png', 'pdf'));
|
||||
if (isError($uploadDataResult))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
return $this->terminateWithError(getError($uploadDataResult), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$dms_id = $result->retval['dms_id'];
|
||||
|
||||
// If data exists
|
||||
if (hasData($uploadDataResult))
|
||||
{
|
||||
// Add file to the DMS (DB + file system)
|
||||
$dms_res = $this->dmslib->add(
|
||||
getData($uploadDataResult)['file_name'],
|
||||
getData($uploadDataResult)['file_type'],
|
||||
fopen(getData($uploadDataResult)['full_path'], 'r'),
|
||||
'Akte', // kategorie_kurzbz
|
||||
null, // dokument_kurzbz
|
||||
null, // beschreibung
|
||||
false, // cis_suche
|
||||
null, // schlagworte
|
||||
getAuthUID() // insertvon
|
||||
);
|
||||
}
|
||||
|
||||
// Error occurred or data not found
|
||||
if (isError($dms_res) || !hasData($dms_res)) $this->terminateWithError(getError($dms_res), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$dms_id = getData($dms_res)->dms_id;
|
||||
|
||||
$person_id = $this->_getPersonId($prestudent_id);
|
||||
|
||||
$result = $this->DokumentModel->load($dokument_kurzbz);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$dokumentResult = $this->DokumentModel->load($dokument_kurzbz);
|
||||
$data = $this->getDataOrTerminateWithError($dokumentResult);
|
||||
|
||||
$bezeichnung = current($data)->bezeichnung;
|
||||
|
||||
//save entry in akte
|
||||
if($dms_id)
|
||||
// Save entry in akte
|
||||
if ($dms_id)
|
||||
{
|
||||
$result = $this->AkteModel->insert([
|
||||
'person_id' => $person_id,
|
||||
@@ -384,7 +390,7 @@ class Dokumente extends FHCAPI_Controller
|
||||
'mimetype' => $_FILES['anhang']['type'],
|
||||
'insertamum' => date('c'),
|
||||
'erstelltam' => date('c'),
|
||||
'insertvon' => $uid,
|
||||
'insertvon' => getAuthUID(),
|
||||
'anmerkung_intern' => $anmerkung_intern,
|
||||
'titel_intern' => $titel_intern,
|
||||
'bezeichnung' => $bezeichnung,
|
||||
@@ -431,28 +437,26 @@ class Dokumente extends FHCAPI_Controller
|
||||
$filecontentbase64 = $data->inhalt;
|
||||
$filename = $data->titel;
|
||||
|
||||
if(intval($data->dms_id) > 0)
|
||||
if (intval($data->dms_id) > 0)
|
||||
{
|
||||
$dmsdokres = $this->dmslib->read($data->dms_id);
|
||||
if (!hasData($dmsdokres)) $this->terminateWithError('DMS File not found');
|
||||
$dmsdok = getData($dmsdokres)[0];
|
||||
$file = $this->dmslib->getOutputFileInfo($data->dms_id, $filename);
|
||||
|
||||
$mimetype = $dmsdok->mimetype;
|
||||
$filecontentbase64 = $dmsdok->file_content;
|
||||
$filename = $dmsdok->name;
|
||||
$this->terminateWithFileOutput(getData($file)->mimetype, file_get_contents(getData($file)->file), $filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
$filecontent = '';
|
||||
|
||||
$filecontent = '';
|
||||
if (!empty($filecontentbase64)) {
|
||||
$filecontent = base64_decode($filecontentbase64, true);
|
||||
|
||||
if (!empty($filecontentbase64)) {
|
||||
$filecontent = base64_decode($filecontentbase64, true);
|
||||
|
||||
if ($filecontent === false) {
|
||||
$this->terminateWithError('Base64-Dekodierung failed.');
|
||||
if ($filecontent === false) {
|
||||
$this->terminateWithError('Base64-Dekodierung failed.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->terminateWithFileOutput($mimetype, $filecontent, $filename);
|
||||
$this->terminateWithFileOutput($mimetype, $filecontent, $filename);
|
||||
}
|
||||
}
|
||||
|
||||
private function _getMissingDocuments($studiengang_kz, $prestudent_id)
|
||||
|
||||
@@ -33,11 +33,6 @@ class Notiz extends Notiz_Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/* public function getUid()
|
||||
{
|
||||
$this->terminateWithSuccess(getAuthUID());
|
||||
}*/
|
||||
|
||||
|
||||
public function getNotizen($id, $type)
|
||||
{
|
||||
@@ -59,317 +54,6 @@ class Notiz extends Notiz_Controller
|
||||
|
||||
}
|
||||
|
||||
/* public function loadNotiz()
|
||||
{
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
|
||||
//$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'notiz_id', 'LEFT');
|
||||
$this->NotizModel->addSelect('*');
|
||||
$this->NotizModel->addSelect("TO_CHAR(CASE WHEN public.tbl_notiz.updateamum >= public.tbl_notiz.insertamum
|
||||
THEN public.tbl_notiz.updateamum ELSE public.tbl_notiz.insertamum END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate");
|
||||
$this->NotizModel->addLimit(1);
|
||||
|
||||
$result = $this->NotizModel->loadWhere(
|
||||
array('notiz_id' => $notiz_id)
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
elseif (!hasData($result))
|
||||
{
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function updateNotiz()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
if (isset($_POST['data']))
|
||||
{
|
||||
$data = json_decode($_POST['data']);
|
||||
unset($_POST['data']);
|
||||
foreach ($data as $k => $v) {
|
||||
$_POST[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
|
||||
if(!$notiz_id)
|
||||
{
|
||||
$this->terminateWithError($this->p->t('ui','error_missingId',['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//Form Validation
|
||||
$this->form_validation->set_rules('titel', 'Titel', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('text', 'Text', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
//update Notiz
|
||||
$uid = getAuthUID();
|
||||
$titel = $this->input->post('titel');
|
||||
$text = $this->input->post('text');
|
||||
$verfasser_uid = $this->input->post('verfasser');
|
||||
$bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid;
|
||||
$erledigt = $this->input->post('erledigt');
|
||||
$start = $this->input->post('start');
|
||||
$ende = $this->input->post('ende');
|
||||
|
||||
$result = $this->NotizModel->update(
|
||||
[
|
||||
'notiz_id' => $notiz_id
|
||||
],
|
||||
[
|
||||
'titel' => $titel,
|
||||
'updatevon' => $uid,
|
||||
'updateamum' => date('c'),
|
||||
'text' => $text,
|
||||
'verfasser_uid' => $verfasser_uid,
|
||||
'bearbeiter_uid' => $bearbeiter_uid,
|
||||
'start' => $start,
|
||||
'ende' => $ende,
|
||||
'erledigt' => $erledigt
|
||||
]
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//update(1) laden aller bereits mit dieser notiz_id verknüpften DMS-Einträge
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
$this->NotizdokumentModel->addJoin('campus.tbl_dms_version', 'dms_id');
|
||||
$dms_uploaded = null;
|
||||
|
||||
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
elseif (!hasData($result))
|
||||
{
|
||||
$dms_id_arr = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = getData($result);
|
||||
foreach($result as $doc) {
|
||||
$dms_id_arr[] = array(
|
||||
'name' => $doc->name,
|
||||
'dms_id' => $doc->dms_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($_FILES as $k => $file)
|
||||
{
|
||||
//update(2) alle neuen files (alle außer type application/x.fhc-dms+json) anhängen
|
||||
if($file["type"] == 'application/x.fhc-dms+json')
|
||||
{
|
||||
$dms_uploaded[] = array(
|
||||
'name' => $file["name"]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'notiz',
|
||||
'version' => 0,
|
||||
'name' => $file["name"],
|
||||
'mimetype' => $file["type"],
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $uid
|
||||
);
|
||||
|
||||
//Todo(manu) check if filetypes weiter eingeschränkt werden sollen
|
||||
//Todo(manu)check name files: nicht gleiches file 2mal hochladen
|
||||
$result = $this->dmslib->upload($dms, $k, array('*'));
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$dms_id = $result->retval['dms_id'];
|
||||
|
||||
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//update(3) check if Dateien gelöscht wurden
|
||||
if(count($dms_uploaded) != count($dms_id_arr))
|
||||
{
|
||||
if (count($dms_uploaded) == 0)
|
||||
{
|
||||
$filesDeleted = $dms_id_arr;
|
||||
}
|
||||
else
|
||||
{
|
||||
$upload_new_names = array_column($dms_uploaded, "name");
|
||||
|
||||
$filesDeleted = array_filter($dms_id_arr, function ($file) use ($upload_new_names) {
|
||||
return !in_array($file["name"], $upload_new_names);
|
||||
});
|
||||
}
|
||||
|
||||
foreach ($filesDeleted as $file)
|
||||
{
|
||||
$result = $this->dmslib->removeAll($file['dms_id']);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
else
|
||||
$this->outputJson($result);
|
||||
}
|
||||
}
|
||||
return $this->terminateWithSuccess($result);
|
||||
}*/
|
||||
|
||||
|
||||
/* public function deleteNotiz()
|
||||
{
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
$type = $this->input->post('type_id');
|
||||
$id = $this->input->post('id');
|
||||
|
||||
//dms_id auslesen aus notizdokument wenn vorhanden
|
||||
$dms_id_arr = [];
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
|
||||
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if(hasData($result))
|
||||
{
|
||||
$result = getData($result);
|
||||
foreach ($result as $doc) {
|
||||
$dms_id_arr[] = $doc->dms_id;
|
||||
}
|
||||
}
|
||||
|
||||
if($dms_id_arr)
|
||||
{
|
||||
$this->load->library('DmsLib');
|
||||
foreach($dms_id_arr as $dms_id)
|
||||
{
|
||||
$result = $this->dmslib->removeAll($dms_id);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->outputJson($result);
|
||||
}
|
||||
}
|
||||
|
||||
//delete Notizzuordnung
|
||||
if($type == "software_id")
|
||||
{
|
||||
// Loads extension Model
|
||||
$this->load->model('extensions/FHC-Core-Softwarebereitstellung/Softwarenotizzuordnung_model', 'ExtensionnotizzuordnungModel');
|
||||
$result = $this->ExtensionnotizzuordnungModel->delete([
|
||||
'notiz_id' => $notiz_id,
|
||||
'id' => strval($id)
|
||||
],
|
||||
[
|
||||
'type_id' => $type
|
||||
]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//notizzuordnungsid!
|
||||
$result = $this->NotizzuordnungModel->delete(['notiz_id' => $notiz_id, $type => $id]);
|
||||
}
|
||||
|
||||
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
//$this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id');
|
||||
|
||||
//TODO (erweitern um Type_id) für Extensions, damit auch Notizzuordnung gelöscht werden kann
|
||||
|
||||
//Löschen von Notiz
|
||||
$result = $this->NotizModel->delete(
|
||||
array('notiz_id' => $notiz_id)
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if(!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
return $this->terminateWithSuccess(current(getData($result)));
|
||||
}*/
|
||||
|
||||
/* public function loadDokumente()
|
||||
{
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
|
||||
$this->NotizModel->addSelect('campus.tbl_dms_version.*');
|
||||
|
||||
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'ON (public.tbl_notiz_dokument.notiz_id = public.tbl_notiz.notiz_id)');
|
||||
$this->NotizModel->addJoin('campus.tbl_dms_version', 'ON (public.tbl_notiz_dokument.dms_id = campus.tbl_dms_version.dms_id)');
|
||||
|
||||
$result = $this->NotizModel->loadWhere(
|
||||
array('public.tbl_notiz.notiz_id' => $notiz_id)
|
||||
);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if(!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result));
|
||||
}*/
|
||||
|
||||
/* public function getMitarbeiter($searchString)
|
||||
{
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
$result = $this->MitarbeiterModel->searchMitarbeiter($searchString);
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess($result);
|
||||
}*/
|
||||
|
||||
public function isBerechtigt($id, $typeId)
|
||||
{
|
||||
if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid'))
|
||||
@@ -379,7 +63,6 @@ class Notiz extends Notiz_Controller
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return success("berechtigt in überschreibender Funktion");
|
||||
/* return $this->terminateWithError('keine Berechtigung bro', self::ERROR_TYPE_GENERAL);*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class Attachment extends FHC_Controller
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->dmslib->download($dms_id);
|
||||
$result = $this->dmslib->getOutputFileInfo($dms_id);
|
||||
if (isError($result))
|
||||
return show_error(getError($result));
|
||||
|
||||
|
||||
@@ -393,7 +393,7 @@ class approveAnrechnungDetail extends Auth_Controller
|
||||
$filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
|
||||
|
||||
// Get file to be downloaded from DMS
|
||||
$download = $this->dmslib->download($dms_id, $filename);
|
||||
$download = $this->dmslib->getOutputFileInfo($dms_id, $filename);
|
||||
if (isError($download)) return $download;
|
||||
|
||||
// Download file
|
||||
|
||||
@@ -282,7 +282,7 @@ class approveAnrechnungUebersicht extends Auth_Controller
|
||||
$filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
|
||||
|
||||
// Get file to be downloaded from DMS
|
||||
$download = $this->dmslib->download($dms_id, $filename);
|
||||
$download = $this->dmslib->getOutputFileInfo($dms_id, $filename);
|
||||
if (isError($download)) return $download;
|
||||
|
||||
// Download file
|
||||
|
||||
@@ -150,15 +150,12 @@ class CreateAnrechnung extends Auth_Controller
|
||||
}
|
||||
|
||||
// Upload document
|
||||
$result = self::_uploadFile();
|
||||
$result = $this->_uploadFile();
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithJsonError($result->retval);
|
||||
}
|
||||
if (isError($result)) $this->terminateWithJsonError(getError($result));
|
||||
|
||||
// Hold just inserted DMS ID
|
||||
$lastInsert_dms_id = $result->retval['dms_id'];
|
||||
$lastInsert_dms_id = getData($result)->dms_id;
|
||||
|
||||
// Save Anrechnung and Anrechnungstatus
|
||||
$result = $this->AnrechnungModel->createAnrechnungsantrag(
|
||||
@@ -227,17 +224,25 @@ class CreateAnrechnung extends Auth_Controller
|
||||
*/
|
||||
private function _uploadFile()
|
||||
{
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'anrechnung',
|
||||
'version' => 0,
|
||||
'name' => $_FILES['uploadfile']['name'],
|
||||
'mimetype' => $_FILES['uploadfile']['type'],
|
||||
'insertamum' => (new DateTime())->format('Y-m-d H:i:s'),
|
||||
'insertvon' => $this->_uid
|
||||
);
|
||||
|
||||
// Upload document
|
||||
return $this->dmslib->upload($dms, 'uploadfile', array('pdf'));
|
||||
$uploadDataResult = uploadFile('uploadfile', array('pdf'));
|
||||
|
||||
// If an error occurred while uploading the file
|
||||
if (isError($uploadDataResult)) return $uploadDataResult;
|
||||
if (!hasData($uploadDataResult)) return error('Upload failed');
|
||||
|
||||
// Add file to the DMS (DB + file system)
|
||||
return $this->_ci->dmslib->add(
|
||||
getData($uploadDataResult)['file_name'],
|
||||
getData($uploadDataResult)['file_type'],
|
||||
fopen(getData($uploadDataResult)['full_path'], 'r'),
|
||||
'anrechnung', // kategorie_kurzbz
|
||||
null, // dokument_kurzbz
|
||||
null, // beschreibung
|
||||
false, // cis_suche
|
||||
null, // schlagworte
|
||||
getAuthUID() // insertvon
|
||||
);
|
||||
}
|
||||
|
||||
private function _LVhasBlockingGrades($studiensemester_kurzbz, $lehrveranstaltung_id, $prestudent_id)
|
||||
@@ -268,4 +273,4 @@ class CreateAnrechnung extends Auth_Controller
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class requestAnrechnung extends Auth_Controller
|
||||
$is_expired = $this->_isExpired($studiensemester_kurzbz);
|
||||
|
||||
// Check if Lehrveranstaltung was already graded with application blocking grades
|
||||
$is_blocked = self::_LVhasBlockingGrades($studiensemester_kurzbz, $lehrveranstaltung_id);
|
||||
$is_blocked = $this->_LVhasBlockingGrades($studiensemester_kurzbz, $lehrveranstaltung_id);
|
||||
|
||||
// Get Anrechung data
|
||||
$anrechnungData = $this->anrechnunglib->getAnrechnungDataByLv($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id);
|
||||
@@ -152,27 +152,24 @@ class requestAnrechnung extends Auth_Controller
|
||||
$prestudent_id = getData($result)[0]->prestudent_id;
|
||||
|
||||
// Exit if application already exists
|
||||
if (self::_applicationExists($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id))
|
||||
if ($this->_applicationExists($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id))
|
||||
{
|
||||
return $this->outputJsonError($this->p->t('anrechnung', 'antragBereitsGestellt'));
|
||||
}
|
||||
|
||||
// Exit if application is a past ( < actual ) studysemester
|
||||
if (self::_applicationIsPastSS($studiensemester_kurzbz))
|
||||
if ($this->_applicationIsPastSS($studiensemester_kurzbz))
|
||||
{
|
||||
return $this->outputJsonError($this->p->t('anrechnung', 'antragNichtFuerVerganganeSS'));
|
||||
}
|
||||
|
||||
// Upload document
|
||||
$result = self::_uploadFile();
|
||||
$result = $this->_uploadFile();
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->outputJsonError($result->retval);
|
||||
}
|
||||
if (isError($result)) return $this->outputJsonError(getError($result));
|
||||
|
||||
// Hold just inserted DMS ID
|
||||
$lastInsert_dms_id = $result->retval['dms_id'];
|
||||
$lastInsert_dms_id = getData($result)->dms_id;
|
||||
|
||||
// Save Anrechnung and Anrechnungstatus
|
||||
$result = $this->AnrechnungModel->createAnrechnungsantrag(
|
||||
@@ -182,8 +179,8 @@ class requestAnrechnung extends Auth_Controller
|
||||
$begruendung_id,
|
||||
$lastInsert_dms_id,
|
||||
$anmerkung,
|
||||
$begruendung_ects,
|
||||
$begruendung_lvinhalt
|
||||
$begruendung_ects,
|
||||
$begruendung_lvinhalt
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
@@ -215,11 +212,11 @@ class requestAnrechnung extends Auth_Controller
|
||||
$this->_checkIfEntitledToReadDMSDoc($dms_id);
|
||||
|
||||
// Get file to be downloaded from DMS
|
||||
$download = $this->dmslib->download($dms_id);
|
||||
if (isError($download)) return $download;
|
||||
$download = $this->dmslib->getOutputFileInfo($dms_id);
|
||||
if (isError($download)) return $download;
|
||||
|
||||
// Download file
|
||||
$this->outputFile(getData($download));
|
||||
// Download file
|
||||
$this->outputFile(getData($download));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -367,16 +364,25 @@ class requestAnrechnung extends Auth_Controller
|
||||
*/
|
||||
private function _uploadFile()
|
||||
{
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'anrechnung',
|
||||
'version' => 0,
|
||||
'name' => $_FILES['uploadfile']['name'],
|
||||
'mimetype' => $_FILES['uploadfile']['type'],
|
||||
'insertamum' => (new DateTime())->format('Y-m-d H:i:s'),
|
||||
'insertvon' => $this->_uid
|
||||
);
|
||||
|
||||
// Upload document
|
||||
return $this->dmslib->upload($dms, 'uploadfile', array('pdf'));
|
||||
$uploadDataResult = uploadFile('uploadfile', array('pdf'));
|
||||
|
||||
// If an error occurred while uploading the file
|
||||
if (isError($uploadDataResult)) return $uploadDataResult;
|
||||
// If an error occurred while uploading the file
|
||||
if (!hasData($uploadDataResult)) return error('Upload failed');
|
||||
|
||||
// Add file to the DMS (DB + file system)
|
||||
return $this->_ci->dmslib->add(
|
||||
getData($uploadDataResult)['file_name'],
|
||||
getData($uploadDataResult)['file_type'],
|
||||
fopen(getData($uploadDataResult)['full_path'], 'r'),
|
||||
'anrechnung'
|
||||
null, // dokument_kurzbz
|
||||
null, // beschreibung
|
||||
false, // cis_suche
|
||||
null, // schlagworte
|
||||
getAuthUID() // insertvon
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ class reviewAnrechnungDetail extends Auth_Controller
|
||||
$filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
|
||||
|
||||
// Get file to be downloaded from DMS
|
||||
$download = $this->dmslib->download($dms_id, $filename);
|
||||
$download = $this->dmslib->getOutputFileInfo($dms_id, $filename);
|
||||
if (isError($download)) return $download;
|
||||
|
||||
// Download file
|
||||
|
||||
@@ -196,7 +196,7 @@ class reviewAnrechnungUebersicht extends Auth_Controller
|
||||
$filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
|
||||
|
||||
// Get file to be downloaded from DMS
|
||||
$download = $this->dmslib->download($dms_id, $filename);
|
||||
$download = $this->dmslib->getOutputFileInfo($dms_id, $filename);
|
||||
if (isError($download)) return $download;
|
||||
|
||||
// Download file
|
||||
|
||||
@@ -147,12 +147,13 @@ abstract class FHC_Controller extends CI_Controller
|
||||
// If the file exists
|
||||
if (isset($fileObj->file) && !isEmptyString($fileObj->file) && file_exists($fileObj->file))
|
||||
{
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: '. $fileObj->mimetype);
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($fileObj->file));
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
|
||||
if (isset($fileObj->disposition)
|
||||
&& ($fileObj->disposition == 'inline' || $fileObj->disposition == 'attachment'))
|
||||
|
||||
@@ -203,26 +203,39 @@ abstract class Notiz_Controller extends FHCAPI_Controller
|
||||
$dms_id_arr = [];
|
||||
foreach ($_FILES as $k => $file)
|
||||
{
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'notiz',
|
||||
'version' => 0,
|
||||
'name' => $file["name"],
|
||||
'mimetype' => $file["type"],
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $uid
|
||||
);
|
||||
|
||||
//Todo(manu) check if filetypes weiter eingeschränkt werden sollen
|
||||
//Todo(manu)check name files: nicht gleiches file 2mal hochladen
|
||||
//Todo define in dms component: readFile, downloadFile
|
||||
$result = $this->dmslib->upload($dms, $k, ['*']);
|
||||
/* $result = $this->dmslib->upload($dms, $k, ['application/pdf','application/x.fhc-dms+json']);*/
|
||||
if (isError($result))
|
||||
$uploadDataResult = uploadFile($k);
|
||||
if (isError($uploadDataResult))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$this->terminateWithError(getError($uploadDataResult), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$dms_id_arr[] = $result->retval['dms_id'];
|
||||
if (!hasData($uploadDataResult))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
$this->terminateWithError('Upload failed', self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
// Add file to the DMS (DB + file system)
|
||||
$addResult = $this->dmslib->add(
|
||||
getData($uploadDataResult)['file_name'],
|
||||
getData($uploadDataResult)['file_type'],
|
||||
fopen(getData($uploadDataResult)['full_path'], 'r'),
|
||||
'notiz', // kategorie_kurzbz
|
||||
null, // dokument_kurzbz
|
||||
null, // beschreibung
|
||||
false, // cis_suche
|
||||
null, // schlagworte
|
||||
getAuthUID() // insertvon
|
||||
);
|
||||
|
||||
// If error occurred
|
||||
if (isError($addResult) || !hasData($addResult))
|
||||
$this->terminateWithError(getError($addResult), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$dms_id_arr[] = getData($addResult)->dms_id;
|
||||
}
|
||||
|
||||
//save entry in Notizdokument
|
||||
@@ -334,22 +347,40 @@ abstract class Notiz_Controller extends FHCAPI_Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'notiz',
|
||||
'version' => 0,
|
||||
'name' => $file["name"],
|
||||
'mimetype' => $file["type"],
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $uid
|
||||
);
|
||||
|
||||
//Todo(manu) check if filetypes weiter eingeschränkt werden sollen
|
||||
//Todo(manu)check name files: nicht gleiches file 2mal hochladen
|
||||
//Todo define in dms component: readFile, downloadFile
|
||||
$result = $this->dmslib->upload($dms, $k, array('*'));
|
||||
$uploadDataResult = uploadFile($k);
|
||||
if (isError($uploadDataResult))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
$this->terminateWithError(getError($uploadDataResult), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if (!hasData($uploadDataResult))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
$this->terminateWithError('Upload failed', self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
$dms_id = $result['dms_id'];
|
||||
// Add file to the DMS (DB + file system)
|
||||
$addResult = $this->dmslib->add(
|
||||
getData($uploadDataResult)['file_name'],
|
||||
getData($uploadDataResult)['file_type'],
|
||||
fopen(getData($uploadDataResult)['full_path'], 'r'),
|
||||
'notiz', // kategorie_kurzbz
|
||||
null, // dokument_kurzbz
|
||||
null, // beschreibung
|
||||
false, // cis_suche
|
||||
null, // schlagworte
|
||||
getAuthUID() // insertvon
|
||||
);
|
||||
|
||||
// If error occurred
|
||||
if (isError($addResult) || !hasData($addResult))
|
||||
$this->terminateWithError(getError($addResult), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$addResult = $this->getDataOrTerminateWithError($addResult);
|
||||
$dms_id = $addResult['dms_id'];
|
||||
|
||||
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
|
||||
|
||||
@@ -476,4 +507,4 @@ abstract class Notiz_Controller extends FHCAPI_Controller
|
||||
return $this->terminateWithSuccess($anzahl->anzahl ?: 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,6 +423,27 @@ function isValidDate($dateString)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to upload a file
|
||||
*/
|
||||
function uploadFile($post_field_name, $allowed_types = array('*'))
|
||||
{
|
||||
$ci =& get_instance(); // get CI instance
|
||||
$ci->load->library(
|
||||
'upload',
|
||||
array(
|
||||
'upload_path' => sys_get_temp_dir(),
|
||||
'allowed_types' => $allowed_types,
|
||||
'overwrite' => true
|
||||
)
|
||||
);
|
||||
|
||||
// If the upload was a success then return the uploaded file info
|
||||
if ($ci->upload->do_upload($post_field_name)) return success($ci->upload->data());
|
||||
|
||||
// If an error occurred then return it
|
||||
return error($ci->upload->display_errors('', ''));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// PHP functions that don't exist in older versions
|
||||
@@ -434,10 +455,10 @@ function isValidDate($dateString)
|
||||
if (!function_exists('array_is_list')) {
|
||||
function array_is_list(array $arr)
|
||||
{
|
||||
if ($arr === []) {
|
||||
return true;
|
||||
}
|
||||
return array_keys($arr) === range(0, count($arr) - 1);
|
||||
if ($arr === []) {
|
||||
return true;
|
||||
}
|
||||
return array_keys($arr) === range(0, count($arr) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
class AkteLib
|
||||
{
|
||||
const AKTE_KATEGORIE_KURZBZ = 'Akte'; // kategorie_kurzbz of dms when inserting for akte
|
||||
const FILE_CONTENT_PROPERTY = 'file_content';
|
||||
|
||||
private $_ci; // Code igniter instance
|
||||
private $_who; // who added this document
|
||||
@@ -180,57 +181,16 @@ class AkteLib
|
||||
*/
|
||||
public function remove($akte_id)
|
||||
{
|
||||
// get dms_id for akte
|
||||
$this->_ci->AkteModel->addSelect('dms_id');
|
||||
$akteResult = $this->_ci->AkteModel->load($akte_id);
|
||||
return $this->_remove($akte_id, null, null);
|
||||
}
|
||||
|
||||
if (isError($akteResult)) return $akteResult;
|
||||
|
||||
if (!hasData($akteResult)) return error("Akte not found");
|
||||
|
||||
$dms_id = getData($akteResult)[0]->dms_id;
|
||||
$error = null;
|
||||
|
||||
// Start DB transaction to avoid deleting only part of the data
|
||||
$this->_ci->db->trans_begin();
|
||||
|
||||
// delete Akte
|
||||
$deleteResult = $this->_ci->AkteModel->delete($akte_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;
|
||||
}
|
||||
/**
|
||||
* Removes Akte by $person_id and $dms_id, removes all associated dms entries and versions, and deletes all associated files
|
||||
* Returns success with removed version numbers or error
|
||||
*/
|
||||
public function removeByPersonIdAndDmsId($person_id, $dms_id)
|
||||
{
|
||||
return $this->_remove(null, $person_id, $dms_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,7 +293,7 @@ class AkteLib
|
||||
if (isError($dmsResult)) return $dmsResult;
|
||||
|
||||
// properties to retrieve from dms
|
||||
$dmsProperties = array('version', 'filename', 'mimetype', 'name', 'beschreibung', 'cis_suche', 'schlagworte', DmsLib::FILE_CONTENT_PROPERTY);
|
||||
$dmsProperties = array('version', 'filename', 'mimetype', 'name', 'beschreibung', 'cis_suche', 'schlagworte', AkteLib::FILE_CONTENT_PROPERTY);
|
||||
|
||||
// set dms properties
|
||||
if (hasData($dmsResult))
|
||||
@@ -363,5 +323,71 @@ class AkteLib
|
||||
// return the object containing akte and dms data
|
||||
return success(getData($akteResult));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes Akte by akte Id, person id and/or dms id
|
||||
* Removes all associated dms entries and versions, and deletes all associated files
|
||||
* Returns success with removed version numbers or error
|
||||
*/
|
||||
private function _remove($akte_id = null, $person_id = null, $dms_id = null)
|
||||
{
|
||||
// Get dms_id for akte
|
||||
$this->_ci->AkteModel->addSelect('dms_id');
|
||||
|
||||
$paramArray = array();
|
||||
|
||||
if (is_int($akte_id)) $paramArray['akte_id'] = $akte_id;
|
||||
if (is_int($person_id)) $paramArray['person_id'] = $person_id;
|
||||
if (is_int($dms_id)) $paramArray['dms_id'] = $dms_id;
|
||||
|
||||
$akteResult = $this->_ci->AkteModel->loadWhere($paramArray);
|
||||
|
||||
if (isError($akteResult)) return $akteResult;
|
||||
|
||||
if (!hasData($akteResult)) return error("Akte not found");
|
||||
|
||||
$dms_id = getData($akteResult)[0]->dms_id;
|
||||
$error = null;
|
||||
|
||||
// Start DB transaction to avoid deleting only part of the data
|
||||
$this->_ci->db->trans_begin();
|
||||
|
||||
// delete Akte
|
||||
$deleteResult = $this->_ci->AkteModel->delete($akte_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,9 @@ use \stdClass as stdClass;
|
||||
|
||||
class DmsLib
|
||||
{
|
||||
const FILE_CONTENT_PROPERTY = 'file_content'; // property name for file content
|
||||
|
||||
private $_UPLOAD_PATH; // temporary directory to store the uploaded file
|
||||
const DMS_SYS_NAME = 'DMS System';
|
||||
|
||||
private $_ci; // code igniter instance
|
||||
private $_who; // who added this document
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
@@ -38,13 +35,6 @@ class DmsLib
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
$this->_UPLOAD_PATH = APPPATH.'tmp/';
|
||||
|
||||
// Set the the _who property
|
||||
$this->_who = 'DMS system'; // default
|
||||
// It is possible to set it using the who parameter
|
||||
if (!isEmptyArray($params) && isset($params['who']) && !isEmptyString($params['who'])) $this->_who = $params['who'];
|
||||
|
||||
$this->_ci->load->model('content/Dms_model', 'DmsModel');
|
||||
$this->_ci->load->model('content/DmsVersion_model', 'DmsVersionModel');
|
||||
$this->_ci->load->model('content/DmsFS_model', 'DmsFSModel');
|
||||
@@ -58,69 +48,85 @@ class DmsLib
|
||||
* Returns success info of added dms entry (dms_id, version, filename) or error
|
||||
*/
|
||||
public function add(
|
||||
$name, $mimetype, $fileHandle, // Required parameters
|
||||
$kategorie_kurzbz = null, $dokument_kurzbz = null, $beschreibung = null, $cis_suche = false, $schlagworte = null
|
||||
// Required parameters
|
||||
$name, $mimetype, $fileHandle,
|
||||
// Optional parameters
|
||||
$kategorie_kurzbz = null, $dokument_kurzbz = null, $beschreibung = null, $cis_suche = false, $schlagworte = null, $insertvon = self::DMS_SYS_NAME
|
||||
)
|
||||
{
|
||||
// create unique filename, using original document name to detect file extension
|
||||
$filename = $this->_getUniqueFilename($name);
|
||||
// If the file handle is not valid
|
||||
if ($fileHandle === false) return error('Was not possible to open the given file');
|
||||
|
||||
// copy file from fileHandle to dms folder
|
||||
$copyFileResult = $this->_copyFile($fileHandle, $filename);
|
||||
// Create unique filename, using original document name to detect file extension
|
||||
$filename = $this->_getUniqueFilename($name);
|
||||
|
||||
if (isError($copyFileResult)) return $copyFileResult;
|
||||
// Copy file from fileHandle to dms folder
|
||||
$copyFileResult = $this->_copyFile($fileHandle, $filename);
|
||||
|
||||
// if file written successful, insert dms
|
||||
$dmsResult = $this->_ci->DmsModel->insert(
|
||||
array(
|
||||
'kategorie_kurzbz' => $kategorie_kurzbz,
|
||||
'dokument_kurzbz' => $dokument_kurzbz
|
||||
)
|
||||
// If an error occrured while copying the file
|
||||
if (isError($copyFileResult)) return $copyFileResult;
|
||||
|
||||
// Insert the new DMS
|
||||
$dmsResult = $this->_ci->DmsModel->insert(
|
||||
array(
|
||||
'kategorie_kurzbz' => $kategorie_kurzbz,
|
||||
'dokument_kurzbz' => $dokument_kurzbz
|
||||
)
|
||||
);
|
||||
|
||||
// If an error occurred
|
||||
if (isError($dmsResult)) return $dmsResult;
|
||||
|
||||
// If a DMS in the previous insert returned the new PK value
|
||||
if (hasData($dmsResult))
|
||||
{
|
||||
$dms_id = getData($dmsResult);
|
||||
|
||||
// Insert the DMS version
|
||||
$dmsVersion = array(
|
||||
'dms_id' => $dms_id,
|
||||
'version' => 0,
|
||||
'filename' => $filename,
|
||||
'mimetype' => $mimetype,
|
||||
'name' => $name,
|
||||
'beschreibung' => $beschreibung,
|
||||
'cis_suche' => $cis_suche,
|
||||
'schlagworte' => $schlagworte,
|
||||
'insertvon' => $insertvon,
|
||||
'insertamum' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
if (isError($dmsResult)) return $dmsResult;
|
||||
$dmsVersionResult = $this->_ci->DmsVersionModel->insert($dmsVersion);
|
||||
|
||||
if (hasData($dmsResult))
|
||||
{
|
||||
$dms_id = getData($dmsResult);
|
||||
$version = 0;
|
||||
// If an error occured
|
||||
if (isError($dmsVersionResult)) return $dmsVersionResult;
|
||||
|
||||
// insert dms version
|
||||
$dmsVersion = array(
|
||||
'dms_id' => $dms_id,
|
||||
'version' => $version,
|
||||
'filename' => $filename,
|
||||
'mimetype' => $mimetype,
|
||||
'name' => $name,
|
||||
'beschreibung' => $beschreibung,
|
||||
'cis_suche' => $cis_suche,
|
||||
'schlagworte' => $schlagworte,
|
||||
'insertvon' => $this->_who,
|
||||
'insertamum' => date('Y-m-d H:i:s')
|
||||
);
|
||||
// Return dms info
|
||||
$resObj = new stdClass();
|
||||
$resObj->dms_id = $dms_id;
|
||||
$resObj->version = 0;
|
||||
$resObj->filename = $filename;
|
||||
|
||||
$dmsVersionResult = $this->_ci->DmsVersionModel->insert($dmsVersion);
|
||||
|
||||
if (isError($dmsVersionResult)) return $dmsVersionResult;
|
||||
|
||||
// return dms info
|
||||
$resObj = new stdClass();
|
||||
$resObj->dms_id = $dms_id;
|
||||
$resObj->version = $version;
|
||||
$resObj->filename = $filename;
|
||||
|
||||
return success($resObj);
|
||||
}
|
||||
else
|
||||
return success();
|
||||
return success($resObj);
|
||||
}
|
||||
else
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a new file with content of fileHandle, adds a new dms version (max version number + 1) for the written file
|
||||
* Returns success with info of added dms version (version, filename) or error
|
||||
*/
|
||||
public function addNewVersion($dms_id, $fileHandle, $name = null, $mimetype = null, $beschreibung = null, $cis_suche = false, $schlagworte = null)
|
||||
public function addNewVersion(
|
||||
// Required parameters
|
||||
$dms_id, $fileHandle,
|
||||
// Optional parameters
|
||||
$name = null, $mimetype = null, $beschreibung = null, $cis_suche = false, $schlagworte = null, $insertvon = self::DMS_SYS_NAME
|
||||
)
|
||||
{
|
||||
// If the file handle is not valid
|
||||
if ($fileHandle === false) return error('Was not possible to open the given file');
|
||||
|
||||
// get the latest version
|
||||
$lastVersionResult = $this->getLastVersion($dms_id);
|
||||
|
||||
@@ -153,7 +159,7 @@ class DmsLib
|
||||
'beschreibung' => isset($beschreibung) ? $beschreibung : $lastVersion->beschreibung,
|
||||
'cis_suche' => isset($cis_suche) ? $cis_suche : $lastVersion->cis_suche,
|
||||
'schlagworte' => isset($schlagworte) ? $schlagworte : $lastVersion->schlagworte,
|
||||
'insertvon' => $this->_who,
|
||||
'insertvon' => $insertvon,
|
||||
'insertamum' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
@@ -179,6 +185,9 @@ class DmsLib
|
||||
*/
|
||||
public function updateLastVersion($dms_id, $fileHandle, $name = null, $mimetype = null, $beschreibung = null, $cis_suche = false, $schlagworte = null)
|
||||
{
|
||||
// If the file handle is not valid
|
||||
if ($fileHandle === false) return error('Was not possible to open the given file');
|
||||
|
||||
// get the latest version
|
||||
$lastVersionResult = $this->getLastVersion($dms_id);
|
||||
|
||||
@@ -225,7 +234,7 @@ class DmsLib
|
||||
|
||||
/**
|
||||
* Gets dms version with highest number
|
||||
* Returns success with dms data and fileHandle with file content or error
|
||||
* Returns success with dms data or error
|
||||
*/
|
||||
public function getLastVersion($dms_id)
|
||||
{
|
||||
@@ -254,7 +263,7 @@ class DmsLib
|
||||
|
||||
/**
|
||||
* Gets specified dms version
|
||||
* Returns success with dms data and fileHandle with file content or error
|
||||
* Returns success with dms data or error
|
||||
*/
|
||||
public function getVersion($dms_id, $version)
|
||||
{
|
||||
@@ -266,11 +275,7 @@ class DmsLib
|
||||
)
|
||||
);
|
||||
|
||||
if (isError($dmsVersionResult)) return $dmsVersionResult;
|
||||
|
||||
if (hasData($dmsVersionResult)) return getData($dmsVersionResult)[0];
|
||||
|
||||
return success();
|
||||
return $dmsVersionResult;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,21 +414,6 @@ class DmsLib
|
||||
return success($removeVersionResultObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform an upload of a file spcifically for the DMS and returns the uploaded file info
|
||||
*/
|
||||
public function upload($allowed_types = array('*'))
|
||||
{
|
||||
// Loads the CI upload library
|
||||
$this->_loadUploadLibrary($allowed_types);
|
||||
|
||||
// If the upload was a success then return the uploaded file info
|
||||
if ($this->_ci->upload->do_upload(DmsLib::FILE_CONTENT_PROPERTY)) return success($this->_ci->upload->data());
|
||||
|
||||
// If an error occurred then return it
|
||||
return error($this->_ci->upload->display_errors('', ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get info from the DMS to be provided to the FHC_Controller->outputFile
|
||||
*/
|
||||
@@ -438,7 +428,7 @@ class DmsLib
|
||||
// If has been found
|
||||
if (hasData($lastVersionResult))
|
||||
{
|
||||
$lastVersion = getData(lastVersionResult)[0];
|
||||
$lastVersion = getData($lastVersionResult)[0];
|
||||
|
||||
$fileObj = new stdClass();
|
||||
$fileObj->filename = $lastVersion->filename;
|
||||
@@ -507,20 +497,5 @@ class DmsLib
|
||||
|
||||
return $uniqueFilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the upload library of CI
|
||||
*/
|
||||
private function _loadUploadLibrary($allowed_types)
|
||||
{
|
||||
$this->_ci->load->library(
|
||||
'upload',
|
||||
array(
|
||||
'upload_path' => $this->_UPLOAD_PATH,
|
||||
'allowed_types' => $allowed_types,
|
||||
'overwrite' => true
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user