diff --git a/core/app.cpp b/core/app.cpp index db4a672..4b42d29 100755 --- a/core/app.cpp +++ b/core/app.cpp @@ -242,6 +242,17 @@ void App::ProcessRequest() log << log1 << "App: there was an unknown exception" << logend; } + + try + { + plugin.Call(WINIX_END_REQUEST); + } + catch(...) + { + log << log1 << "App: an exception when clearing the request (from a plugin)" << logend; + } + + cur.request->Clear(); cur.session = session_manager.GetTmpSession(); } diff --git a/core/pluginmsg.h b/core/pluginmsg.h index ac06250..f78c071 100755 --- a/core/pluginmsg.h +++ b/core/pluginmsg.h @@ -94,6 +94,9 @@ #define WINIX_NOTIFY_ADD_TEMPLATE 3013 +// the request is ended +// you can clear some of your object here +#define WINIX_END_REQUEST 3014 // values from 4000 - 4099 reserved for 'thread' plugin // see plugins/thread/pluginmsg.h diff --git a/plugins/thread/init.cpp b/plugins/thread/init.cpp index a2f0195..2931417 100755 --- a/plugins/thread/init.cpp +++ b/plugins/thread/init.cpp @@ -122,6 +122,11 @@ void PrepareThread(PluginInfo & info) } +void EndRequest(PluginInfo & info) +{ + thread_info.Clear(); +} + } // namespace @@ -139,7 +144,8 @@ using namespace Thread; plugin.Assign(WINIX_FILE_REMOVED, RemoveThread); plugin.Assign(WINIX_NOTIFY_ADD_TEMPLATE, AddNotifyTemplate); plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions); - + plugin.Assign(WINIX_END_REQUEST, EndRequest); + // for other plugins plugin.Assign(WINIX_PL_THREAD_SET_SORTTAB, SetSortTab); plugin.Assign(WINIX_PL_THREAD_READ_THREADS, ReadThreads); diff --git a/plugins/thread/pluginmsg.h b/plugins/thread/pluginmsg.h index b0345e2..30be0c7 100755 --- a/plugins/thread/pluginmsg.h +++ b/plugins/thread/pluginmsg.h @@ -11,6 +11,7 @@ #define headerfile_winix_plugins_thread_pluginmsg +// values from 4000 - 4099 reserved for 'thread' plugin #define WINIX_PL_THREAD_SET_SORTTAB 4000 #define WINIX_PL_THREAD_READ_THREADS 4001 diff --git a/plugins/ticket/Makefile.dep b/plugins/ticket/Makefile.dep index 4400632..5f3358c 100755 --- a/plugins/ticket/Makefile.dep +++ b/plugins/ticket/Makefile.dep @@ -149,7 +149,7 @@ funticket.o: ../../functions/uname.h ../../functions/upload.h funticket.o: ../../functions/uptime.h ../../functions/who.h funticket.o: ../../functions/vim.h ../../core/htmlfilter.h funticket.o: ../../functions/functionbase.h ../../core/synchro.h -funticket.o: ../../core/plugin.h ../../core/pluginmsg.h ../../core/system.h +funticket.o: ../../core/plugin.h pluginmsg.h ../../core/system.h funticket.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h funticket.o: ../../templates/templates.h ../../templates/patterncacher.h funticket.o: ../../templates/ckeditorgetparser.h @@ -201,15 +201,14 @@ init.o: ../../functions/upload.h ../../functions/uptime.h init.o: ../../functions/who.h ../../functions/vim.h ../../core/htmlfilter.h init.o: ../../functions/functionbase.h ../../core/synchro.h editticket.h init.o: createticket.h showtickets.h ../../core/log.h ../../core/plugin.h -init.o: ../../core/pluginmsg.h ../../core/system.h -init.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h -init.o: ../../templates/templates.h ../../templates/patterncacher.h -init.o: ../../templates/ckeditorgetparser.h ../../core/httpsimpleparser.h -init.o: ../../core/log.h ../../templates/indexpatterns.h -init.o: ../../core/sessionmanager.h sessiondata.h ../../core/plugindata.h -init.o: ../../functions/rm.h ../../plugins/thread/showthreads.h -init.o: ../../plugins/thread/threadinfo.h ../../plugins/thread/thread.h -init.o: ../../plugins/thread/pluginmsg.h +init.o: pluginmsg.h ../../core/system.h ../../core/sessionmanager.h +init.o: ../../core/sessioncontainer.h ../../templates/templates.h +init.o: ../../templates/patterncacher.h ../../templates/ckeditorgetparser.h +init.o: ../../core/httpsimpleparser.h ../../core/log.h +init.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h +init.o: sessiondata.h ../../core/plugindata.h ../../functions/rm.h +init.o: ../../plugins/thread/showthreads.h ../../plugins/thread/threadinfo.h +init.o: ../../plugins/thread/thread.h ../../plugins/thread/pluginmsg.h sessiondata.o: sessiondata.h ../../core/plugindata.h ticket.h sessiondata.o: ../../functions/rm.h showtickets.o: showtickets.h tdb.h ticket.h ../../db/dbbase.h @@ -262,8 +261,8 @@ showtickets.o: ../../functions/uname.h ../../functions/upload.h showtickets.o: ../../functions/uptime.h ../../functions/who.h showtickets.o: ../../functions/vim.h ../../core/htmlfilter.h showtickets.o: ../../functions/functionbase.h ../../core/synchro.h -showtickets.o: ../../plugins/thread/pluginmsg.h ../../core/plugin.h -showtickets.o: ../../core/pluginmsg.h ../../core/system.h +showtickets.o: pluginmsg.h ../../plugins/thread/pluginmsg.h +showtickets.o: ../../core/plugin.h ../../core/system.h showtickets.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h showtickets.o: ../../templates/templates.h ../../templates/patterncacher.h showtickets.o: ../../templates/ckeditorgetparser.h @@ -321,7 +320,7 @@ templates.o: ../../functions/vim.h ../../core/htmlfilter.h tdb.h templates.o: ../../db/dbbase.h ../../db/dbconn.h ../../db/dbtextstream.h templates.o: ../../core/error.h editticket.h ../../functions/functionbase.h templates.o: ../../core/synchro.h createticket.h ../../core/misc.h -templates.o: ../../core/plugin.h ../../core/pluginmsg.h ../../core/system.h +templates.o: ../../core/plugin.h pluginmsg.h ../../core/system.h templates.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h templates.o: ../../templates/templates.h ../../templates/patterncacher.h templates.o: ../../templates/ckeditorgetparser.h diff --git a/plugins/ticket/init.cpp b/plugins/ticket/init.cpp index 6ec99a3..718847d 100755 --- a/plugins/ticket/init.cpp +++ b/plugins/ticket/init.cpp @@ -121,6 +121,11 @@ void RemoveSession(PluginInfo & info) } +void EndRequest(PluginInfo & info) +{ + ticket_info.Clear(); +} + // defined in templates.cpp void AddEzcFunctions(PluginInfo & info); @@ -144,6 +149,7 @@ using namespace Ticket; plugin.Assign(WINIX_NOTIFY_ADD_TEMPLATE, AddNotifyTemplate); plugin.Assign(WINIX_SESSION_CREATED, CreateSession); plugin.Assign(WINIX_SESSION_REMOVE, RemoveSession); + plugin.Assign(WINIX_END_REQUEST, EndRequest); tdb.SetConn(info.db->GetConn()); tdb.LogQueries(info.config->log_db_query); diff --git a/plugins/ticket/pluginmsg.h b/plugins/ticket/pluginmsg.h new file mode 100755 index 0000000..839cb07 --- /dev/null +++ b/plugins/ticket/pluginmsg.h @@ -0,0 +1,23 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2011, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfile_winix_plugins_ticket_pluginmsg +#define headerfile_winix_plugins_ticket_pluginmsg + + +// values from 4100 - 4199 reserved for 'ticket' plugin + +#define WINIX_PL_TICKET_SORT_POINTERS 4100 + + + + +#endif + + diff --git a/plugins/ticket/showtickets.cpp b/plugins/ticket/showtickets.cpp index 6601f71..62cb685 100755 --- a/plugins/ticket/showtickets.cpp +++ b/plugins/ticket/showtickets.cpp @@ -10,11 +10,11 @@ #include #include #include "showtickets.h" +#include "pluginmsg.h" #include "plugins/thread/pluginmsg.h" #include "core/plugin.h" - namespace Ticket { @@ -105,6 +105,11 @@ void ShowTickets::CreatePointers() void ShowTickets::SortPointers() { + plugin.Call(WINIX_PL_TICKET_SORT_POINTERS, &ticket_info->item_sort_tab); + + if( plugin.True() > 0 ) + return; + int sort_type = 1; if( cur->request->ParamValue(L"sort") == L"url" ) diff --git a/plugins/ticket/templates.cpp b/plugins/ticket/templates.cpp index c489048..010ad35 100755 --- a/plugins/ticket/templates.cpp +++ b/plugins/ticket/templates.cpp @@ -48,9 +48,9 @@ return percent; -// binary search for conf_item.id in ticket.par_tab (ticket.par_tab must be sorted by 'param') +// binary search for param in ticket.par_tab (ticket.par_tab must be sorted by 'param') // !! zmienic nazwe na find_ticket_param -bool find_ticket_value(const TicketConf::TicketItem & conf_item, const Ticket & ticket, size_t & ticket_par_index) +bool find_ticket_value(long param, const Ticket & ticket, size_t & ticket_par_index) { if( ticket.par_tab.empty() ) return false; @@ -58,25 +58,25 @@ bool find_ticket_value(const TicketConf::TicketItem & conf_item, const Ticket & size_t o1 = 0; size_t o2 = ticket.par_tab.size() - 1; - if( ticket.par_tab[o1].param == conf_item.id ) + if( ticket.par_tab[o1].param == param ) { ticket_par_index = o1; return true; } - if( conf_item.id < ticket.par_tab[o1].param ) + if( param < ticket.par_tab[o1].param ) return false; - if( ticket.par_tab[o2].param == conf_item.id ) + if( ticket.par_tab[o2].param == param ) { - while( o2 > 0 && ticket.par_tab[o2-1].param == conf_item.id ) + while( o2 > 0 && ticket.par_tab[o2-1].param == param ) --o2; ticket_par_index = o2; return true; } - if( conf_item.id > ticket.par_tab[o2].param ) + if( param > ticket.par_tab[o2].param ) return false; @@ -84,15 +84,15 @@ bool find_ticket_value(const TicketConf::TicketItem & conf_item, const Ticket & { ticket_par_index = (o1 + o2) / 2; - if( ticket.par_tab[ticket_par_index].param == conf_item.id ) + if( ticket.par_tab[ticket_par_index].param == param ) { - while( ticket_par_index > 0 && ticket.par_tab[ticket_par_index-1].param == conf_item.id ) + while( ticket_par_index > 0 && ticket.par_tab[ticket_par_index-1].param == param ) --ticket_par_index; return true; } - if( ticket.par_tab[ticket_par_index].param < conf_item.id ) + if( ticket.par_tab[ticket_par_index].param < param ) o1 = ticket_par_index; else o2 = ticket_par_index; @@ -223,15 +223,6 @@ void tickets_tab(Info & i) long id = ticket_info.item_sort_tab[item_sort_index]->id; has_ticket = find_ticket(ticket_info.ticket_tab, id, ticket_index); -/* for(size_t a=0 ; aid ) - { - has_ticket = true; - ticket_index = a; - } - } -*/ plugin.Call(WINIX_PL_THREAD_SET_SORTTAB_INDEX, item_sort_index); } } @@ -258,6 +249,38 @@ void tickets_tab_subject(Info & i) } + +void tickets_tab_value_int(Info & i) +{ + if( has_ticket && ticket_index < ticket_info.ticket_tab.size() ) + { + size_t par_index; + long id = Tol(i.par); + Ticket & ticket = ticket_info.ticket_tab[ticket_index]; + + if( find_ticket_value(id, ticket, par_index) ) + i.out << ticket.par_tab[par_index].int_value; + } +} + + + +void tickets_tab_value_str(Info & i) +{ + if( has_ticket && ticket_index < ticket_info.ticket_tab.size() ) + { + size_t par_index; + long id = Tol(i.par); + Ticket & ticket = ticket_info.ticket_tab[ticket_index]; + + if( find_ticket_value(id, ticket, par_index) ) + i.out << ticket.par_tab[par_index].str_value; + } +} + + + + void tickets_tab_conf_tab(Info & i) { has_value = false; @@ -273,7 +296,7 @@ void tickets_tab_conf_tab(Info & i) { const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_tab_index]; const Ticket & ticket = ticket_info.ticket_tab[ticket_index]; - has_value = find_ticket_value(conf_item, ticket, par_index); + has_value = find_ticket_value(conf_item.id, ticket, par_index); } } } @@ -405,7 +428,7 @@ void ticket_tab(Info & i) if( i.res ) { const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_index]; - has_value = find_ticket_value(conf_item, *ticket_info.ticket, par_index); + has_value = find_ticket_value(conf_item.id, *ticket_info.ticket, par_index); } } @@ -606,7 +629,10 @@ 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_url", tickets_tab_url); + + // you should provide an id (param) as a first parameter + fun->Insert("tickets_tab_value_int", tickets_tab_value_int); + fun->Insert("tickets_tab_value_str", tickets_tab_value_str); fun->Insert("tickets_tab_conf_tab", tickets_tab_conf_tab); fun->Insert("tickets_tab_conf_tab_has_value", tickets_tab_conf_tab_has_value); diff --git a/plugins/ticket/ticketinfo.cpp b/plugins/ticket/ticketinfo.cpp index 18788ae..4d7f5a8 100755 --- a/plugins/ticket/ticketinfo.cpp +++ b/plugins/ticket/ticketinfo.cpp @@ -67,7 +67,6 @@ void TicketInfo::SetFunctions(Functions * pfunctions) void TicketInfo::Clear() { ticket = &ticket_empty; - ticket_tab.clear(); cur_conf_wrap = &cur_conf_wrap_empty; cur_conf = &cur_conf_empty;