*create room
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Fri, 1 Jan 2010 20:32:42 +0000 (20:32 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Fri, 1 Jan 2010 20:32:42 +0000 (20:32 +0000)
*some basic display for event
*fix: normal elementsByTagName traverses the tree, while I only need direct children

git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@395 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

17 files changed:
src/dialogs/eventedit.cpp
src/dialogs/eventedit.h
src/mwin/eventstab.cpp
src/wbase/WHelper.cpp [new file with mode: 0644]
src/wbase/WHelper.h [new file with mode: 0644]
src/wbase/WObject.h
src/wbase/WTransaction.cpp
src/wbase/WTransaction.h
src/wbase/wbase.pri
wob/event.wolf
woc/phpout.cpp
woc/processor.cpp
woc/processor.h
woc/qtout.cpp
www/inc/wbase/object.php
www/inc/wext/autoload.php
www/inc/wext/room.php [new file with mode: 0644]

index aee87fe..0a8779c 100644 (file)
@@ -73,6 +73,11 @@ MEventEditor::MEventEditor(QWidget*w,qint64 id)
        gl->addWidget(description=new QTextEdit,lctr,1);
        description->setPlainText(event.description());
        
+       gl->addWidget(lab=new QLabel(tr("Comment:")),++lctr,0);
+       lab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+       gl->addWidget(comment=new QTextEdit,lctr,1);
+       comment->setPlainText(event.comment());
+       
        gl->addWidget(lab=new QLabel(tr("Start Time:")),++lctr,0);
        lab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
        gl->addWidget(starttime=new QDateTimeEdit,lctr,1);
@@ -123,7 +128,7 @@ MEventEditor::MEventEditor(QWidget*w,qint64 id)
        vl->addLayout(hl=new QHBoxLayout,0);
        hl->addStretch();
        hl->addWidget(p=new QPushButton(tr("Save")));
-//     connect(p,SIGNAL(clicked()),this,SLOT(accept()));
+       connect(p,SIGNAL(clicked()),this,SLOT(accept()));
        connect(p,SIGNAL(clicked()),this,SLOT(writeBack()));
        hl->addWidget(p=new QPushButton(tr("Cancel")));
        connect(p,SIGNAL(clicked()),this,SLOT(reject()));
@@ -170,6 +175,7 @@ void MEventEditor::selectRoom()
        hl->addWidget(p=new QPushButton(tr("New...","new room")),0);
        connect(p,SIGNAL(clicked()),this,SLOT(newRoom()));
        connect(p,SIGNAL(clicked()),&d,SLOT(reject()));
+       p->setEnabled(req->hasRight(req->RCreateRoom));
        hl->addWidget(p=new QPushButton(tr("Select","select room")),0);
        connect(p,SIGNAL(clicked()),&d,SLOT(accept()));
        hl->addWidget(p=new QPushButton(tr("Cancel")),0);
@@ -182,14 +188,17 @@ void MEventEditor::selectRoom()
 }
 
 void MEventEditor::newRoom()
-{/*TODO
+{
+       //TODO: do more intelligent input for new room
        QString rid=QInputDialog::getText(this,tr("New Room"),tr("Name of new room:"));
        if(rid!=""){
-               MRoom rm(req,rid);
-               rm.makeValid();
-               rm.save();
+               MTCreateRoom cr=req->queryCreateRoom(rid,0,rid);
+               if(cr.hasError()){
+                       QMessageBox::warning(this,tr("Warning"),tr("Error while creating new room: %1").arg(cr.errorString()));
+                       return;
+               }
                room->setText(rid);
-       }*/
+       }
 }
 
 void MEventEditor::startTimeChanged(const QDateTime&st)
index 96f5046..8fa2207 100644 (file)
@@ -41,7 +41,7 @@ class MEventEditor:public QDialog
                MOEvent event;
                QDateTimeEdit*starttime,*endtime;
                QLineEdit*title,*artist,*room,*price,*cancelreason;
-               QTextEdit*description;
+               QTextEdit*description,*comment;
                QCheckBox*cancelcheck;
                QSpinBox*capacity;
                QLabel*eventid;
index dfd0eed..01f868b 100644 (file)
@@ -53,21 +53,21 @@ MEventsTab::MEventsTab(QString pk)
        QPushButton*p;
        vl->addWidget(p=new QPushButton(tr("New Event...")),0);
        connect(p,SIGNAL(clicked()),this,SLOT(newEvent()));
-       p->setEnabled(req->hasRole("createevent"));
+       p->setEnabled(req->hasRight(req->RCreateEvent));
        vl->addWidget(p=new QPushButton(tr("Details...")),0);
        connect(p,SIGNAL(clicked()),this,SLOT(editEvent()));
-       p->setEnabled(req->hasRole("geteventdata"));
+       p->setEnabled(req->hasRight(req->RGetEvent));
        vl->addSpacing(15);
        vl->addWidget(p=new QPushButton(tr("Order Ticket...")),0);
-       connect(p,SIGNAL(clicked()),this,SLOT(eventOrderTicket()));
-       p->setEnabled(req->hasRole("createorder"));
+       connect(p,SIGNAL(clicked()),this,SIGNAL(eventOrderTicket()));
+       p->setEnabled(req->hasRight(req->RCreateOrder)||req->hasRight(req->RCreateReservation));
        vl->addSpacing(15);
        vl->addWidget(p=new QPushButton(tr("Event Summary...")),0);
        connect(p,SIGNAL(clicked()),this,SLOT(eventSummary()));
        p->setEnabled(req->hasRole("eventsummary"));
        vl->addSpacing(15);
        vl->addWidget(p=new QPushButton(tr("Cancel Event...")),0);
-       p->setEnabled(req->hasRole("cancelevent"));
+       p->setEnabled(req->hasRight(req->RCancelEvent));
        connect(p,SIGNAL(clicked()),this,SLOT(eventCancel()));
        vl->addStretch(10);
        
@@ -85,7 +85,8 @@ QMenu*MEventsTab::menu()
         ->setEnabled(req->hasRight(req->RGetAllEvents));
        m->addAction(tr("&Show/Edit details..."),this,SLOT(editEvent()))
         ->setEnabled(req->hasRight(req->RGetEvent));
-       m->addAction(tr("&New Event..."),this,SLOT(newEvent()))->setEnabled(req->hasRole("createevent"));
+       m->addAction(tr("&New Event..."),this,SLOT(newEvent()))
+        ->setEnabled(req->hasRight(req->RCreateEvent));
        m->addSeparator();
        showoldevents=m->addAction(tr("Show &old Events"),this,SLOT(updateEvents()));
        showoldevents->setEnabled(req->hasRight(req->RGetAllEvents));
diff --git a/src/wbase/WHelper.cpp b/src/wbase/WHelper.cpp
new file mode 100644 (file)
index 0000000..84ec965
--- /dev/null
@@ -0,0 +1,29 @@
+//
+// C++ Implementation: WHelper
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#include "WHelper.h"
+
+#include <QDomElement>
+#include <QDomNode>
+
+QList<QDomElement>WHelper::elementsByTagName(const QDomElement&root,QString tag)
+{
+       QDomNodeList cn=root.childNodes();
+       QList<QDomElement>ret;
+       for(int i=0;i<cn.size();i++){
+               QDomElement e=cn.at(i).toElement();
+               if(e.isNull())continue;
+               if(e.tagName()!=tag)continue;
+               ret<<e;
+       }
+       return ret;
+}
diff --git a/src/wbase/WHelper.h b/src/wbase/WHelper.h
new file mode 100644 (file)
index 0000000..f9e0f22
--- /dev/null
@@ -0,0 +1,29 @@
+//
+// C++ Interface: WHelper
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#ifndef WOLF_HELPER_H
+#define WOLF_HELPER_H
+
+#include <QList>
+#include <QObject>
+
+class QDomElement;
+class QDomNode;
+
+class WHelper:public QObject
+{
+       protected:
+               /**helper for de-serializers: returns direct child elements with given tag name (necessary because QDomElement::elementsByTagName traverses all children)*/
+               static QList<QDomElement>elementsByTagName(const QDomElement&,QString);
+};
+
+#endif
index afce3bd..1da59ad 100644 (file)
 
 #include "nullable.h"
 #include "exception.h"
