diff --git a/application/config/config.php b/application/config/config.php index 68b85b62f..96b966b37 100755 --- a/application/config/config.php +++ b/application/config/config.php @@ -207,7 +207,7 @@ $config['directory_trigger'] = 'd'; | your log files will fill up very fast. | */ -$config['log_threshold'] = 0; +$config['log_threshold'] = 4; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/api/v1/person/Kontakt.php b/application/controllers/api/v1/person/Kontakt.php index 759f69120..5a59507dc 100644 --- a/application/controllers/api/v1/person/Kontakt.php +++ b/application/controllers/api/v1/person/Kontakt.php @@ -41,13 +41,13 @@ class Kontakt extends APIv1_Controller } else { - $this->response(); + $this->response(); } } public function postKontakt() { - $post = $this->post(); + $post = $this->_parseData($this->post()); if(is_array($post)) { @@ -67,4 +67,19 @@ class Kontakt extends APIv1_Controller $this->response(); } } + + private function _parseData($person) + { + if(is_array($person)) + { + foreach($person as $key=>$value) + { + if($value === "") + { + $person[$key] = null; + } + } + return $person; + } + } } \ No newline at end of file diff --git a/application/controllers/api/v1/person/Person.php b/application/controllers/api/v1/person/Person.php index c3ea2e7ab..e44410847 100644 --- a/application/controllers/api/v1/person/Person.php +++ b/application/controllers/api/v1/person/Person.php @@ -60,8 +60,7 @@ class Person extends APIv1_Controller } else { - $fields = $this->PersonModel->getFields(); - $this->response($fields, REST_Controller::HTTP_OK); + $this->response(); } } @@ -70,15 +69,17 @@ class Person extends APIv1_Controller */ public function postPerson() { + $person = $this->_parseData($this->post()); + if($this->_validate($this->post())) { - if(isset($this->post()['person_id'])) + if(isset($person['person_id']) && !(is_null($person["person_id"])) && ($person["person_id"] != "")) { - $result = $this->PersonModel->update($this->post()['person_id'], $this->post()); + $result = $this->PersonModel->update($person['person_id'], $person); } else { - $result = $this->PersonModel->insert($this->post()); + $result = $this->PersonModel->insert($person); } $this->response($result, REST_Controller::HTTP_OK); @@ -108,6 +109,21 @@ class Person extends APIv1_Controller $this->response(); } } + + private function _parseData($person) + { + if(is_array($person)) + { + foreach($person as $key=>$value) + { + if($value === "") + { + $person[$key] = null; + } + } + return $person; + } + } private function _validate($person = NULL) { @@ -115,7 +131,10 @@ class Person extends APIv1_Controller { return false; } - + + //TODO + return true; + $person['nachname'] = trim($person['nachname']); $person['vorname'] = trim($person['vorname']); $person['vornamen'] = trim($person['vornamen']); diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php index 613a3cb76..171f3a47e 100644 --- a/application/models/person/Person_model.php +++ b/application/models/person/Person_model.php @@ -11,46 +11,6 @@ class Person_model extends DB_Model $this->dbTable = 'public.tbl_person'; $this->pk = 'person_id'; } - - public function getFields() - { - $fields = array( - //Tabellenspalten - "person_id" => NULL, - "sprache" => NULL, - "anrede" => NULL, - "titelpost" => NULL, - "titelpre" => NULL, - "nachname" => NULL, - "vorname" => NULL, - "vornamen" => NULL, - "gebdatum" => NULL, - "gebort" => NULL, - "gebzeit" => NULL, - "foto" => NULL, - "anmerkungen" => NULL, - "homepage" => NULL, - "svnr" => NULL, - "ersatzkennzeichen" => NULL, - "familienstand" => NULL, - "anzahlkinder" => NULL, - "aktiv"=>TRUE, - "insertamum" => NULL, - "insertvon" => NULL, - "updateamum" => NULL, - "updatevon" => NULL, - "geschlecht" => "u", - "staatsbuergerschaft" => NULL, - "geburtsnation" => NULL, - "ext_id" => NULL, - "kurzbeschreibung"> NULL, - "zugangscode" => NULL, - "foto_sperre" => FALSE, - "matr_nr"=> NULL - ); - - return $this->_success($fields); - } /** *