From b3429ff736dd03f5497e4e2fd33ec16bd2b69643 Mon Sep 17 00:00:00 2001 From: konrad Date: Fri, 28 Aug 2009 13:04:36 +0000 Subject: [PATCH] fix event listing order git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@339 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- woc/phpout.cpp | 2 +- www/inc/classes/event.php | 42 +----------------------------------------- 2 files changed, 2 insertions(+), 42 deletions(-) diff --git a/woc/phpout.cpp b/woc/phpout.cpp index 676bb26..359b434 100644 --- a/woc/phpout.cpp +++ b/woc/phpout.cpp @@ -162,7 +162,7 @@ void WocPHPServerOut::newTable(const WocTable&tbl) } code+="\");\n\tif($res!==false && count($res)<1)return false;\n\telse return new WT"+tbl.name()+"($res[0],true);\n}\n\n"; //static get selection - code+="public static function selectFromDB($where){\n\tglobal "+dbi+";\n\t$res="+dbi+"->select(\""+tbl.name()+"\",\"*\",$where);\n\tif($res===false || count($res)<1)return array();\n\t"; + code+="public static function selectFromDB($where=\"\",$orderby=\"\"){\n\tglobal "+dbi+";\n\t$res="+dbi+"->select(\""+tbl.name()+"\",\"*\",$where,$orderby);\n\tif($res===false || count($res)<1)return array();\n\t"; code+="$r=array();\n\tforeach($res as $row)\n\t\t$r[]=new WT"+tbl.name()+"($row,true);\n\treturn $r;\n}\n\n"; //go through columns, generate specific code diff --git a/www/inc/classes/event.php b/www/inc/classes/event.php index 9798291..2573876 100644 --- a/www/inc/classes/event.php +++ b/www/inc/classes/event.php @@ -28,46 +28,6 @@ function getAllEventsForListing() return $db->select("event","eventid","starttime>=".time()." ORDER BY starttime"); } -/**Machine-wrapper for getAllEvents() */ -function getAllEventsXml() -{ - global $db; - $all=getAllEvents(); - if($all===false){ - header("X-MagicSmoke-Status: Error"); - echo "Database Error."; - return; - } - header("X-MagicSmoke-Status: Ok"); - $xml=new DOMDocument; - $root=$xml->createElement("EventList"); - if(count($all)>0) - foreach($all as $k => $ev){ - $nod=$xml->createElement("Event",xq($ev["title"])); - //set direct attributes - $nod->setAttribute("id",$ev["eventid"]); - $nod->setAttribute("start",$ev["starttime"]); - $nod->setAttribute("capacity",$ev["capacity"]); - //find out how many tickets are sold/reserved - $res=$db->select("ticket","status","eventid=".$db->escapeInt($ev["eventid"])); - if($res===false){ - $nod->setAttribute("sold",0); - $nod->setAttribute("reserved",0); - }else{ - $cnt=0; - $rsv=0; - foreach($res as $tc){ - if(($tc["status"] & TICKET_USABLE) == TICKET_USABLE)$cnt++; - if($tc["status"]==TICKET_RESERVED)$rsv++; - } - $nod->setAttribute("sold",$cnt); - $nod->setAttribute("reserved",$rsv); - } - $root->appendChild($nod); - } - $xml->appendChild($root); - echo $xml->saveXml(); -} /**Wrapper around event table*/ class Event @@ -184,7 +144,7 @@ class Event /**XML iface: get all events*/ public static function getAllEvents($trans) { - $evlst=WOEvent::fromTableArrayevent(WTevent::selectFromDB("")); + $evlst=WOEvent::fromTableArrayevent(WTevent::selectFromDB("","ORDER BY starttime")); $trans->setevents($evlst); } }; -- 1.7.2.5