SYNC Scripte für benutzergruppe, gruppe, personlvstudiensemester, reservierung und variable

This commit is contained in:
Andreas Österreicher
2006-12-04 13:55:10 +00:00
parent ba7f640e7c
commit 44979bb8df
16 changed files with 1442 additions and 247 deletions
@@ -0,0 +1,101 @@
<?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>.
*/
/**
* Synchronisiert BenutzerGruppen von Vilesci DB in PORTAL DB
*
*/
require_once('../../vilesci/config.inc.php');
require_once('../../include/fas/benutzergruppe.class.php');
$conn=pg_connect(CONN_STRING) or die('Connection zur Portal Datenbank fehlgeschlagen');
$conn_vilesci=pg_connect(CONN_STRING_VILESCI) or die('Connection zur Vilesci Datenbank fehlgeschlagen');
$error_log='';
$text = '';
$anzahl_eingefuegt=0;
$anzahl_fehler=0;
// ***********************************
// * VILESCI->PORTAL - Synchronisation
// ***********************************
$qry = 'SELECT uid, mailgrp_kurzbz as gruppe_kurzbz, updateamum, updatevon
FROM tbl_personmailgrp
UNION
SELECT uid, einheit_kurzbz as gruppe_kurzbz, updateamum, updatevon
FROM tbl_einheitstudent';
if($result = pg_query($conn_vilesci, $qry))
{
$text.="\n Sync BenutzerGruppe\n\n";
while($row = pg_fetch_object($result))
{
$bngruppe = new benutzergruppe($conn);
$bngruppe->gruppe_kurzbz = $row->gruppe_kurzbz;
$bngruppe->uid = $row->uid;
$bngruppe->updateamum = $row->updateamum;
$bngruppe->updatevon = $row->updatevon;
$bngruppe->insertamum = '';
$bngruppe->insertvon = '';
$qry = "SELECT count(*) as anz FROM tbl_benutzergruppe WHERE
gruppe_kurzbz='".addslashes($row->gruppe_kurzbz)."' AND uid='".addslashes($row->uid)."'";
if($row1=pg_fetch_object(pg_query($conn,$qry)))
{
$new = ($row1->anz>0?false:true);
if(!$bngruppe->save($new))
{
$anzahl_fehler++;
$error_log .= $bngruppe->errormsg."\n";
}
else
$anzahl_eingefuegt++;
}
else
{
$error_log.='Fehler beim Auslesen';
$anzahl_fehler++;
}
}
}
else
$error_log .= "BenutzerGruppen konnten nicht geladen werden\n";
$text.="Anzahl aktualisierte Datensaetze: $anzahl_eingefuegt\n";
$text.="Anzahl der Fehler: $anzahl_fehler\n";
?>
<html>
<head>
<title>Synchro - Vilesci -> Portal - BenutzerGruppe</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
echo nl2br($text);
echo nl2br($error_log);
?>
</body>
</html>
+111
View File
@@ -0,0 +1,111 @@
<?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>.
*/
/**
* Synchronisiert Gruppen von Vilesci DB in PORTAL DB
*
*/
require_once('../../vilesci/config.inc.php');
require_once('../../include/fas/gruppe.class.php');
$conn=pg_connect(CONN_STRING) or die('Connection zur Portal Datenbank fehlgeschlagen');
$conn_vilesci=pg_connect(CONN_STRING_VILESCI) or die('Connection zur Vilesci Datenbank fehlgeschlagen');
$error_log='';
$text = '';
$anzahl_eingefuegt=0;
$anzahl_fehler=0;
// ***********************************
// * VILESCI->PORTAL - Synchronisation
// ***********************************
$qry = 'SELECT einheit_kurzbz as gruppe_kurzbz, studiengang_kz, bezeichnung, semester, typ, mailgrp_kurzbz,
bezeichnung as mailgrp_beschreibung, true as sichtbar , true as aktiv, null as updateamum,
null as updatevon, null as insertamum, null as insertvon
FROM tbl_einheit WHERE mailgrp_kurzbz is null
UNION
SELECT mailgrp_kurzbz as gruppe_kurzbz, studiengang_kz, beschreibung as bezeichnung, null as semester,
null as typ, mailgrp_kurzbz, beschreibung as mailgrp_beschreibung, sichtbar, aktiv, null as updateamum,
null as updatevon, null as insertamum, null as insertvon
FROM tbl_mailgrp';
if($result = pg_query($conn_vilesci, $qry))
{
$text.="\n Sync Gruppe\n\n";
while($row = pg_fetch_object($result))
{
$gruppe = new gruppe($conn);
$gruppe->gruppe_kurzbz = $row->gruppe_kurzbz;
$gruppe->studiengang_kz = $row->studiengang_kz;
$gruppe->bezeichnung = $row->bezeichnung;
$gruppe->semester = $row->semester;
$gruppe->typ = $row->typ;
$gruppe->mailgrp_kurzbz = $row->mailgrp_kurzbz;
$gruppe->mailgrp_beschreibung = $row->mailgrp_beschreibung;
$gruppe->sichtbar = ($row->sichtbar=='f'?true:false);
$gruppe->aktiv = ($row->aktiv=='t'?true:false);
$gruppe->updateamum = $row->updateamum;
$gruppe->updatevon = $row->updatevon;
$gruppe->insertamum = $row->insertamum;
$gruppe->insertvon = $row->insertvon;
$qry = "SELECT count(*) as anz FROM tbl_gruppe where gruppe_kurzbz='".addslashes($row->gruppe_kurzbz)."'";
if($row1=pg_fetch_object(pg_query($conn,$qry)))
{
$new = ($row1->anz>0?false:true);
if(!$gruppe->save($new))
{
$anzahl_fehler++;
$error_log .= $gruppe->errormsg."\n";
}
else
$anzahl_eingefuegt++;
}
else
{
$error_log.='Fehler beim Auslesen';
$anzahl_fehler++;
}
}
}
else
$error_log .= "Gruppen konnten nicht geladen werden\n";
$text.="Anzahl aktualisierte Datensaetze: $anzahl_eingefuegt\n";
$text.="Anzahl der Fehler: $anzahl_fehler\n";
?>
<html>
<head>
<title>Synchro - Vilesci -> Portal - Gruppe</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
echo nl2br($text);
echo nl2br($error_log);
?>
</body>
</html>
@@ -41,7 +41,7 @@ $anzahl_fehler=0;
// ***********************************
//Mitarbeiter
$qry = "SELECT * FROM tbl_person JOIN tbl_mitarbeiter USING(uid) WHERE personalnummer<>'OFF' AND uid NOT LIKE '\_dummy%' AND uid NOT LIKE '\_Dummy%'";
$qry = "SELECT * FROM tbl_person JOIN tbl_mitarbeiter USING(uid) WHERE uid NOT LIKE '\_dummy%' AND uid NOT LIKE '\_Dummy%'";
if($result = pg_query($conn_vilesci, $qry))
{
@@ -57,6 +57,7 @@ if($result = pg_query($conn_vilesci, $qry))
$mitarbeiter->anrede='';
$mitarbeiter->titelpost='';
$mitarbeiter->titelpre=$row->titel;
$mitarbeiter->nachname=$row->nachname;
if(!$len=strpos($row->vornamen,' '))
{
@@ -0,0 +1,104 @@
<?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>.
*/
/**
* Synchronisiert tbl_personlvstudiensemester von Vilesci DB in PORTAL DB
*
*/
require_once('../../vilesci/config.inc.php');
require_once('../../include/fas/personlvstudiensemester.class.php');
$conn=pg_connect(CONN_STRING) or die('Connection zur Portal Datenbank fehlgeschlagen');
$conn_vilesci=pg_connect(CONN_STRING_VILESCI) or die('Connection zur Vilesci Datenbank fehlgeschlagen');
$error_log='';
$text = '';
$anzahl_eingefuegt=0;
$anzahl_fehler=0;
// ***********************************
// * VILESCI->PORTAL - Synchronisation
// ***********************************
$qry = 'SELECT * FROM tbl_personlehrfachstudiensemester';
if($result = pg_query($conn_vilesci, $qry))
{
$text.="\n Sync Personlvstudiensemester\n\n";
while($row = pg_fetch_object($result))
{
$obj = new personlvstudiensemester($conn);
$obj->uid = $row->uid;
$obj->studiensemester_kurzbz = $row->studiensemester_kurzbz;
$qry = "SELECT lehrveranstaltung_nr FROM tbl_lehrveranstaltung WHERE ext_id=$row->lehrfach_nr";
if($row1 = pg_fetch_object(pg_query($conn,$qry)))
{
$obj->lehrveranstaltung_nr = $row1->lehrveranstaltung_nr;
$qry = "SELECT count(*) as anz FROM tbl_personlvstudiensemester WHERE
uid='".addslashes($row->uid)."' AND studiensemester_kurzbz='".addslashes($row->studiensemester_kurzbz)."'
AND lehrveranstaltung_nr='".addslashes($row1->lehrveranstaltung_nr)."';";
if($row1=pg_fetch_object(pg_query($conn,$qry)))
{
$new = ($row1->anz>0?false:true);
if(!$obj->save($new))
{
$anzahl_fehler++;
$error_log .= $obj->errormsg."\n";
}
else
$anzahl_eingefuegt++;
}
else
{
$error_log.='Fehler beim Auslesen';
$anzahl_fehler++;
}
}
else
{
$error_log .= 'Fehler beim auslesen der Lehrveranstaltung_nr\n';
$anzahl_fehler++;
}
}
}
else
$error_log .= "PersonLVStudiensemester konnten nicht geladen werden\n";
$text.="Anzahl aktualisierte Datensaetze: $anzahl_eingefuegt\n";
$text.="Anzahl der Fehler: $anzahl_fehler\n";
?>
<html>
<head>
<title>Synchro - Vilesci -> Portal - PersonLVStudiensemester</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
echo nl2br($text);
echo nl2br($error_log);
?>
</body>
</html>
@@ -0,0 +1,102 @@
<?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>.
*/
/**
* Synchronisiert Reservierungen von Vilesci DB in PORTAL DB
*
*/
require_once('../../vilesci/config.inc.php');
require_once('../../include/fas/reservierung.class.php');
$conn=pg_connect(CONN_STRING) or die('Connection zur Portal Datenbank fehlgeschlagen');
$conn_vilesci=pg_connect(CONN_STRING_VILESCI) or die('Connection zur Vilesci Datenbank fehlgeschlagen');
$error_log='';
$text = '';
$anzahl_eingefuegt=0;
$anzahl_fehler=0;
// ***********************************
// * VILESCI->PORTAL - Synchronisation
// ***********************************
$qry = 'Select * FROM tbl_reservierung';
if($result = pg_query($conn_vilesci, $qry))
{
$text.="\n Sync Reservierung\n\n";
while($row = pg_fetch_object($result))
{
$reservierung = new reservierung($conn);
$reservierung->reservierung_id = $row->reservierung_id;
$reservierung->ort_kurzbz = $row->ort_kurzbz;
$reservierung->studiengang_kz = $row->studiengang_kz;
$reservierung->uid = $row->uid;
$reservierung->stunde = $row->stunde;
$reservierung->datum = $row->datum;
$reservierung->titel = $row->titel;
$reservierung->beschreibung = $row->beschreibung;
$reservierung->semester = $row->semester;
$reservierung->verband = $row->verband;
$reservierung->gruppe = $row->gruppe;
$reservierung->gruppe_kurzbz = $row->einheit_kurzbz;
$qry = "SELECT count(*) as anz FROM tbl_reservierung where reservierung_id='".addslashes($row->reservierung_id)."'";
if($row1 =pg_fetch_object(pg_query($conn,$qry)))
{
$var = ($row1->anz>0?false:true);
//Wenn reservierung vorhanden ist dann updaten sonst neu einfuegen
if(!$reservierung->save($var))
{
$anzahl_fehler++;
$error_log .= $reservierung->errormsg."\n";
}
else
$anzahl_eingefuegt++;
}
else
{
$error_log.='Fehler beim Auslesen';
$anzahl_fehler++;
}
}
}
else
$error_log .= "Reservierungen konnten nicht geladen werden\n";
$text.="Anzahl aktualisierte Datensaetze: $anzahl_eingefuegt\n";
$text.="Anzahl der Fehler: $anzahl_fehler\n";
?>
<html>
<head>
<title>Synchro - Vilesci -> Portal - Reservierung</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
echo nl2br($text);
echo nl2br($error_log);
?>
</body>
</html>
@@ -0,0 +1,94 @@
<?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>.
*/
/**
* Synchronisiert tbl_variable von Vilesci DB in PORTAL DB
*
*/
require_once('../../vilesci/config.inc.php');
require_once('../../include/fas/variable.class.php');
$conn=pg_connect(CONN_STRING) or die("Connection zur Portal Datenbank fehlgeschlagen");
$conn_vilesci=pg_connect(CONN_STRING_VILESCI) or die("Connection zur Vilesci Datenbank fehlgeschlagen");
$error_log='';
$text = '';
$anzahl_eingefuegt=0;
$anzahl_fehler=0;
// ***********************************
// * VILESCI->PORTAL - Synchronisation
// ***********************************
$qry = "SELECT * FROM tbl_variable";
if($result = pg_query($conn_vilesci, $qry))
{
$text.="\n Sync Variable\n\n";
while($row = pg_fetch_object($result))
{
$error=false;
$var = new variable($conn);
$var->uid = $row->uid;
$var->name = $row->name;
$var->wert = $row->wert;
$qry = "SELECT count(*) as anz FROM tbl_variable WHERE uid='$row->uid' AND name='$row->name'";
if($row1 = pg_fetch_object(pg_query($conn, $qry)))
{
if($row1->anz>0) //wenn dieser eintrag schon vorhanden ist
$new=false;
else
$new=true;
if(!$var->save($new))
{
$error_log.=$var->errormsg."\n";
$anzahl_fehler++;
}
else
$anzahl_eingefuegt++;
}
else
$error_log .= "Fehler beim ermitteln der Variable\n";
}
}
else
$error_log .= 'Variablendatensaetze konnten nicht geladen werden\n';
$text.="Anzahl aktualisierte Datensaetze: $anzahl_eingefuegt\n";
$text.="Anzahl der Fehler: $anzahl_fehler\n";
?>
<html>
<head>
<title>Synchro - Vilesci -> Portal - Variable</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
echo nl2br($text);
echo nl2br($error_log);
?>
</body>
</html>