From 7bc17a9202a233b84e450bf5fcfd8deab98f4fca Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Thu, 30 Sep 2010 20:58:20 +0000 Subject: [PATCH] fixed: ticket sets a default function only for directories fixed: reading a new url and subject in Functions::ReadItem() added: tickets are sorted now (by date) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@659 e52654a7-88a9-db11-a3e9-0013d4bc506e --- core/request.cpp | 11 +++ core/request.h | 4 +- functions/emacs.cpp | 35 +++----- functions/emacs.h | 1 + functions/functions.cpp | 48 +++------- functions/functions.h | 8 +- plugins/ticket/Makefile.dep | 164 ++++++++++++++++++---------------- plugins/ticket/funticket.cpp | 1 + plugins/ticket/init.cpp | 4 + plugins/ticket/ticket.h | 6 +- plugins/ticket/ticketinfo.cpp | 27 ++++++ plugins/ticket/ticketinfo.h | 10 ++- 12 files changed, 178 insertions(+), 141 deletions(-) diff --git a/core/request.cpp b/core/request.cpp index 5abde35..33014b0 100755 --- a/core/request.cpp +++ b/core/request.cpp @@ -175,6 +175,17 @@ return true; } +std::string * Request::PostVarp(const char * var) +{ +PostTab::iterator p = post_tab.find(var); + + if( p == post_tab.end() ) + return 0; + +return &p->second; +} + + void Request::PrintGetTab() { diff --git a/core/request.h b/core/request.h index 052bdb0..4be195a 100755 --- a/core/request.h +++ b/core/request.h @@ -127,8 +127,10 @@ struct Request void SetCookie(const char * name, long value, tm * expires = 0); bool IsPostVar(const char * var); - const std::string & PostVar(const char * var); + const std::string & PostVar(const char * var); // !! zamienic na referencje nie do stałej (bez const) bool PostVar(const char * var, std::string & result); + std::string * PostVarp(const char * var); + bool AllPostVarEmpty(); // returning true if all post vars are empty void SendAll(); diff --git a/functions/emacs.cpp b/functions/emacs.cpp index 06d4bf5..fcd836d 100755 --- a/functions/emacs.cpp +++ b/functions/emacs.cpp @@ -77,33 +77,26 @@ return true; void Emacs::PostFunEmacsModifyMountPoint(bool adding) { - if( system->mounts.pmount->type == system->mounts.MountTypeThread() ) - { - if( adding ) - db->EditThreadAddItem(request->dir_tab.back()->id, request->item.id); + if( system->mounts.pmount->type == system->mounts.MountTypeThread() && adding ) + db->EditThreadAddItem(request->dir_tab.back()->id, request->item.id); - system->RedirectToLastDir(); - } - /* !! tticket - else - if( system->mounts.pmount->type == system->mounts.MountTypeTicket() ) - { - system->RedirectToLastDir(); - } - */ - else - { - // system->mounts.MountTypeCms() + + if( system->mounts.pmount->type == system->mounts.MountTypeCms() ) system->RedirectTo(request->item); - } + else + system->RedirectToLastDir(); } void Emacs::MakePost() { - bool adding = !request->is_item; - bool edit_with_url = functions->ReadItem(request->item, Item::file); + bool adding = !request->is_item; + + if( !adding ) + old_url = request->item.url; + + functions->ReadItem(request->item, Item::file); if( adding ) functions->SetUser(request->item); // set user before checking the rebus @@ -120,9 +113,7 @@ void Emacs::MakePost() } else { - // !! moze dodac metode EditFile w klasie functions? - // i ona wywola system->EditFile i poniszego updatera - request->status = system->EditFile(request->item, edit_with_url); + request->status = system->EditFile(request->item, request->item.url != old_url); if( request->status == WINIX_ERR_OK ) TemplatesFunctions::pattern_cacher.UpdatePattern(request->item); diff --git a/functions/emacs.h b/functions/emacs.h index 056c125..abacde0 100755 --- a/functions/emacs.h +++ b/functions/emacs.h @@ -32,6 +32,7 @@ private: bool PostEmacsCheckAbuse(bool adding); void PostFunEmacsModifyMountPoint(bool adding); + std::string old_url; }; diff --git a/functions/functions.cpp b/functions/functions.cpp index 4ed2f80..f56c85a 100755 --- a/functions/functions.cpp +++ b/functions/functions.cpp @@ -168,8 +168,6 @@ void Functions::Add(FunctionBase & fun) void Functions::Create() { - Add(fun_template); - Add(fun_adduser); Add(fun_cat); Add(fun_chmod); @@ -192,6 +190,7 @@ void Functions::Create() Add(fun_rm); Add(fun_run); Add(fun_subject); + Add(fun_template); Add(fun_thread); Add(fun_tinymce); Add(fun_uname); @@ -200,10 +199,6 @@ void Functions::Create() Add(fun_who); plugin.Call(WINIX_CREATE_FUNCTIONS); -// Add(fun_ticket); -// Add(fun_createticket); -// Add(fun_editticket); - } @@ -366,31 +361,13 @@ void Functions::CheckGetPostTimes(time_t difference) // returning true if the 'url' has to be changed -bool Functions::ReadItemUrlSubject(Item & item, Item::Type item_type) +void Functions::ReadItemUrlSubject(Item & item, Item::Type item_type) { - bool with_url = false; - - const std::string & new_url = request->PostVar("url"); - const std::string & new_subject = request->PostVar("subject"); - - if( item_type == Item::file ) - { - if( !request->is_item || new_url != item.url ) - with_url = true; - } - else - { - // !! dla katalogow zawsze ma modyfikowac url? - with_url = true; - } - - - if( !new_url.empty() ) - item.url = new_url; - - if( !new_subject.empty() ) - item.subject = new_subject; + std::string * new_subject = request->PostVarp("subject"); + std::string * new_url = request->PostVarp("url"); + if( new_subject ) + item.subject = *new_subject; if( item.subject.empty() ) { @@ -399,10 +376,11 @@ bool Functions::ReadItemUrlSubject(Item & item, Item::Type item_type) item.subject += ToStr(db->Size(request->dir_tab.back()->id, Item::file)); } + if( new_url ) + item.url = *new_url; + // if item.url is empty then it will be set from item.subject PrepareUrl(item); - -return with_url; } @@ -483,20 +461,18 @@ void Functions::ReadItemContentWithType(Item & item) // item_type - the type of an item you are expecting to read // returns true if the url has to be changed // at the moment this is only checked for Item::file - for Item::dir it returns always true -bool Functions::ReadItem(Item & item, Item::Type item_type) +void Functions::ReadItem(Item & item, Item::Type item_type) { if( item_type == Item::none ) - return false; + return; item.type = item_type; item.parent_id = request->dir_tab.back()->id; // !! moze to dac jako parametr? - bool edit_with_url = ReadItemUrlSubject(item, item_type); + ReadItemUrlSubject(item, item_type); if( item_type == Item::file ) ReadItemContentWithType(item); - -return edit_with_url; } diff --git a/functions/functions.h b/functions/functions.h index 9b50d54..65bba92 100755 --- a/functions/functions.h +++ b/functions/functions.h @@ -114,7 +114,11 @@ public: void ReadItemFilterHtml(Item & item); void ReadItemContent(Item & item, const std::string & content_type); void ReadItemContentWithType(Item & item); - bool ReadItem(Item & item, Item::Type item_type); + + // if item.url is not empty and there is not a post variable "url" + // then the item.url will not be changed + // (the same is for item.subject and "subject" post variable) + void ReadItem(Item & item, Item::Type item_type); void SetUser(Item & item); @@ -138,7 +142,7 @@ private: void SetDefaultFunctionForFile(); void SetDefaultFunctionForDir(); - bool ReadItemUrlSubject(Item & item, Item::Type item_type); + void ReadItemUrlSubject(Item & item, Item::Type item_type); Table table; diff --git a/plugins/ticket/Makefile.dep b/plugins/ticket/Makefile.dep index 4a07b25..975596e 100755 --- a/plugins/ticket/Makefile.dep +++ b/plugins/ticket/Makefile.dep @@ -3,23 +3,23 @@ createticket.o: createticket.h tdb.h ticket.h ../../db/dbbase.h createticket.o: ../../db/dbconn.h ../../db/dbtextstream.h createticket.o: ../../core/textstream.h ../../core/error.h ../../core/log.h -createticket.o: ticketinfo.h ../../core/item.h ../../db/db.h -createticket.o: ../../db/dbbase.h ../../db/dbitemquery.h +createticket.o: ticketinfo.h ../../core/item.h ../../core/system.h +createticket.o: ../../core/dirs.h ../../core/item.h ../../core/dircontainer.h +createticket.o: ../../db/db.h ../../db/dbbase.h ../../db/dbitemquery.h createticket.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h createticket.o: ../../core/thread.h ../../core/dircontainer.h -createticket.o: ../../core/item.h ../../core/ugcontainer.h -createticket.o: ../../functions/functionbase.h ../../core/request.h +createticket.o: ../../core/ugcontainer.h ../../core/request.h createticket.o: ../../core/requesttypes.h ../../core/session.h createticket.o: ../../core/error.h ../../core/user.h ../../core/plugindata.h createticket.o: ../../core/rebus.h ../../core/config.h createticket.o: ../../core/confparser.h ../../core/htmlfilter.h -createticket.o: ../../core/config.h ../../core/system.h ../../core/dirs.h -createticket.o: ../../core/dircontainer.h ../../core/request.h createticket.o: ../../core/mounts.h ../../core/mount.h createticket.o: ../../core/mountparser.h ../../core/users.h createticket.o: ../../core/ugcontainer.h ../../core/lastcontainer.h createticket.o: ../../core/groups.h ../../core/group.h ../../core/loadavg.h -createticket.o: ../../core/notify.h ../../templatesnotify/templatesnotify.h +createticket.o: ../../functions/functionbase.h ../../core/request.h +createticket.o: ../../core/config.h ../../core/notify.h +createticket.o: ../../templatesnotify/templatesnotify.h createticket.o: ../../../ezc/src/ezc.h ../../core/mount.h ../../core/locale.h createticket.o: ../../templates/misc.h ../../templates/localefilter.h createticket.o: ../../core/locale.h ../../core/system.h readticket.h @@ -43,21 +43,21 @@ createticket.o: ../../functions/who.h ../../core/htmlfilter.h editticket.o: editticket.h tdb.h ticket.h ../../db/dbbase.h ../../db/dbconn.h editticket.o: ../../db/dbtextstream.h ../../core/textstream.h editticket.o: ../../core/error.h ../../core/log.h ticketinfo.h -editticket.o: ../../core/item.h ../../db/db.h ../../db/dbbase.h -editticket.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h -editticket.o: ../../core/user.h ../../core/group.h ../../core/thread.h -editticket.o: ../../core/dircontainer.h ../../core/item.h -editticket.o: ../../core/ugcontainer.h ../../functions/functionbase.h -editticket.o: ../../core/request.h ../../core/requesttypes.h -editticket.o: ../../core/session.h ../../core/error.h ../../core/user.h -editticket.o: ../../core/plugindata.h ../../core/rebus.h ../../core/config.h -editticket.o: ../../core/confparser.h ../../core/htmlfilter.h -editticket.o: ../../core/config.h ../../core/system.h ../../core/dirs.h -editticket.o: ../../core/dircontainer.h ../../core/request.h -editticket.o: ../../core/mounts.h ../../core/mount.h ../../core/mountparser.h -editticket.o: ../../core/users.h ../../core/ugcontainer.h -editticket.o: ../../core/lastcontainer.h ../../core/groups.h -editticket.o: ../../core/group.h ../../core/loadavg.h ../../core/notify.h +editticket.o: ../../core/item.h ../../core/system.h ../../core/dirs.h +editticket.o: ../../core/item.h ../../core/dircontainer.h ../../db/db.h +editticket.o: ../../db/dbbase.h ../../db/dbitemquery.h +editticket.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h +editticket.o: ../../core/thread.h ../../core/dircontainer.h +editticket.o: ../../core/ugcontainer.h ../../core/request.h +editticket.o: ../../core/requesttypes.h ../../core/session.h +editticket.o: ../../core/error.h ../../core/user.h ../../core/plugindata.h +editticket.o: ../../core/rebus.h ../../core/config.h ../../core/confparser.h +editticket.o: ../../core/htmlfilter.h ../../core/mounts.h ../../core/mount.h +editticket.o: ../../core/mountparser.h ../../core/users.h +editticket.o: ../../core/ugcontainer.h ../../core/lastcontainer.h +editticket.o: ../../core/groups.h ../../core/group.h ../../core/loadavg.h +editticket.o: ../../functions/functionbase.h ../../core/request.h +editticket.o: ../../core/config.h ../../core/notify.h editticket.o: ../../templatesnotify/templatesnotify.h ../../../ezc/src/ezc.h editticket.o: ../../core/mount.h ../../core/locale.h ../../templates/misc.h editticket.o: ../../templates/localefilter.h ../../core/locale.h @@ -82,21 +82,21 @@ editticket.o: ../../core/htmlfilter.h funticket.o: funticket.h tdb.h ticket.h ../../db/dbbase.h ../../db/dbconn.h funticket.o: ../../db/dbtextstream.h ../../core/textstream.h funticket.o: ../../core/error.h ../../core/log.h ticketinfo.h -funticket.o: ../../core/item.h ../../db/db.h ../../db/dbbase.h -funticket.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h -funticket.o: ../../core/user.h ../../core/group.h ../../core/thread.h -funticket.o: ../../core/dircontainer.h ../../core/item.h -funticket.o: ../../core/ugcontainer.h ../../functions/functionbase.h -funticket.o: ../../core/request.h ../../core/requesttypes.h -funticket.o: ../../core/session.h ../../core/error.h ../../core/user.h -funticket.o: ../../core/plugindata.h ../../core/rebus.h ../../core/config.h -funticket.o: ../../core/confparser.h ../../core/htmlfilter.h -funticket.o: ../../core/config.h ../../core/system.h ../../core/dirs.h -funticket.o: ../../core/dircontainer.h ../../core/request.h -funticket.o: ../../core/mounts.h ../../core/mount.h ../../core/mountparser.h -funticket.o: ../../core/users.h ../../core/ugcontainer.h -funticket.o: ../../core/lastcontainer.h ../../core/groups.h -funticket.o: ../../core/group.h ../../core/loadavg.h ../../core/notify.h +funticket.o: ../../core/item.h ../../core/system.h ../../core/dirs.h +funticket.o: ../../core/item.h ../../core/dircontainer.h ../../db/db.h +funticket.o: ../../db/dbbase.h ../../db/dbitemquery.h +funticket.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h +funticket.o: ../../core/thread.h ../../core/dircontainer.h +funticket.o: ../../core/ugcontainer.h ../../core/request.h +funticket.o: ../../core/requesttypes.h ../../core/session.h +funticket.o: ../../core/error.h ../../core/user.h ../../core/plugindata.h +funticket.o: ../../core/rebus.h ../../core/config.h ../../core/confparser.h +funticket.o: ../../core/htmlfilter.h ../../core/mounts.h ../../core/mount.h +funticket.o: ../../core/mountparser.h ../../core/users.h +funticket.o: ../../core/ugcontainer.h ../../core/lastcontainer.h +funticket.o: ../../core/groups.h ../../core/group.h ../../core/loadavg.h +funticket.o: ../../functions/functionbase.h ../../core/request.h +funticket.o: ../../core/config.h ../../core/notify.h funticket.o: ../../templatesnotify/templatesnotify.h ../../../ezc/src/ezc.h funticket.o: ../../core/mount.h ../../core/locale.h ../../templates/misc.h funticket.o: ../../templates/localefilter.h ../../core/locale.h @@ -104,19 +104,19 @@ funticket.o: ../../core/system.h init.o: tdb.h ticket.h ../../db/dbbase.h ../../db/dbconn.h init.o: ../../db/dbtextstream.h ../../core/textstream.h ../../core/error.h init.o: ../../core/log.h funticket.h ticketinfo.h ../../core/item.h -init.o: ../../db/db.h ../../db/dbbase.h ../../db/dbitemquery.h -init.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h -init.o: ../../core/thread.h ../../core/dircontainer.h ../../core/item.h -init.o: ../../core/ugcontainer.h ../../functions/functionbase.h -init.o: ../../core/request.h ../../core/requesttypes.h ../../core/session.h -init.o: ../../core/error.h ../../core/user.h ../../core/plugindata.h -init.o: ../../core/rebus.h ../../core/config.h ../../core/confparser.h -init.o: ../../core/htmlfilter.h ../../core/config.h ../../core/system.h -init.o: ../../core/dirs.h ../../core/dircontainer.h ../../core/request.h +init.o: ../../core/system.h ../../core/dirs.h ../../core/item.h +init.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h +init.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h ../../core/user.h +init.o: ../../core/group.h ../../core/thread.h ../../core/dircontainer.h +init.o: ../../core/ugcontainer.h ../../core/request.h +init.o: ../../core/requesttypes.h ../../core/session.h ../../core/error.h +init.o: ../../core/user.h ../../core/plugindata.h ../../core/rebus.h +init.o: ../../core/config.h ../../core/confparser.h ../../core/htmlfilter.h init.o: ../../core/mounts.h ../../core/mount.h ../../core/mountparser.h init.o: ../../core/users.h ../../core/ugcontainer.h init.o: ../../core/lastcontainer.h ../../core/groups.h ../../core/group.h -init.o: ../../core/loadavg.h ../../core/notify.h +init.o: ../../core/loadavg.h ../../functions/functionbase.h +init.o: ../../core/request.h ../../core/config.h ../../core/notify.h init.o: ../../templatesnotify/templatesnotify.h ../../../ezc/src/ezc.h init.o: ../../core/mount.h ../../core/locale.h ../../templates/misc.h init.o: ../../templates/localefilter.h ../../core/locale.h @@ -144,43 +144,43 @@ init.o: ../../core/item.h ../../templates/ckeditorgetparser.h init.o: ../../core/httpsimpleparser.h ../../core/log.h init.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h readticket.o: readticket.h ticket.h ticketinfo.h ../../core/item.h -readticket.o: ../../db/db.h ../../db/dbbase.h ../../db/dbitemquery.h -readticket.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h -readticket.o: ../../core/thread.h ../../core/error.h ../../core/log.h -readticket.o: ../../core/dircontainer.h ../../core/item.h -readticket.o: ../../core/ugcontainer.h tdb.h ../../db/dbbase.h -readticket.o: ../../db/dbconn.h ../../db/dbtextstream.h -readticket.o: ../../core/textstream.h ../../core/request.h +readticket.o: ../../core/system.h ../../core/dirs.h ../../core/item.h +readticket.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h +readticket.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h +readticket.o: ../../core/user.h ../../core/group.h ../../core/thread.h +readticket.o: ../../core/error.h ../../core/log.h ../../core/dircontainer.h +readticket.o: ../../core/ugcontainer.h ../../core/request.h readticket.o: ../../core/requesttypes.h ../../core/session.h readticket.o: ../../core/error.h ../../core/user.h ../../core/plugindata.h readticket.o: ../../core/rebus.h ../../core/config.h ../../core/confparser.h -readticket.o: ../../core/htmlfilter.h ../../core/system.h ../../core/dirs.h -readticket.o: ../../core/dircontainer.h ../../core/request.h -readticket.o: ../../core/mounts.h ../../core/mount.h ../../core/mountparser.h -readticket.o: ../../core/users.h ../../core/ugcontainer.h -readticket.o: ../../core/lastcontainer.h ../../core/groups.h -readticket.o: ../../core/group.h ../../core/loadavg.h +readticket.o: ../../core/htmlfilter.h ../../core/mounts.h ../../core/mount.h +readticket.o: ../../core/mountparser.h ../../core/users.h +readticket.o: ../../core/ugcontainer.h ../../core/lastcontainer.h +readticket.o: ../../core/groups.h ../../core/group.h ../../core/loadavg.h +readticket.o: tdb.h ../../db/dbbase.h ../../db/dbconn.h +readticket.o: ../../db/dbtextstream.h ../../core/textstream.h +readticket.o: ../../core/request.h tdb.o: tdb.h ticket.h ../../db/dbbase.h ../../db/dbconn.h tdb.o: ../../db/dbtextstream.h ../../core/textstream.h ../../core/error.h tdb.o: ../../core/log.h ../../core/log.h templates.o: ../../../ezc/src/ezc.h ticketinfo.h ticket.h ../../core/item.h -templates.o: ../../db/db.h ../../db/dbbase.h ../../db/dbitemquery.h -templates.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h -templates.o: ../../core/thread.h ../../core/error.h ../../core/log.h -templates.o: ../../core/dircontainer.h ../../core/item.h -templates.o: ../../core/ugcontainer.h tdb.h ../../db/dbbase.h -templates.o: ../../db/dbconn.h ../../db/dbtextstream.h -templates.o: ../../core/textstream.h editticket.h -templates.o: ../../functions/functionbase.h ../../core/request.h +templates.o: ../../core/system.h ../../core/dirs.h ../../core/item.h +templates.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h +templates.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h +templates.o: ../../core/user.h ../../core/group.h ../../core/thread.h +templates.o: ../../core/error.h ../../core/log.h ../../core/dircontainer.h +templates.o: ../../core/ugcontainer.h ../../core/request.h templates.o: ../../core/requesttypes.h ../../core/session.h templates.o: ../../core/error.h ../../core/user.h ../../core/plugindata.h templates.o: ../../core/rebus.h ../../core/config.h ../../core/confparser.h -templates.o: ../../core/htmlfilter.h ../../core/config.h ../../core/system.h -templates.o: ../../core/dirs.h ../../core/dircontainer.h ../../core/request.h -templates.o: ../../core/mounts.h ../../core/mount.h ../../core/mountparser.h -templates.o: ../../core/users.h ../../core/ugcontainer.h -templates.o: ../../core/lastcontainer.h ../../core/groups.h -templates.o: ../../core/group.h ../../core/loadavg.h ../../core/notify.h +templates.o: ../../core/htmlfilter.h ../../core/mounts.h ../../core/mount.h +templates.o: ../../core/mountparser.h ../../core/users.h +templates.o: ../../core/ugcontainer.h ../../core/lastcontainer.h +templates.o: ../../core/groups.h ../../core/group.h ../../core/loadavg.h +templates.o: tdb.h ../../db/dbbase.h ../../db/dbconn.h +templates.o: ../../db/dbtextstream.h ../../core/textstream.h editticket.h +templates.o: ../../functions/functionbase.h ../../core/request.h +templates.o: ../../core/config.h ../../core/notify.h templates.o: ../../templatesnotify/templatesnotify.h ../../core/mount.h templates.o: ../../core/locale.h ../../templates/misc.h templates.o: ../../templates/localefilter.h ../../core/locale.h @@ -209,11 +209,19 @@ templates.o: ../../templates/patterncacher.h ../../core/item.h templates.o: ../../templates/ckeditorgetparser.h templates.o: ../../core/httpsimpleparser.h ../../core/log.h templates.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h -ticketinfo.o: ticketinfo.h ticket.h ../../core/item.h ../../db/db.h -ticketinfo.o: ../../db/dbbase.h ../../db/dbitemquery.h +ticketinfo.o: ticketinfo.h ticket.h ../../core/item.h ../../core/system.h +ticketinfo.o: ../../core/dirs.h ../../core/item.h ../../core/dircontainer.h +ticketinfo.o: ../../db/db.h ../../db/dbbase.h ../../db/dbitemquery.h ticketinfo.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h ticketinfo.o: ../../core/thread.h ../../core/error.h ../../core/log.h -ticketinfo.o: ../../core/dircontainer.h ../../core/item.h -ticketinfo.o: ../../core/ugcontainer.h tdb.h ../../db/dbbase.h +ticketinfo.o: ../../core/dircontainer.h ../../core/ugcontainer.h +ticketinfo.o: ../../core/request.h ../../core/requesttypes.h +ticketinfo.o: ../../core/session.h ../../core/error.h ../../core/user.h +ticketinfo.o: ../../core/plugindata.h ../../core/rebus.h ../../core/config.h +ticketinfo.o: ../../core/confparser.h ../../core/htmlfilter.h +ticketinfo.o: ../../core/mounts.h ../../core/mount.h ../../core/mountparser.h +ticketinfo.o: ../../core/users.h ../../core/ugcontainer.h +ticketinfo.o: ../../core/lastcontainer.h ../../core/groups.h +ticketinfo.o: ../../core/group.h ../../core/loadavg.h tdb.h ../../db/dbbase.h ticketinfo.o: ../../db/dbconn.h ../../db/dbtextstream.h ticketinfo.o: ../../core/textstream.h diff --git a/plugins/ticket/funticket.cpp b/plugins/ticket/funticket.cpp index 91ec2e0..0fce424 100755 --- a/plugins/ticket/funticket.cpp +++ b/plugins/ticket/funticket.cpp @@ -86,6 +86,7 @@ void FunTicket::MakeGet() db->GetItems(request->item_tab, iq); tdb->GetTickets(request->dir_tab.back()->id, ticket_info->ticket_tab); + ticket_info->SortTickets(); TicketDeleteFirst(); system->CheckAccessToItems(request->item_tab); diff --git a/plugins/ticket/init.cpp b/plugins/ticket/init.cpp index f582946..2ad7d7e 100755 --- a/plugins/ticket/init.cpp +++ b/plugins/ticket/init.cpp @@ -41,6 +41,9 @@ void AddFunctions(PluginInfo & info) void SelectDefaultFunction(PluginInfo & info) { + if( info.request->is_item ) + return; + if( info.system->mounts.pmount->type == ticket_info.mount_type_ticket ) info.request->function = &fun_ticket; } @@ -85,6 +88,7 @@ using namespace Ticket; ticket_info.SetDb(info.db); ticket_info.SetTDb(&tdb); + ticket_info.SetSystem(info.system); fun_ticket.SetTDb(&tdb); fun_ticket.SetTicketInfo(&ticket_info); diff --git a/plugins/ticket/ticket.h b/plugins/ticket/ticket.h index 16d0007..b7837c5 100755 --- a/plugins/ticket/ticket.h +++ b/plugins/ticket/ticket.h @@ -11,6 +11,7 @@ #define headerfile_winix_plugins_ticket_ticket #include +#include namespace Ticket @@ -31,7 +32,8 @@ struct Ticket // the first item (with the content for the ticket) long item_id; - + // an auxiliary object used when sorting a table with tickets + unsigned long sort_id; void Clear() { @@ -45,6 +47,8 @@ struct Ticket expected = 0; progress = 0; item_id = -1; + + sort_id = 0; } diff --git a/plugins/ticket/ticketinfo.cpp b/plugins/ticket/ticketinfo.cpp index a11f972..4b55ddc 100755 --- a/plugins/ticket/ticketinfo.cpp +++ b/plugins/ticket/ticketinfo.cpp @@ -7,6 +7,8 @@ * */ +#include +#include #include "ticketinfo.h" #include "core/error.h" @@ -35,6 +37,11 @@ void TicketInfo::SetDb(Db * pdb) } +void TicketInfo::SetSystem(System * psystem) +{ + system = psystem; +} + void TicketInfo::Clear() { item.Clear(); @@ -54,4 +61,24 @@ void TicketInfo::ReadTicket(long dir_id) } +bool TicketInfo::SortTicketsFun(const Ticket & t1, const Ticket & t2) +{ + return t1.sort_id > t2.sort_id; +} + + +void TicketInfo::SortTickets() +{ +std::vector::iterator i; + + for(i=ticket_tab.begin() ; i!=ticket_tab.end() ; ++i) + { + Item * dir = system->dirs.GetDir(i->dir_id); + i->sort_id = ( dir ) ? (unsigned long)mktime(&dir->date_creation) : 0; + } + + std::sort(ticket_tab.begin(), ticket_tab.end(), SortTicketsFun); +} + + } // namespace diff --git a/plugins/ticket/ticketinfo.h b/plugins/ticket/ticketinfo.h index 44cdefa..b330606 100755 --- a/plugins/ticket/ticketinfo.h +++ b/plugins/ticket/ticketinfo.h @@ -14,10 +14,12 @@ #include #include "ticket.h" #include "core/item.h" +#include "core/system.h" #include "db/db.h" #include "tdb.h" + namespace Ticket { @@ -30,10 +32,11 @@ public: void SetTDb(TDb * ptdb); void SetDb(Db * pdb); + void SetSystem(System * psystem); void Clear(); void ReadTicket(long dir_id); - + void SortTickets(); Item item; bool is_ticket; @@ -56,10 +59,15 @@ public: int mount_par_createticket_on; + + + private: TDb * tdb; Db * db; + System * system; + static bool SortTicketsFun(const Ticket & t1, const Ticket & t2); };