m_basedir=WocProcessor::instance()->baseDir()+"/"+el.attribute("sourceDir",".");
m_subdir=el.attribute("subDir","phpwob");
m_fileext=el.attribute("extension",".inc");
- QList<QDomElement> nl=elementsByTagName(el,"Authenticator");
- if(nl.size()){
- QDomElement el2=nl.at(0).toElement();
- m_isauth=el2.attribute("isAuthenticated","false");
- m_hasrole=el2.attribute("hasRole","false");
- m_username=el2.attribute("userName","\"\"");
- m_authinit=el2.attribute("init","");
- }else{
- m_isauth="false";
- m_hasrole="false";
- m_username="\"\"";
- }
+ m_transbase=el.attribute("transactionBase","WobTransaction");
//cleanup directory (remove normal files, assume remainder is harmless)
QDir d(m_basedir+"/"+m_subdir);
if(d.exists() && str2bool(el.attribute("clean","0"))){
////
//generate code
- QString code="/* TRANSLATOR "+cn+" */\nclass "+cn+" extends WobTransaction{\n";
+ QString code="/* TRANSLATOR "+cn+" */\nclass "+cn+" extends "+m_transbase+"{\n";
//constructor
code+=trnConstruct(trn);
tf.write(code.toAscii());
//request handler:
- code="public function handleRequest(){\n";
+ code="public function handleRequest(){\n\t$this->startTransaction();\n";
//security handling
switch(trn.authMode()){
case WocTransaction::Checked:
code+="\t/*security check: authenticated and authorized*/\n";
- code+="\t"+m_authinit+";\n";
- code+="\tif(!"+m_isauth+"||!"+QString(m_hasrole).replace("%","\""+trn.name()+"\"")+")$this->notAuthenticated();\n";
+ code+="\tif(!$this->isAuthorized(\""+trn.name()+"\""+"))$this->notAuthenticated();\n";
break;
case WocTransaction::Auth:
code+="\t/*security check: authenticated*/\n";
- code+="\t"+m_authinit+";\n";
- code+="\tif(!"+m_isauth+")$this->notAuthenticated();\n";
+ code+="\tif(!$this->isAuthenticated())$this->notAuthenticated();\n";
break;
default:
code+="\t/*no security check, open function*/\n";
//encode outputs/handle errors
code+=trnOutput(trn);
- code+="}\n";
+ code+="\t$this->commitTransaction();\n}\n";
tf.write(code.toAscii());
//getters/setters
QString WocPHPServerOut::trnConstruct(const WocTransaction&trn)
{
- QString code="public function __construct(){\n\t$this->ainput=array(";
+ QString code="public function __construct(){\n\tparent::__construct();\n";
+ code+="\t$this->ainput=array(";
QStringList sl=trn.inputNames();
for(int i=0;i<sl.size();i++){
if(i)code+=",";
//check method
code+="public function havePrivilege($priv){\n";
code+="\tif(!in_array($priv,self::privileges()))return false;\n";
- code+="\treturn "+QString(m_hasrole).replace("%","(\""+trn.name()+":\".$priv)")+";\n}\n";
+ code+="\treturn $this->isAuthorized(\""+trn.name()+":\".$priv);\n}\n";
return code;
}
virtual void newTransaction(const WocTransaction&);
private:
QString m_basedir,m_subdir,m_fileext;
- QString m_isauth,m_hasrole,m_username,m_authinit;
+ //QString m_isauth,m_hasrole,m_username,m_authinit;
+ QString m_transbase;
QFile m_loader,m_schema,m_transact;
/**helper: adds a loader line for a class to autoload.php*/