From bb83ad30e29a13fd540119e722e85776534c1b25 Mon Sep 17 00:00:00 2001 From: Tim Repke <timmothey@gmx.de> Date: Fri, 14 Oct 2016 22:23:14 +0200 Subject: [PATCH] clean up commons.php --- registration-system/frameworks/commons.php | 72 +--------------------- 1 file changed, 2 insertions(+), 70 deletions(-) diff --git a/registration-system/frameworks/commons.php b/registration-system/frameworks/commons.php index b930a64..b28f1b7 100644 --- a/registration-system/frameworks/commons.php +++ b/registration-system/frameworks/commons.php @@ -25,72 +25,6 @@ function comm_from_mysqlDate($date){ return date('d.m.Y', strtotime($date)); } -function comm_get_possible_dates($db, $fid){ - $dates = $db->get("fahrten", ["von", "bis"], ["fahrt_id" => $fid]); - $end = new DateTime($dates['bis']); - $period = new DatePeriod( - new DateTime($dates['von']), - new DateInterval('P1D'), - $end->modify( '+1 day' ) - ); - $ret = []; - foreach($period as $d){ - array_push($ret, $d->format("d.m.Y")); - } - return $ret; - -} - -/* - * returns TRUE iff registration is allowed - */ -function comm_isopen_fid($db_handle, $fid){ - $ret = comm_isopen_fid_helper($db_handle, $fid); - return $ret == 0; -} - -/* - * returns value depending on registration status - * 0 = registration open (slots available) - * 1 = all slots taken -> waitlist open - * 2 = registration closed! - */ -function comm_isopen_fid_helper($db_handle, $fid){ - comm_verbose(3,"checking if fid ". $fid . " is open"); - $open = $db_handle->has('fahrten', ['AND' => ['fahrt_id'=>$fid, 'regopen'=>1]]); - if(!$open) - return 2; - - $cnt = $db_handle->count("bachelor", ["AND"=> - ["backstepped" => NULL, - "fahrt_id" => $fid]]); - $max = $db_handle->get("fahrten", "max_bachelor", ["fahrt_id" => $fid]); - $wl = $db_handle->count('waitlist', ['AND' => - ["transferred" => NULL, - "fahrt_id" => $fid]]); - - comm_verbose(3,"cnt: ".$cnt.", max: ".$max.", open: ".($open ? "yes" : "no")); - - if ( $cnt < $max && $wl == 0 ) - return 0; - - return 1; -} - -function comm_generate_key($db_handle, $check, $conditions){ - again: - $bytes = openssl_random_pseudo_bytes(8); - $hex = bin2hex($bytes); - comm_verbose(3,"generated hex for test: ".$hex); - - foreach($check as $table => $col){ - if($db_handle->has($table, array("AND"=>[$col => $hex]))) goto again; - } - - comm_verbose(2,"generated hex: ".$hex); - return $hex; -} - /* * sends mail * @@ -99,10 +33,8 @@ function comm_generate_key($db_handle, $check, $conditions){ * * returns true/false depending on success */ -function comm_send_mail($db_handle, $addr, $cont, $from = NULL, $bcc = NULL){ - global $config_current_fahrt_id, $config_mailtag; - if(is_null($from)) - $from = $db_handle->get("fahrten", "kontakt", array("fahrt_id"=>$config_current_fahrt_id)); +function comm_send_mail($addr, $cont, $from = NULL, $bcc = NULL){ + global $config_mailtag; $subj = "Wichtige Information"; $mess = $cont; -- GitLab