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:
SimonGschnell
2024-08-07 11:52:50 +02:00
parent c5f57a0689
commit ceb8eb9671
5 changed files with 213 additions and 222 deletions
@@ -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';
}
}
+2 -24
View File
@@ -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