From bd1f717b4c40ff13f8c436def452c83e7ed42506 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Thu, 13 Sep 2012 23:12:48 +0000 Subject: [PATCH] added: some methods in Dystem::Dirs (takes wchar_t * as an argument, now only std::wstring were) changed: in plugin ticket: added message: WINIX_PL_TICKET_CAN_MAKE_REDIRECT it is sent at the end of POST request (editticket, createticket) if we can make a redirect (useful with AJAX) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@887 e52654a7-88a9-db11-a3e9-0013d4bc506e --- core/dirs.cpp | 23 ++++++++++++++++++----- core/dirs.h | 3 +++ plugins/ticket/Makefile.dep | 9 +++++++-- plugins/ticket/createticket.cpp | 5 ++++- plugins/ticket/editticket.cpp | 5 ++++- plugins/ticket/pluginmsg.h | 3 +++ plugins/ticket/templates.cpp | 4 +++- plugins/ticket/ticketinfo.cpp | 18 ++++++++++++++++++ plugins/ticket/ticketinfo.h | 2 ++ 9 files changed, 62 insertions(+), 10 deletions(-) diff --git a/core/dirs.cpp b/core/dirs.cpp index d58af3d..c00f719 100755 --- a/core/dirs.cpp +++ b/core/dirs.cpp @@ -351,7 +351,7 @@ return &(*etc); } -Item * Dirs::GetDir(const std::wstring & name, long parent) +Item * Dirs::GetDir(const wchar_t * name, long parent) { DirContainer::ParentIterator i = dir_tab.FindFirstChild(parent); @@ -363,10 +363,16 @@ return 0; } - -Item * Dirs::GetDir(const std::wstring & path) +Item * Dirs::GetDir(const std::wstring & name, long parent) { - if( path.empty() ) + return GetDir(name.c_str(), parent); +} + + + +Item * Dirs::GetDir(const wchar_t * path) +{ + if( *path == 0 ) return 0; DirContainer::Iterator root = dir_tab.GetRoot(); @@ -376,7 +382,7 @@ Item * Dirs::GetDir(const std::wstring & path) return 0; Item * pitem = &(*root); - const wchar_t * s = path.c_str(); + const wchar_t * s = path; while( ExtractName(s, get_dir_temp) ) { @@ -390,6 +396,13 @@ return pitem; } + +Item * Dirs::GetDir(const std::wstring & path) +{ + return GetDir(path.c_str()); +} + + Item * Dirs::GetDir(long id) { DirContainer::Iterator i = dir_tab.FindId(id); diff --git a/core/dirs.h b/core/dirs.h index ec1702a..d2e66c5 100755 --- a/core/dirs.h +++ b/core/dirs.h @@ -67,7 +67,10 @@ public: Item * GetRootDir(); Item * GetEtcDir(); Item * GetVarDir(); + + Item * GetDir(const wchar_t * name, long parent); Item * GetDir(const std::wstring & name, long parent); + Item * GetDir(const wchar_t * path); Item * GetDir(const std::wstring & path); Item * GetDir(long id); Item * AddDir(const Item & item); diff --git a/plugins/ticket/Makefile.dep b/plugins/ticket/Makefile.dep index 683a9bd..aa9ab22 100755 --- a/plugins/ticket/Makefile.dep +++ b/plugins/ticket/Makefile.dep @@ -483,5 +483,10 @@ ticketinfo.o: ../../functions/upload.h ../../functions/uptime.h ticketinfo.o: ../../functions/who.h ../../functions/vim.h ticketinfo.o: ../../core/htmlfilter.h tdb.h ../../db/dbbase.h ticketinfo.o: ../../db/dbconn.h ../../db/dbtextstream.h ../../core/error.h -ticketinfo.o: ../../core/log.h ../../core/misc.h sessiondata.h -ticketinfo.o: ../../core/plugindata.h ../../functions/rm.h +ticketinfo.o: ../../core/log.h ../../core/misc.h ../../core/plugin.h +ticketinfo.o: pluginmsg.h ../../core/system.h ../../core/sessionmanager.h +ticketinfo.o: ../../core/sessioncontainer.h ../../templates/templates.h +ticketinfo.o: ../../templates/patterncacher.h ../../templates/indexpatterns.h +ticketinfo.o: ../../templates/patterns.h ../../templates/changepatterns.h +ticketinfo.o: ../../templates/htmltextstream.h ../../core/sessionmanager.h +ticketinfo.o: sessiondata.h ../../core/plugindata.h ../../functions/rm.h diff --git a/plugins/ticket/createticket.cpp b/plugins/ticket/createticket.cpp index 0d574fc..2bcd369 100755 --- a/plugins/ticket/createticket.cpp +++ b/plugins/ticket/createticket.cpp @@ -93,7 +93,7 @@ void CreateTicket::Submit(Ticket & ticket, Item & item) { log << log2 << "CreateTicket: added a new ticket" << logend; RemoveTmpTicket(); - system->RedirectTo(item); + ticket_info->MakeRedirectIfPossible(item); } else { @@ -159,7 +159,10 @@ void CreateTicket::MakePost() ticket_info->CopyTicketSpace(meta, item); if( !cur->request->IsPostVar(L"fileuploadsubmit") ) + { Submit(ticket, item); + ticket_info->ticket = 0; // ticket was deleted by Submit() method -- RemoveTmpTicket() was used + } } diff --git a/plugins/ticket/editticket.cpp b/plugins/ticket/editticket.cpp index cc6220b..e55700d 100755 --- a/plugins/ticket/editticket.cpp +++ b/plugins/ticket/editticket.cpp @@ -92,7 +92,7 @@ void EditTicket::Submit(Ticket & ticket, Item & item) { log << log2 << "EditTicket: ticket modified" << logend; RemoveTmpTicket(); - system->RedirectTo(item); + ticket_info->MakeRedirectIfPossible(item); } else { @@ -180,7 +180,10 @@ void EditTicket::MakePost() ticket_info->CopyTicketSpace(meta, item); if( !cur->request->IsPostVar(L"fileuploadsubmit") ) + { Submit(ticket, item); + ticket_info->ticket = 0; // ticket was deleted by Submit() method -- RemoveTmpTicket() was used + } } diff --git a/plugins/ticket/pluginmsg.h b/plugins/ticket/pluginmsg.h index 839cb07..c0fdf5c 100755 --- a/plugins/ticket/pluginmsg.h +++ b/plugins/ticket/pluginmsg.h @@ -16,6 +16,9 @@ #define WINIX_PL_TICKET_SORT_POINTERS 4100 +// +#define WINIX_PL_TICKET_CAN_MAKE_REDIRECT 4110 + #endif diff --git a/plugins/ticket/templates.cpp b/plugins/ticket/templates.cpp index 210a530..1d187a6 100755 --- a/plugins/ticket/templates.cpp +++ b/plugins/ticket/templates.cpp @@ -531,7 +531,9 @@ void ticket_tab(Info & i) value.is_param = true; value.config_par = space.spaces[conf_index]; value.param_id = value.config_par->Long(L"id"); - find_ticket_value(value, ticket_info.ticket->par_tab, ticket_info.item->meta); + + if( ticket_info.ticket && ticket_info.item ) + find_ticket_value(value, ticket_info.ticket->par_tab, ticket_info.item->meta); } } diff --git a/plugins/ticket/ticketinfo.cpp b/plugins/ticket/ticketinfo.cpp index a4a1a25..01dd470 100755 --- a/plugins/ticket/ticketinfo.cpp +++ b/plugins/ticket/ticketinfo.cpp @@ -13,6 +13,8 @@ #include "core/error.h" #include "core/log.h" #include "core/misc.h" +#include "core/plugin.h" +#include "pluginmsg.h" #include "sessiondata.h" namespace Ticket @@ -510,4 +512,20 @@ void TicketInfo::CopyTicketSpace(PT::Space & ticket_space, Item & item) } + +void TicketInfo::MakeRedirectIfPossible(const Item & item) +{ + PluginRes res = plugin.Call(WINIX_PL_TICKET_CAN_MAKE_REDIRECT); + + if( res.res_false > 0 ) + { + log << log4 << "Ticket: redirect prevented" << logend; + return; + } + + system->RedirectTo(item); +} + + + } // namespace diff --git a/plugins/ticket/ticketinfo.h b/plugins/ticket/ticketinfo.h index 5a5cd8a..529ae46 100755 --- a/plugins/ticket/ticketinfo.h +++ b/plugins/ticket/ticketinfo.h @@ -102,6 +102,8 @@ public: void RemoveTicket(long file_id); void CopyTicketSpace(PT::Space & ticket_space, Item & item); + void MakeRedirectIfPossible(const Item & item); + private: Db * db;