From 35a4861abfcd08dbef06dca939bc928167c006d3 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 17 Aug 2017 12:49:41 +0200 Subject: [PATCH] Bugfix in system/aufnahme/PrestudentMultiAssign: - Converting strings 'null' to null values - Better error messages in case of invalid parameters --- .../system/aufnahme/PrestudentMultiAssign.php | 79 +++++++++++++------ 1 file changed, 54 insertions(+), 25 deletions(-) diff --git a/application/controllers/system/aufnahme/PrestudentMultiAssign.php b/application/controllers/system/aufnahme/PrestudentMultiAssign.php index b171f432e..242dd693f 100644 --- a/application/controllers/system/aufnahme/PrestudentMultiAssign.php +++ b/application/controllers/system/aufnahme/PrestudentMultiAssign.php @@ -23,6 +23,13 @@ class PrestudentMultiAssign extends VileSci_Controller $reihungstest = $this->input->post('reihungstest'); $stufe = $this->input->post('stufe'); + // Converts string 'null' to a null value + $stufe = ($stufe == 'null' ? null : $stufe); + $studiengang = ($studiengang == 'null' ? null : $studiengang); + $reihungstest = ($reihungstest == 'null' ? null : $reihungstest); + $aufnahmegruppe = ($aufnahmegruppe == 'null' ? null : $aufnahmegruppe); + $studiensemester = ($studiensemester == 'null' ? null : $studiensemester); + $returnUsers = null; if ($studiengang != null || $studiensemester != null || $aufnahmegruppe!= null || $reihungstest != null || $stufe != null) @@ -63,25 +70,36 @@ class PrestudentMultiAssign extends VileSci_Controller $prestudentIdArray = $this->input->post('prestudent_id'); $stufe = $this->input->post('stufe'); + // Converts string 'null' to a null value + $stufe = ($stufe == 'null' ? null : $stufe); + // Load model PrestudentstatusModel $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel'); - $result = error("No valid parameters"); - if (isset($stufe) && isset($prestudentIdArray) && is_array($prestudentIdArray) && count($prestudentIdArray) >0) - { - $result = $this->PrestudentstatusModel->updateStufe($prestudentIdArray, $stufe); - } - + // Set the HTTP header $this->output->set_header('Content-Type: application/json; charset=utf-8'); - if (isSuccess($result)) + $result = error("No valid parameters"); + if (isset($stufe) + && isset($prestudentIdArray) + && is_array($prestudentIdArray) + && count($prestudentIdArray) > 0) { - echo '{"msg": "Data correctly saved"}'; - } - else - { - echo '{"msg": "Error occurred while saving data, please contact the administrator"}'; - } + $result = $this->PrestudentstatusModel->updateStufe($prestudentIdArray, $stufe); + + if (isSuccess($result)) + { + echo '{"msg": "Data correctly saved"}'; + } + else + { + echo '{"msg": "Error occurred while saving data, please contact the administrator"}'; + } + } + else + { + echo '{"msg": "'.$result->retval.'"}'; + } } /** @@ -92,25 +110,36 @@ class PrestudentMultiAssign extends VileSci_Controller $prestudentIdArray = $this->input->post('prestudent_id'); $aufnahmegruppe = $this->input->post('aufnahmegruppe'); + // Converts string 'null' to a null value + $aufnahmegruppe = ($aufnahmegruppe == 'null' ? null : $aufnahmegruppe); + // Load model PrestudentstatusModel $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + // Set the HTTP header + $this->output->set_header('Content-Type: application/json; charset=utf-8'); + $result = error("No valid parameters"); - if (isset($aufnahmegruppe) && isset($prestudentIdArray) && is_array($prestudentIdArray) && count($prestudentIdArray) >0) + if (isset($aufnahmegruppe) + && isset($prestudentIdArray) + && is_array($prestudentIdArray) + && count($prestudentIdArray) > 0) { $result = $this->PrestudentModel->updateAufnahmegruppe($prestudentIdArray, $aufnahmegruppe); + + if (isSuccess($result)) + { + echo '{"msg": "Data correctly saved"}'; + } + else + { + echo '{"msg": "Error occurred while saving data, please contact the administrator"}'; + } + } + else + { + echo '{"msg": "'.$result->retval.'"}'; } - - $this->output->set_header('Content-Type: application/json; charset=utf-8'); - - if (isSuccess($result)) - { - echo '{"msg": "Data correctly saved"}'; - } - else - { - echo '{"msg": "Error occurred while saving data, please contact the administrator"}'; - } } /**