diff --git a/include/organisationseinheit.class.php b/include/organisationseinheit.class.php new file mode 100644 index 000000000..8c844cb8b --- /dev/null +++ b/include/organisationseinheit.class.php @@ -0,0 +1,142 @@ +, + * Andreas Oesterreicher , + * Rudolf Hangl and + * Gerald Simane-Sequens + */ +/** + * 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; + } +} +?> \ No newline at end of file diff --git a/include/pgsql.class.php b/include/pgsql.class.php index d9f3561f2..b79473c99 100644 --- a/include/pgsql.class.php +++ b/include/pgsql.class.php @@ -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() diff --git a/include/tw/vilesci_menu_main.inc.php b/include/tw/vilesci_menu_main.inc.php index 8e41f53b8..5d61f1fac 100644 --- a/include/tw/vilesci_menu_main.inc.php +++ b/include/tw/vilesci_menu_main.inc.php @@ -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', diff --git a/skin/images/error_go.png b/skin/images/error_go.png new file mode 100644 index 000000000..caa1838d7 Binary files /dev/null and b/skin/images/error_go.png differ diff --git a/skin/images/exclamation.png b/skin/images/exclamation.png new file mode 100644 index 000000000..c37bd062e Binary files /dev/null and b/skin/images/exclamation.png differ diff --git a/system/FHCompleteTDM3PG83.xsl b/system/FHCompleteTDM3PG83.xsl index 6a19b4e1e..e0fd18555 100644 --- a/system/FHCompleteTDM3PG83.xsl +++ b/system/FHCompleteTDM3PG83.xsl @@ -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" => "", diff --git a/system/checkdb.php b/system/checkdb.php index 26901fd67..19b3acddf 100644 --- a/system/checkdb.php +++ b/system/checkdb.php @@ -1,24 +1,161 @@ , + * Andreas Oesterreicher and + * Rudolf Hangl . + */ +/* + * 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 '

Systemcheck!

'; +$uid=get_uid(); + +$rechte = new benutzerberechtigung($conn); +$rechte->getBerechtigungen($uid); +if(!$rechte->isBerechtigt('admin')) + die('Sie haben keine Berechtigung für diese Seite'); + +echo ' + + +Datenbank Check + + + + + + + +'; + +echo '

Datenbank Prüfung


'; +$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 '

Pruefe Tabellen und Attribute!

'; //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.'
'.$sql_query2; - if (!$res_attr=pg_query($conn,$sql_query.$sql_query2)) - echo '
'.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].': '.pg_last_error($conn).'
'.$sql_query.'
'.$sql_query_nn.'
'; - else - echo 'Tabelle '.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].' wurde erfolgreich angelegt!
'; + //if (!$res_attr=pg_query($conn,$sql_query.$sql_query2)) + // echo '
'.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].': '.pg_last_error($conn).'
'.$sql_query.'
'.$sql_query_nn.'
'; + //else + // echo 'Tabelle '.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].' wurde erfolgreich angelegt!
'; + + $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 '
'.$attribut['caption'].': '.pg_last_error($conn).'
'; + { + //echo '
'.$attribut['caption'].': '.pg_last_error($conn).'
'; + } 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!
'; + $sql_query_nn=''; + //echo $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'.'.$attribut['caption'].' ist nicht angelegt!
'; $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 '
'.$attribut['caption'].': '.pg_last_error($conn).'
'.$sql_query.'
'.$sql_query_nn.'
'; - else - echo $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'.'.$attribut['caption'].' wurde erfolgreich hinzugefuegt!
'; + //if (!$res_attr=pg_query($conn,$sql_query.$sql_query_nn)) + // echo '
'.$attribut['caption'].': '.pg_last_error($conn).'
'.$sql_query.'
'.$sql_query_nn.'
'; + //else + // echo $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'.'.$attribut['caption'].' wurde erfolgreich hinzugefuegt!
'; + $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 '

Pruefe Constraints!

'; - -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.'
'; + $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.'
'; } } flush(); $i++; -} +} echo '

Gegenpruefung!

'; $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.'.'.$fieldnameDB.' existiert in der DB, aber nicht in diesem Skript!
'; } } -?> +*/ +$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.=''; + + return $ret; +} +$out_schema.= '
'; +$out_schema.= '
Schema
'; +$out_schema.= ''; + +foreach ($obj as $schema=>$value) +{ + + //Schema + $out_schema.= "\n"; + $out_schema.= ''; + 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.= ''; + $out_schema.= ''; + + + + } + else + { + $out_schema.= ''; + $out_schema.= ''; + } + $out_schema.= ''; + + //Tabelle + if(isset($value['tables'])) + { + $out_tbl.= "\n"; + $out_tbl.= '
'.$schema.''.$schema.'
'; + + foreach ($value['tables'] as $tables=>$tabvalue) + { + $out_tbl.= ''; + if(isset($tabvalue['qry']) && $tabvalue['qry']!='') + { + $out_tbl.= ''; + $out_tbl.= ''; + + $out_tbl_data.=querybox($tables, $tabvalue['qry'], 'table.'.$tables); + + } + else + { + $out_tbl.= ''; + $out_tbl.= ''; + } + $out_tbl.= ''; + + //Attribute + if(isset($tabvalue['attribute'])) + { + $out_att.= "\n"; + $out_att.= '
'.$tables.''.$tables.'
'; + + foreach ($tabvalue['attribute'] as $attrib=>$attvalue) + { + $out_att.= ''; + if(isset($attvalue['qry']) && $attvalue['qry']!='') + { + $out_att.= ''; + $out_att.= ''; + + $out_att_data.=querybox($attrib, $attvalue['qry'], 'attrib.'.$attrib); + } + else + { + $out_att.= ''; + $out_att.= ''; + $out_att.= ''; + $out_att.= ''; + + } + $out_att.= ''; + } + $out_att.= '
'.$attrib.''.$attrib.' '.$attvalue['datatype'].($attvalue['attribute']['length']!=''?' ('.$attvalue['attribute']['length'].')':'').' '. + ($attvalue['attribute']['unique']=='1'?'U':''). + ($attvalue['attribute']['notnull']=='1'?'NN':''). + '
'; + $out_att.= '
'; + } + } + $out_tbl.= ''; + $out_tbl.= ''; + + } +} +$out_schema.= ''; +$out_schema.= ''; + +echo $out_schema; +echo $out_schema_data; +echo $out_tbl; +echo $out_tbl_data; +echo $out_att; +echo $out_att_data; +?> \ No newline at end of file diff --git a/system/update12-20.php b/system/update12-20.php index e9c9027bb..f77acd05b 100644 --- a/system/update12-20.php +++ b/system/update12-20.php @@ -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 'public.tbl_organisationsform: '.pg_last_error($conn).'
'; + else + echo ' public.tbl_organisationsform: Tabelle wurde hinzugefügt!
'; +; +} + +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 'system schema: '.pg_last_error($conn).'
'; + else + echo 'system schema: Tabellen wurde hinzugefügt!
'; + +} ?> diff --git a/vilesci/left.php b/vilesci/left.php index 078bd2c3c..5010763bf 100644 --- a/vilesci/left.php +++ b/vilesci/left.php @@ -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!'); - ?> diff --git a/vilesci/stammdaten/organisationseinheiten.php b/vilesci/stammdaten/organisationseinheiten.php new file mode 100644 index 000000000..7fecfb051 --- /dev/null +++ b/vilesci/stammdaten/organisationseinheiten.php @@ -0,0 +1,96 @@ +, + * Andreas Oesterreicher , + * Rudolf Hangl and + * Gerald Simane-Sequens + */ +/** + * Stellt die Abhaengigkeiten Organisationseinheiten grafisch dar. + */ +require_once('../../config/vilesci.config.inc.php'); +require_once('../../include/organisationseinheit.class.php'); + +echo ' + + + Organisationseinheiten - Übersicht + + + + +

Organisationseinheiten - Übersicht


'; +$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 ''; + 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 ''; + $style = 'style="border: 1px solid gray; font-weight:bold; padding: 0px; margin:0;"'; + echo ''; + } + echo '
'; + + $obj = new organisationseinheit(); + $obj->load($key); + + if($obj->organisationseinheittyp_kurzbz=='Institut') + echo $obj->oe_kurzbz; + else + echo $obj->bezeichnung; + echo ''; + + if(is_array($val) && count($val)>0) + displayh($val); + + echo '
'; +} +echo ''; +?> \ No newline at end of file