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);
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()));
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);
}
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)
MOEvent event;
QDateTimeEdit*starttime,*endtime;
QLineEdit*title,*artist,*room,*price,*cancelreason;
- QTextEdit*description;
+ QTextEdit*description,*comment;
QCheckBox*cancelcheck;
QSpinBox*capacity;
QLabel*eventid;
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);
->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));
--- /dev/null
+//
+// 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;
+}
--- /dev/null
+//
+// 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
#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(){}
m_iface=ifc;
}
WTransaction::WTransaction(const WTransaction&t)
- :QObject()
+ :WHelper()
{
m_stage=t.m_stage;
m_errstr=t.m_errstr;
#include <QString>
#include "nullable.h"
+#include "WHelper.h"
/**base class of all transactions*/
-class WTransaction:public QObject
+class WTransaction:public WHelper
{
Q_OBJECT
public:
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
<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
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");
}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)){
}
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)){
#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;
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
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;
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;
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();
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;
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;
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;
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;
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;
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;
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;
}
//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;
}
//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;
}
//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;
}
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++){
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;
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();
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;
}
}
//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;
}
}
//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;
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;
}
}
//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;
class QDomElement;
+QList<QDomElement>elementsByTagName(const QDomElement&,QString);
+
inline bool str2bool(QString s)
{
bool b;
"//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";
//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])){
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";
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]);
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)){
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;
+ }
};
?>
$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
--- /dev/null
+<?
+//
+// 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