Skip to content
Snippets Groups Projects
Commit 726ef5f6 authored by Tim Repke's avatar Tim Repke
Browse files

check whether registration is open was inconsistent, centralised it to an...

check whether registration is open was inconsistent, centralised it to an already existing function and updated that
parent e91a68e8
No related branches found
No related tags found
No related merge requests found
......@@ -43,10 +43,15 @@ function comm_get_possible_dates($db, $fid){
function comm_isopen_fid($db_handle, $fid){
comm_verbose(3,"checking if fid ". $fid . " is open");
return $db_handle->has("fahrten", array(
"AND" => array(
"fahrt_id"=>$fid,
"regopen"=>1)));
$cnt = $db_handle->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $fid]]);
$max = $db_handle->get("fahrten", "max_bachelor", ["fahrt_id" => $fid]);
$open = $db_handle->has('fahrten', ['AND' => ['fahrt_id'=>$fid, 'regopen'=>1]]);
comm_verbose(3,"cnt: ".$cnt.", max: ".$max.", open: ".($open ? "yes" : "no"));
return ( $open && $cnt < $max );
}
function comm_generate_key($db_handle, $table, $col, $conditions){
......
......@@ -65,11 +65,7 @@ function index_show_content(){
} /*elseif(isset($_REQUEST['bid'])){ // Änderungsformular anzeigen, Anmeldung noch offen?
index_show_formular($fid, $_REQUEST['bid']);
} */ else { // leeres Formular anzeigen
$cnt = $index_db->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $fid]]);
$max = $index_db->get("fahrten", "max_bachelor", ["fahrt_id" => $fid]);
if ($index_db->has('fahrten', ['AND' => ['fahrt_id'=>$fid, 'regopen'=>1]]) && $cnt < $max)
if (comm_isopen_fid($index_db, $fid))
index_show_formular($fid);
else
{
......@@ -115,9 +111,7 @@ function index_form_to_db($data){
$index_db->exec("LOCK TABLES fahrten, bachelor WRITE"); // count should not be calculated in two scripts at once
$cnt = $index_db->count("bachelor", ["AND" => ["backstepped" => NULL, "fahrt_id" => $data['fahrt_id']]]);
$insertOk = $cnt < $res['max_bachelor'];
$insertOk = comm_isopen_fid($index_db, $data['fahrt_id']);
/*if ($cnt+1 >= $res['max_bachelor']) // registration is full already or after the following insert
$index_db->update("fahrten", ["regopen" => 0], ["fahrt_id" => $config_current_fahrt_id]); */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment