updated to the new Pikotools api (new Space struct)
This commit is contained in:
@@ -185,7 +185,7 @@ PT::Space & EditTicket::PrepareSpace()
|
||||
|
||||
if( is_new )
|
||||
{
|
||||
PT::Space * ticket_space = cur->request->item.item_content.meta.FindSpace(L"ticket");
|
||||
PT::Space * ticket_space = cur->request->item.item_content.meta.find_child_space(L"ticket");
|
||||
|
||||
if( ticket_space )
|
||||
{
|
||||
@@ -203,11 +203,11 @@ bool EditTicket::CloseTicket()
|
||||
{
|
||||
cur->request->item.propagate_connector();
|
||||
|
||||
PT::Space & ticket_space = cur->request->item.item_content.meta_admin.FindAddSpace(L"ticket");
|
||||
ticket_space.Add(L"closed", true);
|
||||
PT::Space & ticket_space = cur->request->item.item_content.meta_admin.find_add_child_space(L"ticket");
|
||||
ticket_space.add(L"closed", true);
|
||||
|
||||
PT::Space & thread_space = cur->request->item.item_content.meta_admin.FindAddSpace(L"thread");
|
||||
thread_space.Add(L"closed", true);
|
||||
PT::Space & thread_space = cur->request->item.item_content.meta_admin.find_add_child_space(L"thread");
|
||||
thread_space.add(L"closed", true);
|
||||
|
||||
//if( db->EditAdminMetaById(cur->request->item.ameta, cur->request->item.id) == WINIX_ERR_OK )
|
||||
if( cur->request->item.item_content.update() )
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2018, Tomasz Sowa
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -144,30 +144,36 @@ void SessionData::BuildFileList(std::vector<long> & file_tab, PT::Space & space)
|
||||
{
|
||||
file_tab.clear();
|
||||
|
||||
for(size_t i=0 ; i<space.spaces.size() ; ++i)
|
||||
if( space.child_spaces )
|
||||
{
|
||||
PT::Space & sp = *space.spaces[i];
|
||||
for(size_t i=0 ; i<space.child_spaces->size() ; ++i)
|
||||
{
|
||||
PT::Space & sp = *(*space.child_spaces)[i];
|
||||
|
||||
if( sp.name == L"param" )
|
||||
CheckFile(file_tab, sp);
|
||||
if( sp.name && (*sp.name) == L"param" )
|
||||
CheckFile(file_tab, sp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SessionData::CheckFile(std::vector<long> & file_tab, PT::Space & space)
|
||||
{
|
||||
for(size_t i=0 ; i<space.spaces.size() ; ++i)
|
||||
if( space.child_spaces )
|
||||
{
|
||||
PT::Space & subsp = *space.spaces[i];
|
||||
|
||||
if( subsp.name == L"file" )
|
||||
for(size_t i=0 ; i<space.child_spaces->size() ; ++i)
|
||||
{
|
||||
std::wstring * file_id_str = subsp.GetFirstValue(L"itemid");
|
||||
PT::Space & subsp = *(*space.child_spaces)[i];
|
||||
|
||||
if( file_id_str )
|
||||
if( subsp.name && *subsp.name == L"file" )
|
||||
{
|
||||
long file_id = Tol(*file_id_str);
|
||||
file_tab.push_back(file_id);
|
||||
std::wstring * file_id_str = subsp.get_wstr(L"itemid");
|
||||
|
||||
if( file_id_str )
|
||||
{
|
||||
long file_id = Tol(*file_id_str);
|
||||
file_tab.push_back(file_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -173,16 +173,19 @@ PT::Space * find_ticket_param(long param_id, PT::Space & meta)
|
||||
{
|
||||
wchar_t param_id_str[50];
|
||||
|
||||
// for performane
|
||||
// should be a little faster in each loop comparing only just text
|
||||
Toa(param_id, param_id_str, sizeof(param_id_str)/sizeof(wchar_t));
|
||||
|
||||
for(size_t i=0 ; i<meta.spaces.size() ; ++i)
|
||||
if( meta.child_spaces )
|
||||
{
|
||||
PT::Space & sp = *meta.spaces[i];
|
||||
// for performane
|
||||
// should be a little faster in each loop comparing only just text
|
||||
Toa(param_id, param_id_str, sizeof(param_id_str)/sizeof(wchar_t));
|
||||
|
||||
if( sp.name == L"param" && sp.Text(L"id") == param_id_str )
|
||||
return &sp;
|
||||
for(size_t i=0 ; i<meta.child_spaces->size() ; ++i)
|
||||
{
|
||||
PT::Space & sp = *(*meta.child_spaces)[i];
|
||||
|
||||
if( sp.name && *sp.name == L"param" && sp.is_equal(L"id", param_id_str) )
|
||||
return &sp;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -226,7 +229,7 @@ size_t par_index;
|
||||
}
|
||||
else
|
||||
{
|
||||
PT::Space * meta = item_meta.FindSpace(L"ticket");
|
||||
PT::Space * meta = item_meta.find_child_space(L"ticket");
|
||||
|
||||
if( meta )
|
||||
{
|
||||
@@ -246,15 +249,19 @@ size_t par_index;
|
||||
|
||||
void ticket_print_value_select(Info & i, TicketValue & value)
|
||||
{
|
||||
if( value.is_param && value.is_value )
|
||||
if( value.is_param && value.is_value && value.config_par->child_spaces )
|
||||
{
|
||||
for(size_t a=0 ; a<value.config_par->spaces.size() ; ++a)
|
||||
for(size_t a=0 ; a<value.config_par->child_spaces->size() ; ++a)
|
||||
{
|
||||
PT::Space & sp = *value.config_par->spaces[a];
|
||||
PT::Space & sp = *(*value.config_par->child_spaces)[a];
|
||||
|
||||
if( sp.name == L"option" && sp.Long(L"id") == value.ticket_par->intv )
|
||||
if( sp.name && *sp.name == L"option" && sp.to_long(L"id") == value.ticket_par->intv )
|
||||
{
|
||||
i.out << sp.Text(L"value");
|
||||
std::wstring * val = sp.get_wstr(L"value");
|
||||
|
||||
if( val )
|
||||
i.out << *val;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -267,7 +274,7 @@ void ticket_print_value(Info & i, TicketValue & value)
|
||||
if( !value.is_param || !value.is_value )
|
||||
return;
|
||||
|
||||
std::wstring * type = value.config_par->GetFirstValue(L"type");
|
||||
std::wstring * type = value.config_par->get_wstr(L"type");
|
||||
|
||||
if( value.is_in_ticket_par )
|
||||
{
|
||||
@@ -281,7 +288,10 @@ void ticket_print_value(Info & i, TicketValue & value)
|
||||
}
|
||||
else
|
||||
{
|
||||
i.out << value.value_meta->Text(L"value");
|
||||
std::wstring * val = value.value_meta->get_wstr(L"value");
|
||||
|
||||
if( val )
|
||||
i.out << *val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,10 +322,10 @@ void ticket_meta_value(Info & i)
|
||||
|
||||
void ticket_is_closed(Info & i)
|
||||
{
|
||||
PT::Space * ticket_space = ticket_info.item->item_content.meta_admin.FindSpace(L"ticket");
|
||||
PT::Space * ticket_space = ticket_info.item->item_content.meta_admin.find_child_space(L"ticket");
|
||||
|
||||
if( ticket_space )
|
||||
i.res = ticket_space->Bool(L"closed", false);
|
||||
i.res = ticket_space->to_bool(L"closed", false);
|
||||
}
|
||||
|
||||
|
||||
@@ -330,24 +340,27 @@ void ticket_param_value_for_param_id(Info & i)
|
||||
PT::Space & space = *ticket_info.cur_conf;
|
||||
int id = Toi(i.par);
|
||||
|
||||
|
||||
for( ; conf_index < space.spaces.size() ; ++conf_index)
|
||||
if( space.child_spaces )
|
||||
{
|
||||
if( space.spaces[conf_index]->name == L"param" &&
|
||||
space.spaces[conf_index]->Int(L"id") == id )
|
||||
for( ; conf_index < space.child_spaces->size() ; ++conf_index)
|
||||
{
|
||||
value_for_param_id.Clear();
|
||||
value_for_param_id.is_param = true;
|
||||
value_for_param_id.config_par = space.spaces[conf_index];
|
||||
value_for_param_id.param_id = value_for_param_id.config_par->Long(L"id");
|
||||
PT::Space & sp = *(*space.child_spaces)[conf_index];
|
||||
|
||||
if( ticket_info.ticket && ticket_info.item )
|
||||
if( sp.name && *sp.name == L"param" && sp.to_int(L"id") == id )
|
||||
{
|
||||
find_ticket_value(value_for_param_id, ticket_info.ticket->par_tab, ticket_info.item->item_content.meta);
|
||||
ticket_print_value(i, value_for_param_id);
|
||||
}
|
||||
value_for_param_id.Clear();
|
||||
value_for_param_id.is_param = true;
|
||||
value_for_param_id.config_par = &sp;
|
||||
value_for_param_id.param_id = sp.to_long(L"id");
|
||||
|
||||
break;
|
||||
if( ticket_info.ticket && ticket_info.item )
|
||||
{
|
||||
find_ticket_value(value_for_param_id, ticket_info.ticket->par_tab, ticket_info.item->item_content.meta);
|
||||
ticket_print_value(i, value_for_param_id);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -361,20 +374,21 @@ void ticket_does_param_id_have_value(Info & i)
|
||||
size_t conf_index = 0;
|
||||
PT::Space & space = *ticket_info.cur_conf;
|
||||
|
||||
if( i.params.size() == 2 )
|
||||
if( i.params.size() == 2 && space.child_spaces )
|
||||
{
|
||||
long id = Tol(i.params[0].str);
|
||||
long id2 = Tol(i.params[1].str);
|
||||
|
||||
for( ; conf_index < space.spaces.size() ; ++conf_index)
|
||||
for( ; conf_index < space.child_spaces->size() ; ++conf_index)
|
||||
{
|
||||
if( space.spaces[conf_index]->name == L"param" &&
|
||||
space.spaces[conf_index]->Int(L"id") == id )
|
||||
PT::Space & sp = *(*space.child_spaces)[conf_index];
|
||||
|
||||
if( sp.name && *sp.name == L"param" && sp.to_long(L"id") == id )
|
||||
{
|
||||
value_for_param_id.Clear();
|
||||
value_for_param_id.is_param = true;
|
||||
value_for_param_id.config_par = space.spaces[conf_index];
|
||||
value_for_param_id.param_id = value_for_param_id.config_par->Long(L"id");
|
||||
value_for_param_id.config_par = &sp;
|
||||
value_for_param_id.param_id = sp.to_long(L"id");
|
||||
|
||||
if( ticket_info.ticket && ticket_info.item )
|
||||
{
|
||||
@@ -545,10 +559,10 @@ void tickets_tab_is_closed(Info & i)
|
||||
|
||||
if( tickets_value.is_item )
|
||||
{
|
||||
PT::Space * ticket_space = tickets_value.item->item_content.meta_admin.FindSpace(L"ticket");
|
||||
PT::Space * ticket_space = tickets_value.item->item_content.meta_admin.find_child_space(L"ticket");
|
||||
|
||||
if( ticket_space )
|
||||
i.res = ticket_space->Bool(L"closed", false);
|
||||
i.res = ticket_space->to_bool(L"closed", false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -625,22 +639,27 @@ void tickets_tab_param_value_for_param_id(Info & i)
|
||||
{
|
||||
size_t param_index = 0;
|
||||
PT::Space & space = *ticket_info.cur_conf;
|
||||
int id = Toi(i.par);
|
||||
long id = Tol(i.par);
|
||||
|
||||
for( ; param_index < space.spaces.size() ; ++param_index)
|
||||
if( space.child_spaces )
|
||||
{
|
||||
if( space.spaces[param_index]->name == L"param" &&
|
||||
space.spaces[param_index]->Int(L"id") == id )
|
||||
for( ; param_index < space.child_spaces->size() ; ++param_index)
|
||||
{
|
||||
value_for_param_id.Clear();
|
||||
value_for_param_id.is_param = true;
|
||||
value_for_param_id.config_par = space.spaces[param_index];
|
||||
value_for_param_id.param_id = value_for_param_id.config_par->Long(L"id");
|
||||
PT::Space & sp = *(*space.child_spaces)[param_index];
|
||||
|
||||
find_ticket_value(value_for_param_id, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
|
||||
ticket_print_value(i, value_for_param_id);
|
||||
if( sp.name && *sp.name == L"param" &&
|
||||
sp.to_long(L"id") == id )
|
||||
{
|
||||
value_for_param_id.Clear();
|
||||
value_for_param_id.is_param = true;
|
||||
value_for_param_id.config_par = &sp;
|
||||
value_for_param_id.param_id = sp.to_long(L"id");
|
||||
|
||||
break;
|
||||
find_ticket_value(value_for_param_id, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
|
||||
ticket_print_value(i, value_for_param_id);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -660,32 +679,36 @@ void tickets_tab_does_param_id_have_value(Info & i)
|
||||
long id = Toi(i.params[0].str);
|
||||
long id2 = Toi(i.params[1].str);
|
||||
|
||||
for( ; param_index < space.spaces.size() ; ++param_index)
|
||||
if( space.child_spaces )
|
||||
{
|
||||
if( space.spaces[param_index]->name == L"param" &&
|
||||
space.spaces[param_index]->Int(L"id") == id )
|
||||
for( ; param_index < space.child_spaces->size() ; ++param_index)
|
||||
{
|
||||
value_for_param_id.Clear();
|
||||
value_for_param_id.is_param = true;
|
||||
value_for_param_id.config_par = space.spaces[param_index];
|
||||
value_for_param_id.param_id = value_for_param_id.config_par->Long(L"id");
|
||||
PT::Space & sp = *(*space.child_spaces)[param_index];
|
||||
|
||||
find_ticket_value(value_for_param_id, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
|
||||
|
||||
if( value_for_param_id.is_value )
|
||||
if( sp.name && *sp.name == L"param" && sp.to_long(L"id") == id )
|
||||
{
|
||||
if( value_for_param_id.is_in_ticket_par )
|
||||
{
|
||||
i.res = value_for_param_id.ticket_par->intv == id2;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Ticket: tickets_tab_does_param_id_have_value cannot be used with meta values"
|
||||
<< logend;
|
||||
}
|
||||
}
|
||||
value_for_param_id.Clear();
|
||||
value_for_param_id.is_param = true;
|
||||
value_for_param_id.config_par = &sp;
|
||||
value_for_param_id.param_id = sp.to_long(L"id");
|
||||
|
||||
break;
|
||||
find_ticket_value(value_for_param_id, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
|
||||
|
||||
if( value_for_param_id.is_value )
|
||||
{
|
||||
if( value_for_param_id.is_in_ticket_par )
|
||||
{
|
||||
i.res = value_for_param_id.ticket_par->intv == id2;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Ticket: tickets_tab_does_param_id_have_value cannot be used with meta values"
|
||||
<< logend;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -702,17 +725,27 @@ void tickets_tab_conf_tab(Info & i)
|
||||
conf_index = i.iter;
|
||||
PT::Space & space = *ticket_info.cur_conf;
|
||||
|
||||
while( conf_index < space.spaces.size() && space.spaces[conf_index]->name != L"param" )
|
||||
conf_index += 1;
|
||||
|
||||
i.res = conf_index < space.spaces.size();
|
||||
|
||||
if( i.res )
|
||||
if( space.child_spaces )
|
||||
{
|
||||
value.is_param = true;
|
||||
value.config_par = space.spaces[conf_index];
|
||||
value.param_id = value.config_par->Long(L"id");
|
||||
find_ticket_value(value, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
|
||||
while( conf_index < space.child_spaces->size() )
|
||||
{
|
||||
PT::Space & sp = *(*space.child_spaces)[conf_index];
|
||||
|
||||
if( sp.name && *sp.name == L"param" )
|
||||
break;
|
||||
|
||||
conf_index += 1;
|
||||
}
|
||||
|
||||
i.res = conf_index < space.child_spaces->size();
|
||||
|
||||
if( i.res )
|
||||
{
|
||||
value.is_param = true;
|
||||
value.config_par = (*space.child_spaces)[conf_index];
|
||||
value.param_id = value.config_par->to_long(L"id");
|
||||
find_ticket_value(value, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -751,7 +784,7 @@ void tickets_tab_conf_tab_param_name(Info & i)
|
||||
|
||||
if( value.is_param )
|
||||
{
|
||||
std::wstring * name = value.config_par->GetFirstValue(L"name");
|
||||
std::wstring * name = value.config_par->get_wstr(L"name");
|
||||
|
||||
if( name )
|
||||
i.out << *name;
|
||||
@@ -773,7 +806,7 @@ void tickets_tab_conf_tab_type_is(Info & i)
|
||||
tickets_tab_check_reqid();
|
||||
|
||||
if( value.is_param )
|
||||
i.res = (value.config_par->Text(L"type") == i.par);
|
||||
i.res = value.config_par->is_equal(L"type", i.par);
|
||||
}
|
||||
|
||||
|
||||
@@ -809,13 +842,23 @@ void tickets_tab_conf_tab_file_tab(Info & i)
|
||||
|
||||
PT::Space & mt = *value.value_meta;
|
||||
|
||||
while( tickets_file_index < mt.spaces.size() && mt.spaces[tickets_file_index]->name != L"file" )
|
||||
tickets_file_index += 1;
|
||||
if( mt.child_spaces )
|
||||
{
|
||||
while( tickets_file_index < mt.child_spaces->size() )
|
||||
{
|
||||
PT::Space & sp = *(*mt.child_spaces)[tickets_file_index];
|
||||
|
||||
i.res = (tickets_file_index < mt.spaces.size());
|
||||
if( sp.name && *sp.name == L"file" )
|
||||
break;
|
||||
|
||||
if( i.res && i.iter > 0 )
|
||||
tickets_file_number += 1;
|
||||
tickets_file_index += 1;
|
||||
}
|
||||
|
||||
i.res = (tickets_file_index < mt.child_spaces->size());
|
||||
|
||||
if( i.res && i.iter > 0 )
|
||||
tickets_file_number += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -828,7 +871,7 @@ void tickets_tab_conf_tab_file_tab_index(Info & i)
|
||||
{
|
||||
PT::Space & mt = *value.value_meta;
|
||||
|
||||
if( tickets_file_index < mt.spaces.size() )
|
||||
if( mt.child_spaces && tickets_file_index < mt.child_spaces->size() )
|
||||
i.out << tickets_file_number;
|
||||
}
|
||||
}
|
||||
@@ -843,8 +886,8 @@ void tickets_tab_conf_tab_file_tab_path(Info & i)
|
||||
{
|
||||
PT::Space & mt = *value.value_meta;
|
||||
|
||||
if( tickets_file_index < mt.spaces.size() )
|
||||
i.out << mt.spaces[tickets_file_index]->Text(L"path");
|
||||
if( mt.child_spaces && tickets_file_index < mt.child_spaces->size() )
|
||||
i.out << (*mt.child_spaces)[tickets_file_index]->to_wstr(L"path");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -857,8 +900,8 @@ void tickets_tab_conf_tab_file_tab_itemid(Info & i)
|
||||
{
|
||||
PT::Space & mt = *value.value_meta;
|
||||
|
||||
if( tickets_file_index < mt.spaces.size() )
|
||||
i.out << mt.spaces[tickets_file_index]->Text(L"itemid");
|
||||
if( mt.child_spaces && tickets_file_index < mt.child_spaces->size() )
|
||||
i.out << (*mt.child_spaces)[tickets_file_index]->to_wstr(L"itemid");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -871,8 +914,8 @@ void tickets_tab_conf_tab_file_tab_meta(Info & i)
|
||||
{
|
||||
PT::Space & mt = *value.value_meta;
|
||||
|
||||
if( tickets_file_index < mt.spaces.size() )
|
||||
space_value(i, *mt.spaces[tickets_file_index]);
|
||||
if( mt.child_spaces && tickets_file_index < mt.child_spaces->size() )
|
||||
space_value(i, *(*mt.child_spaces)[tickets_file_index]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -913,19 +956,29 @@ void ticket_tab(Info & i)
|
||||
conf_index = i.iter;
|
||||
PT::Space & space = *ticket_info.cur_conf;
|
||||
|
||||
while( conf_index < space.spaces.size() && space.spaces[conf_index]->name != L"param" )
|
||||
conf_index += 1;
|
||||
|
||||
i.res = conf_index < space.spaces.size();
|
||||
|
||||
if( i.res )
|
||||
if( space.child_spaces )
|
||||
{
|
||||
value.is_param = true;
|
||||
value.config_par = space.spaces[conf_index];
|
||||
value.param_id = value.config_par->Long(L"id");
|
||||
while( conf_index < space.child_spaces->size() )
|
||||
{
|
||||
PT::Space & sp = *(*space.child_spaces)[conf_index];
|
||||
|
||||
if( ticket_info.ticket && ticket_info.item )
|
||||
find_ticket_value(value, ticket_info.ticket->par_tab, ticket_info.item->item_content.meta);
|
||||
if( sp.name && *sp.name == L"param" )
|
||||
break;
|
||||
|
||||
conf_index += 1;
|
||||
}
|
||||
|
||||
i.res = conf_index < space.child_spaces->size();
|
||||
|
||||
if( i.res )
|
||||
{
|
||||
value.is_param = true;
|
||||
value.config_par = (*space.child_spaces)[conf_index];
|
||||
value.param_id = value.config_par->to_long(L"id");
|
||||
|
||||
if( ticket_info.ticket && ticket_info.item )
|
||||
find_ticket_value(value, ticket_info.ticket->par_tab, ticket_info.item->item_content.meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -955,7 +1008,7 @@ void ticket_tab_param_name(Info & i)
|
||||
ticket_tab_check_reqid();
|
||||
|
||||
if( value.is_param )
|
||||
i.out << value.config_par->Text(L"name");
|
||||
i.out << value.config_par->to_wstr(L"name");
|
||||
}
|
||||
|
||||
|
||||
@@ -1008,7 +1061,7 @@ void ticket_tab_type_is(Info & i)
|
||||
ticket_tab_check_reqid();
|
||||
|
||||
if( value.is_param )
|
||||
i.res = (value.config_par->Text(L"type") == i.par);
|
||||
i.res = value.config_par->is_equal(L"type", i.par);
|
||||
}
|
||||
|
||||
|
||||
@@ -1021,10 +1074,20 @@ void ticket_tab_select_tab(Info & i)
|
||||
select_index = i.iter;
|
||||
PT::Space & sp = *value.config_par;
|
||||
|
||||
while( select_index < sp.spaces.size() && sp.spaces[select_index]->name != L"option" )
|
||||
select_index += 1;
|
||||
if( sp.child_spaces )
|
||||
{
|
||||
while( select_index < sp.child_spaces->size() )
|
||||
{
|
||||
PT::Space & sp_child = *(*sp.child_spaces)[select_index];
|
||||
|
||||
i.res = (select_index < sp.spaces.size());
|
||||
if( sp_child.name && *sp_child.name == L"option" )
|
||||
break;
|
||||
|
||||
select_index += 1;
|
||||
}
|
||||
|
||||
i.res = (select_index < sp.child_spaces->size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1037,9 +1100,11 @@ void ticket_tab_select_tab_is_selected(Info & i)
|
||||
{
|
||||
PT::Space & sp = *value.config_par;
|
||||
|
||||
if( select_index < sp.spaces.size() )
|
||||
if( sp.child_spaces && select_index < sp.child_spaces->size() )
|
||||
{
|
||||
long id = sp.spaces[select_index]->Long(L"id");
|
||||
PT::Space & sp_child = *(*sp.child_spaces)[select_index];
|
||||
|
||||
long id = sp_child.to_long(L"id");
|
||||
|
||||
if( value.is_value )
|
||||
{
|
||||
@@ -1048,7 +1113,7 @@ void ticket_tab_select_tab_is_selected(Info & i)
|
||||
}
|
||||
else
|
||||
{
|
||||
i.res = (id == sp.Long(L"default"));
|
||||
i.res = (id == sp.to_long(L"default"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1063,8 +1128,8 @@ void ticket_tab_select_tab_name(Info & i)
|
||||
{
|
||||
PT::Space & sp = *value.config_par;
|
||||
|
||||
if( select_index < sp.spaces.size() )
|
||||
i.out << sp.spaces[select_index]->Text(L"value");
|
||||
if( sp.child_spaces && select_index < sp.child_spaces->size() )
|
||||
i.out << (*sp.child_spaces)[select_index]->to_wstr(L"value");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1077,8 +1142,8 @@ void ticket_tab_select_tab_id(Info & i)
|
||||
{
|
||||
PT::Space & sp = *value.config_par;
|
||||
|
||||
if( select_index < sp.spaces.size() )
|
||||
i.out << sp.spaces[select_index]->Text(L"id");
|
||||
if( sp.child_spaces && select_index < sp.child_spaces->size() )
|
||||
i.out << (*sp.child_spaces)[select_index]->to_wstr(L"id");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1090,8 +1155,8 @@ void ticket_tab_select_tab_meta(Info & i)
|
||||
{
|
||||
PT::Space & sp = *value.config_par;
|
||||
|
||||
if( select_index < sp.spaces.size() )
|
||||
space_value(i, *sp.spaces[select_index]);
|
||||
if( sp.child_spaces && select_index < sp.child_spaces->size() )
|
||||
space_value(i, *(*sp.child_spaces)[select_index]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1110,13 +1175,23 @@ void ticket_tab_file_tab(Info & i)
|
||||
|
||||
PT::Space & mt = *value.value_meta;
|
||||
|
||||
while( ticket_file_index < mt.spaces.size() && mt.spaces[ticket_file_index]->name != L"file" )
|
||||
ticket_file_index += 1;
|
||||
if( mt.child_spaces )
|
||||
{
|
||||
while( ticket_file_index < mt.child_spaces->size() )
|
||||
{
|
||||
PT::Space & sp = *(*mt.child_spaces)[ticket_file_index];
|
||||
|
||||
i.res = (ticket_file_index < mt.spaces.size());
|
||||
if( sp.name && *sp.name == L"file" )
|
||||
break;
|
||||
|
||||
if( i.res && i.iter > 0 )
|
||||
ticket_file_number += 1;
|
||||
ticket_file_index += 1;
|
||||
}
|
||||
|
||||
i.res = (ticket_file_index < mt.child_spaces->size());
|
||||
|
||||
if( i.res && i.iter > 0 )
|
||||
ticket_file_number += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1129,7 +1204,7 @@ void ticket_tab_file_tab_index(Info & i)
|
||||
{
|
||||
PT::Space & mt = *value.value_meta;
|
||||
|
||||
if( ticket_file_index < mt.spaces.size() )
|
||||
if( mt.child_spaces && ticket_file_index < mt.child_spaces->size() )
|
||||
i.out << ticket_file_number;
|
||||
}
|
||||
}
|
||||
@@ -1143,8 +1218,8 @@ void ticket_tab_file_tab_path(Info & i)
|
||||
{
|
||||
PT::Space & mt = *value.value_meta;
|
||||
|
||||
if( ticket_file_index < mt.spaces.size() )
|
||||
i.out << mt.spaces[ticket_file_index]->Text(L"path");
|
||||
if( mt.child_spaces && ticket_file_index < mt.child_spaces->size() )
|
||||
i.out << (*mt.child_spaces)[ticket_file_index]->to_wstr(L"path");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1156,8 +1231,8 @@ void ticket_tab_file_tab_itemid(Info & i)
|
||||
{
|
||||
PT::Space & mt = *value.value_meta;
|
||||
|
||||
if( ticket_file_index < mt.spaces.size() )
|
||||
i.out << mt.spaces[ticket_file_index]->Text(L"itemid");
|
||||
if( mt.child_spaces && ticket_file_index < mt.child_spaces->size() )
|
||||
i.out << (*mt.child_spaces)[ticket_file_index]->to_wstr(L"itemid");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1169,8 +1244,8 @@ void ticket_tab_file_tab_meta(Info & i)
|
||||
{
|
||||
PT::Space & mt = *value.value_meta;
|
||||
|
||||
if( ticket_file_index < mt.spaces.size() )
|
||||
space_value(i, *mt.spaces[ticket_file_index]);
|
||||
if( mt.child_spaces && ticket_file_index < mt.child_spaces->size() )
|
||||
space_value(i, *(*mt.child_spaces)[ticket_file_index]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -106,7 +106,7 @@ void TicketInfo::Clear()
|
||||
|
||||
cur_conf_wrap = &cur_conf_wrap_empty;
|
||||
cur_conf = &cur_conf_empty;
|
||||
cur_conf->Clear();
|
||||
cur_conf->clear();
|
||||
|
||||
item_tab.clear();
|
||||
ticket_tab.clear();
|
||||
@@ -167,9 +167,9 @@ bool TicketInfo::ParseTicketConf(long mount_dir_id, const std::wstring & path)
|
||||
|
||||
conf_tab[mount_dir_id].file_name = path;
|
||||
conf_parser.SetSpace(conf_tab[mount_dir_id].conf);
|
||||
conf_tab[mount_dir_id].conf.Clear();
|
||||
conf_tab[mount_dir_id].conf.clear();
|
||||
|
||||
return (conf_parser.ParseString(config_file.item_content.content_raw) == PT::SpaceParser::ok);
|
||||
return (conf_parser.ParseSpace(config_file.item_content.content_raw) == PT::SpaceParser::ok);
|
||||
}
|
||||
|
||||
|
||||
@@ -264,15 +264,15 @@ void TicketInfo::FindCurrentConf()
|
||||
|
||||
void TicketInfo::CheckMinMaxValue(PT::Space & space, Ticket::TicketParam & par)
|
||||
{
|
||||
std::wstring * type = space.GetFirstValue(L"type");
|
||||
std::wstring * type = space.get_wstr(L"type");
|
||||
|
||||
if( !type )
|
||||
return;
|
||||
|
||||
if( *type == L"integer" )
|
||||
{
|
||||
std::wstring * min_str = space.GetFirstValue(L"min");
|
||||
std::wstring * max_str = space.GetFirstValue(L"min");
|
||||
std::wstring * min_str = space.get_wstr(L"min");
|
||||
std::wstring * max_str = space.get_wstr(L"min");
|
||||
|
||||
if( min_str )
|
||||
{
|
||||
@@ -303,16 +303,19 @@ void TicketInfo::CheckMinMaxValue(PT::Space & space, Ticket::TicketParam & par)
|
||||
else
|
||||
if( *type == L"select" )
|
||||
{
|
||||
for(size_t a=0 ; a<space.spaces.size() ; ++a)
|
||||
if( space.child_spaces )
|
||||
{
|
||||
PT::Space & sp = *space.spaces[a];
|
||||
for(size_t a=0 ; a<space.child_spaces->size() ; ++a)
|
||||
{
|
||||
PT::Space & sp = *(*space.child_spaces)[a];
|
||||
|
||||
if( sp.name == L"option" && sp.Long(L"id") == par.intv )
|
||||
return;
|
||||
if( sp.name && *sp.name == L"option" && sp.to_long(L"id") == par.intv )
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
par.intv = 0;
|
||||
std::wstring * def = space.GetFirstValue(L"default");
|
||||
std::wstring * def = space.get_wstr(L"default");
|
||||
|
||||
if( def )
|
||||
par.intv = Tol(*def);
|
||||
@@ -322,16 +325,19 @@ void TicketInfo::CheckMinMaxValue(PT::Space & space, Ticket::TicketParam & par)
|
||||
|
||||
PT::Space & TicketInfo::FindAddMetaByParam(PT::Space & meta, long param)
|
||||
{
|
||||
for(size_t i=0 ; i<meta.spaces.size() ; ++i)
|
||||
if( meta.child_spaces )
|
||||
{
|
||||
PT::Space & sp = *meta.spaces[i];
|
||||
for(size_t i=0 ; i<meta.child_spaces->size() ; ++i)
|
||||
{
|
||||
PT::Space & sp = *(*meta.child_spaces)[i];
|
||||
|
||||
if( sp.name == L"param" && sp.Long(L"id") == param )
|
||||
return sp;
|
||||
if( sp.name && *sp.name == L"param" && sp.to_long(L"id") == param )
|
||||
return sp;
|
||||
}
|
||||
}
|
||||
|
||||
PT::Space & sp = meta.AddSpace(L"param");
|
||||
sp.Add(L"id", param);
|
||||
PT::Space & sp = meta.add_child_space(L"param");
|
||||
sp.add(L"id", param);
|
||||
|
||||
return sp;
|
||||
}
|
||||
@@ -340,9 +346,9 @@ return sp;
|
||||
|
||||
bool TicketInfo::ReadTicketValue(PT::Space & space, long param_id, Ticket::TicketParam & par, const std::wstring & value, PT::Space & meta)
|
||||
{
|
||||
if( space.Text(L"type") == L"integer" ||
|
||||
space.Text(L"type") == L"progress" ||
|
||||
space.Text(L"type") == L"select" )
|
||||
if( space.is_equal(L"type", L"integer") ||
|
||||
space.is_equal(L"type", L"progress") ||
|
||||
space.is_equal(L"type", L"select") )
|
||||
{
|
||||
par.intv = Tol(value);
|
||||
par.decv.clear();
|
||||
@@ -350,16 +356,16 @@ bool TicketInfo::ReadTicketValue(PT::Space & space, long param_id, Ticket::Ticke
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if( space.Text(L"type") == L"string" ||
|
||||
space.Text(L"type") == L"multistring" )
|
||||
if( space.is_equal(L"type", L"string") ||
|
||||
space.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);
|
||||
sp.add(L"value", value);
|
||||
return false;
|
||||
}
|
||||
if( space.Text(L"type") == L"images" ||
|
||||
space.Text(L"type") == L"files" )
|
||||
if( space.is_equal(L"type", L"images") ||
|
||||
space.is_equal(L"type", L"files") )
|
||||
{
|
||||
if( !value.empty() )
|
||||
{
|
||||
@@ -404,16 +410,16 @@ 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.AddSpace(L"file");
|
||||
PT::Space & file_space = space.add_child_space(L"file");
|
||||
|
||||
if( file.item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
file_space.Add(L"type", L"image");
|
||||
file_space.add(L"type", L"image");
|
||||
else
|
||||
file_space.Add(L"type", L"file");
|
||||
file_space.add(L"type", L"file");
|
||||
|
||||
file_space.Add(L"itemid", file.id);
|
||||
file_space.add(L"itemid", file.id);
|
||||
system->MakePath(file, file_path);
|
||||
file_space.Add(L"path", file_path);
|
||||
file_space.add(L"path", file_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -425,11 +431,11 @@ void TicketInfo::ReadTicketValue(PT::Space & space,
|
||||
void TicketInfo::ReadTicketValue(PT::Space & space,
|
||||
long param_id, const PostFile & value, PT::Space & meta)
|
||||
{
|
||||
std::wstring * type = space.GetFirstValue(L"type");
|
||||
std::wstring * type = space.get_wstr(L"type");
|
||||
|
||||
if( type && (*type == L"images" || *type == L"files") )
|
||||
{
|
||||
std::wstring * upload_path = space.GetFirstValue(L"upload_dir");
|
||||
std::wstring * upload_path = space.get_wstr(L"upload_dir");
|
||||
|
||||
if( upload_path && !upload_path->empty() )
|
||||
{
|
||||
@@ -479,14 +485,17 @@ void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const std::wstr
|
||||
{
|
||||
ticket_param.Clear();
|
||||
|
||||
for(size_t i=0 ; i<cur_conf->spaces.size() ; ++i)
|
||||
if( cur_conf->child_spaces )
|
||||
{
|
||||
PT::Space & space = *cur_conf->spaces[i];
|
||||
|
||||
if( space.name == L"param" && Tol(space.Text(L"id")) == param_id )
|
||||
for(size_t i=0 ; i<cur_conf->child_spaces->size() ; ++i)
|
||||
{
|
||||
ReadTicketParam(space, ticket, param_id, value, meta);
|
||||
return;
|
||||
PT::Space & space = *(*cur_conf->child_spaces)[i];
|
||||
|
||||
if( space.name && *space.name == L"param" && space.to_long(L"id") == param_id )
|
||||
{
|
||||
ReadTicketParam(space, ticket, param_id, value, meta);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,14 +506,17 @@ void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const std::wstr
|
||||
// always adds a new parameter
|
||||
void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, PT::Space & meta)
|
||||
{
|
||||
for(size_t i=0 ; i<cur_conf->spaces.size() ; ++i)
|
||||
if( cur_conf->child_spaces )
|
||||
{
|
||||
PT::Space & space = *cur_conf->spaces[i];
|
||||
|
||||
if( space.name == L"param" && space.Long(L"id") == param_id )
|
||||
for(size_t i=0 ; i<cur_conf->child_spaces->size() ; ++i)
|
||||
{
|
||||
ReadTicketValue(space, param_id, value, meta);
|
||||
return;
|
||||
PT::Space & space = *(*cur_conf->child_spaces)[i];
|
||||
|
||||
if( space.name && *space.name == L"param" && space.to_long(L"id") == param_id )
|
||||
{
|
||||
ReadTicketValue(space, param_id, value, meta);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,29 +529,32 @@ void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, PT::Spac
|
||||
|
||||
bool TicketInfo::DeleteTicketFile(Ticket & ticket, long file_id, PT::Space & meta)
|
||||
{
|
||||
for(size_t i=0 ; i<meta.spaces.size() ; ++i)
|
||||
if( meta.child_spaces )
|
||||
{
|
||||
PT::Space & param = *meta.spaces[i];
|
||||
|
||||
if( param.name == L"param" )
|
||||
for(size_t i=0 ; i<meta.child_spaces->size() ; ++i)
|
||||
{
|
||||
for(size_t z=0 ; z<param.spaces.size() ; ++z)
|
||||
PT::Space & param = *(*meta.child_spaces)[i];
|
||||
|
||||
if( param.name && *param.name == L"param" && param.child_spaces )
|
||||
{
|
||||
PT::Space & file = *param.spaces[z];
|
||||
|
||||
if( file.name == L"file" )
|
||||
for(size_t z=0 ; z<param.child_spaces->size() ; ++z)
|
||||
{
|
||||
if( file.Long(L"itemid") == file_id )
|
||||
PT::Space & file = *(*param.child_spaces)[z];
|
||||
|
||||
if( file.name && *file.name == L"file" )
|
||||
{
|
||||
param.RemoveSpace(z);
|
||||
if( file.to_long(L"itemid") == file_id )
|
||||
{
|
||||
param.remove_child_space(z);
|
||||
|
||||
// !! IMPROVE ME
|
||||
// temporarily we delete the file here
|
||||
// but it should be really deleted when the user will press
|
||||
// the submit button
|
||||
//functions->fun_rm.RemoveFileOrSymlink(file_id, true);
|
||||
// !! IMPROVE ME
|
||||
// temporarily we delete the file here
|
||||
// but it should be really deleted when the user will press
|
||||
// the submit button
|
||||
//functions->fun_rm.RemoveFileOrSymlink(file_id, true);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -616,9 +631,8 @@ void TicketInfo::RemoveTicket(long file_id)
|
||||
|
||||
void TicketInfo::CopyTicketSpace(PT::Space & ticket_space, Item & item)
|
||||
{
|
||||
PT::Space & ticket_meta = item.item_content.meta.FindAddSpace(L"ticket");
|
||||
PT::Space & ticket_meta = item.item_content.meta.find_add_child_space(L"ticket");
|
||||
ticket_meta = ticket_space;
|
||||
ticket_meta.name = L"ticket";
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user