From e3373aae2fecc13994d2746c77737531c616dfa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Tue, 14 Jul 2009 14:21:35 +0000 Subject: [PATCH] --- .../mitarbeiter/mitarbeiteroverlay.xul.php | 2 +- include/basis_db.class.php | 1 + include/benutzerberechtigung.class.php | 1 - include/organisationseinheit.class.php | 50 +++++++++++++++---- include/pgsql.class.php | 5 ++ 5 files changed, 48 insertions(+), 11 deletions(-) diff --git a/content/mitarbeiter/mitarbeiteroverlay.xul.php b/content/mitarbeiter/mitarbeiteroverlay.xul.php index cdbf09e24..ff090e69f 100644 --- a/content/mitarbeiter/mitarbeiteroverlay.xul.php +++ b/content/mitarbeiter/mitarbeiteroverlay.xul.php @@ -26,7 +26,7 @@ header("Expires Mon, 26 Jul 1997 05:00:00 GMT"); header("Pragma: no-cache"); header("Content-type: application/vnd.mozilla.xul+xml"); -require_once('../../vilesci/config.inc.php'); +require_once('../../config/vilesci.config.inc.php'); echo ''; echo ''; diff --git a/include/basis_db.class.php b/include/basis_db.class.php index e1f3f4dc1..c710e304d 100644 --- a/include/basis_db.class.php +++ b/include/basis_db.class.php @@ -24,6 +24,7 @@ abstract class db extends basis abstract function db_affected_rows($result=null); abstract function db_last_error(); abstract function db_free_result($result=null); + abstract function db_version(); } require_once(DB_SYSTEM.'.class.php'); diff --git a/include/benutzerberechtigung.class.php b/include/benutzerberechtigung.class.php index 3eb48d353..564c41365 100644 --- a/include/benutzerberechtigung.class.php +++ b/include/benutzerberechtigung.class.php @@ -356,7 +356,6 @@ class benutzerberechtigung extends basis_db WHERE tbl_benutzerfunktion.uid='".addslashes($uid)."' ORDER BY negativ DESC"; - if(!$this->db_query($qry)) { $this->errormsg='Fehler beim Laden der Berechtigungen'; diff --git a/include/organisationseinheit.class.php b/include/organisationseinheit.class.php index 698b67090..152888b4c 100644 --- a/include/organisationseinheit.class.php +++ b/include/organisationseinheit.class.php @@ -155,21 +155,53 @@ class organisationseinheit extends basis_db { $childs[] = $oe_kurzbz; - $qry = "SELECT * FROM public.tbl_organisationseinheit WHERE oe_parent_kurzbz = '$oe_kurzbz'"; - - if($this->db_query($qry)) + $dbversion = $this->db_version(); + if($dbversion['server']>=8.4) { - $myresult = $this->db_result; - while($row = $this->db_fetch_object($myresult)) + //ab PostgreSQL Version 8.4 wird die Rekursion von der DB aufgeloest + $qry = " + WITH RECURSIVE oes(oe_kurzbz, oe_parent_kurzbz) as + ( + SELECT oe_kurzbz, oe_parent_kurzbz FROM public.tbl_organisationseinheit + WHERE oe_kurzbz='".addslashes($oe_kurzbz)."' + UNION ALL + SELECT o.oe_kurzbz, o.oe_parent_kurzbz FROM public.tbl_organisationseinheit o, oes + WHERE o.oe_parent_kurzbz=oes.oe_kurzbz + ) + SELECT oe_kurzbz + FROM oes + GROUP BY oe_kurzbz;"; + if($myresult = $this->db_query($qry)) { - $childs = array_merge($childs, $this->getChilds($row->oe_kurzbz)); + while($row = $this->db_fetch_object($myresult)) + { + $childs[] = $row->oe_kurzbz; + } } + else + { + $this->errormsg = 'Fehler beim Ermitteln der Childs'; + } + return $childs; } else - { - $this->errormsg = 'Fehler beim Ermitteln der Childs'; + { + //vor 8.4 muss die Rekursion in PHP aufgeloest werden + $qry = "SELECT * FROM public.tbl_organisationseinheit WHERE oe_parent_kurzbz = '$oe_kurzbz'"; + + if($myresult = $this->db_query($qry)) + { + while($row = $this->db_fetch_object($myresult)) + { + $childs = array_merge($childs, $this->getChilds($row->oe_kurzbz)); + } + } + else + { + $this->errormsg = 'Fehler beim Ermitteln der Childs'; + } + return $childs; } - return array_unique($childs); } /** diff --git a/include/pgsql.class.php b/include/pgsql.class.php index f605b646b..245691f7c 100644 --- a/include/pgsql.class.php +++ b/include/pgsql.class.php @@ -133,5 +133,10 @@ class basis_db extends db return pg_free_result($result); } } + + function db_version() + { + return pg_version(basis_db::$db_conn); + } } ?> \ No newline at end of file