mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
_validate method of Person controller now checks correctly the parameters, in accordance with the table structure
This commit is contained in:
@@ -24,8 +24,6 @@ class Person extends APIv1_Controller
|
||||
parent::__construct();
|
||||
// Load model PersonModel
|
||||
$this->load->model('person/person_model', 'PersonModel');
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,43 +116,49 @@ class Person extends APIv1_Controller
|
||||
return $this->_error('Parameter is null');
|
||||
}
|
||||
|
||||
$person['nachname'] = trim($person['nachname']);
|
||||
$person['vorname'] = trim($person['vorname']);
|
||||
$person['vornamen'] = trim($person['vornamen']);
|
||||
$person['anrede'] = trim($person['anrede']);
|
||||
$person['titelpost'] = trim($person['titelpost']);
|
||||
$person['titelpre'] = trim($person['titelpre']);
|
||||
|
||||
if (mb_strlen($person['sprache']) > 16)
|
||||
if (isset($person['nachname']))
|
||||
$person['nachname'] = trim($person['nachname']);
|
||||
if (isset($person['vorname']))
|
||||
$person['vorname'] = trim($person['vorname']);
|
||||
if (isset($person['vornamen']))
|
||||
$person['vornamen'] = trim($person['vornamen']);
|
||||
if (isset($person['anrede']))
|
||||
$person['anrede'] = trim($person['anrede']);
|
||||
if (isset($person['titelpost']))
|
||||
$person['titelpost'] = trim($person['titelpost']);
|
||||
if (isset($person['titelpre']))
|
||||
$person['titelpre'] = trim($person['titelpre']);
|
||||
|
||||
if (isset($person['sprache']) && mb_strlen($person['sprache']) > 16)
|
||||
{
|
||||
return $this->_error('Sprache darf nicht laenger als 16 Zeichen sein');
|
||||
}
|
||||
if (mb_strlen($person['anrede']) > 16)
|
||||
if (isset($person['anrede']) && mb_strlen($person['anrede']) > 16)
|
||||
{
|
||||
return $this->_error('Anrede darf nicht laenger als 16 Zeichen sein');
|
||||
}
|
||||
if (mb_strlen($person['titelpost']) > 32)
|
||||
if (isset($person['titelpost']) && mb_strlen($person['titelpost']) > 32)
|
||||
{
|
||||
return $this->_error('Titelpost darf nicht laenger als 32 Zeichen sein');
|
||||
}
|
||||
if (mb_strlen($person['titelpre']) > 64)
|
||||
if (isset($person['titelpre']) && mb_strlen($person['titelpre']) > 64)
|
||||
{
|
||||
return $this->_error('Titelpre darf nicht laenger als 64 Zeichen sein');
|
||||
}
|
||||
if (mb_strlen($person['nachname']) > 64)
|
||||
if (isset($person['nachname']) && mb_strlen($person['nachname']) > 64)
|
||||
{
|
||||
return $this->_error('Nachname darf nicht laenger als 64 Zeichen sein');
|
||||
}
|
||||
if ($person['nachname'] == '' || is_null($person['nachname']))
|
||||
if (isset($person['nachname']) && ($person['nachname'] == '' || is_null($person['nachname'])))
|
||||
{
|
||||
return $this->_error('Nachname muss eingegeben werden');
|
||||
}
|
||||
|
||||
if (mb_strlen($person['vorname']) > 32)
|
||||
if (isset($person['vorname']) && mb_strlen($person['vorname']) > 32)
|
||||
{
|
||||
return $this->_error('Vorname darf nicht laenger als 32 Zeichen sein');
|
||||
}
|
||||
if (mb_strlen($person['vornamen']) > 128)
|
||||
if (isset($person['vornamen']) && mb_strlen($person['vornamen']) > 128)
|
||||
{
|
||||
return $this->_error('Vornamen darf nicht laenger als 128 Zeichen sein');
|
||||
}
|
||||
@@ -164,32 +168,32 @@ class Person extends APIv1_Controller
|
||||
return $this->_error("Geburtsdatum muss eingegeben werden\n";
|
||||
return false;
|
||||
} */
|
||||
if (mb_strlen($person['gebort']) > 128)
|
||||
if (isset($person['gebort']) && mb_strlen($person['gebort']) > 128)
|
||||
{
|
||||
return $this->_error('Geburtsort darf nicht laenger als 128 Zeichen sein');
|
||||
}
|
||||
|
||||
if (mb_strlen($person['homepage']) > 256)
|
||||
if (isset($person['homepage']) && mb_strlen($person['homepage']) > 256)
|
||||
{
|
||||
return $this->_error('Homepage darf nicht laenger als 256 Zeichen sein');
|
||||
}
|
||||
if (mb_strlen($person['svnr']) > 16)
|
||||
if (isset($person['svnr']) && mb_strlen($person['svnr']) > 16)
|
||||
{
|
||||
return $this->_error('SVNR darf nicht laenger als 16 Zeichen sein');
|
||||
}
|
||||
|
||||
if (mb_strlen($person['matr_nr']) > 32)
|
||||
if (isset($person['matr_nr']) && mb_strlen($person['matr_nr']) > 32)
|
||||
{
|
||||
return $this->_error('Matrikelnummer darf nicht laenger als 32 Zeichen sein');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($person['svnr'] != '' && mb_strlen($person['svnr']) != 16 && mb_strlen($person['svnr']) != 10)
|
||||
if (isset($person['svnr']) && $person['svnr'] != '' && mb_strlen($person['svnr']) != 16 && mb_strlen($person['svnr']) != 10)
|
||||
{
|
||||
return $this->_error('SVNR muss 10 oder 16 Zeichen lang sein');
|
||||
}
|
||||
|
||||
if ($person['svnr'] != '' && mb_strlen($person['svnr']) == 10)
|
||||
if (isset($person['svnr']) && $person['svnr'] != '' && mb_strlen($person['svnr']) == 10)
|
||||
{
|
||||
//SVNR mit Pruefziffer pruefen
|
||||
//Die 4. Stelle in der SVNR ist die Pruefziffer
|
||||
@@ -225,27 +229,27 @@ class Person extends APIv1_Controller
|
||||
}
|
||||
}*/
|
||||
|
||||
if (mb_strlen($person['ersatzkennzeichen']) > 10)
|
||||
if (isset($person['ersatzkennzeichen']) && mb_strlen($person['ersatzkennzeichen']) > 10)
|
||||
{
|
||||
return $this->_error('Ersatzkennzeichen darf nicht laenger als 10 Zeichen sein');
|
||||
}
|
||||
if (mb_strlen($person['familienstand']) > 1)
|
||||
if (isset($person['familienstand']) && mb_strlen($person['familienstand']) > 1)
|
||||
{
|
||||
return $this->_error('Familienstand ist ungueltig');
|
||||
}
|
||||
if ($person['anzahlkinder'] != '' && !is_numeric($person['anzahlkinder']))
|
||||
if (isset($person['anzahlkinder']) && $person['anzahlkinder'] != '' && !is_numeric($person['anzahlkinder']))
|
||||
{
|
||||
return $this->_error('Anzahl der Kinder ist ungueltig');
|
||||
}
|
||||
if ($person['aktiv'] != "t" && $person['aktiv'] != "f")
|
||||
if (!isset($person['aktiv']) || (isset($person['aktiv']) && $person['aktiv'] != "t" && $person['aktiv'] != "f"))
|
||||
{
|
||||
return $this->_error('Aktiv ist ungueltig');
|
||||
}
|
||||
if (!isset($person['person_id']) && mb_strlen($person['insertvon']) > 32)
|
||||
if (!isset($person['person_id']) && isset($person['insertvon']) && mb_strlen($person['insertvon']) > 32)
|
||||
{
|
||||
return $this->_error('Insertvon darf nicht laenger als 32 Zeichen sein');
|
||||
}
|
||||
if (mb_strlen($person['updatevon']) > 32)
|
||||
if (isset($person['updatevon']) && mb_strlen($person['updatevon']) > 32)
|
||||
{
|
||||
return $this->_error('Updatevon darf nicht laenger als 32 Zeichen sein');
|
||||
}
|
||||
@@ -254,25 +258,25 @@ class Person extends APIv1_Controller
|
||||
return $this->_error('Ext_ID ist keine gueltige Zahl';
|
||||
return false;
|
||||
}*/
|
||||
if (mb_strlen($person['geschlecht']) > 1)
|
||||
if (!isset($person['geschlecht']) || (isset($person['geschlecht']) && mb_strlen($person['geschlecht']) > 1))
|
||||
{
|
||||
return $this->_error('Geschlecht darf nicht laenger als 1 Zeichen sein');
|
||||
}
|
||||
if (mb_strlen($person['geburtsnation']) > 3)
|
||||
if (isset($person['geburtsnation']) && mb_strlen($person['geburtsnation']) > 3)
|
||||
{
|
||||
return $this->_error('Geburtsnation darf nicht laenger als 3 Zeichen sein');
|
||||
}
|
||||
if (mb_strlen($person['staatsbuergerschaft']) > 3)
|
||||
if (isset($person['staatsbuergerschaft']) && mb_strlen($person['staatsbuergerschaft']) > 3)
|
||||
{
|
||||
return $this->_error('Staatsbuergerschaft darf nicht laenger als 3 Zeichen sein');
|
||||
}
|
||||
if ($person['geschlecht'] != 'm' && $person['geschlecht'] != 'w' && $person['geschlecht'] != 'u')
|
||||
if (isset($person['geschlecht']) && $person['geschlecht'] != 'm' && $person['geschlecht'] != 'w' && $person['geschlecht'] != 'u')
|
||||
{
|
||||
return $this->_error('Geschlecht muss w, m oder u sein!');
|
||||
}
|
||||
|
||||
//Pruefen ob das Geburtsdatum mit der SVNR uebereinstimmt.
|
||||
if ($person['svnr'] != '' && $person['gebdatum'] != '')
|
||||
if (isset($person['svnr']) && isset($person['gebdatum']) && $person['svnr'] != '' && $person['gebdatum'] != '')
|
||||
{
|
||||
if (mb_ereg("([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})", $person['gebdatum'], $regs))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user