From d2681aa3ba7e0d444bdfba5c6688736b711c075f Mon Sep 17 00:00:00 2001 From: konrad Date: Sat, 17 Nov 2007 18:25:27 +0000 Subject: [PATCH] fix ordercheck and add method to make cart live longer git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@77 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- www/inc/cart.php | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/www/inc/cart.php b/www/inc/cart.php index 7ebb0f3..ff26359 100644 --- a/www/inc/cart.php +++ b/www/inc/cart.php @@ -175,6 +175,7 @@ class Cart global $db; //sanity check if($amount<=0)return false; + $this->renewCart(); //check that ticket can be sold $event=new Event($eventid); if($event->isCancelled())return false; @@ -207,8 +208,12 @@ class Cart global $db; $res=$db->select("cart_ticket","*","where cartid=".$db->escapeString($this->cartid)); if(count($res)>0) - foreach($res as $k=>$tc) - $ret[]=new CartTicket($tc["cartid"],$tc["eventid"],$tc["amount"]); + foreach($res as $k=>$tc){ + $evt=new Event($tc["eventid"]); + //TODO: add more checks (event over, cancelled, etc.pp.) + if($evt->availableTicketAmount()<$tc["amount"]) + $ret[]=new CartError(CE_EVENTNOTICKETS,$tc["eventid"]); + } //vouchers are ok by default, just check amount $itmcnt=count($res); $res=$db->select("cart_voucher","cvid","where cartid=".$db->escapeString($this->cartid)); @@ -219,6 +224,13 @@ class Cart //return... return $ret; } + + /**makes sure the cart continues to exist*/ + public function renewCart() + { + global $db; + $db->update("cart",array("timeout"=>(time()+$CartTimeout)),"cartid=".$db->escapeInt($this->cartid)); + } }; ?> \ No newline at end of file -- 1.7.2.5