fix event listing order
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Fri, 28 Aug 2009 13:04:36 +0000 (13:04 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Fri, 28 Aug 2009 13:04:36 +0000 (13:04 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@339 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

woc/phpout.cpp
www/inc/classes/event.php

index 676bb26..359b434 100644 (file)
@@ -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
index 9798291..2573876 100644 (file)
@@ -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);
        }
 };