mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Technikum-Wien
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Christian Paminger <christian.paminger@technikum-wien.at>,
|
||||
* Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at>,
|
||||
* Rudolf Hangl <rudolf.hangl@technikum-wien.at> and
|
||||
* Gerald Simane-Sequens <gerald.simane-sequens@technikum-wien.at>
|
||||
*/
|
||||
/**
|
||||
* Klasse Organisationseinheit
|
||||
*
|
||||
*/
|
||||
require_once('basis_db.class.php');
|
||||
|
||||
class organisationseinheit extends basis_db
|
||||
{
|
||||
public $new; // @var boolean
|
||||
public $errormsg; // @var string
|
||||
|
||||
//Tabellenspalten
|
||||
public $oe_kurzbz;
|
||||
public $oe_parent_kurzbz;
|
||||
public $bezeichnung;
|
||||
public $organisationseinheittyp_kurzbz;
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
* @param $oe_kurzbz Kurzbz der Organisationseinheit
|
||||
*/
|
||||
public function __construct($oe_kurzbz=null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if($oe_kurzbz != null)
|
||||
$this->load($oe_kurzbz);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Laedt eine Organisationseinheit
|
||||
* @param $oe_kurzbz
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
public function load($oe_kurzbz)
|
||||
{
|
||||
if($oe_kurzbz == '')
|
||||
{
|
||||
$this->errormsg = 'kurzbz darf nicht leer sein';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "SELECT * FROM public.tbl_organisationseinheit WHERE oe_kurzbz = '$oe_kurzbz';";
|
||||
|
||||
if(!$this->db_query($qry))
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden des Datensatzes';
|
||||
return false;
|
||||
}
|
||||
|
||||
if($row=$this->db_fetch_object())
|
||||
{
|
||||
$this->oe_kurzbz = $row->oe_kurzbz;
|
||||
$this->bezeichnung = $row->bezeichnung;
|
||||
$this->oe_parent_kurzbz = $row->oe_parent_kurzbz;
|
||||
$this->organisationseinheittyp_kurzbz = $row->organisationseinheittyp_kurzbz;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Es ist kein Datensatz mit dieser ID vorhanden';
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Liefert die ChildNodes einer Organisationseinheit
|
||||
*
|
||||
* @param $oe_kurzbz
|
||||
* @return Array mit den Childs inkl derm Uebergebenen Element
|
||||
*/
|
||||
public function getChilds($oe_kurzbz)
|
||||
{
|
||||
$childs[] = $oe_kurzbz;
|
||||
|
||||
$qry = "SELECT * FROM public.tbl_organisationseinheit WHERE oe_parent_kurzbz = '$oe_kurzbz'";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
$myresult = $this->db_result;
|
||||
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 array_unique($childs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Liefert die Direkten KindElemente der Organisationseinheit
|
||||
*
|
||||
* @param $oe_kurzbz
|
||||
* @return Array mit den Childs inkl derm Uebergebenen Element
|
||||
*/
|
||||
public function getDirectChilds($oe_kurzbz)
|
||||
{
|
||||
$childs = array();
|
||||
$qry = "SELECT * FROM public.tbl_organisationseinheit WHERE oe_parent_kurzbz = '$oe_kurzbz' ORDER BY organisationseinheittyp_kurzbz DESC, bezeichnung";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$childs[] = $row->oe_kurzbz;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Ermitteln der Childs';
|
||||
}
|
||||
return $childs;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -35,9 +35,12 @@ class basis_db extends db
|
||||
return pg_num_rows($this->db_result);
|
||||
}
|
||||
|
||||
function db_fetch_object()
|
||||
function db_fetch_object($result = null)
|
||||
{
|
||||
return pg_fetch_object($this->db_result);
|
||||
if(is_null($result))
|
||||
return pg_fetch_object($this->db_result);
|
||||
else
|
||||
return pg_fetch_object($result);
|
||||
}
|
||||
|
||||
function db_last_error()
|
||||
|
||||
@@ -133,6 +133,7 @@ $menu=array
|
||||
'Betriebsmittel'=>array('name'=>'Betriebsmittel', 'link'=>'stammdaten/betriebsmittel_frameset.html', 'target'=>'main'),
|
||||
'Reihungstest'=>array('name'=>'Reihungstest', 'link'=>'stammdaten/reihungstestverwaltung.php', 'target'=>'main'),
|
||||
'Firmen'=>array('name'=>'Firmen', 'link'=>'stammdaten/firma_frameset.html', 'target'=>'main'),
|
||||
'Organisationseinheiten'=>array('name'=>'Organisationseinheiten', 'link'=>'stammdaten/organisationseinheiten.php', 'target'=>'main'),
|
||||
'ImExport'=>array
|
||||
(
|
||||
'name'=>'ImExport',
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 734 B |
Binary file not shown.
|
After Width: | Height: | Size: 701 B |
@@ -274,6 +274,26 @@ $datatypes['{3DD56C5A-B10A-4E02-8CB2-C7B4880B63DD}']=array
|
||||
"comments" => "",
|
||||
"ordinal" => "0"
|
||||
);
|
||||
$datatypes['{E62BD1D3-18CA-4571-9A16-606FF04DC894}']=array
|
||||
(
|
||||
"id" => "{E62BD1D3-18CA-4571-9A16-606FF04DC894}",
|
||||
"name" => "Numeric",
|
||||
"caption" => "numeric",
|
||||
"length" => "0",
|
||||
"default" => "'0'" ,
|
||||
"comments" => "",
|
||||
"ordinal" => "0"
|
||||
);
|
||||
$datatypes['{36A9DD5B-49C4-4BB7-86DB-2D4BCCAF58AF}']=array
|
||||
(
|
||||
"id" => "{36A9DD5B-49C4-4BB7-86DB-2D4BCCAF58AF}",
|
||||
"name" => "Real",
|
||||
"caption" => "real",
|
||||
"length" => "0",
|
||||
"default" => "'0'" ,
|
||||
"comments" => "",
|
||||
"ordinal" => "0"
|
||||
);
|
||||
$datatypes['']=array
|
||||
(
|
||||
"id" => "",
|
||||
|
||||
+359
-66
@@ -1,24 +1,161 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Technikum-Wien
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Christian Paminger <christian.paminger@technikum-wien.at>,
|
||||
* Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
|
||||
* Rudolf Hangl <rudolf.hangl@technikum-wien.at>.
|
||||
*/
|
||||
/*
|
||||
* Script zur Pruefung der Datenbank
|
||||
*
|
||||
* database.inc.php enthaelt die Struktur der Datenbank. Diese wird mit der Produktivdatenbank
|
||||
* verglichen und eventuelle Aenderungen werden angezeigt.
|
||||
*/
|
||||
|
||||
|
||||
require ('../config.inc.php');
|
||||
require ('database.inc.php');
|
||||
require_once('../vilesci/config.inc.php');
|
||||
require_once('database.inc.php');
|
||||
require_once('../include/functions.inc.php');
|
||||
require_once('../include/benutzerberechtigung.class.php');
|
||||
|
||||
// Datenbank Verbindung
|
||||
//if (!$conn = pg_pconnect("host=localhost dbname=conquearth user=pam password="))
|
||||
if (!$conn = pg_pconnect(CONN_STRING))
|
||||
die('Es konnte keine Verbindung zum Server aufgebaut werden!'.pg_last_error($conn));
|
||||
|
||||
echo '<H1>Systemcheck!</H1>';
|
||||
$uid=get_uid();
|
||||
|
||||
$rechte = new benutzerberechtigung($conn);
|
||||
$rechte->getBerechtigungen($uid);
|
||||
if(!$rechte->isBerechtigt('admin'))
|
||||
die('Sie haben keine Berechtigung für diese Seite');
|
||||
|
||||
echo '
|
||||
<html>
|
||||
<head>
|
||||
<title>Datenbank Check</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset="UTF-8">
|
||||
<link rel="stylesheet" href="../skin/vilesci.css" type="text/css">
|
||||
<link rel="stylesheet" href="../include/js/tablesort/table.css" type="text/css">
|
||||
<script src="../include/js/tablesort/table.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
String.prototype.startsWith = function(str)
|
||||
{return (this.match("^"+str)==str)}
|
||||
|
||||
function display(id)
|
||||
{
|
||||
if(id.startsWith("table."))
|
||||
disableTables();
|
||||
if(id.startsWith("schema."))
|
||||
disableSchemas();
|
||||
|
||||
document.getElementById(id).style.display="block";
|
||||
return false;
|
||||
}
|
||||
|
||||
function disableSchemas()
|
||||
{
|
||||
elem = document.getElementsByTagName("div");
|
||||
|
||||
for(i=0;i<elem.length;i++)
|
||||
{
|
||||
div = elem[i];
|
||||
if(div.id && (div.id.startsWith("schema.") || div.id.startsWith("table.") || div.id.startsWith("attributes.")))
|
||||
{
|
||||
document.getElementById(div.id).style.display="none";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function disableTables()
|
||||
{
|
||||
elem = document.getElementsByTagName("div");
|
||||
|
||||
for(i=0;i<elem.length;i++)
|
||||
{
|
||||
div=elem[i];
|
||||
if(div.id && (div.id.startsWith("table.") || div.id.startsWith("attributes.")))
|
||||
{
|
||||
document.getElementById(div.id).style.display="none";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
.box
|
||||
{
|
||||
border: 1px solid black;
|
||||
border: 2px solid #E6E6CC;
|
||||
float: left;
|
||||
margin: 10px;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.boxhead
|
||||
{
|
||||
background-color: #F3F3E9;
|
||||
border:0;
|
||||
text-align: center;
|
||||
border-bottom: 1px solid #E6E6CC;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>';
|
||||
|
||||
echo '<H2>Datenbank Prüfung</H2><br />';
|
||||
$obj=array();
|
||||
$obj['']=array();
|
||||
$obj['']['error']=false;
|
||||
$schemas['']=array
|
||||
(
|
||||
"id" => "" ,
|
||||
"name" => "" ,
|
||||
"caption" => "" ,
|
||||
"comments" => "" ,
|
||||
"ordinal" => "0"
|
||||
);
|
||||
|
||||
//Schema pruefen
|
||||
foreach ($schemas as $schema)
|
||||
{
|
||||
$obj[$schema['caption']]=array();
|
||||
$obj[$schema['caption']]['error']=false;
|
||||
|
||||
$qry = "SELECT nspname FROM pg_namespace WHERE nspname='".$schema['caption']."'";
|
||||
if($result = pg_query($conn, $qry))
|
||||
{
|
||||
if(!pg_num_rows($result)>0)
|
||||
{
|
||||
$obj[$schema['caption']]['qry']='CREATE SCHEMA '.$schema['caption'].';';
|
||||
$obj[$schema['caption']]['error']=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '<H2>Pruefe Tabellen und Attribute!</H2>';
|
||||
|
||||
//var_dump($datatypes);
|
||||
$tabs=array_keys($tabellen);
|
||||
//print_r($tabs);
|
||||
|
||||
$i=0;
|
||||
foreach ($tabellen AS $tabelle)
|
||||
{
|
||||
$obj[$schemas[$tabelle['schemaid']]['caption']]['tables'][$tabelle['caption']]=array();
|
||||
$sql_query2='';
|
||||
$pk='';
|
||||
// Tabelle pruefen
|
||||
@@ -35,7 +172,7 @@ foreach ($tabellen AS $tabelle)
|
||||
{
|
||||
if ($datatypes[$attribut['datatypeid']]['caption']!='geometry')
|
||||
{
|
||||
//echo $datatypes[$attribut['datatypeid']]['caption'];
|
||||
//echo $datatypes[$attribut['datatypeid']]['caption'];
|
||||
$sql_query.= $attribut['caption'].' ';
|
||||
if ($attribut['pk'])
|
||||
$pk.=$attribut['caption'].',';
|
||||
@@ -62,30 +199,40 @@ foreach ($tabellen AS $tabelle)
|
||||
$sql_query.=', CONSTRAINT "pk_'.$schemas[$tabelle['schemaid']]['caption'].'_'.$tabelle['caption'].'" PRIMARY KEY ('.substr($pk,0,-1).')';
|
||||
$sql_query.=');';
|
||||
//echo $sql_query.'<BR>'.$sql_query2;
|
||||
if (!$res_attr=pg_query($conn,$sql_query.$sql_query2))
|
||||
echo '<BR><strong>'.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].': '.pg_last_error($conn).' </strong><BR>'.$sql_query.'<BR>'.$sql_query_nn.'<BR>';
|
||||
else
|
||||
echo 'Tabelle '.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].' wurde erfolgreich angelegt!<BR>';
|
||||
//if (!$res_attr=pg_query($conn,$sql_query.$sql_query2))
|
||||
// echo '<BR><strong>'.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].': '.pg_last_error($conn).' </strong><BR>'.$sql_query.'<BR>'.$sql_query_nn.'<BR>';
|
||||
//else
|
||||
// echo 'Tabelle '.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].' wurde erfolgreich angelegt!<BR>';
|
||||
|
||||
$obj[$schemas[$tabelle['schemaid']]['caption']]['tables'][$tabelle['caption']]['qry']=$sql_query;
|
||||
$obj[$schemas[$tabelle['schemaid']]['caption']]['error']=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Attribute pruefen
|
||||
foreach ($tabelle['attribute'] AS $attribut)
|
||||
{
|
||||
$obj[$schemas[$tabelle['schemaid']]['caption']]['tables'][$tabelle['caption']]['attribute'][$attribut['caption']]=array();
|
||||
|
||||
//var_dump($attribut);
|
||||
$sql_query="SELECT nspname AS schemaname, relname AS tablename, pg_get_userbyid(relowner) AS tableowner, attname AS attribute
|
||||
FROM pg_catalog.pg_attribute JOIN pg_catalog.pg_class ON (attrelid=relfilenode) JOIN pg_namespace ON (oid=relnamespace)
|
||||
WHERE relkind='r' AND nspname='".$schemas[$tabelle['schemaid']]['caption']."' AND relname='".$tabelle['caption']."'
|
||||
AND attname='".$attribut['caption']."'; ";
|
||||
if (!$res_attr=pg_query($conn,$sql_query))
|
||||
echo '<BR><strong>'.$attribut['caption'].': '.pg_last_error($conn).' </strong><BR>';
|
||||
{
|
||||
//echo '<BR><strong>'.$attribut['caption'].': '.pg_last_error($conn).' </strong><BR>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pg_num_rows($res_attr)==1)
|
||||
echo $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'.'.$attribut['caption'].': OK - ';
|
||||
{
|
||||
//echo $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'.'.$attribut['caption'].': OK - ';
|
||||
}
|
||||
else if (pg_num_rows($res_attr)==0)
|
||||
{
|
||||
$sql_query_nn='';
|
||||
echo $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'.'.$attribut['caption'].' ist nicht angelegt!<BR>';
|
||||
$sql_query_nn='';
|
||||
//echo $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'.'.$attribut['caption'].' ist nicht angelegt!<BR>';
|
||||
$sql_query='ALTER TABLE '.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'
|
||||
ADD COLUMN '.$attribut['caption'].' ';
|
||||
$sql_query.=$datatypes[$attribut['datatypeid']]['caption'];
|
||||
@@ -96,89 +243,94 @@ foreach ($tabellen AS $tabelle)
|
||||
if ($attribut['unique'])
|
||||
$sql_query.=' UNIQUE';
|
||||
if ($attribut['defaultvalue']!="")
|
||||
$sql_query.=' DEFAULT '.$attribut['defaultvalue'];
|
||||
else
|
||||
$sql_query.=' DEFAULT '.$attribut['defaultvalue'];
|
||||
else
|
||||
$attribut['defaultvalue']=$datatypes[$attribut['datatypeid']]['default'];
|
||||
if ($attribut['checkconstraint']!="")
|
||||
$sql_query.=' CHECK ('.$attribut['checkconstraint'].')';
|
||||
if ($attribut['notnull'])
|
||||
if ($attribut['notnull'])
|
||||
{
|
||||
$sql_query_nn.='UPDATE '.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'
|
||||
SET '.$attribut['caption'].'='.$attribut['defaultvalue'].';';
|
||||
$sql_query_nn.='ALTER TABLE '.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'
|
||||
ALTER COLUMN '.$attribut['caption'].' SET NOT NULL;';
|
||||
$sql_query_nn.='UPDATE '.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'
|
||||
SET '.$attribut['caption'].'='.$attribut['defaultvalue'].';';
|
||||
$sql_query_nn.='ALTER TABLE '.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'
|
||||
ALTER COLUMN '.$attribut['caption'].' SET NOT NULL;';
|
||||
}
|
||||
$sql_query.=';';
|
||||
//echo $sql_query;
|
||||
if (!$res_attr=pg_query($conn,$sql_query.$sql_query_nn))
|
||||
echo '<BR><strong>'.$attribut['caption'].': '.pg_last_error($conn).' </strong><BR>'.$sql_query.'<BR>'.$sql_query_nn.'<BR>';
|
||||
else
|
||||
echo $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'.'.$attribut['caption'].' wurde erfolgreich hinzugefuegt!<BR>';
|
||||
//if (!$res_attr=pg_query($conn,$sql_query.$sql_query_nn))
|
||||
// echo '<BR><strong>'.$attribut['caption'].': '.pg_last_error($conn).' </strong><BR>'.$sql_query.'<BR>'.$sql_query_nn.'<BR>';
|
||||
//else
|
||||
// echo $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'.'.$attribut['caption'].' wurde erfolgreich hinzugefuegt!<BR>';
|
||||
$obj[$schemas[$tabelle['schemaid']]['caption']]['tables'][$tabelle['caption']]['attribute'][$attribut['caption']]['qry']=$sql_query;
|
||||
$obj[$schemas[$tabelle['schemaid']]['caption']]['error']=true;
|
||||
}
|
||||
$obj[$schemas[$tabelle['schemaid']]['caption']]['tables'][$tabelle['caption']]['attribute'][$attribut['caption']]['datatype']=$datatypes[$attribut['datatypeid']]['caption'];
|
||||
$obj[$schemas[$tabelle['schemaid']]['caption']]['tables'][$tabelle['caption']]['attribute'][$attribut['caption']]['attribute']=$attribut;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flush();
|
||||
$i++;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
echo '<H2>Pruefe Constraints!</H2>';
|
||||
|
||||
function getTablenameFromAttributIDs($attr)
|
||||
{
|
||||
global $tabellen;
|
||||
global $schemas;
|
||||
$attributid=null;
|
||||
foreach ($attr AS $attribut)
|
||||
$attributid=$attribut;
|
||||
|
||||
function getTablenameFromAttributIDs($attr)
|
||||
{
|
||||
global $tabellen;
|
||||
global $schemas;
|
||||
$attributid=null;
|
||||
foreach ($attr AS $attribut)
|
||||
$attributid=$attribut;
|
||||
foreach ($tabellen AS $tabelle)
|
||||
foreach ($tabelle['attribute'] AS $attribut)
|
||||
if ($attribut['id']==$attributid)
|
||||
return $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'];
|
||||
return false;
|
||||
}
|
||||
function getAttributesnameFromAttributIDs($attr)
|
||||
{
|
||||
global $tabellen;
|
||||
global $schemas;
|
||||
$attributes='';
|
||||
foreach ($attr AS $attributid)
|
||||
if ($attribut['id']==$attributid)
|
||||
return $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'];
|
||||
return false;
|
||||
}
|
||||
function getAttributesnameFromAttributIDs($attr)
|
||||
{
|
||||
global $tabellen;
|
||||
global $schemas;
|
||||
$attributes='';
|
||||
foreach ($attr AS $attributid)
|
||||
foreach ($tabellen AS $tabelle)
|
||||
foreach ($tabelle['attribute'] AS $attribute)
|
||||
if ($attribute['id']==$attributid)
|
||||
$attributes.=$attribute['caption'].', ';
|
||||
return substr($attributes,0,-2);
|
||||
}
|
||||
|
||||
if ($attribute['id']==$attributid)
|
||||
$attributes.=$attribute['caption'].', ';
|
||||
return substr($attributes,0,-2);
|
||||
}
|
||||
|
||||
//Alter table campus.tbl_paabgabe add Constraint projektarbeit_paabgabe foreign key (projektarbeit_id) references lehre.tbl_projektarbeit (projektarbeit_id) on update cascade on delete restrict;
|
||||
|
||||
|
||||
foreach ($relations AS $relation)
|
||||
{
|
||||
$sql_query='';
|
||||
$pk='';
|
||||
// Auf Foreign Key pruefen
|
||||
//var_dump($relation);
|
||||
if (count($relation['foreignkeys'])>0)
|
||||
{
|
||||
foreach ($relation['foreignkeys'] AS $foreignkey)
|
||||
{
|
||||
//var_dump($relation);
|
||||
if (count($relation['foreignkeys'])>0)
|
||||
{
|
||||
foreach ($relation['foreignkeys'] AS $foreignkey)
|
||||
{
|
||||
$parenttable=getTablenameFromAttributIDs($foreignkey['attrparent']);
|
||||
$childtable=getTablenameFromAttributIDs($foreignkey['attrchild']);
|
||||
$childtable=getTablenameFromAttributIDs($foreignkey['attrchild']);
|
||||
$parentattr=getAttributesnameFromAttributIDs($foreignkey['attrparent']);
|
||||
$childattr=getAttributesnameFromAttributIDs($foreignkey['attrchild']);
|
||||
$childattr=getAttributesnameFromAttributIDs($foreignkey['attrchild']);
|
||||
//$constrname=str_replace('.','_',);
|
||||
$sql_query='ALTER TABLE '.$childtable.' ADD CONSTRAINT '.$relation['caption'].' FOREIGN KEY ('.$childattr.') REFERENCES '.$parenttable.' ('.$parentattr.') ';
|
||||
$sql_query.='ON UPDATE CASCADE ON DELETE RESTRICT;';
|
||||
//if (refintegritychildupdate)
|
||||
// $sql_query.='
|
||||
echo $sql_query.'<BR>';
|
||||
$sql_query='ALTER TABLE '.$childtable.' ADD CONSTRAINT '.$relation['caption'].' FOREIGN KEY ('.$childattr.') REFERENCES '.$parenttable.' ('.$parentattr.') ';
|
||||
$sql_query.='ON UPDATE CASCADE ON DELETE RESTRICT;';
|
||||
//if (refintegritychildupdate)
|
||||
// $sql_query.='
|
||||
echo $sql_query.'<BR>';
|
||||
}
|
||||
}
|
||||
|
||||
flush();
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
echo '<H2>Gegenpruefung!</H2>';
|
||||
$sql_query="SELECT schemaname,tablename FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema' AND schemaname != 'sync' AND schemaname != 'papaya';";
|
||||
@@ -208,4 +360,145 @@ if (!$result=@pg_query($conn,$sql_query))
|
||||
echo 'Attribut '.$fulltablename.'.<strong>'.$fieldnameDB.'</strong> existiert in der DB, aber nicht in diesem Skript!<BR>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
*/
|
||||
$out_schema="\n";
|
||||
$out_schema_data="\n";
|
||||
$out_tbl="\n";
|
||||
$out_tbl_data="\n";
|
||||
$out_att="\n";
|
||||
$out_att_data="\n";
|
||||
|
||||
function querybox($title, $qry, $id)
|
||||
{
|
||||
$ret="\n";
|
||||
$ret.='<div class="box" id="'.$id.'" style="display: none">';
|
||||
$ret.='<div class="boxhead">'.$title.'</div>';
|
||||
if(strlen($qry)>50)
|
||||
{
|
||||
$cols=55;
|
||||
$rows = strlen($qry)/50;
|
||||
|
||||
if($rows>10)
|
||||
$rows = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cols=strlen($qry);
|
||||
$rows=1;
|
||||
}
|
||||
$ret.='<br /><textarea readonly="true" cols="'.$cols.'" rows="'.$rows.'">'.$qry.'</textarea>';
|
||||
$ret.='<br /><br /><input type="button" value="Commit" />';
|
||||
$ret.='</div>';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
$out_schema.= '<div class="box" id="schema">';
|
||||
$out_schema.= '<div class="boxhead">Schema</div>';
|
||||
$out_schema.= '<table>';
|
||||
|
||||
foreach ($obj as $schema=>$value)
|
||||
{
|
||||
|
||||
//Schema
|
||||
$out_schema.= "\n";
|
||||
$out_schema.= '<tr>';
|
||||
if($value['error'])
|
||||
{
|
||||
if(isset($value['qry']) && $value['qry']!='')
|
||||
{
|
||||
$out_schema_data.=querybox($schema, $value['qry'], 'schema.'.$schema);
|
||||
$img = "exclamation.png";
|
||||
}
|
||||
else
|
||||
{
|
||||
$img = "error_go.png";
|
||||
}
|
||||
$out_schema.= '<td><a href="#" onclick="display(\'schema.'.$schema.'\')"><img src="../skin/images/'.$img.'" /></a></td>';
|
||||
$out_schema.= '<td><a href="#" onclick="display(\'schema.'.$schema.'\')">'.$schema.'</a></td>';
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$out_schema.= '<td></td>';
|
||||
$out_schema.= '<td><a href="#" onclick="display(\'schema.'.$schema.'\')">'.$schema.'</a></td>';
|
||||
}
|
||||
$out_schema.= '</tr>';
|
||||
|
||||
//Tabelle
|
||||
if(isset($value['tables']))
|
||||
{
|
||||
$out_tbl.= "\n";
|
||||
$out_tbl.= '<div class="box" id="schema.'.$schema.'" style="display: none">';
|
||||
$out_tbl.= '<div class="boxhead">'.$schema.'</div>';
|
||||
$out_tbl.= '<table>';
|
||||
|
||||
foreach ($value['tables'] as $tables=>$tabvalue)
|
||||
{
|
||||
$out_tbl.= '<tr>';
|
||||
if(isset($tabvalue['qry']) && $tabvalue['qry']!='')
|
||||
{
|
||||
$out_tbl.= '<td><a href="#" onclick="display(\'table.'.$tables.'\')"><img src="../skin/images/exclamation.png" /></a></td>';
|
||||
$out_tbl.= '<td><a href="#" onclick="display(\'table.'.$tables.'\')">'.$tables.'</a></td>';
|
||||
|
||||
$out_tbl_data.=querybox($tables, $tabvalue['qry'], 'table.'.$tables);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$out_tbl.= '<td></td>';
|
||||
$out_tbl.= '<td><a href="#" onclick="display(\'table.'.$tables.'\')">'.$tables.'</a></td>';
|
||||
}
|
||||
$out_tbl.= '</tr>';
|
||||
|
||||
//Attribute
|
||||
if(isset($tabvalue['attribute']))
|
||||
{
|
||||
$out_att.= "\n";
|
||||
$out_att.= '<div class="box" id="table.'.$tables.'" style="display: none">';
|
||||
$out_att.= '<div class="boxhead">'.$tables.'</div>';
|
||||
$out_att.= '<table>';
|
||||
|
||||
foreach ($tabvalue['attribute'] as $attrib=>$attvalue)
|
||||
{
|
||||
$out_att.= '<tr>';
|
||||
if(isset($attvalue['qry']) && $attvalue['qry']!='')
|
||||
{
|
||||
$out_att.= '<td><a href="#" onclick="display(\'attrib.'.$attrib.'\')"><img src="../skin/images/exclamation.png" /></a></td>';
|
||||
$out_att.= '<td><a href="#" onclick="display(\'attrib.'.$attrib.'\')">'.$attrib.'</a></td>';
|
||||
|
||||
$out_att_data.=querybox($attrib, $attvalue['qry'], 'attrib.'.$attrib);
|
||||
}
|
||||
else
|
||||
{
|
||||
$out_att.= '<td></td>';
|
||||
$out_att.= '<td><a href="#" onclick="display(\'attrib.'.$attrib.'\')">'.$attrib.'</a></td>';
|
||||
$out_att.= '<td> <a href="#" onclick="display(\'attrib.'.$attrib.'\')">'.$attvalue['datatype'].($attvalue['attribute']['length']!=''?' ('.$attvalue['attribute']['length'].')':'').'</a></td>';
|
||||
$out_att.= '<td> <a href="#" onclick="display(\'attrib.'.$attrib.'\')">'.
|
||||
($attvalue['attribute']['unique']=='1'?'U':'').
|
||||
($attvalue['attribute']['notnull']=='1'?'NN':'').
|
||||
'</a></td>';
|
||||
|
||||
}
|
||||
$out_att.= '</tr>';
|
||||
}
|
||||
$out_att.= '</table>';
|
||||
$out_att.= '</div>';
|
||||
}
|
||||
}
|
||||
$out_tbl.= '</table>';
|
||||
$out_tbl.= '</div>';
|
||||
|
||||
}
|
||||
}
|
||||
$out_schema.= '</table>';
|
||||
$out_schema.= '</div>';
|
||||
|
||||
echo $out_schema;
|
||||
echo $out_schema_data;
|
||||
echo $out_tbl;
|
||||
echo $out_tbl_data;
|
||||
echo $out_att;
|
||||
echo $out_att_data;
|
||||
?>
|
||||
@@ -57,5 +57,117 @@ if(!$result = @pg_query($conn, "SELECT * FROM public.tbl_rolle LIMIT 1;"))
|
||||
constrains umbenannt';
|
||||
}
|
||||
|
||||
if(!$result = @pg_query($conn, "SELECT * FROM public.tbl_organisationseinheit LIMIT 1;"))
|
||||
{
|
||||
$qry = "CREATE TABLE public.tbl_organisationseinheit
|
||||
(
|
||||
oe_kurzbz Character varying(32) NOT NULL,
|
||||
oe_parent_kurzbz Character varying(32),
|
||||
bezeichnung Character varying(256),
|
||||
organisationseinheittyp_kurzbz Character varying(16) NOT NULL
|
||||
)
|
||||
WITH (OIDS=FALSE);
|
||||
|
||||
ALTER TABLE public.tbl_organisationseinheit ADD CONSTRAINT pk_tbl_organisationseinheit PRIMARY KEY (oe_kurzbz);
|
||||
ALTER TABLE public.tbl_organisationseinheit ADD CONSTRAINT oe_parent_oe FOREIGN KEY (oe_parent_kurzbz) REFERENCES public.tbl_organisationseinheit (oe_kurzbz) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
CREATE TABLE public.tbl_organisationseinheittyp
|
||||
(
|
||||
organisationseinheittyp_kurzbz Character varying(16) NOT NULL,
|
||||
bezeichnung Character varying(256),
|
||||
beschreibung text
|
||||
)
|
||||
WITH (OIDS=FALSE);
|
||||
|
||||
ALTER TABLE public.tbl_organisationseinheittyp ADD CONSTRAINT pk_organisationseinheittyp PRIMARY KEY (organisationseinheittyp_kurzbz);
|
||||
ALTER TABLE public.tbl_organisationseinheit ADD CONSTRAINT organisationseinheit_organisationseinheittyp FOREIGN KEY (organisationseinheittyp_kurzbz) REFERENCES public.tbl_organisationseinheittyp (organisationseinheittyp_kurzbz) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
GRANT SELECT on public.tbl_organisationseinheit TO GROUP web;
|
||||
GRANT SELECT, INSERT, UDPATE, DELETE on public.tbl_organisationseinheit TO GROUP admin;
|
||||
|
||||
GRANT SELECT on public.tbl_organisationseinheittyp TO GROUP web;
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE on public.tbl_organisationseinheittyp TO GROUP admin;
|
||||
|
||||
ALTER TABLE public.tbl_studiengang ADD COLUMN oe_kurzbz character varying(32);
|
||||
ALTER TABLE public.tbl_studiengang ADD CONSTRAINT studiengang_organisationseinheit FOREIGN KEY (oe_kurzbz) REFERENCES public.tbl_organisationseinheit (oe_kurzbz) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE public.tbl_fachbereich ADD COLUMN oe_kurzbz character varying(32);
|
||||
ALTER TABLE public.tbl_fachbereich ADD CONSTRAINT fachbereich_organisationseinheit FOREIGN KEY (oe_kurzbz) REFERENCES public.tbl_organisationseinheit (oe_kurzbz) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
";
|
||||
if(!pg_query($conn, $qry))
|
||||
echo '<strong>public.tbl_organisationsform: '.pg_last_error($conn).' </strong><br>';
|
||||
else
|
||||
echo ' public.tbl_organisationsform: Tabelle wurde hinzugefügt!<br>';
|
||||
;
|
||||
}
|
||||
|
||||
if(!$result = @pg_query($conn, "SELECT * FROM system.tbl_berechtigung LIMIT 1;"))
|
||||
{
|
||||
$qry = "CREATE SCHEMA system;
|
||||
CREATE TABLE system.tbl_benutzerrolle
|
||||
(
|
||||
benutzerberechtigung_id serial NOT NULL,
|
||||
uid Character varying(16),
|
||||
funktion_kurzbz Character varying(16),
|
||||
rolle_kurzbz Character varying(32),
|
||||
berechtigung_kurzbz Character varying(16),
|
||||
art Character varying(5) DEFAULT 'r'::character varying NOT NULL,
|
||||
oe_kurzbz Character varying(32),
|
||||
studiensemester_kurzbz Character varying(16),
|
||||
start Date,
|
||||
ende Date,
|
||||
negativ Boolean DEFAULT FALSE NOT NULL,
|
||||
updateamum Timestamp,
|
||||
updatevon Character varying(16),
|
||||
insertamum Timestamp DEFAULT now(),
|
||||
insertvon Character varying(16)
|
||||
)
|
||||
WITH (OIDS=FALSE);
|
||||
|
||||
CREATE INDEX idx_userberechtigung_uid ON system.tbl_benutzerrolle (uid);
|
||||
ALTER TABLE system.tbl_benutzerrolle ADD CONSTRAINT pk_tbl_benutzerberechtigung PRIMARY KEY (benutzerberechtigung_id);
|
||||
|
||||
CREATE TABLE system.tbl_berechtigung
|
||||
(
|
||||
berechtigung_kurzbz Character varying(16) NOT NULL,
|
||||
beschreibung Character varying(256)
|
||||
)
|
||||
WITH (OIDS=FALSE);
|
||||
ALTER TABLE system.tbl_berechtigung ADD CONSTRAINT pk_tbl_berechtigung PRIMARY KEY (berechtigung_kurzbz);
|
||||
|
||||
CREATE TABLE system.tbl_rolle
|
||||
(
|
||||
rolle_kurzbz Character varying(32) NOT NULL,
|
||||
beschreibung Character varying(256)
|
||||
) WITH (OIDS=FALSE);
|
||||
|
||||
ALTER TABLE system.tbl_rolle ADD CONSTRAINT pk_tbl_rolle PRIMARY KEY (rolle_kurzbz);
|
||||
|
||||
CREATE TABLE system.tbl_rolleberechtigung
|
||||
(
|
||||
berechtigung_kurzbz Character varying(16) NOT NULL,
|
||||
rolle_kurzbz Character varying(32) NOT NULL
|
||||
)
|
||||
WITH (OIDS=FALSE);
|
||||
|
||||
ALTER TABLE system.tbl_rolleberechtigung ADD CONSTRAINT pk_tbl_rolleberechtigung PRIMARY KEY (berechtigung_kurzbz,rolle_kurzbz);
|
||||
|
||||
GRANT SELECT ON system.tbl_benutzerrolle TO GROUP web;
|
||||
GRANT SELECT ON system.tbl_berechtigung TO GROUP web;
|
||||
GRANT SELECT ON system.tbl_rolle TO GROUP web;
|
||||
GRANT SELECT ON system.tbl_rolleberechtigung TO GROUP web;
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON system.tbl_benutzerrolle TO GROUP web;
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON system.tbl_berechtigung TO GROUP web;
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON system.tbl_rolle TO GROUP web;
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON system.tbl_rolleberechtigung TO GROUP web;
|
||||
";
|
||||
|
||||
if(!pg_query($conn, $qry))
|
||||
echo '<strong>system schema: '.pg_last_error($conn).' </strong><br>';
|
||||
else
|
||||
echo 'system schema: Tabellen wurde hinzugefügt!<br>';
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
+3
-4
@@ -25,13 +25,13 @@
|
||||
* Die Menuepunkt mit den zugehoerigen Links befinden sich in einem
|
||||
* Array welches includiert wird.
|
||||
*/
|
||||
require('config.inc.php');
|
||||
require('../config/vilesci.config.inc.php');
|
||||
require('../include/functions.inc.php');
|
||||
require('../include/benutzerberechtigung.class.php');
|
||||
require_once('../include/'.EXT_FKT_PATH.'/vilesci_menu_main.inc.php');
|
||||
$uid=get_uid();
|
||||
$conn=pg_connect(CONN_STRING) or die('Connection zur Portal Datenbank fehlgeschlagen');
|
||||
$berechtigung=new benutzerberechtigung($conn);
|
||||
//$conn=pg_connect(CONN_STRING) or die('Connection zur Portal Datenbank fehlgeschlagen');
|
||||
$berechtigung=new benutzerberechtigung();
|
||||
$berechtigung->getBerechtigungen($uid);
|
||||
if (!($berechtigung->isBerechtigt('admin') ||
|
||||
$berechtigung->isBerechtigt('support') ||
|
||||
@@ -39,7 +39,6 @@
|
||||
$berechtigung->isBerechtigt('lehre') ||
|
||||
$berechtigung->isBerechtigt('lv-plan') ))
|
||||
die ('Keine Berechtigung!');
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Technikum-Wien
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Christian Paminger <christian.paminger@technikum-wien.at>,
|
||||
* Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at>,
|
||||
* Rudolf Hangl <rudolf.hangl@technikum-wien.at> and
|
||||
* Gerald Simane-Sequens <gerald.simane-sequens@technikum-wien.at>
|
||||
*/
|
||||
/**
|
||||
* Stellt die Abhaengigkeiten Organisationseinheiten grafisch dar.
|
||||
*/
|
||||
require_once('../../config/vilesci.config.inc.php');
|
||||
require_once('../../include/organisationseinheit.class.php');
|
||||
|
||||
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Organisationseinheiten - Übersicht</title>
|
||||
<link rel="stylesheet" href="../../skin/vilesci.css" type="text/css">
|
||||
<meta http-equiv="content-type" content="text/html" charset="UTF-8" />
|
||||
</head>
|
||||
<body class="Background_main">
|
||||
<h2>Organisationseinheiten - Übersicht</h2><br />';
|
||||
$arr = array();
|
||||
|
||||
$arr = getChilds('etw');
|
||||
$arr1['etw'] = $arr;
|
||||
displayh($arr1);
|
||||
|
||||
//Liefert die Kindelemente einer Organisationseinheit in
|
||||
//einem verschachteltem Array zurueck
|
||||
function getChilds($foo)
|
||||
{
|
||||
$obj = new organisationseinheit();
|
||||
$arr = array();
|
||||
$arr1 = $obj->getDirectChilds($foo);
|
||||
foreach ($arr1 as $value)
|
||||
$arr[$value]=array();
|
||||
|
||||
foreach ($arr as $val=>$k)
|
||||
{
|
||||
$hlp = getChilds($val);
|
||||
$arr[$val] = $hlp;
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
//Zeigt das Array in einer Verschachtelten Tabelle an
|
||||
function displayh($arr)
|
||||
{
|
||||
echo '<table style="text-align: left; padding:0;" cellspacing=0 cellpadding=0>';
|
||||
foreach ($arr as $key=>$val)
|
||||
{
|
||||
//wenn noch Kindelemente dranhaengen dann einen Rahmen zeichen, sonst nicht
|
||||
if(is_array($val) && count($val)>0)
|
||||
$style = 'style="border: 1px solid gray; font-weight:bold; padding-right: 10px;padding-left: 10px; margin:0;"';
|
||||
else
|
||||
$style = 'style="padding-left: 10px;padding-right: 10px;"';
|
||||
|
||||
echo '<tr><td valign="center" '.$style.'>';
|
||||
|
||||
$obj = new organisationseinheit();
|
||||
$obj->load($key);
|
||||
|
||||
if($obj->organisationseinheittyp_kurzbz=='Institut')
|
||||
echo $obj->oe_kurzbz;
|
||||
else
|
||||
echo $obj->bezeichnung;
|
||||
echo '</td>';
|
||||
$style = 'style="border: 1px solid gray; font-weight:bold; padding: 0px; margin:0;"';
|
||||
echo '<td valign="center" '.$style.'>';
|
||||
|
||||
if(is_array($val) && count($val)>0)
|
||||
displayh($val);
|
||||
|
||||
echo '</td></tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
echo '</body></html>';
|
||||
?>
|
||||
Reference in New Issue
Block a user