diff --git a/plugins/thread/init.cpp b/plugins/thread/init.cpp index 0a5e33e..047ffbb 100755 --- a/plugins/thread/init.cpp +++ b/plugins/thread/init.cpp @@ -103,6 +103,7 @@ void SetSortTab(PluginInfo & info) typedef std::vector SortTab; SortTab * psort_tab = reinterpret_cast(info.p1); + // !! IMPROVE ME // !! dodac jakies czyszczenie tej tablicy wskaznikow na koncu przetwarzania requestu // aby kiedys przypadkowo nie odwolac sie do nie istniejacego obiektu // poprzez bezposrednie uzycie jakiejs funkcji z ezc diff --git a/plugins/ticket/createticket.cpp b/plugins/ticket/createticket.cpp index 2bcd369..aa4cd5a 100755 --- a/plugins/ticket/createticket.cpp +++ b/plugins/ticket/createticket.cpp @@ -161,7 +161,7 @@ void CreateTicket::MakePost() if( !cur->request->IsPostVar(L"fileuploadsubmit") ) { Submit(ticket, item); - ticket_info->ticket = 0; // ticket was deleted by Submit() method -- RemoveTmpTicket() was used + ticket_info->ticket = ticket_info->GetEmptyTicket(); // ticket was deleted by Submit() method -- RemoveTmpTicket() was used } } diff --git a/plugins/ticket/editticket.cpp b/plugins/ticket/editticket.cpp index e55700d..3fbc783 100755 --- a/plugins/ticket/editticket.cpp +++ b/plugins/ticket/editticket.cpp @@ -182,7 +182,7 @@ void EditTicket::MakePost() if( !cur->request->IsPostVar(L"fileuploadsubmit") ) { Submit(ticket, item); - ticket_info->ticket = 0; // ticket was deleted by Submit() method -- RemoveTmpTicket() was used + ticket_info->ticket = ticket_info->GetEmptyTicket(); // ticket was deleted by Submit() method -- RemoveTmpTicket() was used } } diff --git a/plugins/ticket/init.cpp b/plugins/ticket/init.cpp index 025b127..0410ed4 100755 --- a/plugins/ticket/init.cpp +++ b/plugins/ticket/init.cpp @@ -17,6 +17,7 @@ #include "sessiondata.h" #include "plugins/thread/showthreads.h" #include "plugins/thread/pluginmsg.h" +#include "pluginmsg.h" @@ -139,6 +140,14 @@ void EndRequest(PluginInfo & info) } +void ShowTicketsFromDir(PluginInfo & info) +{ + fun_show_tickets.ShowTicketsFromDir(info.l1); +} + + + + // defined in templates.cpp void AddEzcFunctions(PluginInfo & info); @@ -162,6 +171,7 @@ using namespace Ticket; plugin.Assign(WINIX_SESSION_CREATED, CreateSession); plugin.Assign(WINIX_PLUGIN_SESSION_DATA_REMOVE, RemoveSession); plugin.Assign(WINIX_END_REQUEST, EndRequest); + plugin.Assign(WINIX_PL_TICKET_LOAD_TICKETS, ShowTicketsFromDir); tdb.SetConn(info.db->GetConn()); tdb.LogQueries(info.config->log_db_query); diff --git a/plugins/ticket/pluginmsg.h b/plugins/ticket/pluginmsg.h index c0fdf5c..35a2ce5 100755 --- a/plugins/ticket/pluginmsg.h +++ b/plugins/ticket/pluginmsg.h @@ -2,7 +2,7 @@ * This file is a part of Winix * and is not publicly distributed * - * Copyright (c) 2011, Tomasz Sowa + * Copyright (c) 2011-2012, Tomasz Sowa * All rights reserved. * */ @@ -17,7 +17,13 @@ // -#define WINIX_PL_TICKET_CAN_MAKE_REDIRECT 4110 +#define WINIX_PL_TICKET_CAN_MAKE_REDIRECT 4101 + + +// in l1 you shoud give the directory_id +// from the tickets have to be read +// and you can use only ezc functions to display the tickets +#define WINIX_PL_TICKET_LOAD_TICKETS 4102 diff --git a/plugins/ticket/showtickets.cpp b/plugins/ticket/showtickets.cpp index 4de79a5..8361876 100755 --- a/plugins/ticket/showtickets.cpp +++ b/plugins/ticket/showtickets.cpp @@ -63,7 +63,7 @@ bool ShowTickets::Sort::operator()(const Item * item1, const Item * item2) -void ShowTickets::ReadFiles() +void ShowTickets::ReadFiles(long dir_id) { // reading files DbItemQuery iq; @@ -77,7 +77,7 @@ void ShowTickets::ReadFiles() iq.sel_privileges = true; iq.sel_date = true; iq.sel_meta = true; - iq.WhereParentId(cur->request->dir_tab.back()->id); + iq.WhereParentId(dir_id); iq.WhereType(Item::file); iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE); @@ -128,22 +128,28 @@ void ShowTickets::ReadTickets() } -void ShowTickets::MakeGet() +void ShowTickets::ShowTicketsFromDir(long dir_id) { ticket_info->Clear(); - ticket_info->FindCurrentConf(); + ticket_info->FindCurrentConf(dir_id); - ReadFiles(); + ReadFiles(dir_id); CreatePointers(); SortPointers(); ReadTickets(); + // !! IMPROVE ME may a better name instead of WINIX_PL_THREAD_SET_SORTTAB? plugin.Call(WINIX_PL_THREAD_SET_SORTTAB, &ticket_info->item_sort_tab); plugin.Call(WINIX_PL_THREAD_READ_THREADS); } +void ShowTickets::MakeGet() +{ + ShowTicketsFromDir(cur->request->dir_tab.back()->id); +} + } // namespace diff --git a/plugins/ticket/showtickets.h b/plugins/ticket/showtickets.h index d717aff..681ca52 100755 --- a/plugins/ticket/showtickets.h +++ b/plugins/ticket/showtickets.h @@ -2,7 +2,7 @@ * This file is a part of Winix * and is not publicly distributed * - * Copyright (c) 2010, Tomasz Sowa + * Copyright (c) 2010-2012, Tomasz Sowa * All rights reserved. * */ @@ -31,13 +31,15 @@ public: bool HasAccess(); void MakeGet(); + void ShowTicketsFromDir(long dir_id); + private: TDb * tdb; TicketInfo * ticket_info; std::vector file_id_tab; - void ReadFiles(); + void ReadFiles(long dir_id); void CreatePointers(); void SortPointers(); void ReadTickets(); diff --git a/plugins/ticket/ticketinfo.cpp b/plugins/ticket/ticketinfo.cpp index 01dd470..6558a53 100755 --- a/plugins/ticket/ticketinfo.cpp +++ b/plugins/ticket/ticketinfo.cpp @@ -198,23 +198,38 @@ void TicketInfo::ReadTicketConf(bool skip_existing_configs) } -void TicketInfo::FindCurrentConf() +void TicketInfo::FindCurrentConf(long dir_id) { - long dir_id = cur->mount->dir_id; - ConfTab::iterator i = conf_tab.find(dir_id); + Mount * mount = system->mounts.CalcMount(dir_id); - if( i != conf_tab.end() ) + if( mount ) { - cur_conf_wrap = &i->second; - cur_conf = &i->second.conf; + // long dir_id = cur->mount->dir_id; + ConfTab::iterator i = conf_tab.find(mount->dir_id); + + if( i != conf_tab.end() ) + { + cur_conf_wrap = &i->second; + cur_conf = &i->second.conf; + } + else + { + log << log1 << "Ticket: there is no a ticket_conf parameter in the mount point (an empty config used)" << logend; + } } else { - log << log1 << "Ticket: there is no a ticket_conf parameter in the mount point (an empty config used)" << logend; + log << log1 << "Ticket: I cannot find the mount point for dir id: " << dir_id << logend; } } +void TicketInfo::FindCurrentConf() +{ + if( !cur->request->dir_tab.empty() ) + FindCurrentConf(cur->request->dir_tab.back()->id); +} + diff --git a/plugins/ticket/ticketinfo.h b/plugins/ticket/ticketinfo.h index 529ae46..c780621 100755 --- a/plugins/ticket/ticketinfo.h +++ b/plugins/ticket/ticketinfo.h @@ -97,6 +97,7 @@ public: void ReadTicketConf(bool skip_existing_configs = false); + void FindCurrentConf(long dir_id); void FindCurrentConf(); void ReadTicketParams(Ticket & ticket, bool clear_ticket, PT::Space & meta); void RemoveTicket(long file_id); @@ -104,6 +105,10 @@ public: void MakeRedirectIfPossible(const Item & item); + // may now it is better to use null pointers instead of this empty objects? + Ticket * GetEmptyTicket() { return &ticket_empty; }; + //Item * GetEmptyItem(); + private: Db * db;