added: now plugin ticket uses a new horizontal table (plugins.ticket)
columns: dir_id, param, value we are able to build complicated tickets git-svn-id: svn://ttmath.org/publicrep/winix/trunk@664 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -7,9 +7,9 @@ init.o: ../../core/log.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 ../../db/db.h
|
||||
init.o: ../../db/dbbase.h ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
init.o: ../../core/textstream.h ../../db/dbitemquery.h ../../core/item.h
|
||||
init.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
|
||||
init.o: ../../core/thread.h ../../core/error.h ../../core/dircontainer.h
|
||||
init.o: ../../core/textstream.h ../../core/error.h ../../db/dbitemquery.h
|
||||
init.o: ../../core/item.h ../../db/dbitemcolumns.h ../../core/user.h
|
||||
init.o: ../../core/group.h ../../core/thread.h ../../core/dircontainer.h
|
||||
init.o: ../../core/ugcontainer.h bot.h stats.h templates.h
|
||||
init.o: ../../core/plugin.h ../../core/pluginmsg.h ../../core/request.h
|
||||
init.o: ../../core/system.h ../../core/dirs.h ../../core/dircontainer.h
|
||||
@@ -49,9 +49,10 @@ templates.o: ../../core/confparser.h ../../core/htmlfilter.h
|
||||
templates.o: ../../core/request.h ../../core/system.h ../../core/dirs.h
|
||||
templates.o: ../../core/item.h ../../core/dircontainer.h ../../db/db.h
|
||||
templates.o: ../../db/dbbase.h ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
templates.o: ../../core/textstream.h ../../db/dbitemquery.h ../../core/item.h
|
||||
templates.o: ../../core/textstream.h ../../core/error.h
|
||||
templates.o: ../../db/dbitemquery.h ../../core/item.h
|
||||
templates.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
|
||||
templates.o: ../../core/thread.h ../../core/error.h ../../core/dircontainer.h
|
||||
templates.o: ../../core/thread.h ../../core/dircontainer.h
|
||||
templates.o: ../../core/ugcontainer.h ../../core/mounts.h ../../core/mount.h
|
||||
templates.o: ../../core/error.h ../../core/mountparser.h ../../core/users.h
|
||||
templates.o: ../../core/user.h ../../core/ugcontainer.h
|
||||
|
@@ -3,28 +3,28 @@
|
||||
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 ticketparser.h ticketconf.h ../../core/item.h
|
||||
createticket.o: ../../core/system.h ../../core/dirs.h ../../core/item.h
|
||||
createticket.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h
|
||||
createticket.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h
|
||||
createticket.o: ../../core/user.h ../../core/group.h ../../core/thread.h
|
||||
createticket.o: ../../core/dircontainer.h ../../core/ugcontainer.h
|
||||
createticket.o: ../../functions/functionbase.h ../../core/item.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: ../../core/request.h ../../core/requesttypes.h
|
||||
createticket.o: ../../core/session.h ../../core/error.h ../../core/user.h
|
||||
createticket.o: ../../core/plugindata.h ../../core/rebus.h
|
||||
createticket.o: ../../core/config.h ../../core/confparser.h
|
||||
createticket.o: ../../core/htmlfilter.h ../../core/mounts.h
|
||||
createticket.o: ../../core/mount.h ../../core/mountparser.h
|
||||
createticket.o: ../../core/users.h ../../core/ugcontainer.h
|
||||
createticket.o: ../../core/lastcontainer.h ../../core/groups.h
|
||||
createticket.o: ../../core/group.h ../../core/loadavg.h
|
||||
createticket.o: ../../functions/functionbase.h ../../core/request.h
|
||||
createticket.o: ../../core/config.h ../../core/notify.h
|
||||
createticket.o: ../../templatesnotify/templatesnotify.h
|
||||
createticket.o: ../../core/htmlfilter.h ../../core/config.h
|
||||
createticket.o: ../../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: ../../../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
|
||||
createticket.o: ../../functions/functions.h ../../functions/functionbase.h
|
||||
createticket.o: ../../core/locale.h ../../core/system.h ticketinfo.h
|
||||
createticket.o: ticketparser.h ticketconf.h ../../functions/functions.h
|
||||
createticket.o: ../../functions/functionbase.h
|
||||
createticket.o: ../../functions/functionparser.h ../../functions/adduser.h
|
||||
createticket.o: ../../functions/cat.h ../../functions/chmod.h
|
||||
createticket.o: ../../functions/privchanger.h ../../functions/chown.h
|
||||
@@ -50,19 +50,19 @@ editticket.o: ../../db/db.h ../../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: ../../core/mounts.h ../../core/mount.h ../../core/error.h
|
||||
editticket.o: ../../core/mountparser.h ../../core/config.h
|
||||
editticket.o: ../../core/confparser.h ../../core/htmlfilter.h
|
||||
editticket.o: ../../core/users.h ../../core/user.h ../../core/ugcontainer.h
|
||||
editticket.o: ../../core/lastcontainer.h ../../core/groups.h
|
||||
editticket.o: ../../core/group.h ../../core/rebus.h ../../core/loadavg.h
|
||||
editticket.o: ../../functions/functionbase.h ../../core/request.h
|
||||
editticket.o: ../../core/config.h ../../core/notify.h
|
||||
editticket.o: ../../core/requesttypes.h ../../core/session.h
|
||||
editticket.o: ../../core/plugindata.h ../../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
|
||||
editticket.o: ../../core/system.h readticket.h ../../functions/functions.h
|
||||
editticket.o: ../../core/system.h ../../functions/functions.h
|
||||
editticket.o: ../../functions/functionbase.h ../../functions/functionparser.h
|
||||
editticket.o: ../../functions/adduser.h ../../functions/cat.h
|
||||
editticket.o: ../../functions/chmod.h ../../functions/privchanger.h
|
||||
@@ -89,15 +89,15 @@ funticket.o: ../../db/db.h ../../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: ../../core/mounts.h ../../core/mount.h ../../core/error.h
|
||||
funticket.o: ../../core/mountparser.h ../../core/config.h
|
||||
funticket.o: ../../core/confparser.h ../../core/htmlfilter.h
|
||||
funticket.o: ../../core/users.h ../../core/user.h ../../core/ugcontainer.h
|
||||
funticket.o: ../../core/lastcontainer.h ../../core/groups.h
|
||||
funticket.o: ../../core/group.h ../../core/rebus.h ../../core/loadavg.h
|
||||
funticket.o: ../../functions/functionbase.h ../../core/request.h
|
||||
funticket.o: ../../core/config.h ../../core/notify.h
|
||||
funticket.o: ../../core/requesttypes.h ../../core/session.h
|
||||
funticket.o: ../../core/plugindata.h ../../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
|
||||
@@ -110,14 +110,14 @@ init.o: ../../core/item.h ../../core/dircontainer.h ../../db/db.h
|
||||
init.o: ../../db/dbbase.h ../../db/dbitemquery.h ../../db/dbitemcolumns.h
|
||||
init.o: ../../core/user.h ../../core/group.h ../../core/thread.h
|
||||
init.o: ../../core/dircontainer.h ../../core/ugcontainer.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/mounts.h ../../core/mount.h
|
||||
init.o: ../../core/mountparser.h ../../core/users.h ../../core/ugcontainer.h
|
||||
init.o: ../../core/lastcontainer.h ../../core/groups.h ../../core/group.h
|
||||
init.o: ../../core/request.h ../../core/mounts.h ../../core/mount.h
|
||||
init.o: ../../core/error.h ../../core/mountparser.h ../../core/config.h
|
||||
init.o: ../../core/confparser.h ../../core/htmlfilter.h ../../core/users.h
|
||||
init.o: ../../core/user.h ../../core/ugcontainer.h ../../core/lastcontainer.h
|
||||
init.o: ../../core/groups.h ../../core/group.h ../../core/rebus.h
|
||||
init.o: ../../core/loadavg.h ../../functions/functionbase.h
|
||||
init.o: ../../core/request.h ../../core/config.h ../../core/notify.h
|
||||
init.o: ../../core/request.h ../../core/requesttypes.h ../../core/session.h
|
||||
init.o: ../../core/plugindata.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,23 +144,6 @@ init.o: ../../templates/misc.h ../../templates/patterncacher.h
|
||||
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 ticketparser.h ticketconf.h
|
||||
readticket.o: ../../core/item.h ../../core/system.h ../../core/dirs.h
|
||||
readticket.o: ../../core/item.h ../../core/dircontainer.h ../../db/db.h
|
||||
readticket.o: ../../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/ugcontainer.h
|
||||
readticket.o: ../../core/request.h ../../core/requesttypes.h
|
||||
readticket.o: ../../core/session.h ../../core/error.h ../../core/user.h
|
||||
readticket.o: ../../core/plugindata.h ../../core/rebus.h ../../core/config.h
|
||||
readticket.o: ../../core/confparser.h ../../core/htmlfilter.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 tdb.h ../../db/dbbase.h
|
||||
readticket.o: ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
readticket.o: ../../core/textstream.h ../../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
|
||||
@@ -169,20 +152,19 @@ templates.o: ticketconf.h ../../core/item.h ../../core/system.h
|
||||
templates.o: ../../core/dirs.h ../../core/item.h ../../core/dircontainer.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/ugcontainer.h
|
||||
templates.o: ../../core/request.h ../../core/requesttypes.h
|
||||
templates.o: ../../core/session.h ../../core/error.h ../../core/user.h
|
||||
templates.o: ../../core/plugindata.h ../../core/rebus.h ../../core/config.h
|
||||
templates.o: ../../core/thread.h ../../core/dircontainer.h
|
||||
templates.o: ../../core/ugcontainer.h ../../core/log.h ../../core/request.h
|
||||
templates.o: ../../core/mounts.h ../../core/mount.h ../../core/error.h
|
||||
templates.o: ../../core/mountparser.h ../../core/config.h
|
||||
templates.o: ../../core/confparser.h ../../core/htmlfilter.h
|
||||
templates.o: ../../core/mounts.h ../../core/mount.h ../../core/mountparser.h
|
||||
templates.o: ../../core/users.h ../../core/ugcontainer.h
|
||||
templates.o: ../../core/users.h ../../core/user.h ../../core/ugcontainer.h
|
||||
templates.o: ../../core/lastcontainer.h ../../core/groups.h
|
||||
templates.o: ../../core/group.h ../../core/loadavg.h tdb.h ../../db/dbbase.h
|
||||
templates.o: ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
templates.o: ../../core/textstream.h editticket.h
|
||||
templates.o: ../../core/group.h ../../core/rebus.h ../../core/loadavg.h tdb.h
|
||||
templates.o: ../../db/dbbase.h ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
templates.o: ../../core/textstream.h ../../core/error.h editticket.h
|
||||
templates.o: ../../functions/functionbase.h ../../core/request.h
|
||||
templates.o: ../../core/config.h ../../core/notify.h
|
||||
templates.o: ../../core/requesttypes.h ../../core/session.h
|
||||
templates.o: ../../core/plugindata.h ../../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
|
||||
@@ -217,16 +199,15 @@ ticketinfo.o: ../../core/item.h ../../core/system.h ../../core/dirs.h
|
||||
ticketinfo.o: ../../core/item.h ../../core/dircontainer.h ../../db/db.h
|
||||
ticketinfo.o: ../../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/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/thread.h ../../core/dircontainer.h
|
||||
ticketinfo.o: ../../core/ugcontainer.h ../../core/log.h ../../core/request.h
|
||||
ticketinfo.o: ../../core/mounts.h ../../core/mount.h ../../core/error.h
|
||||
ticketinfo.o: ../../core/mountparser.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/users.h ../../core/user.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 ../../core/log.h
|
||||
ticketinfo.o: ../../core/group.h ../../core/rebus.h ../../core/loadavg.h
|
||||
ticketinfo.o: tdb.h ../../db/dbbase.h ../../db/dbconn.h
|
||||
ticketinfo.o: ../../db/dbtextstream.h ../../core/textstream.h
|
||||
ticketinfo.o: ../../core/error.h ../../core/log.h ../../core/misc.h
|
||||
ticketparser.o: ticketparser.h ticketconf.h ../../core/log.h
|
||||
|
@@ -1 +1 @@
|
||||
o = createticket.o editticket.o funticket.o init.o readticket.o tdb.o templates.o ticketconf.o ticketinfo.o ticketparser.o
|
||||
o = createticket.o editticket.o funticket.o init.o tdb.o templates.o ticketconf.o ticketinfo.o ticketparser.o
|
||||
|
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
#include "createticket.h"
|
||||
#include "readticket.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
|
||||
@@ -80,45 +79,16 @@ bool CreateTicket::HasAccess()
|
||||
}
|
||||
|
||||
|
||||
bool CreateTicket::FunCreateTicketCheckAbuse()
|
||||
{
|
||||
if( !system->rebus.CheckRebus() )
|
||||
{
|
||||
request->status = WINIX_ERR_INCORRECT_REBUS;
|
||||
return false;
|
||||
}
|
||||
|
||||
functions->CheckGetPostTimes();
|
||||
|
||||
if( request->session->spam_score > 0 )
|
||||
{
|
||||
request->status = WINIX_ERR_SPAM;
|
||||
log << log1 << "Content: ignoring due to suspected spamming" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateTicket::AddTicket()
|
||||
{
|
||||
static std::string temp;
|
||||
|
||||
ticket_info->ticket.dir_id = request->dir_tab.back()->id; // a new directory created by Mkdir()
|
||||
ticket_info->ticket.item_id = request->item.id; // this id is set by PostFunEmacsAdd()
|
||||
|
||||
// a new directory created by system->AddDir()
|
||||
ticket_info->ticket.dir_id = request->dir_tab.back()->id;
|
||||
request->status = tdb->AddTicket(ticket_info->ticket);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CreateTicket::PostFunCreateTicketLogAndRedirect()
|
||||
void CreateTicket::LogAndRedirect()
|
||||
{
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
@@ -136,42 +106,42 @@ void CreateTicket::PostFunCreateTicketLogAndRedirect()
|
||||
|
||||
void CreateTicket::MakePost()
|
||||
{
|
||||
functions->ReadItem(request->item, Item::dir);
|
||||
functions->SetUser(request->item);
|
||||
ticket_info->FindCurrentConf();
|
||||
functions->ReadItem(ticket_info->item, Item::file);
|
||||
functions->SetUser(ticket_info->item);
|
||||
ticket_info->item.privileges = request->dir_tab.back()->privileges; // !! tymczasowo takie same jak z katalogu nadrzednego
|
||||
|
||||
ReadTicket read_ticket;
|
||||
read_ticket.Read(system, request, ticket_info, &ticket_info->ticket);
|
||||
ticket_info->ReadTicketParams();
|
||||
|
||||
request->item.privileges = 0777; // !! tymczasowo 777 aby wszyscy mogli wysylac posty
|
||||
|
||||
if( !FunCreateTicketCheckAbuse() )
|
||||
{
|
||||
functions->ReadItemContentWithType(request->item); // for correctly displaying the form
|
||||
if( functions->CheckAbuse() )
|
||||
return;
|
||||
}
|
||||
|
||||
request->status = system->dirs.AddDirectory(request->item, true);
|
||||
ticket_info->item.type = Item::dir;
|
||||
request->status = system->dirs.AddDirectory(ticket_info->item, true);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
functions->ReadItemContentWithType(request->item);
|
||||
request->item.type = Item::file;
|
||||
request->item.privileges = 0644; // !! tymczasowo
|
||||
request->item.parent_id = request->dir_tab.back()->id;
|
||||
ticket_info->item.type = Item::file;
|
||||
ticket_info->item.privileges = 0644; // !! tymczasowo
|
||||
ticket_info->item.parent_id = request->dir_tab.back()->id;
|
||||
|
||||
request->status = system->AddFile(request->item);
|
||||
// adding without notificating
|
||||
request->status = system->AddFile(ticket_info->item, false);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
AddTicket();
|
||||
}
|
||||
|
||||
PostFunCreateTicketLogAndRedirect();
|
||||
LogAndRedirect();
|
||||
}
|
||||
|
||||
|
||||
void CreateTicket::MakeGet()
|
||||
{
|
||||
ticket_info->FindCurrentConf();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
@@ -11,8 +11,8 @@
|
||||
#define headerfile_winix_plugins_ticket_createticket
|
||||
|
||||
#include "tdb.h"
|
||||
#include "ticketinfo.h"
|
||||
#include "functions/functionbase.h"
|
||||
#include "ticketinfo.h"
|
||||
|
||||
|
||||
namespace Ticket
|
||||
@@ -31,12 +31,12 @@ public:
|
||||
bool HasAccess(bool check_root);
|
||||
bool HasAccess();
|
||||
void MakePost();
|
||||
void MakeGet();
|
||||
|
||||
private:
|
||||
|
||||
bool FunCreateTicketCheckAbuse();
|
||||
void AddTicket();
|
||||
void PostFunCreateTicketLogAndRedirect();
|
||||
void LogAndRedirect();
|
||||
|
||||
TDb * tdb;
|
||||
TicketInfo * ticket_info;
|
||||
|
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
#include "editticket.h"
|
||||
#include "readticket.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
|
||||
@@ -68,17 +67,23 @@ return true;
|
||||
|
||||
|
||||
|
||||
void EditTicket::EditTicketCheckFirstItem()
|
||||
void EditTicket::GetFirstItem(Item & item)
|
||||
{
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
DbItemQuery iq;
|
||||
iq.Limit(1);
|
||||
iq.WhereParentId(request->dir_tab.back()->id);
|
||||
db->GetItems(item_tab, iq); // !! chwilowo GetItems() nie zwraca zadnych kodow bledow
|
||||
|
||||
if( ticket_info->ticket.item_id == -1 )
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
if( item_tab.empty() )
|
||||
{
|
||||
// creating a new item (the item was deleted by a user)
|
||||
|
||||
Item item;
|
||||
item.parent_id = request->dir_tab.back()->id;
|
||||
item.subject = request->dir_tab.back()->subject;
|
||||
item.type = Item::file;
|
||||
@@ -86,146 +91,118 @@ void EditTicket::EditTicketCheckFirstItem()
|
||||
functions->SetUser(item);
|
||||
functions->PrepareUrl(item);
|
||||
|
||||
request->status = db->AddItem(item); // !! moze system->AddFile() tutaj?
|
||||
request->status = system->AddFile(item);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
log << log2 << "EditTicket: added the first item with content for the ticket, item.id: " << item.id << logend;
|
||||
ticket_info->ticket.item_id = item.id;
|
||||
}
|
||||
log << log2 << "EditTicket: added the first item with content for the ticket, item.id: "
|
||||
<< item.id << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
item = item_tab[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::EditTicketModTicket()
|
||||
void EditTicket::ModifyTicket()
|
||||
{
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
Ticket ticket;
|
||||
ReadTicket read_ticket;
|
||||
read_ticket.Read(system, request, ticket_info, &ticket);
|
||||
|
||||
ticket_info->ticket.type = ticket.type;
|
||||
ticket_info->ticket.status = ticket.status;
|
||||
ticket_info->ticket.priority = ticket.priority;
|
||||
ticket_info->ticket.category = ticket.category;
|
||||
ticket_info->ticket.expected = ticket.expected;
|
||||
ticket_info->ticket.progress = ticket.progress;
|
||||
|
||||
request->status = tdb->EditTicketById(ticket_info->ticket);
|
||||
ticket_info->ReadTicketParams();
|
||||
request->status = tdb->RemoveAddTicket(ticket_info->ticket);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::EditTicketModDir()
|
||||
void EditTicket::ModifyLastDir()
|
||||
{
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
// we don't modify the url
|
||||
|
||||
Item & dir = *request->dir_tab.back();
|
||||
bool edit_dir_subject = (dir.subject != request->item.subject);
|
||||
|
||||
if( edit_dir_subject )
|
||||
if( dir.subject != ticket_info->item.subject )
|
||||
{
|
||||
dir.subject = request->item.subject;
|
||||
dir.subject = ticket_info->item.subject;
|
||||
request->status = db->EditItemById(dir, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EditTicket::EditTicketModFirstItem()
|
||||
void EditTicket::ModifyFirstItem()
|
||||
{
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
// modyfing the first item (the one with content)
|
||||
functions->ReadItemContentWithType(request->item);
|
||||
|
||||
Item item;
|
||||
db->GetItemById(ticket_info->ticket.item_id, item);
|
||||
item.subject = request->item.subject;
|
||||
item.content = request->item.content;
|
||||
item.content_type = request->item.content_type;
|
||||
// the url doesn't matter
|
||||
|
||||
db->EditItemById(item, false);
|
||||
// we don't modify the url and don't use notifications
|
||||
system->EditFile(ticket_info->item, false, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::PostFunEditTicketLogAndRedirect()
|
||||
void EditTicket::LogAndRedirect()
|
||||
{
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
log << log2 << "Content: edited a ticket" << logend;
|
||||
log << log2 << "EditTicket: edited a ticket" << logend;
|
||||
system->RedirectToLastDir();
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Content: problem with editing a ticket, error code: "
|
||||
log << log1 << "EditTicket: problem with editing a ticket, error code: "
|
||||
<< request->status << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool EditTicket::FunCreateTicketCheckAbuse()
|
||||
{
|
||||
if( !system->rebus.CheckRebus() )
|
||||
{
|
||||
request->status = WINIX_ERR_INCORRECT_REBUS;
|
||||
return false;
|
||||
}
|
||||
|
||||
functions->CheckGetPostTimes();
|
||||
|
||||
if( request->session->spam_score > 0 )
|
||||
{
|
||||
request->status = WINIX_ERR_SPAM;
|
||||
log << log1 << "Content: ignoring due to suspected spamming" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void EditTicket::MakePost()
|
||||
{
|
||||
functions->ReadItem(request->item, Item::dir);
|
||||
// co z uzytkownikiem i grup<75>? chyba nie wczytane? !!! (wczesniej bylo SetUser() w ReadItem() - teraz nie ma)
|
||||
// dodac informacje o modyfikacji !!!
|
||||
ticket_info->FindCurrentConf();
|
||||
|
||||
if( !FunCreateTicketCheckAbuse() )
|
||||
{
|
||||
functions->ReadItemContentWithType(request->item); // for correctly displaying the form
|
||||
// reading the first item from the db or creating it if not exists
|
||||
GetFirstItem(ticket_info->item);
|
||||
|
||||
// reading information from POST
|
||||
functions->ReadItem(ticket_info->item, Item::file);
|
||||
|
||||
if( functions->CheckAbuse() )
|
||||
return;
|
||||
}
|
||||
|
||||
if( tdb->GetTicketByDirId(request->dir_tab.back()->id, ticket_info->ticket) != WINIX_ERR_OK )
|
||||
if( tdb->GetTicket(request->dir_tab.back()->id, ticket_info->ticket) != WINIX_ERR_OK )
|
||||
{
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
}
|
||||
|
||||
EditTicketCheckFirstItem();
|
||||
EditTicketModTicket();
|
||||
EditTicketModDir();
|
||||
EditTicketModFirstItem();
|
||||
PostFunEditTicketLogAndRedirect();
|
||||
ModifyTicket();
|
||||
ModifyLastDir();
|
||||
ModifyFirstItem();
|
||||
LogAndRedirect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::MakeGet()
|
||||
{
|
||||
db->GetItemById(ticket_info->ticket.item_id, request->item);
|
||||
ticket_info->FindCurrentConf();
|
||||
|
||||
// the subject we get from the last directory
|
||||
request->item.subject = request->dir_tab.back()->subject;
|
||||
DbItemQuery iq;
|
||||
iq.Limit(1);
|
||||
iq.WhereParentId(request->dir_tab.back()->id);
|
||||
db->GetItems(item_tab, iq); // !! chwilowo GetItems() nie zwraca kodow bledow
|
||||
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
{
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
}
|
||||
|
||||
if( !item_tab.empty() )
|
||||
ticket_info->item = item_tab[0];
|
||||
}
|
||||
|
||||
|
||||
|
@@ -35,15 +35,15 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void EditTicketCheckFirstItem();
|
||||
void EditTicketModTicket();
|
||||
void EditTicketModDir();
|
||||
void EditTicketModFirstItem();
|
||||
void PostFunEditTicketLogAndRedirect();
|
||||
bool FunCreateTicketCheckAbuse();
|
||||
void GetFirstItem(Item & item);
|
||||
void ModifyTicket();
|
||||
void ModifyLastDir();
|
||||
void ModifyFirstItem();
|
||||
void LogAndRedirect();
|
||||
|
||||
TDb * tdb;
|
||||
TicketInfo * ticket_info;
|
||||
std::vector<Item> item_tab;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -8,6 +8,9 @@
|
||||
*/
|
||||
|
||||
#include "funticket.h"
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
|
||||
namespace Ticket
|
||||
@@ -41,58 +44,94 @@ void FunTicket::Clear()
|
||||
|
||||
bool FunTicket::HasAccess()
|
||||
{
|
||||
if( request->is_item || system->mounts.pmount->type != ticket_info->mount_type_ticket )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return !request->is_item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void FunTicket::TicketDeleteFirst()
|
||||
{
|
||||
if( !ticket_info->is_ticket )
|
||||
return;
|
||||
|
||||
for(size_t i=0 ; i<request->item_tab.size() ; ++i)
|
||||
{
|
||||
if( request->item_tab[i].id == ticket_info->ticket.item_id )
|
||||
{
|
||||
// this is the first item with the content for the ticket
|
||||
|
||||
if( !system->HasReadAccess(request->item_tab[i]) )
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
|
||||
request->item_tab.erase(request->item_tab.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunTicket::MakeGet()
|
||||
{
|
||||
ticket_info->FindCurrentConf();
|
||||
ticket_info->ReadTicket(request->dir_tab.back()->id);
|
||||
|
||||
DbItemQuery iq;
|
||||
|
||||
iq.WhereParentId(request->dir_tab.back()->id);
|
||||
iq.WhereType(Item::file);
|
||||
iq.WhereAuth(Item::auth_none);
|
||||
|
||||
db->GetItems(request->item_tab, iq);
|
||||
tdb->GetTickets(request->dir_tab.back()->id, ticket_info->ticket_tab);
|
||||
ticket_info->SortTickets();
|
||||
|
||||
TicketDeleteFirst();
|
||||
if( !request->item_tab.empty() )
|
||||
{
|
||||
if( system->HasReadAccess(request->item_tab[0]) )
|
||||
{
|
||||
ticket_info->item = request->item_tab[0];
|
||||
request->item_tab.erase(request->item_tab.begin());
|
||||
}
|
||||
else
|
||||
{
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
system->CheckAccessToItems(request->item_tab);
|
||||
SelectTickets();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunTicket::SelectTickets()
|
||||
{
|
||||
child_tab.clear();
|
||||
system->dirs.GetDirChilds(request->dir_tab.back()->id, child_tab);
|
||||
|
||||
SortDirs();
|
||||
PageDirs();
|
||||
CreateIdTab();
|
||||
tdb->GetTickets(id_tab, ticket_info->ticket_tab);
|
||||
ticket_info->SortTickets();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FunTicket::SortByDate::operator()(const Item * item1, const Item * item2)
|
||||
{
|
||||
tm tm1 = item1->date_creation;
|
||||
tm tm2 = item2->date_creation;
|
||||
|
||||
time_t time1 = mktime(&tm1);
|
||||
time_t time2 = mktime(&tm2);
|
||||
|
||||
return time1 < time2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunTicket::SortDirs()
|
||||
{
|
||||
// temporarily sorting by date
|
||||
SortByDate sort(this);
|
||||
std::sort(child_tab.begin(), child_tab.end(), sort);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunTicket::PageDirs()
|
||||
{
|
||||
// temporarily show every tickets
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunTicket::CreateIdTab()
|
||||
{
|
||||
id_tab.clear();
|
||||
|
||||
for(size_t i=0 ; i<child_tab.size() ; ++i)
|
||||
id_tab.push_back(child_tab[i]->id);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
@@ -34,9 +34,23 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void TicketDeleteFirst();
|
||||
TDb * tdb;
|
||||
TicketInfo * ticket_info;
|
||||
std::vector<Item*> child_tab;
|
||||
std::vector<long> id_tab;
|
||||
|
||||
struct SortByDate
|
||||
{
|
||||
FunTicket * fun_ticket;
|
||||
SortByDate(FunTicket * f) : fun_ticket(f) {}
|
||||
bool operator()(const Item * item1, const Item * item2);
|
||||
};
|
||||
|
||||
void SelectTickets();
|
||||
void SortDirs();
|
||||
void PageDirs();
|
||||
void CreateIdTab();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@@ -89,6 +89,11 @@ void ContentMake(PluginInfo & info)
|
||||
}
|
||||
|
||||
|
||||
void InitTicket(PluginInfo & info)
|
||||
{
|
||||
ticket_info.progress_prefix = info.config->Text("ticket_form_progress_prefix", "progress");
|
||||
}
|
||||
|
||||
void AddEzcFunctions(PluginInfo & info);
|
||||
|
||||
} // namespace Ticket
|
||||
@@ -99,6 +104,7 @@ void Init(PluginInfo & info)
|
||||
{
|
||||
using namespace Ticket;
|
||||
|
||||
plugin.Assign(WINIX_PLUGIN_INIT, InitTicket);
|
||||
plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions);
|
||||
plugin.Assign(WINIX_CREATE_FUNCTIONS, AddFunctions);
|
||||
plugin.Assign(WINIX_SELECT_DEFAULT_FUNCTION, SelectDefaultFunction);
|
||||
@@ -107,10 +113,12 @@ using namespace Ticket;
|
||||
plugin.Assign(WINIX_CONTENT_MAKE, ContentMake);
|
||||
|
||||
tdb.SetConn(info.db->GetConn());
|
||||
tdb.LogQueries(info.config->log_db_query);
|
||||
|
||||
ticket_info.SetDb(info.db);
|
||||
ticket_info.SetTDb(&tdb);
|
||||
ticket_info.SetSystem(info.system);
|
||||
ticket_info.SetRequest(info.request);
|
||||
|
||||
fun_ticket.SetTDb(&tdb);
|
||||
fun_ticket.SetTicketInfo(&ticket_info);
|
||||
|
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "readticket.h"
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
|
||||
|
||||
ReadTicket::ReadTicket()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ReadTicket::ReadTicketType()
|
||||
{
|
||||
static std::string temp;
|
||||
|
||||
request->PostVar("type", temp);
|
||||
ticket->type = atoi(temp.c_str());
|
||||
|
||||
if( ticket->type >= system->mounts.pmount->param[ticket_info->mount_par_ticket_type].arg.size() )
|
||||
ticket->type = system->mounts.pmount->param[ticket_info->mount_par_ticket_type].arg.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ReadTicket::ReadTicketStatus()
|
||||
{
|
||||
static std::string temp;
|
||||
|
||||
request->PostVar("status", temp);
|
||||
ticket->status = atoi(temp.c_str());
|
||||
|
||||
if( ticket->status >= system->mounts.pmount->param[ticket_info->mount_par_ticket_status].arg.size() )
|
||||
ticket->status = system->mounts.pmount->param[ticket_info->mount_par_ticket_status].arg.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ReadTicket::ReadTicketPriority()
|
||||
{
|
||||
static std::string temp;
|
||||
|
||||
request->PostVar("priority", temp);
|
||||
ticket->priority = atoi(temp.c_str());
|
||||
|
||||
if( ticket->priority >= system->mounts.pmount->param[ticket_info->mount_par_ticket_priority].arg.size() )
|
||||
ticket->priority = system->mounts.pmount->param[ticket_info->mount_par_ticket_priority].arg.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ReadTicket::ReadTicketCategory()
|
||||
{
|
||||
static std::string temp;
|
||||
|
||||
request->PostVar("category", temp);
|
||||
ticket->category = atoi(temp.c_str());
|
||||
|
||||
if( ticket->category >= system->mounts.pmount->param[ticket_info->mount_par_ticket_category].arg.size() )
|
||||
ticket->category = system->mounts.pmount->param[ticket_info->mount_par_ticket_category].arg.size();
|
||||
}
|
||||
|
||||
|
||||
void ReadTicket::ReadTicketExpected()
|
||||
{
|
||||
static std::string temp;
|
||||
|
||||
request->PostVar("expected", temp);
|
||||
ticket->expected = atoi(temp.c_str());
|
||||
|
||||
if( ticket->expected >= system->mounts.pmount->param[ticket_info->mount_par_ticket_expected].arg.size() )
|
||||
ticket->expected = system->mounts.pmount->param[ticket_info->mount_par_ticket_expected].arg.size();
|
||||
}
|
||||
|
||||
|
||||
void ReadTicket::ReadTicketProgress()
|
||||
{
|
||||
static std::string temp;
|
||||
|
||||
request->PostVar("progress", temp);
|
||||
int p = atoi(temp.c_str());
|
||||
|
||||
if( p < 0 )
|
||||
p = 0;
|
||||
|
||||
if( p > 100 )
|
||||
p = 100;
|
||||
|
||||
ticket->progress = p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ReadTicket::Read(System * psystem, Request * prequest, TicketInfo * pinfo, Ticket * pticket)
|
||||
{
|
||||
system = psystem;
|
||||
request = prequest;
|
||||
ticket = pticket;
|
||||
ticket_info = pinfo;
|
||||
|
||||
ticket->parent_id = request->dir_tab.back()->id;
|
||||
|
||||
ReadTicketType();
|
||||
ReadTicketStatus();
|
||||
ReadTicketPriority();
|
||||
ReadTicketCategory();
|
||||
ReadTicketExpected();
|
||||
ReadTicketProgress();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_plugins_ticket_readticket
|
||||
#define headerfile_winix_plugins_ticket_readticket
|
||||
|
||||
#include "ticket.h"
|
||||
#include "ticketinfo.h"
|
||||
#include "core/request.h"
|
||||
#include "core/system.h"
|
||||
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
|
||||
|
||||
class ReadTicket
|
||||
{
|
||||
public:
|
||||
ReadTicket();
|
||||
void Read(System * psystem, Request * prequest, TicketInfo * pinfo, Ticket * pticket);
|
||||
|
||||
private:
|
||||
Request * request;
|
||||
Ticket * ticket;
|
||||
System * system;
|
||||
TicketInfo * ticket_info;
|
||||
|
||||
void ReadTicketType();
|
||||
void ReadTicketStatus();
|
||||
void ReadTicketPriority();
|
||||
void ReadTicketCategory();
|
||||
void ReadTicketExpected();
|
||||
void ReadTicketProgress();
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
#endif
|
@@ -17,17 +17,16 @@ namespace Ticket
|
||||
|
||||
|
||||
|
||||
Error TDb::GetTicketByDirId(long dir_id, Ticket & ticket)
|
||||
Error TDb::GetTicket(long dir_id, Ticket & ticket)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error status = WINIX_ERR_OK;
|
||||
ticket.Clear();
|
||||
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R("select ticket.id, ticket.dir_id, ticket.parent_id, ticket.type, ticket.status, ticket.priority, "
|
||||
"ticket.category, ticket.expected, ticket.progress, ticket.item_id "
|
||||
"from core.ticket "
|
||||
query << R("select dir_id, param, value from plugins.ticket "
|
||||
"where ticket.dir_id=") << dir_id << R(";");
|
||||
|
||||
r = AssertQuery(query);
|
||||
@@ -35,57 +34,20 @@ Error TDb::GetTicketByDirId(long dir_id, Ticket & ticket)
|
||||
|
||||
int rows = Rows(r);
|
||||
|
||||
if( rows > 1 )
|
||||
log << log1 << "Db: there is more than one ticket with dir_id: " << dir_id << logend;
|
||||
else
|
||||
if( rows == 0 )
|
||||
throw Error(WINIX_ERR_NO_TICKET);
|
||||
|
||||
TicketColumns tc;
|
||||
Ticket::TicketParam par;
|
||||
ticket.dir_id = dir_id;
|
||||
|
||||
tc.SetColumns(r);
|
||||
tc.SetTicket(r, 0, ticket);
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
status = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Error TDb::GetTickets(long parent_id, std::vector<Ticket> & ticket_tab)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error status = WINIX_ERR_OK;
|
||||
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R("select ticket.id, ticket.dir_id, ticket.parent_id, ticket.type, ticket.status, ticket.priority, "
|
||||
"ticket.category, ticket.expected, ticket.progress, ticket.item_id "
|
||||
"from core.ticket "
|
||||
"where ticket.parent_id = ") << parent_id << R(";");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_TUPLES_OK);
|
||||
|
||||
int rows = Rows(r);
|
||||
Ticket ticket;
|
||||
TicketColumns tc;
|
||||
|
||||
tc.SetColumns(r);
|
||||
int cparam = AssertColumn(r, "param");
|
||||
int cvalue = AssertColumn(r, "value");
|
||||
|
||||
for(int i=0 ; i<rows ; ++i)
|
||||
{
|
||||
tc.SetTicket(r, i, ticket);
|
||||
ticket_tab.push_back(ticket);
|
||||
par.param = AssertValueInt(r, i, cparam);
|
||||
par.value = AssertValueInt(r, i, cvalue);
|
||||
ticket.par_tab.push_back(par);
|
||||
}
|
||||
}
|
||||
catch(const Error & e)
|
||||
@@ -95,66 +57,92 @@ Error TDb::GetTickets(long parent_id, std::vector<Ticket> & ticket_tab)
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
bool TDb::IsTicket(long dir_id)
|
||||
|
||||
|
||||
|
||||
Error TDb::GetTickets(const std::vector<long> & dir_id_tab, std::vector<Ticket> & ticket_tab)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
bool is_ticket = false;
|
||||
PGresult * r = 0;
|
||||
Error status = WINIX_ERR_OK;
|
||||
ticket_tab.clear();
|
||||
|
||||
if( dir_id_tab.empty() )
|
||||
return status;
|
||||
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << "select ticket.id from core.ticket "
|
||||
"where ticket.dir_id = '" << dir_id << "';";
|
||||
CreateIdList(dir_id_tab, dir_list);
|
||||
query << R("select dir_id, param, value from plugins.ticket "
|
||||
"where ticket.dir_id in ") << R(dir_list) << R(" order by dir_id;");
|
||||
|
||||
// !! moze dodac operator <<(std::vector(long)) do query?
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_TUPLES_OK);
|
||||
|
||||
is_ticket = (Rows(r) == 1);
|
||||
int rows = Rows(r);
|
||||
Ticket::TicketParam par;
|
||||
|
||||
int cdir_id = AssertColumn(r, "dir_id");
|
||||
int cparam = AssertColumn(r, "param");
|
||||
int cvalue = AssertColumn(r, "value");
|
||||
long last_dir_id = -1;
|
||||
|
||||
for(int i=0 ; i<rows ; ++i)
|
||||
{
|
||||
long dir_id = AssertValueLong(r, i, cdir_id);
|
||||
|
||||
if( i==0 || last_dir_id != dir_id )
|
||||
{
|
||||
ticket_tab.push_back(Ticket());
|
||||
ticket_tab.back().dir_id = dir_id;
|
||||
last_dir_id = dir_id;
|
||||
}
|
||||
|
||||
par.param = AssertValueInt(r, i, cparam);
|
||||
par.value = AssertValueInt(r, i, cvalue);
|
||||
ticket_tab.back().par_tab.push_back(par);
|
||||
}
|
||||
}
|
||||
catch(const Error &)
|
||||
catch(const Error & e)
|
||||
{
|
||||
status = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
dir_list.clear();
|
||||
|
||||
return is_ticket;
|
||||
return status;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
Error TDb::AddTicket(Ticket & ticket)
|
||||
|
||||
Error TDb::AddTicket(const Ticket & ticket)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error status = WINIX_ERR_OK;
|
||||
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R("insert into core.ticket (dir_id, parent_id, type, status, priority, "
|
||||
"category, expected, progress, item_id) values (")
|
||||
<< ticket.dir_id
|
||||
<< ticket.parent_id
|
||||
<< ticket.type
|
||||
<< ticket.status
|
||||
<< ticket.priority
|
||||
<< ticket.category
|
||||
<< ticket.expected
|
||||
<< ticket.progress
|
||||
<< ticket.item_id
|
||||
<< R(");");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_COMMAND_OK);
|
||||
|
||||
ticket.id = AssertCurrval("core.ticket_id_seq");
|
||||
for(size_t i=0 ; i<ticket.par_tab.size() ; ++i)
|
||||
{
|
||||
query.Clear();
|
||||
query << R("insert into plugins.ticket (dir_id, param, value) values (")
|
||||
<< ticket.dir_id
|
||||
<< ticket.par_tab[i].param
|
||||
<< ticket.par_tab[i].value
|
||||
<< R(");");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_COMMAND_OK);
|
||||
}
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
@@ -169,67 +157,28 @@ return status;
|
||||
|
||||
|
||||
|
||||
Error TDb::EditTicketById(Ticket & ticket)
|
||||
Error TDb::RemoveAddTicket(const Ticket & ticket)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error status = WINIX_ERR_OK;
|
||||
Error status = BeginTrans();
|
||||
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R("update core.ticket set (dir_id, parent_id, type, status, "
|
||||
"priority, category, expected, progress, item_id) = (")
|
||||
<< ticket.dir_id
|
||||
<< ticket.parent_id
|
||||
<< ticket.type
|
||||
<< ticket.status
|
||||
<< ticket.priority
|
||||
<< ticket.category
|
||||
<< ticket.expected
|
||||
<< ticket.progress
|
||||
<< ticket.item_id
|
||||
<< R(") where id=")
|
||||
<< ticket.id
|
||||
<< R(";");
|
||||
if( status != WINIX_ERR_OK )
|
||||
return status;
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_COMMAND_OK);
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
status = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
status = RemoveTicket(ticket.dir_id);
|
||||
|
||||
if( status == WINIX_ERR_OK )
|
||||
status = AddTicket(ticket);
|
||||
|
||||
if( status == WINIX_ERR_OK )
|
||||
status = CommitTrans();
|
||||
else
|
||||
RollbackTrans();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Error TDb::EditTicketRemoveItem(long item_id)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error status = WINIX_ERR_OK;
|
||||
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R("update core.ticket set item_id = -1 where item_id=") << item_id << R(";");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_COMMAND_OK);
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
status = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Error TDb::RemoveTicket(long dir_id)
|
||||
@@ -240,7 +189,7 @@ Error TDb::RemoveTicket(long dir_id)
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R("delete from core.ticket where dir_id=") << dir_id << R(";");
|
||||
query << R("delete from plugins.ticket where dir_id=") << dir_id << R(";");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_COMMAND_OK);
|
||||
@@ -248,7 +197,7 @@ Error TDb::RemoveTicket(long dir_id)
|
||||
long rows = AffectedRows(r);
|
||||
|
||||
if( rows > 0 )
|
||||
log << log2 << "Db: deleted " << rows << " rows from core.ticket" << logend;
|
||||
log << log2 << "Db: deleted " << rows << " rows from plugins.ticket" << logend;
|
||||
|
||||
}
|
||||
catch(const Error & e)
|
||||
@@ -265,36 +214,5 @@ return status;
|
||||
|
||||
|
||||
|
||||
void TDb::TicketColumns::SetColumns(PGresult * r)
|
||||
{
|
||||
// PQfnumber returns -1 if there is no such a column
|
||||
id = PQfnumber(r, "id");
|
||||
dir_id = PQfnumber(r, "dir_id");
|
||||
parent_id = PQfnumber(r, "parent_id");
|
||||
type = PQfnumber(r, "type");
|
||||
status = PQfnumber(r, "status");
|
||||
priority = PQfnumber(r, "priority");
|
||||
category = PQfnumber(r, "category");
|
||||
expected = PQfnumber(r, "expected");
|
||||
progress = PQfnumber(r, "progress");
|
||||
item_id = PQfnumber(r, "item_id");
|
||||
}
|
||||
|
||||
|
||||
void TDb::TicketColumns::SetTicket(PGresult * r, long row, Ticket & ticket)
|
||||
{
|
||||
if( id != -1 ) ticket.id = DbBase::AssertValueLong(r, row, id);
|
||||
if( dir_id != -1 ) ticket.dir_id = DbBase::AssertValueLong(r, row, dir_id);
|
||||
if( parent_id != -1 ) ticket.parent_id = DbBase::AssertValueLong(r, row, parent_id);
|
||||
if( type != -1 ) ticket.type = DbBase::AssertValueInt(r, row, type);
|
||||
if( status != -1 ) ticket.status = DbBase::AssertValueInt(r, row, status);
|
||||
if( priority != -1 ) ticket.priority = DbBase::AssertValueInt(r, row, priority);
|
||||
if( category != -1 ) ticket.category = DbBase::AssertValueInt(r, row, category);
|
||||
if( expected != -1 ) ticket.expected = DbBase::AssertValueInt(r, row, expected);
|
||||
if( progress != -1 ) ticket.progress = DbBase::AssertValueInt(r, row, progress);
|
||||
if( item_id != -1 ) ticket.item_id = DbBase::AssertValueLong(r, row, item_id);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@@ -23,32 +23,19 @@ namespace Ticket
|
||||
|
||||
class TDb : public DbBase
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
Error GetTicketByDirId(long dir_id, Ticket & ticket);
|
||||
Error GetTickets(long parent_id, std::vector<Ticket> & ticket_tab);
|
||||
//bool IsTicket(long dir_id);
|
||||
Error AddTicket(Ticket & ticket);
|
||||
Error EditTicketById(Ticket & ticket);
|
||||
Error EditTicketRemoveItem(long item_id);
|
||||
Error GetTicket(long dir_id, Ticket & ticket);
|
||||
Error GetTickets(const std::vector<long> & dir_id_tab, std::vector<Ticket> & ticket_tab);
|
||||
Error AddTicket(const Ticket & ticket);
|
||||
Error RemoveAddTicket(const Ticket & ticket); // first removing and then adding a ticket
|
||||
Error RemoveTicket(long dir_id);
|
||||
|
||||
|
||||
struct TicketColumns
|
||||
{
|
||||
int id, dir_id, parent_id, type, status, priority, category, expected, progress, item_id;
|
||||
|
||||
void SetColumns(PGresult * r);
|
||||
void SetTicket(PGresult * r, long row, Ticket & ticket);
|
||||
};
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
DbTextStream query;
|
||||
std::string dir_list;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -46,12 +46,56 @@ return percent;
|
||||
|
||||
|
||||
|
||||
void find_ticket_value(const TicketConf::TicketItem & conf_item, const Ticket & ticket, bool * has_value, int * value)
|
||||
{
|
||||
*has_value = false;
|
||||
*value = 0;
|
||||
|
||||
for(size_t a=0 ; a < ticket.par_tab.size() ; a++)
|
||||
{
|
||||
int par = ticket.par_tab[a].param;
|
||||
int val = ticket.par_tab[a].value;
|
||||
|
||||
if( par == conf_item.id )
|
||||
{
|
||||
*has_value = true;
|
||||
*value = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_print_value(Info & i, size_t conf_index, int value)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
{
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_index];
|
||||
|
||||
if( conf_item.type == TicketConf::TicketItem::TypeInteger )
|
||||
i.out << value;
|
||||
else
|
||||
if( conf_item.type == TicketConf::TicketItem::TypeSelect )
|
||||
{
|
||||
if( value < (int)conf_item.select.size() )
|
||||
HtmlEscape(i.out, conf_item.select[value].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ticket_is(Info & i)
|
||||
{
|
||||
i.res = ticket_info.is_ticket;
|
||||
}
|
||||
|
||||
|
||||
void ticket_item_subject(Info & i)
|
||||
{
|
||||
HtmlEscape(i.out, ticket_info.item.subject);
|
||||
}
|
||||
|
||||
|
||||
void ticket_item_content(Info & i)
|
||||
{
|
||||
@@ -85,511 +129,277 @@ void ticket_can_edit(Info & i)
|
||||
}
|
||||
|
||||
|
||||
void ticket_type(Info & i)
|
||||
|
||||
|
||||
|
||||
namespace ns_tickets_tab
|
||||
{
|
||||
if( ticket_info.ticket.type < system->mounts.pmount->param[ticket_info.mount_par_ticket_type].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_type].arg[ticket_info.ticket.type]);
|
||||
}
|
||||
static size_t tickets_tab_index;
|
||||
static size_t conf_tab_index;
|
||||
static bool has_value;
|
||||
static int value;
|
||||
|
||||
|
||||
void ticket_status(Info & i)
|
||||
void tickets_tab(Info & i)
|
||||
{
|
||||
if( ticket_info.ticket.status < system->mounts.pmount->param[ticket_info.mount_par_ticket_status].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_status].arg[ticket_info.ticket.status]);
|
||||
}
|
||||
|
||||
|
||||
void ticket_priority(Info & i)
|
||||
{
|
||||
if( ticket_info.ticket.priority < system->mounts.pmount->param[ticket_info.mount_par_ticket_priority].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_priority].arg[ticket_info.ticket.priority]);
|
||||
}
|
||||
|
||||
|
||||
void ticket_category(Info & i)
|
||||
{
|
||||
if( ticket_info.ticket.category < system->mounts.pmount->param[ticket_info.mount_par_ticket_category].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_category].arg[ticket_info.ticket.category]);
|
||||
}
|
||||
|
||||
|
||||
void ticket_expected(Info & i)
|
||||
{
|
||||
if( ticket_info.ticket.expected < system->mounts.pmount->param[ticket_info.mount_par_ticket_expected].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_expected].arg[ticket_info.ticket.expected]);
|
||||
tickets_tab_index = i.iter;
|
||||
i.res = tickets_tab_index < ticket_info.ticket_tab.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ticket_progress(Info & i)
|
||||
Item * tickets_tab_find_index_dir()
|
||||
{
|
||||
i.out << ticket_info.ticket.progress;
|
||||
}
|
||||
Item * dir = 0;
|
||||
|
||||
if( tickets_tab_index < ticket_info.ticket_tab.size() )
|
||||
{
|
||||
long dir_id = ticket_info.ticket_tab[tickets_tab_index].dir_id;
|
||||
dir = system->dirs.GetDir(dir_id);
|
||||
}
|
||||
|
||||
void ticket_progress_image_number(Info & i)
|
||||
{
|
||||
int percent = ticket_info.ticket.progress;
|
||||
i.out << ticket_calc_progress_image_number(percent);
|
||||
return dir;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
void tickets_tab_url(Info & i)
|
||||
{
|
||||
Item * dir = tickets_tab_find_index_dir();
|
||||
|
||||
if( dir )
|
||||
HtmlEscape(i.out, dir->url);
|
||||
}
|
||||
|
||||
|
||||
void tickets_tab_subject_empty(Info & i)
|
||||
{
|
||||
Item * dir = tickets_tab_find_index_dir();
|
||||
|
||||
if( dir )
|
||||
i.res = dir->subject.empty();
|
||||
}
|
||||
|
||||
|
||||
void tickets_tab_subject(Info & i)
|
||||
{
|
||||
Item * dir = tickets_tab_find_index_dir();
|
||||
|
||||
if( dir )
|
||||
HtmlEscape(i.out, dir->subject);
|
||||
}
|
||||
|
||||
|
||||
void tickets_tab_conf_tab(Info & i)
|
||||
{
|
||||
if( tickets_tab_index < ticket_info.ticket_tab.size() )
|
||||
{
|
||||
conf_tab_index = i.iter;
|
||||
i.res = conf_tab_index < ticket_info.cur_conf->tab.size();
|
||||
|
||||
if( i.res )
|
||||
{
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_tab_index];
|
||||
const Ticket & ticket = ticket_info.ticket_tab[tickets_tab_index];
|
||||
find_ticket_value(conf_item, ticket, &has_value, &value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void tickets_tab_conf_tab_value(Info & i)
|
||||
{
|
||||
if( has_value )
|
||||
ticket_print_value(i, conf_tab_index, value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static size_t ticket_tab_index;
|
||||
void tickets_tab_conf_tab_is_progress(Info & i)
|
||||
{
|
||||
if( has_value &&
|
||||
conf_tab_index < ticket_info.cur_conf->tab.size() )
|
||||
{
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_tab_index];
|
||||
i.res = IsSubString(ticket_info.progress_prefix, conf_item.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void tickets_tab_conf_tab_progress_image_number(Info & i)
|
||||
{
|
||||
if( has_value )
|
||||
i.out << ticket_calc_progress_image_number(value);
|
||||
}
|
||||
|
||||
|
||||
} // namespace ns_tickets_tab
|
||||
|
||||
|
||||
|
||||
namespace ns_ticket_tab
|
||||
{
|
||||
static size_t conf_index;
|
||||
static size_t select_index;
|
||||
static bool has_value;
|
||||
static int value;
|
||||
|
||||
|
||||
void ticket_tab(Info & i)
|
||||
{
|
||||
ticket_tab_index = i.iter;
|
||||
conf_index = i.iter;
|
||||
i.res = conf_index < ticket_info.cur_conf->tab.size();
|
||||
|
||||
i.res = ticket_tab_index < ticket_info.ticket_tab.size();
|
||||
if( i.res )
|
||||
{
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_index];
|
||||
find_ticket_value(conf_item, ticket_info.ticket, &has_value, &value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_url(Info & i)
|
||||
void ticket_tab_param(Info & i)
|
||||
{
|
||||
if( ticket_tab_index < ticket_info.ticket_tab.size() )
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
HtmlEscape(i.out, ticket_info.cur_conf->tab[conf_index].name);
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_value(Info & i)
|
||||
{
|
||||
if( has_value )
|
||||
ticket_print_value(i, conf_index, value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ticket_tab_param_index(Info & i)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
i.out << ticket_info.cur_conf->tab[conf_index].id;
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_value_index(Info & i)
|
||||
{
|
||||
if( has_value )
|
||||
i.out << value;
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_is_select(Info & i)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
i.res = ticket_info.cur_conf->tab[conf_index].type == TicketConf::TicketItem::TypeSelect;
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_is_integer(Info & i)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
i.res = ticket_info.cur_conf->tab[conf_index].type == TicketConf::TicketItem::TypeInteger;
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_select_tab(Info & i)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
{
|
||||
Item * dir = system->dirs.GetDir( ticket_info.ticket_tab[ticket_tab_index].dir_id );
|
||||
|
||||
if( dir )
|
||||
select_index = i.iter;
|
||||
i.res = select_index < ticket_info.cur_conf->tab[conf_index].select.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_select_tab_is_default(Info & i)
|
||||
{
|
||||
if( has_value )
|
||||
{
|
||||
i.res = select_index == value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() &&
|
||||
select_index < ticket_info.cur_conf->tab[conf_index].select.size() )
|
||||
{
|
||||
HtmlEscape(i.out, dir->url);
|
||||
}
|
||||
else
|
||||
{
|
||||
i.out << "<!-- unknown directory -->";
|
||||
i.res = select_index == ticket_info.cur_conf->tab[conf_index].select_default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_subject(Info & i)
|
||||
void ticket_tab_select_tab_name(Info & i)
|
||||
{
|
||||
if( ticket_tab_index < ticket_info.ticket_tab.size() )
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() &&
|
||||
select_index < ticket_info.cur_conf->tab[conf_index].select.size() )
|
||||
{
|
||||
Item * dir = system->dirs.GetDir( ticket_info.ticket_tab[ticket_tab_index].dir_id );
|
||||
|
||||
if( dir )
|
||||
{
|
||||
if( !dir->subject.empty() )
|
||||
HtmlEscape(i.out, dir->subject);
|
||||
else
|
||||
HtmlEscape(i.out, dir->url);
|
||||
}
|
||||
else
|
||||
{
|
||||
i.out << "<!-- unknown subject -->";
|
||||
}
|
||||
HtmlEscape(i.out, ticket_info.cur_conf->tab[conf_index].select[select_index].name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_subject_empty(Info & i)
|
||||
void ticket_tab_select_tab_id(Info & i)
|
||||
{
|
||||
i.res = true;
|
||||
|
||||
if( ticket_tab_index < ticket_info.ticket_tab.size() )
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() &&
|
||||
select_index < ticket_info.cur_conf->tab[conf_index].select.size() )
|
||||
{
|
||||
Item * dir = system->dirs.GetDir( ticket_info.ticket_tab[ticket_tab_index].dir_id );
|
||||
|
||||
if( dir )
|
||||
i.res = dir->subject.empty();
|
||||
i.out << ticket_info.cur_conf->tab[conf_index].select[select_index].id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_author(Info & i)
|
||||
{
|
||||
bool unknown = true;
|
||||
|
||||
|
||||
if( ticket_tab_index < ticket_info.ticket_tab.size() )
|
||||
{
|
||||
Item * dir = system->dirs.GetDir( ticket_info.ticket_tab[ticket_tab_index].dir_id );
|
||||
|
||||
if( dir )
|
||||
{
|
||||
User * puser = system->users.GetUser(dir->user_id);
|
||||
unknown = false;
|
||||
|
||||
if( puser )
|
||||
HtmlEscape(i.out, puser->name);
|
||||
else
|
||||
{
|
||||
i.out << "~";
|
||||
|
||||
if( !dir->guest_name.empty() )
|
||||
HtmlEscape(i.out, dir->guest_name);
|
||||
else
|
||||
i.out << "guest"; // !! dodac do konfiga
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace ns_ticket_tab
|
||||
|
||||
|
||||
if( unknown )
|
||||
{
|
||||
i.out << "<!-- unknown user -->";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ticket_tab_type(Info & i)
|
||||
{
|
||||
if( ticket_tab_index >= ticket_info.ticket_tab.size() )
|
||||
return;
|
||||
|
||||
Ticket & t = ticket_info.ticket_tab[ticket_tab_index];
|
||||
|
||||
if( t.type < system->mounts.pmount->param[ticket_info.mount_par_ticket_type].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_type].arg[t.type]);
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_status(Info & i)
|
||||
{
|
||||
if( ticket_tab_index >= ticket_info.ticket_tab.size() )
|
||||
return;
|
||||
|
||||
Ticket & t = ticket_info.ticket_tab[ticket_tab_index];
|
||||
|
||||
if( t.status < system->mounts.pmount->param[ticket_info.mount_par_ticket_status].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_status].arg[t.status]);
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_priority(Info & i)
|
||||
{
|
||||
if( ticket_tab_index >= ticket_info.ticket_tab.size() )
|
||||
return;
|
||||
|
||||
Ticket & t = ticket_info.ticket_tab[ticket_tab_index];
|
||||
|
||||
if( t.priority < system->mounts.pmount->param[ticket_info.mount_par_ticket_priority].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_priority].arg[t.priority]);
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_category(Info & i)
|
||||
{
|
||||
if( ticket_tab_index >= ticket_info.ticket_tab.size() )
|
||||
return;
|
||||
|
||||
Ticket & t = ticket_info.ticket_tab[ticket_tab_index];
|
||||
|
||||
if( t.category < system->mounts.pmount->param[ticket_info.mount_par_ticket_category].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_category].arg[t.category]);
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_expected(Info & i)
|
||||
{
|
||||
if( ticket_tab_index >= ticket_info.ticket_tab.size() )
|
||||
return;
|
||||
|
||||
Ticket & t = ticket_info.ticket_tab[ticket_tab_index];
|
||||
|
||||
if( t.expected < system->mounts.pmount->param[ticket_info.mount_par_ticket_expected].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_expected].arg[t.expected]);
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_progress(Info & i)
|
||||
{
|
||||
if( ticket_tab_index >= ticket_info.ticket_tab.size() )
|
||||
return;
|
||||
|
||||
i.out << ticket_info.ticket_tab[ticket_tab_index].progress;
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_progress_image_number(Info & i)
|
||||
{
|
||||
if( ticket_tab_index >= ticket_info.ticket_tab.size() )
|
||||
return;
|
||||
|
||||
int percent = ticket_info.ticket_tab[ticket_tab_index].progress;
|
||||
i.out << ticket_calc_progress_image_number(percent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
static size_t ticket_type_tab_ind;
|
||||
|
||||
|
||||
void ticket_type_tab(Info & i)
|
||||
{
|
||||
ticket_type_tab_ind = i.iter;
|
||||
|
||||
i.res = ticket_type_tab_ind < system->mounts.pmount->param[ticket_info.mount_par_ticket_type].arg.size();
|
||||
}
|
||||
|
||||
|
||||
void ticket_type_tab_defined(Info & i)
|
||||
{
|
||||
i.res = system->mounts.pmount->param[ticket_info.mount_par_ticket_type].defined;
|
||||
}
|
||||
|
||||
|
||||
void ticket_type_tab_isdefault(Info & i)
|
||||
{
|
||||
if( ticket_info.is_ticket )
|
||||
{
|
||||
i.res = (ticket_type_tab_ind == ticket_info.ticket.type);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mount::ParamRow & p = system->mounts.pmount->param[ticket_info.mount_par_ticket_type_default];
|
||||
|
||||
if( !p.defined || p.arg.empty() )
|
||||
return; // default false
|
||||
|
||||
size_t value = atoi( p.arg[0].c_str() );
|
||||
i.res = (ticket_type_tab_ind == value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_type_tab_index(Info & i)
|
||||
{
|
||||
i.out << ticket_type_tab_ind;
|
||||
}
|
||||
|
||||
|
||||
void ticket_type_tab_name(Info & i)
|
||||
{
|
||||
if( ticket_type_tab_ind < system->mounts.pmount->param[ticket_info.mount_par_ticket_type].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_type].arg[ticket_type_tab_ind]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
static size_t ticket_status_tab_ind;
|
||||
|
||||
|
||||
void ticket_status_tab(Info & i)
|
||||
{
|
||||
ticket_status_tab_ind = i.iter;
|
||||
|
||||
i.res = ticket_status_tab_ind < system->mounts.pmount->param[ticket_info.mount_par_ticket_status].arg.size();
|
||||
}
|
||||
|
||||
|
||||
void ticket_status_tab_defined(Info & i)
|
||||
{
|
||||
i.res = system->mounts.pmount->param[ticket_info.mount_par_ticket_status].defined;
|
||||
}
|
||||
|
||||
|
||||
void ticket_status_tab_isdefault(Info & i)
|
||||
{
|
||||
if( ticket_info.is_ticket )
|
||||
{
|
||||
i.res = (ticket_status_tab_ind == ticket_info.ticket.status);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mount::ParamRow & p = system->mounts.pmount->param[ticket_info.mount_par_ticket_status_default];
|
||||
|
||||
if( !p.defined || p.arg.empty() )
|
||||
return; // default false
|
||||
|
||||
size_t value = atoi( p.arg[0].c_str() );
|
||||
i.res = (ticket_status_tab_ind == value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_status_tab_index(Info & i)
|
||||
{
|
||||
i.out << ticket_status_tab_ind;
|
||||
}
|
||||
|
||||
|
||||
void ticket_status_tab_name(Info & i)
|
||||
{
|
||||
if( ticket_status_tab_ind < system->mounts.pmount->param[ticket_info.mount_par_ticket_status].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_status].arg[ticket_status_tab_ind]);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
static size_t ticket_priority_tab_ind;
|
||||
|
||||
|
||||
void ticket_priority_tab(Info & i)
|
||||
{
|
||||
ticket_priority_tab_ind = i.iter;
|
||||
|
||||
i.res = ticket_priority_tab_ind < system->mounts.pmount->param[ticket_info.mount_par_ticket_priority].arg.size();
|
||||
}
|
||||
|
||||
|
||||
void ticket_priority_tab_defined(Info & i)
|
||||
{
|
||||
i.res = system->mounts.pmount->param[ticket_info.mount_par_ticket_priority].defined;
|
||||
}
|
||||
|
||||
|
||||
void ticket_priority_tab_isdefault(Info & i)
|
||||
{
|
||||
if( ticket_info.is_ticket )
|
||||
{
|
||||
i.res = (ticket_priority_tab_ind == ticket_info.ticket.priority);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mount::ParamRow & p = system->mounts.pmount->param[ticket_info.mount_par_ticket_priority_default];
|
||||
|
||||
if( !p.defined || p.arg.empty() )
|
||||
return; // default false
|
||||
|
||||
size_t value = atoi( p.arg[0].c_str() );
|
||||
i.res = (ticket_priority_tab_ind == value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_priority_tab_index(Info & i)
|
||||
{
|
||||
i.out << ticket_priority_tab_ind;
|
||||
}
|
||||
|
||||
|
||||
void ticket_priority_tab_name(Info & i)
|
||||
{
|
||||
if( ticket_priority_tab_ind < system->mounts.pmount->param[ticket_info.mount_par_ticket_priority].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_priority].arg[ticket_priority_tab_ind]);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
static size_t ticket_category_tab_ind;
|
||||
|
||||
|
||||
void ticket_category_tab(Info & i)
|
||||
{
|
||||
ticket_category_tab_ind = i.iter;
|
||||
|
||||
i.res = ticket_category_tab_ind < system->mounts.pmount->param[ticket_info.mount_par_ticket_category].arg.size();
|
||||
}
|
||||
|
||||
|
||||
void ticket_category_tab_defined(Info & i)
|
||||
{
|
||||
i.res = system->mounts.pmount->param[ticket_info.mount_par_ticket_category].defined;
|
||||
}
|
||||
|
||||
|
||||
void ticket_category_tab_isdefault(Info & i)
|
||||
{
|
||||
if( ticket_info.is_ticket )
|
||||
{
|
||||
i.res = (ticket_category_tab_ind == ticket_info.ticket.category);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mount::ParamRow & p = system->mounts.pmount->param[ticket_info.mount_par_ticket_category_default];
|
||||
|
||||
if( !p.defined || p.arg.empty() )
|
||||
return; // default false
|
||||
|
||||
size_t value = atoi( p.arg[0].c_str() );
|
||||
i.res = (ticket_category_tab_ind == value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_category_tab_index(Info & i)
|
||||
{
|
||||
i.out << ticket_category_tab_ind;
|
||||
}
|
||||
|
||||
|
||||
void ticket_category_tab_name(Info & i)
|
||||
{
|
||||
if( ticket_category_tab_ind < system->mounts.pmount->param[ticket_info.mount_par_ticket_category].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_category].arg[ticket_category_tab_ind]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
static size_t ticket_expected_tab_ind;
|
||||
|
||||
|
||||
void ticket_expected_tab(Info & i)
|
||||
{
|
||||
ticket_expected_tab_ind = i.iter;
|
||||
|
||||
i.res = ticket_expected_tab_ind < system->mounts.pmount->param[ticket_info.mount_par_ticket_expected].arg.size();
|
||||
}
|
||||
|
||||
|
||||
void ticket_expected_tab_defined(Info & i)
|
||||
{
|
||||
i.res = system->mounts.pmount->param[ticket_info.mount_par_ticket_expected].defined;
|
||||
}
|
||||
|
||||
|
||||
void ticket_expected_tab_isdefault(Info & i)
|
||||
{
|
||||
if( ticket_info.is_ticket )
|
||||
{
|
||||
i.res = (ticket_expected_tab_ind == ticket_info.ticket.expected);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mount::ParamRow & p = system->mounts.pmount->param[ticket_info.mount_par_ticket_expected_default];
|
||||
|
||||
if( !p.defined || p.arg.empty() )
|
||||
return; // default false
|
||||
|
||||
size_t value = atoi( p.arg[0].c_str() );
|
||||
i.res = (ticket_expected_tab_ind == value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_expected_tab_index(Info & i)
|
||||
{
|
||||
i.out << ticket_expected_tab_ind;
|
||||
}
|
||||
|
||||
|
||||
void ticket_expected_tab_name(Info & i)
|
||||
{
|
||||
if( ticket_expected_tab_ind < system->mounts.pmount->param[ticket_info.mount_par_ticket_expected].arg.size() )
|
||||
HtmlEscape(i.out, system->mounts.pmount->param[ticket_info.mount_par_ticket_expected].arg[ticket_expected_tab_ind]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AddEzcFunctions(PluginInfo & info)
|
||||
{
|
||||
using namespace ns_tickets_tab;
|
||||
using namespace ns_ticket_tab;
|
||||
|
||||
|
||||
Ezc::Functions * fun = reinterpret_cast<Ezc::Functions*>(info.p1);
|
||||
|
||||
fun->Insert("ticket_is", ticket_is);
|
||||
fun->Insert("ticket_item_subject", ticket_item_subject);
|
||||
fun->Insert("ticket_item_content", ticket_item_content);
|
||||
fun->Insert("ticket_item_content_type_is", ticket_item_content_type_is);
|
||||
fun->Insert("ticket_item_print_content", ticket_item_print_content);
|
||||
fun->Insert("ticket_can_create", ticket_can_create);
|
||||
fun->Insert("ticket_can_edit", ticket_can_edit);
|
||||
|
||||
fun->Insert("tickets_tab", tickets_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_url", tickets_tab_url);
|
||||
|
||||
|
||||
fun->Insert("tickets_tab_conf_tab", tickets_tab_conf_tab);
|
||||
fun->Insert("tickets_tab_conf_tab_value", tickets_tab_conf_tab_value);
|
||||
fun->Insert("tickets_tab_conf_tab_is_progress", tickets_tab_conf_tab_is_progress);
|
||||
fun->Insert("tickets_tab_conf_tab_progress_image_number", tickets_tab_conf_tab_progress_image_number);
|
||||
|
||||
|
||||
fun->Insert("ticket_tab", ticket_tab);
|
||||
fun->Insert("ticket_tab_param", ticket_tab_param);
|
||||
fun->Insert("ticket_tab_value", ticket_tab_value);
|
||||
fun->Insert("ticket_tab_param_index", ticket_tab_param_index);
|
||||
fun->Insert("ticket_tab_value_index", ticket_tab_value_index);
|
||||
|
||||
fun->Insert("ticket_tab_is_select", ticket_tab_is_select);
|
||||
fun->Insert("ticket_tab_is_integer", ticket_tab_is_integer);
|
||||
|
||||
fun->Insert("ticket_tab_select_tab", ticket_tab_select_tab);
|
||||
fun->Insert("ticket_tab_select_tab_is_default", ticket_tab_select_tab_is_default);
|
||||
fun->Insert("ticket_tab_select_tab_id", ticket_tab_select_tab_id);
|
||||
fun->Insert("ticket_tab_select_tab_name", ticket_tab_select_tab_name);
|
||||
|
||||
|
||||
/*
|
||||
fun->Insert("ticket_type", ticket_type);
|
||||
fun->Insert("ticket_status", ticket_status);
|
||||
fun->Insert("ticket_priority", ticket_priority);
|
||||
@@ -640,6 +450,7 @@ void AddEzcFunctions(PluginInfo & info)
|
||||
fun->Insert("ticket_expected_tab_isdefault", ticket_expected_tab_isdefault);
|
||||
fun->Insert("ticket_expected_tab_index", ticket_expected_tab_index);
|
||||
fun->Insert("ticket_expected_tab_name", ticket_expected_tab_name);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@@ -10,8 +10,8 @@
|
||||
#ifndef headerfile_winix_plugins_ticket_ticket
|
||||
#define headerfile_winix_plugins_ticket_ticket
|
||||
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
namespace Ticket
|
||||
@@ -19,36 +19,28 @@ namespace Ticket
|
||||
|
||||
struct Ticket
|
||||
{
|
||||
long id;
|
||||
struct TicketParam
|
||||
{
|
||||
int param;
|
||||
int value;
|
||||
|
||||
TicketParam()
|
||||
{
|
||||
param = value = 0;
|
||||
}
|
||||
};
|
||||
|
||||
long dir_id;
|
||||
long parent_id;
|
||||
unsigned int type;
|
||||
unsigned int status;
|
||||
unsigned int priority;
|
||||
unsigned int category;
|
||||
unsigned int expected;
|
||||
unsigned int progress; // 0 - 100 (percentage)
|
||||
|
||||
// the first item (with the content for the ticket)
|
||||
long item_id;
|
||||
|
||||
// an auxiliary object used when sorting a table with tickets
|
||||
std::vector<TicketParam> par_tab;
|
||||
|
||||
// auxiliary object used during sorting
|
||||
unsigned long sort_id;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
id = -1;
|
||||
dir_id = -1;
|
||||
parent_id = -1;
|
||||
type = 0;
|
||||
status = 0;
|
||||
priority = 0;
|
||||
category = 0;
|
||||
expected = 0;
|
||||
progress = 0;
|
||||
item_id = -1;
|
||||
|
||||
sort_id = 0;
|
||||
dir_id = -1;
|
||||
par_tab.clear();
|
||||
sort_id = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +48,6 @@ struct Ticket
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@@ -12,6 +12,8 @@
|
||||
#include "ticketinfo.h"
|
||||
#include "core/error.h"
|
||||
#include "core/log.h"
|
||||
#include "core/misc.h"
|
||||
|
||||
|
||||
|
||||
namespace Ticket
|
||||
@@ -42,21 +44,31 @@ void TicketInfo::SetSystem(System * psystem)
|
||||
system = psystem;
|
||||
}
|
||||
|
||||
|
||||
void TicketInfo::SetRequest(Request * prequest)
|
||||
{
|
||||
request = prequest;
|
||||
}
|
||||
|
||||
|
||||
void TicketInfo::Clear()
|
||||
{
|
||||
item.Clear();
|
||||
is_ticket = false;
|
||||
ticket.Clear();
|
||||
ticket_tab.clear();
|
||||
|
||||
cur_conf_wrap = &cur_conf_wrap_empty;
|
||||
cur_conf = &cur_conf_empty;
|
||||
}
|
||||
|
||||
|
||||
void TicketInfo::ReadTicket(long dir_id)
|
||||
{
|
||||
if( tdb->GetTicketByDirId(dir_id, ticket) == WINIX_ERR_OK )
|
||||
if( tdb->GetTicket(dir_id, ticket) == WINIX_ERR_OK )
|
||||
{
|
||||
is_ticket = true;
|
||||
db->GetItemById(ticket.item_id, item);
|
||||
//db->GetItemById(ticket.item_id, item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,5 +212,89 @@ void TicketInfo::ReadTicketConf(bool skip_existing_configs)
|
||||
}
|
||||
|
||||
|
||||
void TicketInfo::FindCurrentConf()
|
||||
{
|
||||
if( !system->mounts.pmount )
|
||||
return;
|
||||
|
||||
long dir_id = system->mounts.pmount->dir_id;
|
||||
|
||||
ConfTab::iterator i = conf_tab.find(dir_id);
|
||||
|
||||
if( i != conf_tab.end() )
|
||||
{
|
||||
cur_conf_wrap = &i->second;
|
||||
cur_conf = &i->second.conf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool TicketInfo::CheckMinMaxValue(const TicketConf::TicketItem & ticket_item, Ticket::TicketParam & par)
|
||||
{
|
||||
if( ticket_item.type == TicketConf::TicketItem::TypeInteger )
|
||||
{
|
||||
if( par.value < ticket_item.integer_min )
|
||||
par.value = ticket_item.integer_min;
|
||||
|
||||
if( par.value > ticket_item.integer_max )
|
||||
par.value = ticket_item.integer_max;
|
||||
}
|
||||
else
|
||||
if( ticket_item.type == TicketConf::TicketItem::TypeSelect )
|
||||
{
|
||||
for(size_t a=0 ; a<ticket_item.select.size() ; ++a)
|
||||
{
|
||||
if( ticket_item.select[a].id == par.value )
|
||||
return true;
|
||||
}
|
||||
|
||||
log << log1 << "Ticket: incorrect select's value, param: "
|
||||
<< par.param << ", value: " << par.value << " (ignored)" << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TicketInfo::CheckMinMaxValue(Ticket::TicketParam & par)
|
||||
{
|
||||
for(size_t i=0 ; i<cur_conf->tab.size() ; ++i)
|
||||
{
|
||||
if( par.param == cur_conf->tab[i].id )
|
||||
return CheckMinMaxValue(cur_conf->tab[i], par);
|
||||
}
|
||||
|
||||
log << log1 << "Ticket: unknown param: " << par.param << " (ignored)" << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void TicketInfo::ReadTicketParams()
|
||||
{
|
||||
PostTab::iterator i;
|
||||
const char parstr[] = "ticketparam"; // !! dodac do konfiga? i szablony tez niech bior<6F> z konfiga
|
||||
size_t parlen = sizeof(parstr) / sizeof(char) - 1;
|
||||
Ticket::TicketParam param;
|
||||
|
||||
ticket.par_tab.clear();
|
||||
|
||||
for(i=request->post_tab.begin() ; i!=request->post_tab.end() ; ++i)
|
||||
{
|
||||
if( IsSubString(parstr, i->first.c_str()) )
|
||||
{
|
||||
param.param = atoi(i->first.c_str() + parlen);
|
||||
param.value = atoi(i->second.c_str());
|
||||
|
||||
if( CheckMinMaxValue(param) )
|
||||
ticket.par_tab.push_back(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
@@ -47,6 +47,7 @@ public:
|
||||
void SetTDb(TDb * ptdb);
|
||||
void SetDb(Db * pdb);
|
||||
void SetSystem(System * psystem);
|
||||
void SetRequest(Request * prequest);
|
||||
|
||||
void Clear();
|
||||
void ReadTicket(long dir_id);
|
||||
@@ -61,7 +62,14 @@ public:
|
||||
typedef std::map<long, TicketConfWrap> ConfTab;
|
||||
ConfTab conf_tab;
|
||||
|
||||
// used by templates
|
||||
// will not be null
|
||||
const TicketConfWrap * cur_conf_wrap;
|
||||
const TicketConf * cur_conf;
|
||||
|
||||
// default: "progress"
|
||||
// can be set in config in option: ticket_form_progress_prefix
|
||||
std::string progress_prefix;
|
||||
|
||||
int mount_type_ticket;
|
||||
|
||||
@@ -82,17 +90,26 @@ public:
|
||||
int mount_par_createticket_on;
|
||||
|
||||
void ReadTicketConf(bool skip_existing_configs = false);
|
||||
|
||||
void FindCurrentConf();
|
||||
bool CheckMinMaxValue(const TicketConf::TicketItem & ticket_item, Ticket::TicketParam & par);
|
||||
bool CheckMinMaxValue(Ticket::TicketParam & par);
|
||||
void ReadTicketParams();
|
||||
|
||||
private:
|
||||
TDb * tdb;
|
||||
Db * db;
|
||||
System * system;
|
||||
Request * request;
|
||||
TicketParser ticket_parser;
|
||||
Item item_conf;
|
||||
std::string path_dir;
|
||||
std::string path_file;
|
||||
|
||||
// for cur_conf_wrap and cur_conf
|
||||
const TicketConfWrap cur_conf_wrap_empty;
|
||||
const TicketConf cur_conf_empty;
|
||||
|
||||
|
||||
static bool SortTicketsFun(const Ticket & t1, const Ticket & t2);
|
||||
bool GetConfContent(const std::string & path);
|
||||
bool ParseTicketConf(long mount_dir_id, const std::string & path);
|
||||
|
Reference in New Issue
Block a user