mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
corrects the way how to active ampeln check whether an ampel was bestaetigt or not and adds the Ampel_Benutzer_Bestaetigt_model
This commit is contained in:
@@ -56,7 +56,9 @@ class Ampeln extends FHCAPI_Controller
|
||||
$this->form_validation->set_rules('ampel_id', 'Ampel ID', 'required|integer');
|
||||
if($this->form_validation->run() == FALSE) $this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$insert_into_result = $this->AmpelModel->confirmAmpel($ampel_id,$this->uid);
|
||||
// load Ampel_benutzer_bestaetigt_model to confirm the ampel
|
||||
$this->load->model('content/Ampel_Benutzer_Bestaetigt_model', 'AmpelBenutzerBestaetigtModel');
|
||||
$insert_into_result = $this->AmpelBenutzerBestaetigtModel->insert(["ampel_id"=> $ampel_id, "uid"=> $this->uid]);
|
||||
|
||||
$insert_into_result = $this->getDataOrTerminateWithError($insert_into_result);
|
||||
|
||||
@@ -78,8 +80,8 @@ class Ampeln extends FHCAPI_Controller
|
||||
$activeAmpeln = $this->getDataOrTerminateWithError($activeAmpeln);
|
||||
|
||||
foreach($activeAmpeln as $ampel){
|
||||
|
||||
// only include non confirmed active ampeln in the result
|
||||
|
||||
// only include non confirmed active ampeln in the result
|
||||
if(!$ampel->bestaetigt){
|
||||
|
||||
// check if the user was assigned to the ampel
|
||||
|
||||
@@ -94,8 +94,6 @@ class DB_Model extends CI_Model
|
||||
$this->load->library('UDFLib');
|
||||
// Loads the logs library
|
||||
$this->load->library('LogLib');
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
class Ampel_Benutzer_Bestaetigt_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_ampel_benutzer_bestaetigt';
|
||||
$this->pk = 'ampel_benutzer_bestaetigt_id';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,12 +23,12 @@ class Ampel_model extends DB_Model
|
||||
$userLanguage = getUserLanguage();
|
||||
|
||||
$bestaetigt = '';
|
||||
if($uid != null){
|
||||
if($uid != null ){
|
||||
$bestaetigt = ',
|
||||
COALESCE((
|
||||
SELECT true
|
||||
FROM public.tbl_ampel_benutzer_bestaetigt a
|
||||
WHERE a.ampel_id = ampel_id
|
||||
WHERE a.ampel_id = ' . $this->dbTable . '.ampel_id
|
||||
AND uid = ' . $this->escape($uid) . ' LIMIT 1), false) as bestaetigt';
|
||||
}
|
||||
|
||||
@@ -111,28 +111,6 @@ class Ampel_model extends DB_Model
|
||||
return $result; //will contain the error-msg from execQuery
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* confirms Ampel by the user.
|
||||
* @param int $ampel_id Ampel-ID
|
||||
* @param string $uid UID
|
||||
* @return stdClass insert into result
|
||||
*/
|
||||
public function confirmAmpel($ampel_id, $uid)
|
||||
{
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if a user is assigned to an ampel
|
||||
* @param string $uid userID
|
||||
|
||||
Reference in New Issue
Block a user