diff --git a/application/controllers/api/frontend/v1/Ampeln.php b/application/controllers/api/frontend/v1/Ampeln.php index 19f465a11..bc2bca597 100644 --- a/application/controllers/api/frontend/v1/Ampeln.php +++ b/application/controllers/api/frontend/v1/Ampeln.php @@ -74,10 +74,10 @@ class Ampeln extends FHCAPI_Controller // fetch active ampeln $activeAmpeln = $this->AmpelModel->active(); - + $activeAmpeln = $this->getDataOrTerminateWithError($activeAmpeln); - - foreach($activeAmpeln as $ampel){ + + foreach($activeAmpeln as $ampel){ // check if ampel is confirmed by user $confirmedByUser = $this->AmpelModel->isConfirmed($ampel->ampel_id,$this->uid); @@ -108,8 +108,8 @@ class Ampeln extends FHCAPI_Controller $userAmpeln = array(); $ampel_result = $this->AmpelModel->active(); - - $ampel_result = $this->getDataOrTerminateWithError($ampel_result); + + $ampel_result = $this->getDataOrTerminateWithError($ampel_result); foreach($ampel_result as $ampel){ $confirmedByUser = $this->AmpelModel->isConfirmed($ampel->ampel_id,$this->uid); @@ -120,7 +120,7 @@ class Ampeln extends FHCAPI_Controller $zugeteilt = $this->getDataOrTerminateWithError($zugeteilt); - if($zugeteilt) $userAmpeln[] = $this->translateAmpel($ampel); + if($zugeteilt) $userAmpeln[] = $ampel; } $this->terminateWithSuccess($userAmpeln); @@ -142,8 +142,7 @@ class Ampeln extends FHCAPI_Controller // check if ampel is confirmed by user $confirmedByUser = $this->AmpelModel->isConfirmed($ampel->ampel_id,$this->uid); $ampel->bestaetigt = $confirmedByUser; - // translate ampeln - return $this->translateAmpel($ampel); + return $ampel; }, $alle_ampeln); $this->terminateWithSuccess($alle_ampeln); diff --git a/application/models/content/Ampel_model.php b/application/models/content/Ampel_model.php index 7d5714c98..33de9fbbe 100755 --- a/application/models/content/Ampel_model.php +++ b/application/models/content/Ampel_model.php @@ -22,12 +22,12 @@ class Ampel_model extends DB_Model { $userLanguage = getUserLanguage(); - $parametersArray = null; + $parametersArray = []; $query = ' - SELECT *, beschreibung[('.$this->getLanguageIndex($this->escape($userLanguage)).')], buttontext[('. $this->getLanguageIndex($this->escape($userLanguage)).')] + SELECT *, beschreibung[('.$this->getLanguageIndex($this->escape($userLanguage)).')] as beschreibung_trans, buttontext[('.$this->getLanguageIndex($this->escape($userLanguage)).')] as buttontext_trans FROM public.tbl_ampel WHERE'; - + if ($email === true) { $parametersArray['email'] = $email; @@ -108,10 +108,15 @@ class Ampel_model extends DB_Model */ public function confirmAmpel($ampel_id, $uid) { - if(isset($ampel_id) && isset($uid)) - return error("parameter were missing to execute the insert into"); - - return $this->execQuery(' + $this->load->library('form_validation'); + $this->form_validation->set_data(['ampel_id' => $ampel_id, 'uid' => $uid]); + $this->form_validation->set_rules('ampel_id', 'Ampel ID', 'required|integer'); + $this->form_validation->set_rules('uid', 'UID', 'required'); + + if ($this->form_validation->run() == FALSE) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + return $this->execQuery(' INSERT INTO public.tbl_ampel_benutzer_bestaetigt (ampel_id, uid) VALUES (?,?);', array($ampel_id, $uid)); } @@ -140,9 +145,8 @@ class Ampel_model extends DB_Model return success(current($zugeteilt)->zugeteilt); } - - - + // THIS FUNCTION IS NOT IN USE + // fetches all ampeln that were assigned to the user after the working start_date function alleAmpeln($uid){ $userLanguage = getUserLanguage(); @@ -157,7 +161,7 @@ class Ampel_model extends DB_Model $benutzerStartDate = $datum->mktime_fromdate(date(current(getData($benutzerStartDate))->insertamum)); $allAmpeln = $this->execReadOnlyQuery(" - SELECT *, beschreibung[(".$this->getLanguageIndex($this->escape($userLanguage)).")], buttontext[(".$this->getLanguageIndex($this->escape($userLanguage)).")] FROM + SELECT *, beschreibung[(".$this->getLanguageIndex($this->escape($userLanguage)).")] as beschreibung_trans, buttontext[(".$this->getLanguageIndex($this->escape($userLanguage)).")] as buttontext_trans FROM public.tbl_ampel"); if(isError($allAmpeln)) return error(getError($allAmpeln)); diff --git a/public/js/components/DashboardWidget/Ampel.js b/public/js/components/DashboardWidget/Ampel.js index 5617c5c53..7257d70c1 100755 --- a/public/js/components/DashboardWidget/Ampel.js +++ b/public/js/components/DashboardWidget/Ampel.js @@ -139,7 +139,7 @@ export default { - +
{{$p.t('ampeln','super')}}
@@ -149,7 +149,7 @@ export default {
{{$p.t('ampeln','newestAmpeln')}}
- +
@@ -196,9 +196,9 @@ export default { {{ ampel.kurzbz }}
-
+
- +