From 39b4c8057d5da1e3102dd68e7c95b7ad497e537e Mon Sep 17 00:00:00 2001 From: bison-paolo Date: Wed, 19 Oct 2016 14:49:54 +0200 Subject: [PATCH] Removed _parseData workaround --- .../controllers/api/v1/content/Dms.php | 6 ++-- .../controllers/api/v1/crm/Prestudent.php | 8 ++--- .../api/v1/crm/Prestudentstatus.php | 4 +-- .../controllers/api/v1/person/Adresse.php | 12 +++---- .../controllers/api/v1/person/Kontakt.php | 29 ++++++++--------- .../controllers/api/v1/person/Person.php | 4 +-- application/core/APIv1_Controller.php | 31 ------------------- 7 files changed, 32 insertions(+), 62 deletions(-) diff --git a/application/controllers/api/v1/content/Dms.php b/application/controllers/api/v1/content/Dms.php index 1bc8b1d6b..58fd53d14 100644 --- a/application/controllers/api/v1/content/Dms.php +++ b/application/controllers/api/v1/content/Dms.php @@ -51,7 +51,7 @@ class Dms extends APIv1_Controller */ public function postDms() { - $dms = $this->_parseData($this->post()); + $dms = $this->post(); if ($this->_validatePost($dms)) { @@ -70,9 +70,9 @@ class Dms extends APIv1_Controller */ public function postDelDms() { - $dms = $this->_parseData($this->post()); + $dms = $this->post(); - if ($this->_validateDelete($dms)) + if ($this->_validateDelete($this->post())) { $result = $this->dmslib->delete($dms["person_id"], $dms["dms_id"]); diff --git a/application/controllers/api/v1/crm/Prestudent.php b/application/controllers/api/v1/crm/Prestudent.php index 8b274cd06..98dd61aef 100644 --- a/application/controllers/api/v1/crm/Prestudent.php +++ b/application/controllers/api/v1/crm/Prestudent.php @@ -140,9 +140,9 @@ class Prestudent extends APIv1_Controller */ public function postPrestudent() { - $prestudent = $this->_parseData($this->post()); + $prestudent = $this->post(); - if ($this->_validate($prestudent)) + if ($this->_validate($this->post())) { if (isset($prestudent['prestudent_id'])) { @@ -183,7 +183,7 @@ class Prestudent extends APIv1_Controller */ public function postAddReihungstest() { - $ddReihungstest = $this->_parseData($this->post()); + $ddReihungstest = $this->post(); if ($this->_validateReihungstest($ddReihungstest)) { @@ -212,7 +212,7 @@ class Prestudent extends APIv1_Controller */ public function postDelReihungstest() { - $ddReihungstest = $this->_parseData($this->post()); + $ddReihungstest = $this->post(); if (isset($ddReihungstest['rt_person_id'])) { diff --git a/application/controllers/api/v1/crm/Prestudentstatus.php b/application/controllers/api/v1/crm/Prestudentstatus.php index 395585879..93ad9aeb1 100644 --- a/application/controllers/api/v1/crm/Prestudentstatus.php +++ b/application/controllers/api/v1/crm/Prestudentstatus.php @@ -74,7 +74,7 @@ class Prestudentstatus extends APIv1_Controller */ public function postPrestudentstatus() { - $prestudentstatus = $this->_parseData($this->post()); + $prestudentstatus = $this->post(); if ($this->_validate($prestudentstatus)) { @@ -109,7 +109,7 @@ class Prestudentstatus extends APIv1_Controller */ public function deletePrestudentstatus() { - $prestudentstatus = $this->_parseData($this->delete()); + $prestudentstatus = $this->delete(); if ($this->_validate($prestudentstatus)) { diff --git a/application/controllers/api/v1/person/Adresse.php b/application/controllers/api/v1/person/Adresse.php index 9adaf5d19..04c8de722 100644 --- a/application/controllers/api/v1/person/Adresse.php +++ b/application/controllers/api/v1/person/Adresse.php @@ -47,17 +47,17 @@ class Adresse extends APIv1_Controller public function postAdresse() { - $post = $this->_parseData($this->post()); + $adresse = $this->post(); - if (is_array($post)) + if (is_array($adresse)) { - if (isset($post['adresse_id'])) + if (isset($adresse['adresse_id'])) { - $result = $this->AdresseModel->update($post['adresse_id'], $post); + $result = $this->AdresseModel->update($adresse['adresse_id'], $adresse); } else { - $result = $this->AdresseModel->insert($post); + $result = $this->AdresseModel->insert($adresse); } $this->response($result, REST_Controller::HTTP_OK); @@ -67,4 +67,4 @@ class Adresse extends APIv1_Controller $this->response(); } } -} +} \ No newline at end of file diff --git a/application/controllers/api/v1/person/Kontakt.php b/application/controllers/api/v1/person/Kontakt.php index aa1cc49cb..00d5db5fd 100644 --- a/application/controllers/api/v1/person/Kontakt.php +++ b/application/controllers/api/v1/person/Kontakt.php @@ -13,7 +13,7 @@ */ // ------------------------------------------------------------------------ -if (! defined("BASEPATH")) exit("No direct script access allowed"); +if (! defined('BASEPATH')) exit('No direct script access allowed'); class Kontakt extends APIv1_Controller { @@ -23,13 +23,14 @@ class Kontakt extends APIv1_Controller public function __construct() { parent::__construct(); + // Load model PersonModel - $this->load->model("person/kontakt_model", "KontaktModel"); + $this->load->model('person/kontakt_model', 'KontaktModel'); } public function getKontakt() { - $kontakt_id = $this->get("kontakt_id"); + $kontakt_id = $this->get('kontakt_id'); if (isset($kontakt_id)) { @@ -45,7 +46,7 @@ class Kontakt extends APIv1_Controller public function getOnlyKontakt() { - $kontakt_id = $this->get("kontakt_id"); + $kontakt_id = $this->get('kontakt_id'); if (isset($kontakt_id)) { @@ -61,7 +62,7 @@ class Kontakt extends APIv1_Controller public function getKontaktByPersonID() { - $person_id = $this->get("person_id"); + $person_id = $this->get('person_id'); if (isset($person_id)) { @@ -77,11 +78,11 @@ class Kontakt extends APIv1_Controller public function getOnlyKontaktByPersonID() { - $person_id = $this->get("person_id"); + $person_id = $this->get('person_id'); if (isset($person_id)) { - $result = $this->KontaktModel->loadWhere(array("person_id" => $person_id)); + $result = $this->KontaktModel->loadWhere(array('person_id' => $person_id)); $this->response($result, REST_Controller::HTTP_OK); } @@ -93,8 +94,8 @@ class Kontakt extends APIv1_Controller public function getKontaktByPersonIDKontaktTyp() { - $person_id = $this->get("person_id"); - $kontakttyp = $this->get("kontakttyp"); + $person_id = $this->get('person_id'); + $kontakttyp = $this->get('kontakttyp'); if (isset($person_id) && isset($kontakttyp)) { @@ -110,17 +111,17 @@ class Kontakt extends APIv1_Controller public function postKontakt() { - $post = $this->_parseData($this->post()); + $kontakt = $this->post(); - if (is_array($post)) + if (is_array($kontakt)) { - if (isset($post["kontakt_id"])) + if (isset($kontakt['kontakt_id'])) { - $result = $this->KontaktModel->update($post["kontakt_id"], $post); + $result = $this->KontaktModel->update($kontakt['kontakt_id'], $kontakt); } else { - $result = $this->KontaktModel->insert($post); + $result = $this->KontaktModel->insert($kontakt); } $this->response($result, REST_Controller::HTTP_OK); diff --git a/application/controllers/api/v1/person/Person.php b/application/controllers/api/v1/person/Person.php index 993505cf3..dad4e325c 100644 --- a/application/controllers/api/v1/person/Person.php +++ b/application/controllers/api/v1/person/Person.php @@ -90,8 +90,8 @@ class Person extends APIv1_Controller */ public function postPerson() { - $person = $this->_parseData($this->post()); - $validation = $this->_validate($this->post()); + $person = $this->post(); + $validation = $this->_validate($person); if (isSuccess($validation)) { diff --git a/application/core/APIv1_Controller.php b/application/core/APIv1_Controller.php index cb5196dd6..5c529a4b4 100644 --- a/application/core/APIv1_Controller.php +++ b/application/core/APIv1_Controller.php @@ -11,35 +11,4 @@ class APIv1_Controller extends REST_Controller // Loads return messages $this->load->helper('Message'); } - - /** - * - * @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