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

master
Tomasz Sowa 2 years ago
parent 66173c7a31
commit 0f78968579

@ -27,7 +27,7 @@
<div class="uk-margin">
<label class="uk-form-label" for="winix_nick_id">{nick}</label>
<div class="uk-form-controls">
<input class="uk-input" id="winix_nick_id" type="text" name="guestname" value="[item_guest_name]">
<input class="uk-input" id="winix_nick_id" type="text" name="guestname" value="[item.content.guest_name]">
</div>
</div>

@ -173,7 +173,7 @@
<div class="uk-margin">
<label class="uk-form-label" for="winix_nick_id">{nick}</label>
<div class="uk-form-controls">
<input class="uk-input" id="winix_nick_id" type="text" name="guestname" value="[item_guest_name]">
<input class="uk-input" id="winix_nick_id" type="text" name="guestname" value="[item.content.guest_name]">
</div>
</div>

@ -46,7 +46,17 @@
<div class="uk-margin">
<div class="uk-form-controls">
<textarea class="uk-textarea" rows="20" name="envvar" id="winix_content_id">[if winix_function_param_is "a"][if env_user.user.is_admin_env_object][env_user.user.admin_env "dump_to_space" "pretty"][end][else][if env_user.user.is_env_object][env_user.user.env "dump_to_space" "pretty"][end][end]</textarea>
<textarea class="uk-textarea" rows="20" name="envvar" id="winix_content_id">[ezc clear_all_white_nodes "yes"]
[if winix_function_param_is "a"]
[if env_user.user.is_admin_env_object]
[env_user.user.admin_env "dump_to_space" "pretty"]
[end]
[else]
[if env_user.user.is_env_object]
[env_user.user.env "dump_to_space" "pretty"]
[end]
[end]
[end]</textarea>
</div>
</div>

@ -12,7 +12,7 @@
<form class="uk-form-stacked" method="post" action="[doc_base_url][dir][if request.is_item][item.url]/[end]meta[if winix_function_param_is "a"]/a[end]">
<div class="uk-margin">
<label class="uk-form-label" for="winix_meta_textarea">
<label class="uk-form-label" for="winix_content_id">
[if winix_function_param_is "a"]
[if request.is_item]
{meta_admin_for_page}:
@ -33,7 +33,21 @@
</label>
<div class="uk-form-controls">
<textarea class="uk-textarea" id="winix_meta_textarea" rows="20" name="itemmeta">[if winix_function_param_is "a"][if request.is_item][item.content.admin_meta "dump"][else][dir_last_admin_meta_str][end][else][if request.is_item][item.content.meta "dump"][else][dir_last_meta_str][end][end]</textarea>
<textarea class="uk-textarea" id="winix_content_id" rows="20" name="itemmeta">[ezc clear_all_white_nodes "yes"]
[if winix_function_param_is "a"]
[if request.is_item]
[item.content.admin_meta "dump_to_space" "pretty"]
[else]
[dir_last_admin_meta_str]
[end]
[else]
[if request.is_item]
[item.content.meta "dump_to_space" "pretty"]
[else]
[dir_last_meta_str]
[end]
[end]
[end]</textarea>
</div>
</div>

@ -44,7 +44,7 @@
[end]
[end]
</table>
[item_print_content]
[item.content.print_content]
</div>

@ -60,7 +60,7 @@
[end]
[if or [winix_function_is "emacs"] [winix_function_is "env"]]
[if or [winix_function_is "emacs"] [winix_function_is "env"] [winix_function_is "meta"]]
<script type="text/javascript" src="[doc_base_url_common]/codemirror/5.59.2/lib/codemirror.js"></script>
<link rel="stylesheet" href="[doc_base_url_common]/codemirror/5.59.2/lib/codemirror.css" type="text/css">

@ -199,6 +199,9 @@ void CreateTicket::MakePost()
Submit(ticket, item);
ticket_info->ticket = ticket_info->GetEmptyTicket(); // ticket was deleted by Submit() method -- RemoveTmpTicket() was used
}
cur->request->is_item = true;
cur->request->models.Add(L"item", item);
}