+#include "WHelper.h"
 
 class QDomElement;
 class QDomDocument;
 
 /**base class of all web based objects*/
-class WObject:public QObject
+class WObject:public WHelper
 {
        protected:
                WObject(){}
index 8005179..c50556d 100644 (file)
@@ -29,7 +29,7 @@ WTransaction::WTransaction(QString ifc)
        m_iface=ifc;
 }
 WTransaction::WTransaction(const WTransaction&t)
-       :QObject()
+       :WHelper()
 {
        m_stage=t.m_stage;
        m_errstr=t.m_errstr;
index faed0c1..74b0afc 100644 (file)
 #include <QString>
 
 #include "nullable.h"
+#include "WHelper.h"
 
 /**base class of all transactions*/
-class WTransaction:public QObject
+class WTransaction:public WHelper
 {
        Q_OBJECT
        public:
index 389787b..656be41 100644 (file)
@@ -1,11 +1,13 @@
 HEADERS += \
        wbase/nullable.h \
+       wbase/WHelper.h \
        wbase/WObject.h \
        wbase/WTransaction.h \
        wbase/WInterface.h
 
 SOURCES += \
        wbase/WObject.cpp \
+       wbase/WHelper.cpp \
        wbase/WTransaction.cpp \
        wbase/WInterface.cpp
 
index 0c474d7..f98ef76 100644 (file)
                <Property name="amountSold" type="int"/>
                <Property name="amountReserved" type="int"/>
                <Property name="description" type="string"/>
+               <Property name="comment" type="string"/>
                <Property name="tax" type="int"/>
                
                <Mapping table="event">
                        <Map column="eventid" property="id"/>
                        <Map column="title"/>
                        <Map property="artist">
-                               <Call lang="php" method="WOArtist::fromTableartist($table->getObjectForartistid())"/>
+                               <Call lang="php" method="WOArtist::fromTableartist(WTartist::getFromDB($table->artistid))"/>
                        </Map>
                        <Map column="description"/>
                        <Map column="comment"/>
        </Class>
        
        <Class name="Room">
-              <Property name="id" type="string"/>
-              <Property name="capacity" type="int"/>
-              <Property name="description" type="string"/>
-              
-              <Mapping table="room">
-                      <Map column="roomid" property="id"/>
-                      <Map column="capacity"/>
-                      <Map column="description"/>
-              </Mapping>
+               <Abstract lang="php"/>
+               <Property name="id" type="string"/>
+               <Property name="capacity" type="int"/>
+               <Property name="description" type="string"/>
+               
+               <Mapping table="room">
+                       <Map column="roomid" property="id"/>
+                       <Map column="capacity"/>
+                       <Map column="description"/>
+               </Mapping>
        </Class>
        
        <Transaction name="GetEvent">
                </Output>
        </Transaction>
        
+       <Transaction name="CreateEvent"/>
+       <Transaction name="ChangeEvent"/>
+       
        <Transaction name="CancelEvent">
                <Input>
                        <Var name="eventid" type="int"/>
        
        <Transaction name="GetAllRooms">
                <Input/>
-               <Call lang="php" method="$this->setrooms(WORoom::getFromTableArrayroom(WTRoom::selectFromDB('')));"/>
+               <Call lang="php" method="$this->setrooms(WORoom::fromTableArrayroom(WTroom::selectFromDB('')));"/>
                <Output>
                        <Var name="rooms" type="List:Room"/>
                </Output>
        </Transaction>
+       
+       <Transaction name="CreateRoom">
+               <Input>
+                       <Var name="roomid" type="string"/>
+                       <Var name="capacity" type="int"/>
+                       <Var name="description" type="string"/>
+               </Input>
+               <Call lang="php" method="WORoom::createRoom($this);"/>
+               <Output>
+                       <Var name="room" type="Room"/>
+               </Output>
+       </Transaction>
 </Wolf>
\ No newline at end of file
index d265edf..74cfbc8 100644 (file)
@@ -31,7 +31,7 @@ WocPHPServerOut::WocPHPServerOut(const QDomElement&el)
        m_basedir=WocProcessor::instance()->baseDir()+"/"+el.attribute("sourceDir",".");
        m_subdir=el.attribute("subDir","phpwob");
        m_fileext=el.attribute("extension",".inc");
-       QDomNodeList nl=el.elementsByTagName("Authenticator");
+       QList<QDomElement> nl=elementsByTagName(el,"Authenticator");
        if(nl.size()){
                QDomElement el2=nl.at(0).toElement();
                m_isauth=el2.attribute("isAuthenticated","false");
@@ -907,7 +907,7 @@ QString WocPHPServerOut::trnInput(const WocTransaction&trn)
                }else{
                        if(trn.isListType(t)){
                                QString pt=trn.plainType(t);
-                               code+="\t\tforeach($root->getElementsByTagName(\""+sl[i]+"\") as $el){\n";
+                               code+="\t\tforeach(WObject::elementsByTagName($root,\""+sl[i]+"\") as $el){\n";
                                if(trn.isObjectType(t)){
                                        code+="\t\t\t$this->ainput[\""+sl[i]+"\"][]=WO"+pt+"::fromXml($xml,$el);\n";
                                }else if(trn.isBlobType(t)){
@@ -920,7 +920,7 @@ QString WocPHPServerOut::trnInput(const WocTransaction&trn)
                                }
                                code+="\t\t}\n";
                        }else{
-                               code+="\t\tforeach($root->getElementsByTagName(\""+sl[i]+"\") as $el){\n";
+                               code+="\t\tforeach(WObject::elementsByTagName($root,\""+sl[i]+"\") as $el){\n";
                                if(trn.isObjectType(t)){
                                        code+="\t\t\t$this->ainput[\""+sl[i]+"\"]=WO"+t+"::fromXml($xml,$el);\n";
                                }else if(trn.isBlobType(t)){
index 16f84c8..5ec9e2b 100644 (file)
 #include <QDomElement>
 #include <QProcess>
 
+QList<QDomElement>elementsByTagName(const QDomElement&root,QString tag)
+{
+       QDomNodeList cn=root.childNodes();
+       QList<QDomElement>ret;
+       for(int i=0;i<cn.size();i++){
+               QDomElement e=cn.at(i).toElement();
+               if(e.isNull())continue;
+               if(e.tagName()!=tag)continue;
+               ret<<e;
+       }
+       return ret;
+}
+
 
 WocProcessor* WocProcessor::inst=0;
 
@@ -127,7 +140,7 @@ bool WocProcessor::processFile(QString fn)
                                m_dbSchema=el.attribute("schema","dbSchema");
                        if(el.hasAttribute("version"))
                                m_dbVer=el.attribute("version");
-                       QDomNodeList nl=el.elementsByTagName("AuditTables");
+                       QList<QDomElement> nl=elementsByTagName(el,"AuditTables");
                        for(int i=0;i<nl.size();i++)
                                WocTable::parseAuditStatic(nl.at(i).toElement());
                }else
@@ -360,7 +373,7 @@ WocClass::WocClass(const QDomElement&cls)
        m_sbase=cls.attribute("serverbase","WObject");
        m_cbase=cls.attribute("clientbase","WObject");
        //scan properties
-       QDomNodeList nl=cls.elementsByTagName("Property");
+       QList<QDomElement> nl=elementsByTagName(cls,"Property");
        for(int i=0;i<nl.size();i++){
                QDomElement el=nl.at(i).toElement();
                if(el.isNull())continue;
@@ -385,7 +398,7 @@ WocClass::WocClass(const QDomElement&cls)
                if(s!="")m_propdoc.insert(p.name,s);
        }
        //scan enums
-       nl=cls.elementsByTagName("Enum");
+       nl=elementsByTagName(cls,"Enum");
        for(int i=0;i<nl.size();i++){
                QDomElement el=nl.at(i).toElement();
                if(el.isNull())continue;
@@ -423,7 +436,7 @@ WocClass::WocClass(const QDomElement&cls)
                        ev=tab.columnEnums(ref[1]);
                }
                //scan values
-               QDomNodeList nl2=el.elementsByTagName("Value");
+               QList<QDomElement> nl2=elementsByTagName(el,"Value");
                int nxval=0;
                for(int j=0;j<nl2.size();j++){
                        QDomElement el2=nl2.at(j).toElement();
@@ -441,7 +454,7 @@ WocClass::WocClass(const QDomElement&cls)
                m_enumvals.insert(nm,ev);
        }
        //scan mappings
-       nl=cls.elementsByTagName("Mapping");
+       nl=elementsByTagName(cls,"Mapping");
        for(int i=0;i<nl.size();i++){
                QDomElement el=nl.at(i).toElement();
                if(el.isNull())continue;
@@ -457,7 +470,7 @@ WocClass::WocClass(const QDomElement&cls)
                        return;
                }
                QList<s_map>map;
-               QDomNodeList nl2=el.elementsByTagName("Map");
+               QList<QDomElement> nl2=elementsByTagName(el,"Map");
                for(int j=0;j<nl2.size();j++){
                        QDomElement el2=nl2.at(j).toElement();
                        if(el2.isNull())continue;
@@ -470,7 +483,7 @@ WocClass::WocClass(const QDomElement&cls)
                                qDebug("Warning: empty mapping in class %s mapping %s. Ignoring it.",m_name.toAscii().data(),name.toAscii().data());
                                continue;
                        }
-                       QDomNodeList nl3=el2.elementsByTagName("Call");
+                       QList<QDomElement> nl3=elementsByTagName(el2,"Call");
                        for(int k=0;k<nl3.size();k++){
                                QDomElement el3=nl3.at(k).toElement();
                                if(el3.isNull())continue;
@@ -483,7 +496,7 @@ WocClass::WocClass(const QDomElement&cls)
                m_maps.insert(name,map);
        }
        //docu
-       nl=cls.elementsByTagName("Doc");
+       nl=elementsByTagName(cls,"Doc");
        for(int i=0;i<nl.size();i++){
                QString s=nl.at(i).toElement().text().trimmed();
                if(s!="")m_docstrings<<s;
@@ -493,7 +506,7 @@ WocClass::WocClass(const QDomElement&cls)
                qDebug("Warning: class %s should be declared abstract.",m_name.toAscii().data());
        }
        //conditional abstraction (must be after check or we'll get false positives)
-       nl=cls.elementsByTagName("Abstract");
+       nl=elementsByTagName(cls,"Abstract");
        for(int i=0;i<nl.size();i++){
                QString s=nl.at(i).toElement().attribute("lang").trimmed();
                if(s!="")m_cabstract<<s;
@@ -662,7 +675,7 @@ WocTable::WocTable(const QDomElement&tbl)
        m_audit=str2bool(tbl.attribute("audit","0"));
        qDebug("Info: parsing table %s",m_name.toAscii().data());
        //Columns
-       QDomNodeList nl=tbl.elementsByTagName("Column");
+       QList<QDomElement> nl=elementsByTagName(tbl,"Column");
        for(int i=0;i<nl.size();i++){
                QDomElement el=nl.at(i).toElement();
                if(el.isNull())continue;
@@ -676,7 +689,7 @@ WocTable::WocTable(const QDomElement&tbl)
                m_columns.append(cl.second);
        }
        //Audit Columns
-       nl=tbl.elementsByTagName("AuditColumn");
+       nl=elementsByTagName(tbl,"AuditColumn");
        for(int i=0;i<nl.size();i++){
                QDomElement el=nl.at(i).toElement();
                if(el.isNull())continue;
@@ -686,7 +699,7 @@ WocTable::WocTable(const QDomElement&tbl)
        }
        
        //Foreign getter methods
-       nl=tbl.elementsByTagName("Foreign");
+       nl=elementsByTagName(tbl,"Foreign");
        for(int i=0;i<nl.size();i++){
                QDomElement el=nl.at(i).toElement();
                if(el.isNull())continue;
@@ -698,12 +711,12 @@ WocTable::WocTable(const QDomElement&tbl)
        }
        
        //Presets
-       nl=tbl.elementsByTagName("Preset");
+       nl=elementsByTagName(tbl,"Preset");
        for(int i=0;i<nl.size();i++){
                QDomElement el=nl.at(i).toElement();
                if(el.isNull())continue;
                QMap<QString,QString>ps;
-               QDomNodeList nl2=el.elementsByTagName("V");
+               QList<QDomElement> nl2=elementsByTagName(el,"V");
                for(int j=0;j<nl2.size();j++){
                        QDomElement el2=nl2.at(j).toElement();
                        if(el2.isNull())continue;
@@ -727,7 +740,7 @@ WocTable::WocTable(const QDomElement&tbl)
        }
        
        //Docu
-       nl=tbl.elementsByTagName("Doc");
+       nl=elementsByTagName(tbl,"Doc");
        for(int i=0;i<nl.size();i++){
                QString s=nl.at(i).toElement().text().trimmed();
                if(s!="")m_docstrings<<s;
@@ -786,7 +799,7 @@ QPair<bool,WocTable::s_col> WocTable::parseColumn(const QDomElement&el,QString m
        }
        cl.defaultval=el.attribute("default");
        //TODO: validate default against type
-       QDomNodeList nl2=el.elementsByTagName("Value");
+       QList<QDomElement> nl2=elementsByTagName(el,"Value");
        int nxval=0;
        //enum values
        for(int j=0;j<nl2.size();j++){
@@ -802,7 +815,7 @@ QPair<bool,WocTable::s_col> WocTable::parseColumn(const QDomElement&el,QString m
                nxval++;
        }
        //default calls
-       nl2=el.elementsByTagName("Call");
+       nl2=elementsByTagName(el,"Call");
        for(int j=0;j<nl2.size();j++){
                QDomElement el2=nl2.at(j).toElement();
                if(el2.isNull())continue;
@@ -811,9 +824,9 @@ QPair<bool,WocTable::s_col> WocTable::parseColumn(const QDomElement&el,QString m
                cl.methodcalls.insert(lang,meth);
        }
        //docu
-       nl2=el.childNodes();
-       for(int j=0;j<nl2.size();j++){
-               QDomNode n=nl2.at(j);
+       QDomNodeList nl3=el.childNodes();
+       for(int j=0;j<nl3.size();j++){
+               QDomNode n=nl3.at(j);
                if(n.isText()||n.isCDATASection())cl.doc+=" "+n.nodeValue();
                else
                if(n.isElement()&&n.nodeName()=="Doc")cl.doc+=" "+n.toElement().text();
@@ -994,7 +1007,7 @@ QString WocTable::columnCall(QString col,QString lang)const
 QList<WocTable::s_col>WocTable::m_staticauditcolumns;
 void WocTable::parseAuditStatic(const QDomElement&el)
 {
-       QDomNodeList nl=el.elementsByTagName("Column");
+       QList<QDomElement> nl=elementsByTagName(el,"Column");
        for(int i=0;i<nl.size();i++){
                QDomElement el2=nl.at(i).toElement();
                if(el2.isNull())continue;
@@ -1075,12 +1088,12 @@ WocTransaction::WocTransaction(const QDomElement&root)
                }
        }
        //input tag
-       QDomNodeList nl=root.elementsByTagName("Input");
+       QList<QDomElement> nl=elementsByTagName(root,"Input");
        for(int i=0;i<nl.size();i++){
                QDomElement el=nl.at(i).toElement();
                if(el.isNull())continue;
                //variables
-               QDomNodeList nl2=el.elementsByTagName("Var");
+               QList<QDomElement> nl2=elementsByTagName(el,"Var");
                for(int j=0;j<nl2.size();j++){
                        QDomElement el2=nl2.at(j).toElement();
                        if(el2.isNull())continue;
@@ -1104,7 +1117,7 @@ WocTransaction::WocTransaction(const QDomElement&root)
                }
        }
        //call tag
-       nl=root.elementsByTagName("Call");
+       nl=elementsByTagName(root,"Call");
        for(int j=0;j<nl.size();j++){
                QDomElement el=nl.at(j).toElement();
                if(el.isNull())continue;
@@ -1118,12 +1131,12 @@ WocTransaction::WocTransaction(const QDomElement&root)
                m_call.insert(nm,mt);
        }
        //output
-       nl=root.elementsByTagName("Output");
+       nl=elementsByTagName(root,"Output");
        for(int i=0;i<nl.size();i++){
                QDomElement el=nl.at(i).toElement();
                if(el.isNull())continue;
                //variables
-               QDomNodeList nl2=el.elementsByTagName("Var");
+               QList<QDomElement> nl2=elementsByTagName(el,"Var");
                for(int j=0;j<nl2.size();j++){
                        QDomElement el2=nl2.at(j).toElement();
                        if(el2.isNull())continue;
@@ -1147,13 +1160,13 @@ WocTransaction::WocTransaction(const QDomElement&root)
                }
        }
        //docu
-       nl=root.elementsByTagName("Doc");
+       nl=elementsByTagName(root,"Doc");
        for(int i=0;i<nl.size();i++){
                QString s=nl.at(i).toElement().text().trimmed();
                if(s!="")m_docstrings<<s;
        }
        //privileges
-       nl=root.elementsByTagName("Privilege");
+       nl=elementsByTagName(root,"Privilege");
        for(int i=0;i<nl.size();i++){
                QString s=nl.at(i).toElement().attribute("name").trimmed();
                if(s!="")m_privileges<<s;
index dd32476..a59d84b 100644 (file)
@@ -21,6 +21,8 @@
 
 class QDomElement;
 
+QList<QDomElement>elementsByTagName(const QDomElement&,QString);
+
 inline bool str2bool(QString s)
 {
        bool b;
index 3be218d..813b448 100644 (file)
@@ -30,7 +30,6 @@ static const QByteArray SRCSTART=
        "//DO NOT EDIT THIS FILE DIRECTLY, USE THE XML SOURCE!\n"
        "#include \"%.h\"\n"
        "#include <QDomElement>\n"
-       "#include <QDomNodeList>\n"
        "#include <QDomDocument>\n";
 //end section of all source files
 static const QByteArray SRCEND="\n//END OF AUTOMATICALLY GENERATED FILE\n";
@@ -290,10 +289,10 @@ void WocQtClientOut::classDeserializer(const WocClass&cls,MFile&hdr,MFile&src,QS
        //implement deserializer (as constructor)
        hcd+="\t"+cn+"(const QDomElement&);\n";
        scd+=cn+"::"+cn+"(const QDomElement&root)\n\t:WObject()\n{\n";
-       scd+="\tQDomNodeList nl;\n";
+       scd+="\tQList<QDomElement> nl;\n";
        for(int i=0;i<k.size();i++){
                if(cls.propertyIsList(k[i])){
-                       scd+="\tnl=root.elementsByTagName(\""+k[i]+"\");\n";
+                       scd+="\tnl=elementsByTagName(root,\""+k[i]+"\");\n";
                        scd+="\tfor(int i=0;i<nl.size();i++){\n\t\tQDomElement el=nl.at(i).toElement();\n";
                        scd+="\t\tif(el.isNull())continue;\n";
                        if(cls.propertyIsInt(k[i])){
@@ -357,7 +356,7 @@ void WocQtClientOut::classDeserializer(const WocClass&cls,MFile&hdr,MFile&src,QS
                                scd+="\t}\n";
                        }else{
                                //element stored types...
-                               scd+="\tnl=root.elementsByTagName(\""+k[i]+"\");\n";
+                               scd+="\tnl=elementsByTagName(root,\""+k[i]+"\");\n";
                                scd+="\tif(nl.size()>0){\n";
                                if(cls.propertyIsString(k[i])){
                                        scd+="\t\tset"+k[i]+"(nl.at(0).toElement().text());\n";
@@ -676,12 +675,12 @@ QString WocQtClientOut::trnOutput(const WocTransaction&trn)
        code+="\troot=doc.documentElement();\n";
        //decide where to go, error handling
        code+="\tif(m_wobstatus!=\"ok\"){\n\t\tm_stage=Error;m_errtype=\"_server\";m_errstr=\"unknown server error\";\n";
-       code+="\t\tQDomNodeList nl=root.elementsByTagName(\"Error\");\n";
+       code+="\t\tQList<QDomElement> nl=elementsByTagName(root,\"Error\");\n";
        code+="\t\tif(nl.size()==0)return;\n";
        code+="\t\ttmp=nl.at(0).toElement();\n";
        code+="\t\tm_errtype=tmp.attribute(\"type\",\"_server\");\n";
        code+="\t\tm_errstr=tmp.text();\n\treturn;\n\t}\n";
-       code+="\tQDomNodeList nl;\n";
+       code+="\tQList<QDomElement> nl;\n";
        //parse parameters
        for(int i=0;i<sl.size();i++){
                QString t=trn.outputType(sl[i]);
@@ -691,7 +690,7 @@ QString WocQtClientOut::trnOutput(const WocTransaction&trn)
                        if(trn.isBoolType(t))code+="==\"yes\"";
                        code+=";\n";
                }else{
-                       code+="\tnl=root.elementsByTagName(\""+sl[i]+"\");\n";
+                       code+="\tnl=elementsByTagName(root,\""+sl[i]+"\");\n";
                        if(trn.isListType(t)){
                                code+="\tfor(int i=0;i<nl.size();i++){\n";
                                if(trn.isObjectType(t)){
index 4e27b1e..57253e1 100644 (file)
 class WObject {
        protected function __construct(){}
        
+       /**helper function that returns only the elements directly beneith the one given as $root*/
+       public static function elementsByTagName($root,$tag)
+       {
+               $list=array();
+               foreach($root->childNodes as $node){
+                       if($node->nodeType == XML_ELEMENT_NODE)
+                               if($node->tagName == $tag)
+                                       $list[]=$node;
+               }
+               return $list;
+       }
 };
 
 ?>
index 22a289d..d51e01e 100644 (file)
@@ -16,4 +16,5 @@ $AUTOCLASS["WOOrderInfo"]="inc/wext/order.php";
 $AUTOCLASS["WOOrder"]="inc/wext/order.php";
 $AUTOCLASS["WOTicket"]="inc/wext/ticket.php";
 $AUTOCLASS["WOTemplate"]="inc/wext/template.php";
+$AUTOCLASS["WORoom"]="inc/wext/room.php";
 ?>
\ No newline at end of file
diff --git a/www/inc/wext/room.php b/www/inc/wext/room.php
new file mode 100644 (file)
index 0000000..59ce2ee
--- /dev/null
@@ -0,0 +1,36 @@
+<?
+//
+// PHP Implementation: room
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+class WORoom extends WORoomAbstract
+{
+       /**called from the CreateRoom transaction*/
+       public static function createRoom($trans)
+       {
+               //check
+               $rm=WTroom::getFromDB($trans->getroomid());
+               if($rm!==false){
+                       $trans->abortWithError(tr("Room already exists"));
+                       return;
+               }
+               //create
+               $rm=WTroom::newRow();
+               $rm->roomid=$trans->getroomid();
+               $rm->capacity=$trans->getcapacity();
+               $rm->description=$trans->getdescription();
+               $rm->insert();
+               //return
+               $trans->setroom(WORoom::fromTableroom($rm));
+       }
+};
+
+?>
\ No newline at end of file