load->model("crm/prestudent_model", "PrestudentModel"); // Load library ReihungstestLib $this->load->library("ReihungstestLib"); } /** * @return void */ public function getPrestudent() { $prestudentID = $this->get("prestudent_id"); if (isset($prestudentID)) { $result = $this->PrestudentModel->load($prestudentID); $this->response($result, REST_Controller::HTTP_OK); } else { $this->response(); } } /** * @return void */ public function getPrestudentByPersonID() { $person_id = $this->get("person_id"); if (isset($person_id)) { $result = $this->PrestudentModel->load(array("person_id" => $person_id)); $this->response($result, REST_Controller::HTTP_OK); } else { $this->response(); } } /** * @return void */ public function postPrestudent() { $prestudent = $this->_parseData($this->post()); if ($this->_validate($prestudent)) { if (isset($prestudent["prestudent_id"])) { $result = $this->PrestudentModel->update($prestudent["prestudent_id"], $prestudent); } else { $result = $this->PrestudentModel->insert($prestudent); } $this->response($result, REST_Controller::HTTP_OK); } else { $this->response(); } } /** * @return void */ public function deletePrestudent() { if ($this->_validate($this->delete())) { $result = $this->PrestudentModel->delete($this->delete()["prestudent_id"]); $this->response($result, REST_Controller::HTTP_OK); } else { $this->response(); } } /** * @return void */ public function postAddReihungstest() { $ddReihungstest = $this->_parseData($this->post()); if ($this->_validateReihungstest($ddReihungstest)) { if(isset($ddReihungstest["new"]) && $ddReihungstest["new"] == true) { // Remove new parameter to avoid DB insert errors unset($ddReihungstest["new"]); $result = $this->reihungstestlib->insertPersonReihungstest($ddReihungstest); } else { $result = $this->reihungstestlib->updatePersonReihungstest($ddReihungstest); } $this->response($result, REST_Controller::HTTP_OK); } else { $this->response(); } } /** * @return void */ public function postDelReihungstest() { $ddReihungstest = $this->_parseData($this->post()); if (isset($ddReihungstest["rt_person_id"])) { $result = $this->reihungstestlib->deletePersonReihungstest($ddReihungstest); $this->response($result, REST_Controller::HTTP_OK); } else { $this->response(); } } private function _validate($prestudent = NULL) { return true; } private function _validateReihungstest($ddReihungstest = NULL) { if (!isset($ddReihungstest["person_id"]) || !isset($ddReihungstest["rt_id"]) || !isset($ddReihungstest["studienplan_id"])) { return false; } return true; } }