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
This commit is contained in:
Tomasz Sowa 2010-09-30 20:58:20 +00:00
parent d94a08b991
commit 7bc17a9202
12 changed files with 178 additions and 141 deletions

View File

@ -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()
{

View File

@ -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();

View File

@ -77,25 +77,14 @@ return true;
void Emacs::PostFunEmacsModifyMountPoint(bool adding)
{
if( system->mounts.pmount->type == system->mounts.MountTypeThread() )
{
if( adding )
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();
}
@ -103,7 +92,11 @@ void Emacs::PostFunEmacsModifyMountPoint(bool adding)
void Emacs::MakePost()
{
bool adding = !request->is_item;
bool edit_with_url = functions->ReadItem(request->item, Item::file);
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);

View File

@ -32,6 +32,7 @@ private:
bool PostEmacsCheckAbuse(bool adding);
void PostFunEmacsModifyMountPoint(bool adding);
std::string old_url;
};

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -11,6 +11,7 @@
#define headerfile_winix_plugins_ticket_ticket
#include <string>
#include <ctime>
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;
}

View File

@ -7,6 +7,8 @@
*
*/
#include <algorithm>
#include <ctime>
#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<Ticket>::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

View File

@ -14,10 +14,12 @@
#include <vector>
#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);
};