From 5743d05478f234bc509bc77f9d67d67f9c56e4ee Mon Sep 17 00:00:00 2001 From: Andreas Moik Date: Thu, 28 Jul 2016 13:30:09 +0200 Subject: [PATCH] bugfixes --- content/dokumentenakt.pdf.php | 54 +++++++++++++++---------------- include/dokument_export.class.php | 4 ++- include/pdf.class.php | 2 +- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/content/dokumentenakt.pdf.php b/content/dokumentenakt.pdf.php index 8755bf3b3..de6401bdf 100755 --- a/content/dokumentenakt.pdf.php +++ b/content/dokumentenakt.pdf.php @@ -68,21 +68,6 @@ foreach($prestudent_ids as $pid) if(!$prestudent->load($pid)) cleanUpAndDie($p->t('tools/studentWurdeNichtGefunden')."(".$pid.")", $tmpDir); - /* - * Deckblatt - */ - $filename = $tmpDir . "/".uniqid(); - $doc = new dokument_export('Bewerberakt'); - $doc->addDataArray(array('vorname' => $prestudent->vorname, 'nachname' => $prestudent->nachname),'bewerberakt'); - - if(!$doc->create('pdf')) - die($doc->errormsg); -// $doc->temp_filename = $filename; - $document = $doc->output(false); - $filename = $tmpDir.'/'.uniqid(); - file_put_contents($filename, $document); - $doc->close(); - $allDocs[] = $filename; /* @@ -100,25 +85,24 @@ foreach($prestudent_ids as $pid) AND prestudent_id='.$db->db_add_param($pid, FHC_INTEGER).'; '; + $preDocs = array(); $result = $db->db_query($query); while($row = $db->db_fetch_object($result)) { - - $filename = ""; - if($row->dms_id != null) + if($row->inhalt != null) + { + $filename = $tmpDir . "/".uniqid(); + $fileData = base64_decode($row->inhalt); + file_put_contents($filename, $fileData); + } + else if($row->dms_id != null) { $dms = new dms(); $dms->load($row->dms_id); $filename = DMS_PATH . $dms->filename; } - else if($row->inhalt != null) - { - $filename = $tmpDir . "/".uniqid(); - $fileData = base64_decode($row->inhalt); - file_put_contents($filename, $fileData); - } if($filename == "") @@ -146,16 +130,30 @@ foreach($prestudent_ids as $pid) { $fullFilename = $row->titel; } - else - cleanUpAndDie("falscher typ TODO", $tmpDir); // only filled, if the file is supported if($fullFilename != "") { - $allDocs[] = $fullFilename; + $preDocs[] = $fullFilename; } - } + + /* + * Deckblatt + */ + $filename = $tmpDir . "/".uniqid(); + $doc = new dokument_export($_GET["vorlage_kurzbz"]); + $doc->addDataArray(array('vorname' => $prestudent->vorname, 'nachname' => $prestudent->nachname),"bewerberakt"); + + if(!$doc->create('pdf')) + die($doc->errormsg); + + $document = $doc->output(false); + $filename = $tmpDir.'/'.uniqid(); + file_put_contents($filename, $document); + $doc->close(); + $allDocs[] = $filename; + $allDocs = array_merge($allDocs, $preDocs); } diff --git a/include/dokument_export.class.php b/include/dokument_export.class.php index c06f29abb..f78a8c86e 100644 --- a/include/dokument_export.class.php +++ b/include/dokument_export.class.php @@ -256,6 +256,7 @@ class dokument_export case 'pdf': $this->temp_filename='out.pdf'; exec("unoconv -e IsSkipEmptyPages=false --stdout -f pdf $tempname_zip > ".$this->temp_filename, $out, $ret); + if($ret!=0) { $this->errormsg = 'Dokumentenkonvertierung ist derzeit nicht möglich. Bitte informieren Sie den Administrator'; @@ -341,8 +342,9 @@ class dokument_export if($this->styles_xsl!='') unlink('styles.xml'); - unlink('out.zip'); unlink($this->temp_filename); + if(file_exists("out.zip")) + unlink('out.zip'); if(count($this->images)>0) { diff --git a/include/pdf.class.php b/include/pdf.class.php index 033c0f5a6..6d0cc7fc7 100644 --- a/include/pdf.class.php +++ b/include/pdf.class.php @@ -44,7 +44,7 @@ class Pdf } if(finfo_file($finfo, $f) != "application/pdf") { - $this->errormsg = "Wrong format: '$f'"; + $this->errormsg = "Wrong format(".finfo_file($finfo, $f)."): '$f'"; return false; } }