@ -150,8 +150,7 @@ void SessionData::BuildFileList(std::vector<long> & file_tab, pt::Space & space)
{
for(pt::Space * sp : *child_table)
{
if( sp->is_equal(L"name", L"param") )
CheckFile(file_tab, *sp);
CheckFile(file_tab, *sp);
}
}
}
@ -165,10 +164,7 @@ void SessionData::CheckFile(std::vector<long> & file_tab, pt::Space & space)
{
for(pt::Space * sp : *child_table)
{
if( sp->is_equal(L"name", L"file") )
{
file_tab.push_back(sp->to_long(L"itemid"));
}
file_tab.push_back(sp->to_long(L"itemid"));
}
}
}

@ -43,7 +43,6 @@
#include "templates/templates.h"
#include "sessiondata.h"
#include "plugins/thread/pluginmsg.h"
#include "templates/miscspace.h"
#include "space/space.h"
#include "pluginmsg.h"
@ -171,13 +170,13 @@ return false;
*/
pt::Space * find_ticket_param(long param_id, pt::Space & meta)
{
pt::Space::TableType * child_table = meta.find_child_space_table();
pt::Space::TableType * params = meta.get_table(L"params");
if( child_table )
if( params )
{
for(pt::Space * sp : *child_table)
for(pt::Space * sp : *params)
{
if( sp->is_child_space_name(L"param") && sp->to_long(L"id") == param_id )
if( sp->to_long(L"id") == param_id )
return sp;
}
}
@ -223,7 +222,7 @@ size_t par_index;
}
else
{
pt::Space * meta = item_meta.find_child_space(L"ticket");
pt::Space * meta = item_meta.get_space(L"ticket");
if( meta )
{
@ -245,18 +244,21 @@ void ticket_print_value_select(Info & i, TicketValue & value)
{
if( value.is_param && value.is_value )
{
pt::Space::TableType * child_table = value.config_par->find_child_space_table();
pt::Space::TableType * options = value.config_par->get_table(L"options");
for(pt::Space * sp : *child_table)
if( options )
{
if( sp->is_child_space_name(L"option") && sp->to_long(L"id") == value.ticket_par->intv )
for(pt::Space * sp : *options)
{
std::wstring * val = sp->get_wstr(L"value");
if( sp->to_long(L"id") == value.ticket_par->intv )
{
std::wstring * val = sp->get_wstr(L"value");
if( val )
i.out << *val;
if( val )
i.out << *val;
break;
break;
}
}
}
}
@ -308,15 +310,15 @@ void ticket_is_creating_new(Info & i)
i.res = ticket_info.create_new_ticket;
}
void ticket_meta_value(Info & i)
{
if( ticket_info.item )
space_value(i, ticket_info.item->item_content.meta);
}
//void ticket_meta_value(Info & i)
//{
// if( ticket_info.item )
// space_value(i, ticket_info.item->item_content.meta);
//}
void ticket_is_closed(Info & i)
{
pt::Space * ticket_space = ticket_info.item->item_content.meta_admin.find_child_space(L"ticket");
pt::Space * ticket_space = ticket_info.item->item_content.meta_admin.get_space(L"ticket");
if( ticket_space )
i.res = ticket_space->to_bool(L"closed", false);
@ -333,13 +335,13 @@ void ticket_param_value_for_param_id(Info & i)
pt::Space & space = *ticket_info.cur_conf;
int id = Toi(i.par);
pt::Space::TableType * child_table = space.find_child_space_table();
pt::Space::TableType * params = space.get_table(L"params");
if( child_table )
if( params )
{
for(pt::Space * sp : *child_table)
for(pt::Space * sp : *params)
{
if( sp->is_child_space_name(L"param") && sp->to_int(L"id") == id )
if( sp->to_int(L"id") == id )
{
value_for_param_id.Clear();
value_for_param_id.is_param = true;
@ -365,16 +367,16 @@ void ticket_does_param_id_have_value(Info & i)
value_for_param_id.Clear();
pt::Space & space = *ticket_info.cur_conf;
pt::Space::TableType * child_table = space.find_child_space_table();
pt::Space::TableType * params = space.get_table(L"params");
if( i.params.size() == 2 && child_table )
if( i.params.size() == 2 && params )
{
long id = Tol(i.params[0].str);
long id2 = Tol(i.params[1].str);
for(pt::Space * sp : *child_table)
for(pt::Space * sp : *params)
{
if( sp->is_child_space_name(L"param") && sp->to_long(L"id") == id )
if( sp->to_long(L"id") == id )
{
value_for_param_id.Clear();
value_for_param_id.is_param = true;
@ -550,7 +552,7 @@ void tickets_tab_is_closed(Info & i)
if( tickets_value.is_item )
{
pt::Space * ticket_space = tickets_value.item->item_content.meta_admin.find_child_space(L"ticket");
pt::Space * ticket_space = tickets_value.item->item_content.meta_admin.get_space(L"ticket");
if( ticket_space )
i.res = ticket_space->to_bool(L"closed", false);
@ -587,13 +589,13 @@ void tickets_tab_subject(Info & i)
}
void tickets_tab_meta_value(Info & i)
{
tickets_tab_check_reqid();
if( tickets_value.is_item )
space_value(i, tickets_value.item->item_content.meta);
}
//void tickets_tab_meta_value(Info & i)
//{
// tickets_tab_check_reqid();
//
// if( tickets_value.is_item )
// space_value(i, tickets_value.item->item_content.meta);
//}
@ -631,13 +633,13 @@ void tickets_tab_param_value_for_param_id(Info & i)
pt::Space & space = *ticket_info.cur_conf;
long id = Tol(i.par);
pt::Space::TableType * child_table = space.find_child_space_table();
pt::Space::TableType * params = space.get_table(L"params");
if( child_table )
if( params )
{
for(pt::Space * sp : *child_table)
for(pt::Space * sp : *params)
{
if( sp->is_child_space_name(L"param") && sp->to_long(L"id") == id )
if( sp->to_long(L"id") == id )
{
value_for_param_id.Clear();
value_for_param_id.is_param = true;
@ -667,13 +669,13 @@ void tickets_tab_does_param_id_have_value(Info & i)
long id = Toi(i.params[0].str);
long id2 = Toi(i.params[1].str);
pt::Space::TableType * child_table = space.find_child_space_table();
pt::Space::TableType * params = space.get_table(L"params");
if( child_table )
if( params )
{
for(pt::Space * sp : *child_table)
for(pt::Space * sp : *params)
{
if( sp->is_child_space_name(L"param") && sp->to_long(L"id") == id )
if( sp->to_long(L"id") == id )
{
value_for_param_id.Clear();
value_for_param_id.is_param = true;
@ -712,27 +714,16 @@ void tickets_tab_conf_tab(Info & i)
{
conf_index = i.iter;
pt::Space & space = *ticket_info.cur_conf;
pt::Space::TableType * params = space.get_table(L"params");
pt::Space::TableType * child_table = space.find_child_space_table();
if( child_table )
if( params )
{
while( conf_index < child_table->size() )
{
pt::Space & sp = *(*child_table)[conf_index];
if( sp.is_child_space_name(L"param") )
break;
conf_index += 1;
}
i.res = conf_index < child_table->size();
i.res = conf_index < params->size();
if( i.res )
{
value.is_param = true;
value.config_par = (*child_table)[conf_index];
value.config_par = (*params)[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);
}
@ -831,21 +822,11 @@ void tickets_tab_conf_tab_file_tab(Info & i)
tickets_file_number = 0;
pt::Space & mt = *value.value_meta;
pt::Space::TableType * child_table = mt.find_child_space_table();
pt::Space::TableType * files = mt.get_table(L"files");
if( child_table )
if( files )
{
while( tickets_file_index < child_table->size() )
{
pt::Space & sp = *(*child_table)[tickets_file_index];
if( sp.is_child_space_name(L"file") )
break;
tickets_file_index += 1;
}
i.res = (tickets_file_index < child_table->size());
i.res = (tickets_file_index < files->size());
if( i.res && i.iter > 0 )
tickets_file_number += 1;
@ -861,9 +842,12 @@ void tickets_tab_conf_tab_file_tab_index(Info & i)
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space & mt = *value.value_meta;
pt::Space::TableType * files = mt.get_table(L"files");
if( mt.find_child_space(tickets_file_index) )
if( files && tickets_file_index < files->size() )
{
i.out << tickets_file_number;
}
}
}
@ -876,10 +860,12 @@ void tickets_tab_conf_tab_file_tab_path(Info & i)
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space & mt = *value.value_meta;
pt::Space * sp = mt.find_child_space(tickets_file_index);
pt::Space::TableType * files = mt.get_table(L"files");
if( sp )
i.out << sp->to_wstr(L"path");
if( files && tickets_file_index < files->size() )
{
(*files)[tickets_file_index]->to_wstr(L"path");
}
}
}
@ -891,28 +877,30 @@ void tickets_tab_conf_tab_file_tab_itemid(Info & i)
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space & mt = *value.value_meta;
pt::Space * sp = mt.find_child_space(tickets_file_index);
pt::Space::TableType * files = mt.get_table(L"files");
if( sp )
i.out << sp->to_long(L"itemid");
if( files && tickets_file_index < files->size() )
{
(*files)[tickets_file_index]->to_long(L"itemid");
}
}
}
void tickets_tab_conf_tab_file_tab_meta(Info & i)
{
tickets_tab_check_reqid();
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space & mt = *value.value_meta;
pt::Space * sp = mt.find_child_space(tickets_file_index);
if( sp )
space_value(i, *sp);
}
}
//void tickets_tab_conf_tab_file_tab_meta(Info & i)
//{
// tickets_tab_check_reqid();
//
// if( value.is_value && !value.is_in_ticket_par )
// {
// pt::Space & mt = *value.value_meta;
// pt::Space * sp = mt.find_child_space(tickets_file_index);
//
// if( sp )
// space_value(i, *sp);
// }
//}
//
} // namespace ns_tickets_tab
@ -949,26 +937,16 @@ void ticket_tab(Info & i)
conf_index = i.iter;
pt::Space & space = *ticket_info.cur_conf; // CHECKME is ticket_info.cur_conf always set?
pt::Space::TableType * child_table = space.find_child_space_table();
pt::Space::TableType * params = space.get_table(L"params");
if( child_table )
if( params )
{
while( conf_index < child_table->size() )
{
pt::Space & sp = *(*child_table)[conf_index];
if( sp.is_child_space_name(L"param") )
break;
conf_index += 1;
}
i.res = conf_index < child_table->size();
i.res = conf_index < params->size();
if( i.res )
{
value.is_param = true;
value.config_par = (*child_table)[conf_index];
value.config_par = (*params)[conf_index];
value.param_id = value.config_par->to_long(L"id");
if( ticket_info.ticket && ticket_info.item )
@ -1042,13 +1020,13 @@ void ticket_tab_value_dec(Info & i)
}
void ticket_tab_value_meta(Info & i)
{
ticket_tab_check_reqid();
if( value.is_value && !value.is_in_ticket_par )
space_value(i, *value.value_meta);
}
//void ticket_tab_value_meta(Info & i)
//{
// ticket_tab_check_reqid();
//
// if( value.is_value && !value.is_in_ticket_par )
// space_value(i, *value.value_meta);
//}
void ticket_tab_type_is(Info & i)
@ -1067,21 +1045,11 @@ void ticket_tab_select_tab(Info & i)
if( value.is_param )
{
select_index = i.iter;
pt::Space::TableType * child_table = value.config_par->find_child_space_table();
pt::Space::TableType * options = value.config_par->get_table(L"options");
if( child_table )
if( options )
{
while( select_index < child_table->size() )
{
pt::Space & sp = *(*child_table)[select_index];
if( sp.is_child_space_name(L"option") )
break;
select_index += 1;
}
i.res = (select_index < child_table->size());
i.res = (select_index < options->size());
}
}
}
@ -1093,12 +1061,11 @@ void ticket_tab_select_tab_is_selected(Info & i)
if( value.is_param )
{
pt::Space::TableType * child_table = value.config_par->find_child_space_table();
pt::Space::TableType * options = value.config_par->get_table(L"options");
if( child_table && select_index < child_table->size() )
if( options && select_index < options->size() )
{
pt::Space & sp = *(*child_table)[select_index];
pt::Space & sp = *(*options)[select_index];
long id = sp.to_long(L"id");
if( value.is_value )
@ -1121,10 +1088,12 @@ void ticket_tab_select_tab_name(Info & i)
if( value.is_param )
{
pt::Space * sp = value.config_par->find_child_space(select_index);
pt::Space::TableType * options = value.config_par->get_table(L"options");
if( sp )
i.out << sp->to_wstr(L"value");
if( options && select_index < options->size() )
{
i.out << (*options)[select_index]->to_wstr(L"value");
}
}
}
@ -1135,25 +1104,27 @@ void ticket_tab_select_tab_id(Info & i)
if( value.is_param )
{
pt::Space * sp = value.config_par->find_child_space(select_index);
pt::Space::TableType * options = value.config_par->get_table(L"options");
if( sp )
i.out << sp->to_wstr(L"id");
if( options && select_index < options->size() )
{
i.out << (*options)[select_index]->to_wstr(L"id");
}
}
}
void ticket_tab_select_tab_meta(Info & i)
{
ticket_tab_check_reqid();
if( value.is_param )
{
pt::Space * sp = value.config_par->find_child_space(select_index);
if( sp )
space_value(i, *sp);
}
}
//void ticket_tab_select_tab_meta(Info & i)
//{
// ticket_tab_check_reqid();
//
// if( value.is_param )
// {
// pt::Space * sp = value.config_par->find_child_space(select_index);
//
// if( sp )
// space_value(i, *sp);
// }
//}
@ -1163,26 +1134,16 @@ void ticket_tab_file_tab(Info & i)
if( value.is_value && !value.is_in_ticket_par )
{
ticket_file_index = i.iter;
ticket_file_index = i.iter;
if( i.iter == 0 )
ticket_file_number = 0;
pt::Space::TableType * child_table = value.value_meta->find_child_space_table();
pt::Space::TableType * files = value.value_meta->get_table(L"files");
if( child_table )
if( files )
{
while( ticket_file_index < child_table->size() )
{
pt::Space & sp = *(*child_table)[ticket_file_index];
if( sp.is_child_space_name(L"file") )
break;
ticket_file_index += 1;
}
i.res = (ticket_file_index < child_table->size());
i.res = (ticket_file_index < files->size());
if( i.res && i.iter > 0 )
ticket_file_number += 1;
@ -1197,10 +1158,12 @@ void ticket_tab_file_tab_index(Info & i)
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space * sp = value.value_meta->find_child_space(ticket_file_index);
pt::Space::TableType * files = value.value_meta->get_table(L"files");
if( sp )
if( files && ticket_file_index < files->size() )
{
i.out << ticket_file_number;
}
}
}
@ -1211,10 +1174,12 @@ void ticket_tab_file_tab_path(Info & i)
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space * sp = value.value_meta->find_child_space(ticket_file_index);
pt::Space::TableType * files = value.value_meta->get_table(L"files");
if( sp )
i.out << sp->to_wstr(L"path");
if( files && ticket_file_index < files->size() )
{
i.out << (*files)[ticket_file_index]->to_wstr(L"path");
}
}
}
@ -1224,25 +1189,27 @@ void ticket_tab_file_tab_itemid(Info & i)
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space * sp = value.value_meta->find_child_space(ticket_file_index);
pt::Space::TableType * files = value.value_meta->get_table(L"files");
if( sp )
i.out << sp->to_long(L"itemid");
if( files && ticket_file_index < files->size() )
{
i.out << (*files)[ticket_file_index]->to_long(L"itemid");
}
}
}
void ticket_tab_file_tab_meta(Info & i)
{
ticket_tab_check_reqid();
if( value.is_value && !value.is_in_ticket_par )
{
pt::Space * sp = value.value_meta->find_child_space(ticket_file_index);
if( sp )
space_value(i, *sp);
}
}
//void ticket_tab_file_tab_meta(Info & i)
//{
// ticket_tab_check_reqid();
//
// if( value.is_value && !value.is_in_ticket_par )
// {
// pt::Space * sp = value.value_meta->find_child_space(ticket_file_index);
//
// if( sp )
// space_value(i, *sp);
// }
//}
@ -1263,7 +1230,7 @@ using namespace ns_ticket_tab;
fun->Insert("ticket_can_create", ticket_can_create);
fun->Insert("ticket_can_edit", ticket_can_edit);
fun->Insert("ticket_is_creating_new", ticket_is_creating_new);
fun->Insert("ticket_meta_value", ticket_meta_value);
// fun->Insert("ticket_meta_value", ticket_meta_value);
fun->Insert("ticket_is_closed", ticket_is_closed);
fun->Insert("ticket_param_value_for_param_id", ticket_param_value_for_param_id);
@ -1274,7 +1241,7 @@ using namespace ns_ticket_tab;
fun->Insert("tickets_tab_url", tickets_tab_url);
fun->Insert("tickets_tab_subject_empty", tickets_tab_subject_empty);
fun->Insert("tickets_tab_subject", tickets_tab_subject);
fun->Insert("tickets_tab_meta_value", tickets_tab_meta_value);
// fun->Insert("tickets_tab_meta_value", tickets_tab_meta_value);
fun->Insert("tickets_tab_date_creation", tickets_tab_date_creation);
fun->Insert("tickets_tab_date_creation_nice", tickets_tab_date_creation_nice);
@ -1293,7 +1260,7 @@ using namespace ns_ticket_tab;
fun->Insert("tickets_tab_conf_tab_file_tab_index", tickets_tab_conf_tab_file_tab_index);
fun->Insert("tickets_tab_conf_tab_file_tab_path", tickets_tab_conf_tab_file_tab_path);
fun->Insert("tickets_tab_conf_tab_file_tab_itemid", tickets_tab_conf_tab_file_tab_itemid);
fun->Insert("tickets_tab_conf_tab_file_tab_meta", tickets_tab_conf_tab_file_tab_meta);
// fun->Insert("tickets_tab_conf_tab_file_tab_meta", tickets_tab_conf_tab_file_tab_meta);
fun->Insert("ticket_tab", ticket_tab);
@ -1304,20 +1271,20 @@ using namespace ns_ticket_tab;
fun->Insert("ticket_tab_value", ticket_tab_value);
fun->Insert("ticket_tab_value_int", ticket_tab_value_int);
fun->Insert("ticket_tab_value_dec", ticket_tab_value_dec);
fun->Insert("ticket_tab_value_meta", ticket_tab_value_meta);
// fun->Insert("ticket_tab_value_meta", ticket_tab_value_meta);
fun->Insert("ticket_tab_type_is", ticket_tab_type_is);
fun->Insert("ticket_tab_select_tab", ticket_tab_select_tab);
fun->Insert("ticket_tab_select_tab_is_selected", ticket_tab_select_tab_is_selected);
fun->Insert("ticket_tab_select_tab_name", ticket_tab_select_tab_name);
fun->Insert("ticket_tab_select_tab_id", ticket_tab_select_tab_id);
fun->Insert("ticket_tab_select_tab_meta", ticket_tab_select_tab_meta);
// fun->Insert("ticket_tab_select_tab_meta", ticket_tab_select_tab_meta);
fun->Insert("ticket_tab_file_tab", ticket_tab_file_tab);
fun->Insert("ticket_tab_file_tab_index", ticket_tab_file_tab_index);
fun->Insert("ticket_tab_file_tab_path", ticket_tab_file_tab_path);
fun->Insert("ticket_tab_file_tab_itemid", ticket_tab_file_tab_itemid);
fun->Insert("ticket_tab_file_tab_meta", ticket_tab_file_tab_meta);
// fun->Insert("ticket_tab_file_tab_meta", ticket_tab_file_tab_meta);
}

@ -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::TableType * files = files_space->get_table();
for(size_t f=0 ; f < files->size() ; ++f)
{
pt::Space * file = (*param_child_table)[z];
pt::Space * file = (*files)[f];
if( file->is_child_space_name(L"file") && file->to_long(L"itemid") == file_id )
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;
}

Loading…
Cancel
Save