Sync Lehrfach, Sprache, Diverse Aenderungen bei Sync Lehrverbaende, mitrabeiter, Studenten

This commit is contained in:
Andreas Österreicher
2006-11-29 15:18:25 +00:00
parent 6af0939000
commit d0c5e7e40d
10 changed files with 624 additions and 74 deletions
+101
View File
@@ -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 Lehrfaecher von Vilesci DB in PORTAL DB
*
*/
require_once('../../vilesci/config.inc.php');
require_once('../../include/fas/lehrfach.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
// ***********************************
//Mitarbeiter
$qry = "Select * FROM tbl_lehrfach";
if($result = pg_query($conn_vilesci, $qry))
{
$text.="\n Sync Lehrfaecher\n\n";
while($row = pg_fetch_object($result))
{
$error=false;
$lf = new lehrfach($conn);
$lf->lehrfach_nr = $row->lehrfach_nr;
$lf->studiengang_kz = $row->studiengang_kz;
$lf->fachbereich_id = $row->fachbereich_id;
$lf->kurzbz = $row->kurzbz;
$lf->bezeichnung = $row->bezeichnung;
$lf->farbe = $row->farbe;
$lf->aktiv = ($row->aktiv=='t'?true:false);
$lf->semester = $row->semester;
$lf->sprache = ($row->sprache!=''?$row->sprache:'German');
$qry = "SELECT count(*) as anz FROM tbl_lehrfach WHERE lehrfach_nr='$row->lehrfach_nr'";
if($row1 = pg_fetch_object(pg_query($conn, $qry)))
{
if($row1->anz>0) //wenn dieser eintrag schon vorhanden ist
$lf->new=false;
else
$lf->new=true;
if(!$lf->save())
{
$error_log.=$lf->errormsg."\n";
$anzahl_fehler++;
}
else
$anzahl_eingefuegt++;
}
else
$error_log .= "Fehler beim ermitteln der UID\n";
}
}
else
$error_log .= 'Lehrfaecher 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 - Lehrfach</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>
@@ -4,9 +4,6 @@
*
*/
require_once('../../vilesci/config.inc.php');
require_once('../../include/fas/person.class.php');
require_once('../../include/fas/benutzer.class.php');
require_once('../../include/fas/mitarbeiter.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");
@@ -43,7 +40,7 @@ $text .= "Anzahl der Fehler: $anzahl_fehler\n";
?>
<html>
<head>
<title>Synchro - Vilesci -> Portal - Personen</title>
<title>Synchro - Vilesci -> Portal - Lehrverbaende</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
+27 -5
View File
@@ -1,6 +1,26 @@
<?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 Personendatensaetze von Vilesci DB in PORTAL DB
* Synchronisiert Mitarbeiterdatensaetze von Vilesci DB in PORTAL DB
*
*/
require_once('../../vilesci/config.inc.php');
@@ -21,7 +41,7 @@ $anzahl_fehler=0;
// ***********************************
//Mitarbeiter
$qry = "SELECT * FROM tbl_person JOIN tbl_mitarbeiter USING(uid) WHERE personalnummer<>'OFF'";
$qry = "SELECT * FROM tbl_person JOIN tbl_mitarbeiter USING(uid) WHERE personalnummer<>'OFF' AND uid NOT LIKE '\_dummy%' AND uid NOT LIKE '\_Dummy%'";
if($result = pg_query($conn_vilesci, $qry))
{
@@ -40,7 +60,7 @@ if($result = pg_query($conn_vilesci, $qry))
$mitarbeiter->nachname=$row->nachname;
if(!$len=strpos($row->vornamen,' '))
{
$student->vorname=$row->vornamen;
$mitarbeiter->vorname=$row->vornamen;
$mitarbeiter->vornamen='';
}
else
@@ -111,8 +131,10 @@ if($result = pg_query($conn_vilesci, $qry))
$anzahl_fehler++;
}
else
$error_log .= "$row->nachname ($row->uid) hat keine Personalnummer\n";
$error_log .= "Fehler beim ermitteln der UID\n";
}
else
$error_log .= "$row->nachname ($row->uid) hat keine Personalnummer\n";
}
}
else
@@ -123,7 +145,7 @@ $text.="Anzahl der Fehler: $anzahl_fehler\n";
<html>
<head>
<title>Synchro - Vilesci -> Portal - Personen</title>
<title>Synchro - Vilesci -> Portal - Mitarbeiter</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
@@ -0,0 +1,73 @@
<?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 die Sprache von Vilesci DB in PORTAL DB
*
*/
require_once('../../vilesci/config.inc.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 sprache FROM tbl_sprache";
if($result = pg_query($conn_vilesci, $qry))
{
$text.="Sync der Sprache\n\n";
while($row=pg_fetch_object($result))
{
$qry = "INSERT INTO tbl_sprache(sprache) VALUES('$row->sprache');";
if(!pg_query($conn, $qry))
{
$error_log.= "Fehler beim einfuegen des Datensatzes: $qry";
$anzahl_fehler++;
}
else
$anzahl_eingefuegt++;
}
}
$text .= "Anzahl eingefuegter Datensaetze: $anzahl_eingefuegt\n";
$text .= "Anzahl der Fehler: $anzahl_fehler\n";
?>
<html>
<head>
<title>Synchro - Vilesci -> Portal - Sprache</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>
@@ -1,4 +1,24 @@
<?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 Studentendatensaetze von Vilesci DB in PORTAL DB
*
+21 -20
View File
@@ -27,11 +27,11 @@ class benutzer extends person
var $bnaktiv; // boolean
var $alias; // varchar(256)
/**
* Konstruktor - Uebergibt die Connection und laedt optional einen benutzer
* @param $conn Datenbank-Connection
* $benutzer_id Benutzer der geladen werden soll (default=null)
*/
// **************************************************************************
// * Konstruktor - Uebergibt die Connection und laedt optional einen Benutzer
// * @param $conn Datenbank-Connection
// * $benutzer_id Benutzer der geladen werden soll (default=null)
// **************************************************************************
function benutzer($conn, $benutzer_id=null, $unicode=false)
{
$this->conn = $conn;
@@ -51,18 +51,20 @@ class benutzer extends person
$this->load($benutzer_id);
}
/**
* Laedt Benutzer mit der uebergebenen ID
* @param $benutzer_id ID der Person die geladen werden soll
*/
// ***********************************************************
// * Laedt Benutzer mit der uebergebenen ID
// * @param $benutzer_id ID der Person die geladen werden soll
// ***********************************************************
function load($benutzer_id)
{
}
/**
* Prueft die Variablen auf gueltigkeit
*/
// *******************************************
// * Prueft die Variablen vor dem Speichern
// * auf Gueltigkeit.
// * @return true wenn ok, false im Fehlerfall
// *******************************************
function validate()
{
if(strlen($this->uid)>16)
@@ -92,12 +94,12 @@ class benutzer extends person
}
}
/**
* Speichert die Benutzerdaten in die Datenbank
* Wenn $new auf true gesetzt ist wird ein neuer Datensatz angelegt
* ansonsten der Datensatz mit $uid upgedated
* @return true wenn erfolgreich, false im Fehlerfall
*/
// ******************************************************************
// * Speichert die Benutzerdaten in die Datenbank
// * Wenn $new auf true gesetzt ist wird ein neuer Datensatz angelegt
// * ansonsten der Datensatz mit $uid upgedated
// * @return true wenn erfolgreich, false im Fehlerfall
// ******************************************************************
function save()
{
//Variablen auf Gueltigkeit pruefen
@@ -124,8 +126,7 @@ class benutzer extends person
$this->addslashes($this->insertamum).",".
$this->addslashes($this->insertvon).",".
$this->addslashes($this->updateamum).",".
$this->addslashes($this->updatevon).",".
");";
$this->addslashes($this->updatevon).");";
}
else
{
+232
View File
@@ -0,0 +1,232 @@
<?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>.
*/
class lehrfach
{
var $conn; // resource DB-Handle
var $errormsg; // string
var $new; // boolean
var $lehrfaecher = array(); // lehrfach Objekt
//Tabellenspalten
var $lehrfach_nr; // integer
var $studiengang_kz; // integer
var $fachbereich_id; // integer
var $kurzbz; // varchar(12)
var $bezeichnung; // varchar(255)
var $farbe; // char(6)
var $aktiv; // boolean
var $semester; // smallint
var $sprache; // varchar(16)
// ***********************************************************************
// * Konstruktor - Uebergibt die Connection und laedt optional ein LF
// * @param $conn Datenbank-Connection
// * $lehrfach_nr Lehrfach das geladen werden soll (default=null)
// * $unicode Gibt an ob die Daten mit UNICODE Codierung
// * oder LATIN9 Codierung verarbeitet werden sollen
// ***********************************************************************
function lehrfach($conn, $lehrfach_nr=null, $unicode=false)
{
$this->conn = $conn;
if($unicode)
$qry = "SET CLIENT_ENCODING TO 'UNICODE';";
else
$qry = "SET CLIENT_ENCODING TO 'LATIN9';";
if(!pg_query($conn,$qry))
{
$this->errormsg = 'Encoding konnte nicht gesetzt werden';
return false;
}
if($lehrfach_nr != null)
$this->load($lehrfach_nr);
}
// *********************************************************
// * Laedt Lehrfach mit der uebergebenen ID
// * @param $lehrfach_nr Nr des LF das geladen werden soll
// *********************************************************
function load($lehrfach_nr)
{
//lehrfach_nr auf Gueltigkeit pruefen
if(is_numeric($lehrfach_nr) && $lehrfach_nr!='')
{
$qry = "SELECT * FROM tbl_lehrfach WHERE lehrfach_nr='$lehrfach_nr'";
if(!$result=pg_query($this->conn,$qry))
{
$this->errormsg = 'Fehler beim lesen des Lehrfaches';
return false;
}
if($row = pg_fetch_object($result))
{
$this->lehrfach_nr = $row->lehrfach_nr;
$this->studiengang_kz = $row->studiengang_kz;
$this->fachbereich_id = $row->fachbereich_id;
$this->kurzbz = $row->kurzbz;
$this->bezeichnung = $row->bezeichnung;
$this->farbe = $row->farbe;
$this->aktiv = ($row->aktiv=='t'?true:false);
$this->semester = $row->semester;
$this->sprache = $row->sprache;
}
else
{
$this->errormsg = 'Es ist kein Lehrfach mit der Nr '.$lehrfach_nr.' vorhanden';
return false;
}
return true;
}
else
{
$this->errormsg = 'Die lehrfach_nr muss eine gueltige Zahl sein';
return false;
}
}
// *******************************************
// * Prueft die Variablen vor dem Speichern
// * auf Gueltigkeit.
// * @return true wenn ok, false im Fehlerfall
// *******************************************
function validate()
{
if(!is_numeric($this->studiengang_kz))
{
$this->errormsg = 'Studiengang_kz muss eine gueltige Zahl sein';
return false;
}
if(!is_numeric($this->fachbereich_id))
{
$this->errormsg = 'Fachbereich_id muss eine gueltige Zahl sein';
return false;
}
if(strlen($this->kurzbz)>12)
{
$this->errormsg = 'Kurzbezeichnung darf nicht laenger als 12 Zeichen sein';
return false;
}
if(strlen($this->bezeichnung)>255)
{
$this->errormsg = 'Bezeichnung darf nicht laenger als 255 Zeichen sein';
return false;
}
if(strlen($this->farbe)>6)
{
$this->errormsg = 'Farbe darf nicht laenger als 6 Zeichen sein';
return false;
}
if(!is_bool($this->aktiv))
{
$this->errormsg = 'Aktiv muss ein boolscher Wert sein';
return false;
}
if($this->semester!='' && !is_numeric($this->semester))
{
$this->errormsg = 'Semester muss eine Zahl sein';
return false;
}
if(strlen($this->sprache)>16)
{
$this->errormsg = 'Sprache darf nicht laenger als 16 Zeichen sein';
return false;
}
return true;
}
// ************************************************
// * wenn $var '' ist wird "null" zurueckgegeben
// * wenn $var !='' ist werden Datenbankkritische
// * zeichen mit backslash versehen und das ergbnis
// * unter hochkomma gesetzt.
// ************************************************
function addslashes($var)
{
return ($var!=''?"'".addslashes($var)."'":'null');
}
// ************************************************************
// * Speichert das Lehrfach in die Datenbank
// * Wenn $new auf true gesetzt ist wird ein neuer Datensatz
// * angelegt, ansonsten der Datensatz mit $lehrfach_nr upgedated
// * @return true wenn erfolgreich, false im Fehlerfall
// ************************************************************
function save()
{
//Variablen auf Gueltigkeit pruefen
if(!$this->validate())
return false;
if($this->new)
{
$qry = 'INSERT INTO tbl_lehrfach (lehrfach_nr, studiengang_kz, fachbereich_id, kurzbz,
bezeichnung, farbe, aktiv, semester, sprache)
VALUES('.$this->addslashes($this->lehrfach_nr).','.
$this->addslashes($this->studiengang_kz).','.
$this->addslashes($this->fachbereich_id).','.
$this->addslashes($this->kurzbz).','.
$this->addslashes($this->bezeichnung).','.
$this->addslashes($this->farbe).','.
($this->aktiv?'true':'false').','.
$this->addslashes($this->semester).','.
$this->addslashes($this->sprache).');';
}
else
{
//lehrfach_nr auf Gueltigkeit pruefen
if(!is_numeric($this->lehrfach_nr))
{
$this->errormsg = 'Lehrfach_nr muss eine gueltige Zahl sein';
return false;
}
$qry = 'UPDATE tbl_lehrfach SET'.
' studiengang_kz='.$this->addslashes($this->studiengang_kz).','.
' fachbereich_id='.$this->addslashes($this->fachbereich_id).','.
' kurzbz='.$this->addslashes($this->kurzbz).','.
' bezeichnung='.$this->addslashes($this->bezeichnung).','.
' farbe='.$this->addslashes($this->farbe).','.
' aktiv='.($this->aktiv?'true':'false').','.
' semester='.$this->semester.','.
' sprache='.$this->addslashes($this->sprache).
" WHERE lehrfach_nr='$this->lehrfach_nr'";
}
if(pg_query($this->conn,$qry))
{
//Log schreiben
return true;
}
else
{
$this->errormsg = 'Fehler beim Speichern des Lehrfaches:'.$qry;
return false;
}
}
}
?>
+33 -15
View File
@@ -1,7 +1,23 @@
<?php
/**
* Klasse Mitarbeiter abgeleitet von Benutzer (Portal)
* @create 27-11-2006
/* 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>.
*/
class mitarbeiter extends benutzer
@@ -15,9 +31,11 @@ class mitarbeiter extends benutzer
var $fixangestellt; //boolean
var $telefonklappe; //varchar(25)
/**
* Konstruktor
*/
// ***********************************************************************
// * Konstruktor - Uebergibt die Connection und laedt optional eine Person
// * @param $conn Datenbank-Connection
// * $person_id Person die geladen werden soll (default=null)
// ***********************************************************************
function mitarbeiter($conn, $person_id=null, $unicode=false)
{
$this->conn = $conn;
@@ -38,10 +56,10 @@ class mitarbeiter extends benutzer
$this->load($person_id);
}
/**
* ueberprueft die Variablen auf Gueltigkeit
* @return true wenn gueltig, false im Fehlerfall
*/
// ************************************************
// * ueberprueft die Variablen auf Gueltigkeit
// * @return true wenn gueltig, false im Fehlerfall
// ************************************************
function validate()
{
if(strlen($this->uid)>16)
@@ -94,10 +112,10 @@ class mitarbeiter extends benutzer
}
/**
* Speichert die Mitarbeiterdaten in die Datenbank
* @return true wenn ok, false im Fehlerfall
*/
// *************************************************
// * Speichert die Mitarbeiterdaten in die Datenbank
// * @return true wenn ok, false im Fehlerfall
// *************************************************
function save()
{
//Variablen checken
@@ -125,7 +143,7 @@ class mitarbeiter extends benutzer
($this->fixangestellt?'true':'false').','.
$this->addslashes($this->telefonklappe).','.
$this->addslashes($this->updateamum).','.
$this->updatevon."');";
$this->addslashes($this->updatevon).');';
}
else
{
+100 -19
View File
@@ -53,11 +53,11 @@ class person
var $updatevon; // varchar(16)
var $ext_id; // bigint
/**
* Konstruktor - Uebergibt die Connection und laedt optional eine Person
* @param $conn Datenbank-Connection
* $person_id Person die geladen werden soll (default=null)
*/
// ***********************************************************************
// * Konstruktor - Uebergibt die Connection und laedt optional eine Person
// * @param $conn Datenbank-Connection
// * $person_id Person die geladen werden soll (default=null)
// ***********************************************************************
function person($conn, $person_id=null, $unicode=false)
{
$this->conn = $conn;
@@ -77,10 +77,10 @@ class person
$this->load($person_id);
}
/**
* Laedt Person mit der uebergebenen ID
* @param $person_id ID der Person die geladen werden soll
*/
// *********************************************************
// * Laedt Person mit der uebergebenen ID
// * @param $person_id ID der Person die geladen werden soll
// *********************************************************
function load($person_id)
{
//person_id auf gueltigkeit pruefen
@@ -117,7 +117,7 @@ class person
$this->ersatzkennzeichen = $row->ersatzkennzeichen;
$this->familienstand = $row->familienstand;
$this->anzahlkinder = $row->anzahlkinder;
$this->aktiv = $row->aktiv;
$this->aktiv = ($row->aktiv=='t'?true:false);
$this->insertamum = $row->insertamum;
$this->insertvon = $row->insertvon;
$this->updateamum = $row->updateamum;
@@ -139,6 +139,11 @@ class person
}
}
// *******************************************
// * Prueft die Variablen vor dem Speichern
// * auf Gueltigkeit.
// * @return true wenn ok, false im Fehlerfall
// *******************************************
function validate()
{
if(strlen($this->sprache)>16)
@@ -166,28 +171,104 @@ class person
$this->errormsg = 'Nachname darf nicht laenger als 64 Zeichen sein';
return false;
}
//...
return true;
if(strlen($this->vorname)>32)
{
$this->errormsg = 'Vorname darf nicht laenger als 32 Zeichen sein';
return false;
}
if(strlen($this->vornamen)>128)
{
$this->errormsg = 'Vornamen darf nicht laenger als 128 Zeichen sein';
return false;
}
//ToDo Gebdatum pruefen -> laut bis muss er aelter als 10 Jahre sein
if(strlen($this->gebort)>128)
{
$this->errormsg = 'Geburtsort darf nicht laenger als 128 Zeichen sein';
return false;
}
if($this->foto!='' && !is_numeric($this->foto))
{
$this->errormsg = 'FotoOID ist ungueltig';
return false;
}
if(strlen($this->anmerkungen)>256)
{
$this->errormsg = 'Anmerkungen darf nicht laenger als 256 Zeichen sein';
return false;
}
if(strlen($this->homepage)>256)
{
$this->errormsg = 'Homepage darf nicht laenger als 256 Zeichen sein';
return false;
}
if(strlen($this->svnr)>10)
{
$this->errormsg = 'SVNR darf nicht laenger als 10 Zeichen sein';
return false;
}
if(strlen($this->ersatzkennzeichen)>10)
{
$this->errormsg = 'Ersatzkennzeichen darf nicht laenger als 10 Zeichen sein';
return false;
}
if(strlen($this->familienstand)>1)
{
$this->errormsg = 'Familienstand ist ungueltig';
return false;
}
if($this->anzahlkinder!='' && !is_numeric($this->anzahlkinder))
{
$this->errormsg = 'Anzahl der Kinder ist ungueltig';
return false;
}
if(!is_bool($this->aktiv))
{
$this->errormsg = 'Aktiv ist ungueltig';
return false;
}
if(strlen($this->insertvon)>16)
{
$this->errormsg = 'Insertvon darf nicht laenger als 16 Zeichen sien';
return false;
}
if(strlen($this->updatevon)>16)
{
$this->errormsg = 'Updatevon darf nicht laenger als 16 Zeichen sein';
return false;
}
if($this->ext_id!='' && !is_numeric($this->ext_id))
{
$this->errormsg = 'Ext_ID ist keine gueltige Zahl';
return false;
}
return true;
}
// ************************************************
// * wenn $var '' ist wird "null" zurueckgegeben
// * wenn $var !='' ist werden Datenbankkritische
// * zeichen mit backslash versehen und das ergbnis
// * unter hochkomma gesetzt.
// ************************************************
function addslashes($var)
{
return ($var!=''?"'".addslashes($var)."'":'null');
}
/**
* Speichert die Personendaten in die Datenbank
* Wenn $new auf true gesetzt ist wird ein neuer Datensatz angelegt
* ansonsten der Datensatz mit $person_id upgedated
* @return true wenn erfolgreich, false im Fehlerfall
*/
// ************************************************************
// * Speichert die Personendaten in die Datenbank
// * Wenn $new auf true gesetzt ist wird ein neuer Datensatz
// * angelegt, ansonsten der Datensatz mit $person_id upgedated
// * @return true wenn erfolgreich, false im Fehlerfall
// ************************************************************
function save()
{
//Variablen auf Gueltigkeit pruefen
if(!$this->validate())
return false;
/*
/* Verschachtelte transaktionen funktionieren nicht!
if(!pg_query($this->conn,'BEGIN;'))
{
$this->errormsg = 'Transaktion konnte nicht gesetzt werden';
+16 -11
View File
@@ -31,9 +31,11 @@ class student extends benutzer
var $verband;
var $gruppe;
/**
* Konstruktor
*/
// ***********************************************************************
// * Konstruktor - Uebergibt die Connection und laedt optional eine Person
// * @param $conn Datenbank-Connection
// * $person_id Person die geladen werden soll (default=null)
// ***********************************************************************
function student($conn, $student_id=null, $unicode=false)
{
$this->conn = $conn;
@@ -54,10 +56,11 @@ class student extends benutzer
$this->load($student_id);
}
/**
* ueberprueft die Variablen auf Gueltigkeit
* @return true wenn gueltig, false im Fehlerfall
*/
// *******************************************
// * Prueft die Variablen vor dem Speichern
// * auf Gueltigkeit.
// * @return true wenn ok, false im Fehlerfall
// *******************************************
function validate()
{
if(strlen($this->uid)>16)
@@ -110,10 +113,12 @@ class student extends benutzer
}
/**
* Speichert die Studentendaten in die Datenbank
* @return true wenn ok, false im Fehlerfall
*/
// ************************************************************
// * Speichert die Studentendaten in die Datenbank
// * Wenn $new auf true gesetzt ist wird ein neuer Datensatz
// * angelegt, ansonsten der Datensatz mit $person_id upgedated
// * @return true wenn erfolgreich, false im Fehlerfall
// ************************************************************
function save()
{
//Variablen checken