From da15323c2f6910fed2aa5476945c6095d3354d6a Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Fri, 14 Sep 2012 07:14:54 +0000 Subject: [PATCH] added: to plugin thread: message WINIX_PL_THREAD_CAN_MAKE_REDIRECT (similar as for ticket) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@888 e52654a7-88a9-db11-a3e9-0013d4bc506e --- plugins/thread/Makefile.dep | 28 ++++++++++++++++++++++++++++ plugins/thread/createthread.cpp | 2 +- plugins/thread/pluginmsg.h | 6 +++++- plugins/thread/reply.cpp | 2 +- plugins/thread/threadinfo.cpp | 26 +++++++++++++++++++++++++- plugins/thread/threadinfo.h | 2 ++ plugins/ticket/templates.cpp | 23 +++++++++++++++++++++++ 7 files changed, 85 insertions(+), 4 deletions(-) diff --git a/plugins/thread/Makefile.dep b/plugins/thread/Makefile.dep index 7587ed0..2543d54 100755 --- a/plugins/thread/Makefile.dep +++ b/plugins/thread/Makefile.dep @@ -384,3 +384,31 @@ threadinfo.o: ../../core/users.h ../../core/groups.h ../../core/group.h threadinfo.o: ../../core/loadavg.h ../../core/image.h threadinfo.o: ../../core/threadmanager.h ../../core/timezones.h threadinfo.o: ../../core/timezone.h thread.h tdb.h ../../db/dbbase.h +threadinfo.o: ../../core/plugin.h pluginmsg.h ../../core/system.h +threadinfo.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h +threadinfo.o: ../../functions/functions.h ../../functions/functionbase.h +threadinfo.o: ../../functions/functionparser.h ../../core/cur.h +threadinfo.o: ../../functions/adduser.h ../../functions/cat.h +threadinfo.o: ../../functions/chmod.h ../../functions/privchanger.h +threadinfo.o: ../../core/request.h ../../functions/chown.h +threadinfo.o: ../../functions/ckeditor.h ../../functions/cp.h +threadinfo.o: ../../functions/default.h ../../functions/download.h +threadinfo.o: ../../functions/emacs.h ../../functions/env.h +threadinfo.o: ../../functions/last.h ../../functions/login.h +threadinfo.o: ../../functions/logout.h ../../functions/ln.h +threadinfo.o: ../../functions/ls.h ../../functions/man.h +threadinfo.o: ../../functions/meta.h ../../functions/mkdir.h +threadinfo.o: ../../functions/mv.h ../../functions/nicedit.h +threadinfo.o: ../../functions/node.h ../../functions/passwd.h +threadinfo.o: ../../functions/priv.h ../../functions/pw.h +threadinfo.o: ../../functions/reload.h ../../functions/rm.h +threadinfo.o: ../../functions/rmuser.h ../../functions/sort.h +threadinfo.o: ../../functions/specialdefault.h ../../functions/stat.h +threadinfo.o: ../../functions/subject.h ../../functions/template.h +threadinfo.o: ../../functions/tinymce.h ../../functions/uname.h +threadinfo.o: ../../functions/upload.h ../../functions/uptime.h +threadinfo.o: ../../functions/who.h ../../functions/vim.h +threadinfo.o: ../../core/htmlfilter.h ../../templates/templates.h +threadinfo.o: ../../templates/patterncacher.h ../../templates/indexpatterns.h +threadinfo.o: ../../templates/patterns.h ../../templates/changepatterns.h +threadinfo.o: ../../templates/htmltextstream.h ../../core/sessionmanager.h diff --git a/plugins/thread/createthread.cpp b/plugins/thread/createthread.cpp index 8600aae..9ce211d 100755 --- a/plugins/thread/createthread.cpp +++ b/plugins/thread/createthread.cpp @@ -89,7 +89,7 @@ void CreateThread::MakePost() if( cur->request->status == WINIX_ERR_OK ) { log << log2 << "CreateThread: added a new thread" << logend; - system->RedirectTo(cur->request->item); + thread_info->MakeRedirectIfPossible(cur->request->item); SendNotify(cur->request->item); } else diff --git a/plugins/thread/pluginmsg.h b/plugins/thread/pluginmsg.h index 30be0c7..cd85bc3 100755 --- a/plugins/thread/pluginmsg.h +++ b/plugins/thread/pluginmsg.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. * */ @@ -19,6 +19,10 @@ #define WINIX_PL_THREAD_PREPARE_THREAD 4003 +#define WINIX_PL_THREAD_SEARCH_THREAD_DIR 4004 + + +#define WINIX_PL_THREAD_CAN_MAKE_REDIRECT 4005 #endif diff --git a/plugins/thread/reply.cpp b/plugins/thread/reply.cpp index 98a15b4..c1fc73e 100755 --- a/plugins/thread/reply.cpp +++ b/plugins/thread/reply.cpp @@ -106,7 +106,7 @@ void Reply::MakePost() if( cur->request->status == WINIX_ERR_OK ) { log << log2 << "Reply: added an answer in a thread" << logend; - system->RedirectTo(cur->request->item); + thread_info->MakeRedirectIfPossible(cur->request->item); SendNotify(cur->request->item); } else diff --git a/plugins/thread/threadinfo.cpp b/plugins/thread/threadinfo.cpp index 9525f6e..bf6bca2 100755 --- a/plugins/thread/threadinfo.cpp +++ b/plugins/thread/threadinfo.cpp @@ -2,12 +2,14 @@ * 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. * */ #include "threadinfo.h" +#include "core/plugin.h" +#include "pluginmsg.h" @@ -43,6 +45,12 @@ void ThreadInfo::Clear() Item * ThreadInfo::FindThreadDir() { + Item * plugin_dir = 0; + plugin.Call(WINIX_PL_THREAD_SEARCH_THREAD_DIR, &plugin_dir); + + if( plugin_dir ) + return plugin_dir; + const std::wstring & dir_str = system->mounts.pmount->FirstArg(mount_par_thread_dir); if( dir_str.empty() ) @@ -132,6 +140,22 @@ void ThreadInfo::Repair() } + +void ThreadInfo::MakeRedirectIfPossible(const Item & item) +{ + PluginRes res = plugin.Call(WINIX_PL_THREAD_CAN_MAKE_REDIRECT); + + if( res.res_false > 0 ) + { + log << log4 << "Thread: redirect prevented" << logend; + return; + } + + system->RedirectTo(item); +} + + + } // namespace diff --git a/plugins/thread/threadinfo.h b/plugins/thread/threadinfo.h index ef323b2..87b1439 100755 --- a/plugins/thread/threadinfo.h +++ b/plugins/thread/threadinfo.h @@ -69,6 +69,8 @@ public: // repairing the database void Repair(); + void MakeRedirectIfPossible(const Item & item); + private: Db * db; diff --git a/plugins/ticket/templates.cpp b/plugins/ticket/templates.cpp index 1d187a6..0f5610c 100755 --- a/plugins/ticket/templates.cpp +++ b/plugins/ticket/templates.cpp @@ -422,6 +422,27 @@ void tickets_tab_subject(Info & i) } +void tickets_tab_date_creation(Info & i) +{ + tickets_tab_check_reqid(); + + if( tickets_value.is_item ) + i.out << tickets_value.item->date_creation; + +} + + +void tickets_tab_date_creation_nice(Info & i) +{ + tickets_tab_check_reqid(); + + if( tickets_value.is_item ) + print_date_nice(i, tickets_value.item->date_creation); +} + + + + void tickets_tab_conf_tab(Info & i) { tickets_tab_check_reqid(); @@ -796,6 +817,8 @@ 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_date_creation", tickets_tab_date_creation); + fun->Insert("tickets_tab_date_creation_nice", tickets_tab_date_creation_nice); fun->Insert("tickets_tab_conf_tab", tickets_tab_conf_tab); fun->Insert("tickets_tab_conf_tab_has_value", tickets_tab_conf_tab_has_value);