updated ticket plugin to the new ezc api (child spaces were removed)

This commit is contained in:
2021-06-29 23:42:57 +02:00
parent 66173c7a31
commit 0f78968579
10 changed files with 237 additions and 259 deletions

View File

@@ -302,18 +302,15 @@ void TicketInfo::CheckMinMaxValue(pt::Space & space, Ticket::TicketParam & par)
else
if( *type == L"select" )
{
pt::Space::TableType * child_table = space.get_table(L"ticket_params"); // CHECKME it was space.find_child_space_table();
pt::Space::TableType * child_table = space.get_table(L"options"); // CHECKME it was space.find_child_space_table();
if( child_table )
{
for(pt::Space * sp : *child_table)
{
if( sp->is_equal(L"name", L"option") )
if( sp->to_long(L"id") == par.intv )
{
if( sp->to_long(L"id") == par.intv )
{
return;
}
return;
}
}
}
@@ -329,29 +326,25 @@ void TicketInfo::CheckMinMaxValue(pt::Space & space, Ticket::TicketParam & par)
pt::Space & TicketInfo::FindAddMetaByParam(pt::Space & meta, long param)
{
pt::Space * child_table = meta.get_space(L"params"); // CHECKME it was meta.find_child_space_table();
pt::Space * params = meta.get_space(L"params"); // CHECKME it was meta.find_child_space_table();
if( child_table && child_table->is_table() )
if( params && params->is_table() )
{
for(pt::Space * sp : *child_table->get_table() )
for(pt::Space * sp : *params->get_table() )
{
if( sp->is_equal(L"name", L"param") )
if( sp->to_long(L"id") == param )
{
if( sp->to_long(L"id") == param )
{
return *sp;
}
return *sp;
}
}
}
else
if( !child_table )
if( !params )
{
child_table = &meta.add_empty_space(L"params");
params = &meta.add_empty_space(L"params");
}
pt::Space & sp = child_table->add_empty_space();
sp.add(L"name", L"param");
pt::Space & sp = params->add_empty_space();
sp.add(L"id", param);
return sp;
@@ -359,28 +352,28 @@ pt::Space & TicketInfo::FindAddMetaByParam(pt::Space & meta, long param)
bool TicketInfo::ReadTicketValue(pt::Space & space, long param_id, Ticket::TicketParam & par, const std::wstring & value, pt::Space & meta)
bool TicketInfo::ReadTicketValue(pt::Space & config_param, long param_id, Ticket::TicketParam & par, const std::wstring & value, pt::Space & meta)
{
if( space.is_equal(L"type", L"integer") ||
space.is_equal(L"type", L"progress") ||
space.is_equal(L"type", L"select") )
if( config_param.is_equal(L"type", L"integer") ||
config_param.is_equal(L"type", L"progress") ||
config_param.is_equal(L"type", L"select") )
{
par.intv = Tol(value);
par.decv.clear();
CheckMinMaxValue(space, par);
CheckMinMaxValue(config_param, par);
return true;
}
else
if( space.is_equal(L"type", L"string") ||
space.is_equal(L"type", L"multistring") )
if( config_param.is_equal(L"type", L"string") ||
config_param.is_equal(L"type", L"multistring") )
{
// !! dodac cos co sprawdzi czy string nie zawiera znakow konca linii
pt::Space & sp = FindAddMetaByParam(meta, param_id);
sp.add(L"value", value);
return false;
}
if( space.is_equal(L"type", L"images") ||
space.is_equal(L"type", L"files") )
if( config_param.is_equal(L"type", L"images") ||
config_param.is_equal(L"type", L"files") )
{
if( !value.empty() )
{
@@ -406,7 +399,7 @@ return false;
void TicketInfo::ReadTicketValue(pt::Space & space,
void TicketInfo::ReadTicketValue(pt::Space & config_param,
long param_id,
const PostFile & value,
pt::Space & meta,
@@ -424,8 +417,9 @@ void TicketInfo::ReadTicketValue(pt::Space & space,
if( cur->request->status == WINIX_ERR_OK )
{
pt::Space & space = FindAddMetaByParam(meta, param_id);
pt::Space & file_space = space.get_add_space(L"file"); // CHECKME it was space.add_child_space(L"file");
pt::Space & meta_param = FindAddMetaByParam(meta, param_id);
pt::Space & meta_files = meta_param.get_add_space(L"files");
pt::Space & file_space = meta_files.add_empty_space();
if( file.item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
file_space.add(L"type", L"image");
@@ -469,9 +463,8 @@ void TicketInfo::ReadTicketValue(pt::Space & space,
}
// adding a new parameter only if it not exists in ticket.par_tab
void TicketInfo::ReadTicketParam(pt::Space & space, Ticket & ticket, long param_id, const std::wstring & value, pt::Space & meta)
void TicketInfo::ReadTicketParam(pt::Space & config_param, Ticket & ticket, long param_id, const std::wstring & value, pt::Space & meta)
{
ticket_param.param = param_id;
@@ -482,7 +475,7 @@ void TicketInfo::ReadTicketParam(pt::Space & space, Ticket & ticket, long param_
// parameter param_id already exists in ticket.par_tab
// (overwritting)
if( ReadTicketValue(space, param_id, ticket_param, value, meta) )
if( ReadTicketValue(config_param, param_id, ticket_param, value, meta) )
ticket.par_tab[i2] = ticket_param;
return;
@@ -490,7 +483,7 @@ void TicketInfo::ReadTicketParam(pt::Space & space, Ticket & ticket, long param_
}
// adding a new parameter param_id
if( ReadTicketValue(space, param_id, ticket_param, value, meta) )
if( ReadTicketValue(config_param, param_id, ticket_param, value, meta) )
ticket.par_tab.push_back(ticket_param);
}
@@ -499,13 +492,13 @@ void TicketInfo::ReadTicketParam(pt::Space & space, Ticket & ticket, long param_
void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const std::wstring & value, pt::Space & meta)
{
ticket_param.Clear();
pt::Space::TableType * child_table = cur_conf->get_table(L"params"); // CHECKME it was cur_conf->find_child_space_table();
pt::Space::TableType * params = cur_conf->get_table(L"params");
if( child_table )
if( params )
{
for(pt::Space * space : *child_table)
for(pt::Space * space : *params)
{
if( space->is_equal(L"name", L"param") && space->to_long(L"id") == param_id )
if( space->to_long(L"id") == param_id )
{
ReadTicketParam(*space, ticket, param_id, value, meta);
return;
@@ -526,13 +519,10 @@ void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, pt::Spac
{
for(pt::Space * sp : *child_table)
{
if( sp->is_equal(L"name", L"param") )
if( sp->to_long(L"id") == param_id )
{
if( sp->to_long(L"id") == param_id )
{
ReadTicketValue(*sp, param_id, value, meta);
return;
}
ReadTicketValue(*sp, param_id, value, meta);
return;
}
}
}
@@ -546,25 +536,25 @@ void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, pt::Spac
bool TicketInfo::DeleteTicketFile(Ticket & ticket, long file_id, pt::Space & meta)
{
// FIXME !!!!!!!!!!!!!!1
/*
pt::Space::TableType * meta_child_table = meta.find_child_space_table();
pt::Space::TableType * params = meta.get_table(L"params");
if( meta_child_table )
if( params )
{
for(pt::Space * param : *meta_child_table)
for(pt::Space * param : *params)
{
pt::Space::TableType * param_child_table = param->find_child_space_table();
pt::Space * files_space = param->get_space(L"files");
if( param_child_table && param->is_child_space_name(L"param") )
if( files_space && files_space->is_table() )
{
for(size_t z=0 ; z < param_child_table->size() ; ++z)
{
pt::Space * file = (*param_child_table)[z];
pt::Space::TableType * files = files_space->get_table();
if( file->is_child_space_name(L"file") && file->to_long(L"itemid") == file_id )
for(size_t f=0 ; f < files->size() ; ++f)
{
pt::Space * file = (*files)[f];
if( file->to_long(L"itemid") == file_id )
{
param->remove_child_space(z);
files_space->remove(f);
// !! IMPROVE ME
// temporarily we delete the file here
@@ -579,9 +569,7 @@ bool TicketInfo::DeleteTicketFile(Ticket & ticket, long file_id, pt::Space & met
}
}
*/
return false;
}