From 3986d7a89fa7f89d35ef83440a047fc7cbdd6596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Wed, 26 Sep 2018 07:44:49 +0200 Subject: [PATCH] =?UTF-8?q?Zus=C3=A4tzliche=20Pr=C3=BCfung=20hinzugef?= =?UTF-8?q?=C3=BCgt=20beim=20Download=20von=20Notizdokumenten=20ob=20diese?= =?UTF-8?q?=20auch=20tats=C3=A4chlich=20an=20einer=20Notiz=20h=C3=A4ngen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/notizdokdownload.php | 19 +++--- include/notiz.class.php | 113 +++++++++++++++++++++-------------- 2 files changed, 80 insertions(+), 52 deletions(-) diff --git a/content/notizdokdownload.php b/content/notizdokdownload.php index 90fde00d0..227149a0d 100644 --- a/content/notizdokdownload.php +++ b/content/notizdokdownload.php @@ -22,9 +22,10 @@ * oder im Filesystem, in diesem Fall ist die Akte mit einer DMS ID verknuepft in welcher der Dateiname steht. */ require_once('../config/vilesci.config.inc.php'); -require_once('../include/dms.class.php'); +require_once('../include/dms.class.php'); require_once('../include/benutzerberechtigung.class.php'); require_once('../include/functions.inc.php'); +require_once('../include/notiz.class.php'); $user = get_uid(); $rechte = new benutzerberechtigung(); @@ -34,11 +35,15 @@ if(!$rechte->isBerechtigt('admin') && !$rechte->isBerechtigt('assistenz') && !$r if(isset($_GET['id']) && is_numeric($_GET['id'])) { - $dms = new dms(); - if(!$dms->load($_GET['id'])) - die('Kein Dokument vorhanden'); + $notiz = new notiz(); + if(!$notiz->isNotizDokument($_GET['id'])) + die('Dokument wurde nicht gefunden oder haengt nicht an einer Notiz'); - $filename=DMS_PATH.$dms->filename; + $dms = new dms(); + if(!$dms->load($_GET['id'])) + die('Kein Dokument vorhanden'); + + $filename=DMS_PATH.$dms->filename; if(!isset($_GET['notimeupdate'])) $dms->touch($dms->dms_id, $dms->version); @@ -54,7 +59,7 @@ if(isset($_GET['id']) && is_numeric($_GET['id'])) header('Content-Disposition: inline; filename="'.$dms->name.'"'); header('Content-Length: ' .filesize($filename)); - while (!feof($handle)) + while (!feof($handle)) { echo fread($handle, 8192); } @@ -71,4 +76,4 @@ else echo "Ungueltige DMS-ID"; } -?> \ No newline at end of file +?> diff --git a/include/notiz.class.php b/include/notiz.class.php index 08ba10e41..63f15638d 100644 --- a/include/notiz.class.php +++ b/include/notiz.class.php @@ -24,7 +24,7 @@ class notiz extends basis_db { public $new; public $result=array(); - public $dokumente=array(); + public $dokumente=array(); //Tabellenspalten public $notiz_id; @@ -40,15 +40,15 @@ class notiz extends basis_db public $updateamum; public $updatevon; - public $projekt_kurzbz; - public $projektphase_id; - public $projekttask_id; - public $uid; - public $person_id; - public $prestudent_id; - public $bestellung_id; - public $lehreinheit_id; - public $anrechnung_id; + public $projekt_kurzbz; + public $projektphase_id; + public $projekttask_id; + public $uid; + public $person_id; + public $prestudent_id; + public $bestellung_id; + public $lehreinheit_id; + public $anrechnung_id; /** * Konstruktor @@ -93,7 +93,7 @@ class notiz extends basis_db $this->insertvon=$row->insertvon; $this->updateamum=$row->updateamum; $this->updatevon=$row->updatevon; - $this->getDokumente($row->notiz_id); + $this->getDokumente($row->notiz_id); return true; } @@ -123,17 +123,17 @@ class notiz extends basis_db return false; } - // Dokumente der Notiz löschen - $this->getDokumente($notiz_id); - if(!empty($this->dokumente)) - { - $dms = new dms(); + // Dokumente der Notiz löschen + $this->getDokumente($notiz_id); + if(!empty($this->dokumente)) + { + $dms = new dms(); - foreach($this->dokumente as $dms_id) - { - $dms->deleteDms($dms_id); - } - } + foreach($this->dokumente as $dms_id) + { + $dms->deleteDms($dms_id); + } + } $qry = "Delete FROM public.tbl_notiz WHERE notiz_id=".$this->db_add_param($notiz_id, FHC_INTEGER); @@ -267,14 +267,14 @@ class notiz extends basis_db } } - /** - * Speichert ein Dokument zur Notiz - * @param int $dms_id - * @return boolean - */ - public function saveDokument($dms_id) - { - $qry = "INSERT INTO public.tbl_notiz_dokument(notiz_id, dms_id) VALUES(". + /** + * Speichert ein Dokument zur Notiz + * @param int $dms_id + * @return boolean + */ + public function saveDokument($dms_id) + { + $qry = "INSERT INTO public.tbl_notiz_dokument(notiz_id, dms_id) VALUES(". $this->db_add_param($this->notiz_id, FHC_INTEGER).','. $this->db_add_param($dms_id, FHC_INTEGER).');'; @@ -287,7 +287,7 @@ class notiz extends basis_db $this->errormsg = 'Fehler beim Speichern der Daten'; return false; } - } + } /** * @@ -377,7 +377,7 @@ class notiz extends basis_db $obj->insertvon=$row->insertvon; $obj->updateamum=$row->updateamum; $obj->updatevon=$row->updatevon; - $obj->getDokumente($row->notiz_id); + $obj->getDokumente($row->notiz_id); $this->result[] = $obj; } @@ -404,9 +404,9 @@ class notiz extends basis_db public.tbl_notiz LEFT JOIN public.tbl_notizzuordnung USING(notiz_id) WHERE person_id = ' . $this->db_add_param($person_id, FHC_INTEGER) . - ' AND (insertvon = ' . $this->db_add_param('online') .' OR insertvon = ' . $this->db_add_param('online_notiz').') + ' AND (insertvon = ' . $this->db_add_param('online') .' OR insertvon = ' . $this->db_add_param('online_notiz').') - ORDER BY notiz_id'; + ORDER BY notiz_id'; if($result = $this->db_query($qry)) { @@ -444,7 +444,7 @@ class notiz extends basis_db * (Name und Adresse der besuchten Schule) in eine Notiz mit * insertvon = online_ausbildung gespeichert. * Wird auf UDF umgebaut! - * + * * Laedt die Notizen zur Ausbilund vom Bewerbungstool * @param $person_id int * @return boolean @@ -457,8 +457,8 @@ class notiz extends basis_db public.tbl_notiz LEFT JOIN public.tbl_notizzuordnung USING(notiz_id) WHERE person_id = ' . $this->db_add_param($person_id, FHC_INTEGER) . - ' AND insertvon = ' . $this->db_add_param('online_ausbildung') . - ' ORDER BY notiz_id'; + ' AND insertvon = ' . $this->db_add_param('online_ausbildung') . + ' ORDER BY notiz_id'; if($result = $this->db_query($qry)) { @@ -564,13 +564,13 @@ class notiz extends basis_db } } - /** - * Laedt die Dokumente der Notiz - * @return boolean - */ - public function getDokumente($notiz_id) - { - $qry = "SELECT dms_id FROM public.tbl_notiz_dokument WHERE notiz_id=".$this->db_add_param($notiz_id, FHC_INTEGER); + /** + * Laedt die Dokumente der Notiz + * @return boolean + */ + public function getDokumente($notiz_id) + { + $qry = "SELECT dms_id FROM public.tbl_notiz_dokument WHERE notiz_id=".$this->db_add_param($notiz_id, FHC_INTEGER); if($this->db_query($qry)) { @@ -579,12 +579,35 @@ class notiz extends basis_db $this->dokumente[] = $row->dms_id; } - return true; + return true; } else { $this->errormsg = 'Fehler beim Laden der Daten'; return false; } - } + } + + /** + * Prueft ob das Dokument an einer Notiz haengt + * @param $dms_id DMS id des Dokuments. + * @return boolean true wenn das Dokument an einer Notiz hängt, sonst false. + */ + public function isNotizDokument($dms_id) + { + $qry = "SELECT * FROM public.tbl_notiz_dokument WHERE dms_id=".$this->db_add_param($dms_id, FHC_INTEGER); + + if($result = $this->db_query($qry)) + { + if($this->db_num_rows($result)>0) + return true; + else + return false; + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } }