diff --git a/application/controllers/api/v1/crm/Prestudentstatus.php b/application/controllers/api/v1/crm/Prestudentstatus.php index 5b19dbc61..f1bfda16a 100644 --- a/application/controllers/api/v1/crm/Prestudentstatus.php +++ b/application/controllers/api/v1/crm/Prestudentstatus.php @@ -55,22 +55,26 @@ class Prestudentstatus extends APIv1_Controller */ public function postPrestudentstatus() { - if ($this->_validate($this->post())) + $prestudentstatus = $this->_parseData($this->post()); + + $this->response($prestudentstatus); + + if ($this->_validate($prestudentstatus)) { - if (isset($this->post()['ausbildungssemester']) && isset($this->post()['studiensemester_kurzbz']) && - isset($this->post()['status_kurzbz']) && isset($this->post()['prestudent_id'])) + if (isset($prestudentstatus['ausbildungssemester']) && isset($prestudentstatus['studiensemester_kurzbz']) && + isset($prestudentstatus['status_kurzbz']) && isset($prestudentstatus['prestudent_id'])) { - $pksArray = array($this->post()['ausbildungssemester'], - $this->post()['studiensemester_kurzbz'], - $this->post()['status_kurzbz'], - $this->post()['prestudent_id'] + $pksArray = array($prestudentstatus['ausbildungssemester'], + $prestudentstatus['studiensemester_kurzbz'], + $prestudentstatus['status_kurzbz'], + $prestudentstatus['prestudent_id'] ); - $result = $this->PrestudentstatusModel->update($pksArray, $this->post()); + $result = $this->PrestudentstatusModel->update($pksArray, $prestudentstatus); } else { - $result = $this->PrestudentstatusModel->insert($this->post()); + $result = $this->PrestudentstatusModel->insert($prestudentstatus); } $this->response($result, REST_Controller::HTTP_OK); diff --git a/application/controllers/api/v1/person/Kontakt.php b/application/controllers/api/v1/person/Kontakt.php index 5d5407bf8..00015ff78 100644 --- a/application/controllers/api/v1/person/Kontakt.php +++ b/application/controllers/api/v1/person/Kontakt.php @@ -67,19 +67,4 @@ 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 c0c3168ea..71edf5ef3 100644 --- a/application/controllers/api/v1/person/Person.php +++ b/application/controllers/api/v1/person/Person.php @@ -109,21 +109,6 @@ 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) { diff --git a/application/core/APIv1_Controller.php b/application/core/APIv1_Controller.php index b33c5a530..cc3d3fef8 100644 --- a/application/core/APIv1_Controller.php +++ b/application/core/APIv1_Controller.php @@ -4,10 +4,42 @@ require_once APPPATH . '/libraries/REST_Controller.php'; class APIv1_Controller extends REST_Controller { - function __construct() - { - parent::__construct(); - //$this->load->library('session'); // -> autoload - //$this->load->library('database'); -> autoload + function __construct() + { + parent::__construct(); + //$this->load->library('session'); // -> autoload + //$this->load->library('database'); -> autoload + + } + + /** + * + * @param type $data + * @return typeparses empty string to NULL + */ + protected function _parseData($data) + { + if(is_array($data)) + { + foreach($data as $key=>$value) + { + if($value === "") + { + $data[$key] = NULL; + } + } + return $data; + } + elseif(is_object($data)) + { + //TODO + } + else + { + if($data == "") + { + return NULL; + } + } } } \ No newline at end of file