tickets has been moved to a new plugin 'ticket'
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@657 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
27
plugins/ticket/Makefile
Executable file
27
plugins/ticket/Makefile
Executable file
@@ -0,0 +1,27 @@
|
||||
include Makefile.o.dep
|
||||
|
||||
name = ticket.so
|
||||
|
||||
|
||||
all: $(o)
|
||||
$(CXX) -shared -Wl,-soname,$(name).so -o $(name) $(CXXFLAGS) *.o
|
||||
|
||||
|
||||
|
||||
.SUFFIXES: .cpp .o
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -c $(CXXFLAGS) $<
|
||||
|
||||
|
||||
|
||||
depend:
|
||||
makedepend -Y. -I../.. -I../../../ezc/src -f- *.cpp > Makefile.dep
|
||||
echo -n "o = " > Makefile.o.dep
|
||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f $(name)
|
||||
|
||||
include Makefile.dep
|
216
plugins/ticket/Makefile.dep
Executable file
216
plugins/ticket/Makefile.dep
Executable file
@@ -0,0 +1,216 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
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: ../../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/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: ../../../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: ../../functions/functionparser.h ../../functions/adduser.h
|
||||
createticket.o: ../../functions/cat.h ../../functions/chmod.h
|
||||
createticket.o: ../../functions/privchanger.h ../../functions/chown.h
|
||||
createticket.o: ../../functions/ckeditor.h ../../functions/cp.h
|
||||
createticket.o: ../../functions/createthread.h ../../functions/default.h
|
||||
createticket.o: ../../functions/download.h ../../functions/emacs.h
|
||||
createticket.o: ../../functions/last.h ../../functions/login.h
|
||||
createticket.o: ../../functions/logout.h ../../functions/ls.h
|
||||
createticket.o: ../../functions/mkdir.h ../../functions/mv.h
|
||||
createticket.o: ../../functions/node.h ../../functions/priv.h
|
||||
createticket.o: ../../functions/reload.h ../../functions/rm.h
|
||||
createticket.o: ../../functions/run.h ../../functions/subject.h
|
||||
createticket.o: ../../functions/funthread.h ../../functions/template.h
|
||||
createticket.o: ../../functions/tinymce.h ../../functions/uname.h
|
||||
createticket.o: ../../functions/upload.h ../../functions/uptime.h
|
||||
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: ../../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: ../../functions/functionbase.h ../../functions/functionparser.h
|
||||
editticket.o: ../../functions/adduser.h ../../functions/cat.h
|
||||
editticket.o: ../../functions/chmod.h ../../functions/privchanger.h
|
||||
editticket.o: ../../functions/chown.h ../../functions/ckeditor.h
|
||||
editticket.o: ../../functions/cp.h ../../functions/createthread.h
|
||||
editticket.o: ../../functions/default.h ../../functions/download.h
|
||||
editticket.o: ../../functions/emacs.h ../../functions/last.h
|
||||
editticket.o: ../../functions/login.h ../../functions/logout.h
|
||||
editticket.o: ../../functions/ls.h ../../functions/mkdir.h
|
||||
editticket.o: ../../functions/mv.h ../../functions/node.h
|
||||
editticket.o: ../../functions/priv.h ../../functions/reload.h
|
||||
editticket.o: ../../functions/rm.h ../../functions/run.h
|
||||
editticket.o: ../../functions/subject.h ../../functions/funthread.h
|
||||
editticket.o: ../../functions/template.h ../../functions/tinymce.h
|
||||
editticket.o: ../../functions/uname.h ../../functions/upload.h
|
||||
editticket.o: ../../functions/uptime.h ../../functions/who.h
|
||||
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: ../../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
|
||||
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/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: ../../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
|
||||
init.o: ../../core/system.h editticket.h createticket.h ../../core/log.h
|
||||
init.o: ../../core/plugin.h ../../core/pluginmsg.h
|
||||
init.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h
|
||||
init.o: ../../functions/functions.h ../../functions/functionbase.h
|
||||
init.o: ../../functions/functionparser.h ../../functions/adduser.h
|
||||
init.o: ../../functions/cat.h ../../functions/chmod.h
|
||||
init.o: ../../functions/privchanger.h ../../functions/chown.h
|
||||
init.o: ../../functions/ckeditor.h ../../functions/cp.h
|
||||
init.o: ../../functions/createthread.h ../../functions/default.h
|
||||
init.o: ../../functions/download.h ../../functions/emacs.h
|
||||
init.o: ../../functions/last.h ../../functions/login.h
|
||||
init.o: ../../functions/logout.h ../../functions/ls.h ../../functions/mkdir.h
|
||||
init.o: ../../functions/mv.h ../../functions/node.h ../../functions/priv.h
|
||||
init.o: ../../functions/reload.h ../../functions/rm.h ../../functions/run.h
|
||||
init.o: ../../functions/subject.h ../../functions/funthread.h
|
||||
init.o: ../../functions/template.h ../../functions/tinymce.h
|
||||
init.o: ../../functions/uname.h ../../functions/upload.h
|
||||
init.o: ../../functions/uptime.h ../../functions/who.h
|
||||
init.o: ../../core/htmlfilter.h ../../templates/templates.h
|
||||
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 ../../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/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
|
||||
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
|
||||
ticket.o: ../../../ezc/src/ezc.h ticketinfo.h ticket.h ../../core/item.h
|
||||
ticket.o: ../../db/db.h ../../db/dbbase.h ../../db/dbitemquery.h
|
||||
ticket.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
|
||||
ticket.o: ../../core/thread.h ../../core/error.h ../../core/log.h
|
||||
ticket.o: ../../core/dircontainer.h ../../core/item.h
|
||||
ticket.o: ../../core/ugcontainer.h tdb.h ../../db/dbbase.h ../../db/dbconn.h
|
||||
ticket.o: ../../db/dbtextstream.h ../../core/textstream.h editticket.h
|
||||
ticket.o: ../../functions/functionbase.h ../../core/request.h
|
||||
ticket.o: ../../core/requesttypes.h ../../core/session.h ../../core/error.h
|
||||
ticket.o: ../../core/user.h ../../core/plugindata.h ../../core/rebus.h
|
||||
ticket.o: ../../core/config.h ../../core/confparser.h ../../core/htmlfilter.h
|
||||
ticket.o: ../../core/config.h ../../core/system.h ../../core/dirs.h
|
||||
ticket.o: ../../core/dircontainer.h ../../core/request.h ../../core/mounts.h
|
||||
ticket.o: ../../core/mount.h ../../core/mountparser.h ../../core/users.h
|
||||
ticket.o: ../../core/ugcontainer.h ../../core/lastcontainer.h
|
||||
ticket.o: ../../core/groups.h ../../core/group.h ../../core/loadavg.h
|
||||
ticket.o: ../../core/notify.h ../../templatesnotify/templatesnotify.h
|
||||
ticket.o: ../../core/mount.h ../../core/locale.h ../../templates/misc.h
|
||||
ticket.o: ../../templates/localefilter.h ../../core/locale.h
|
||||
ticket.o: ../../core/system.h createticket.h ../../core/misc.h
|
||||
ticket.o: ../../core/plugin.h ../../core/pluginmsg.h
|
||||
ticket.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h
|
||||
ticket.o: ../../functions/functions.h ../../functions/functionbase.h
|
||||
ticket.o: ../../functions/functionparser.h ../../functions/adduser.h
|
||||
ticket.o: ../../functions/cat.h ../../functions/chmod.h
|
||||
ticket.o: ../../functions/privchanger.h ../../functions/chown.h
|
||||
ticket.o: ../../functions/ckeditor.h ../../functions/cp.h
|
||||
ticket.o: ../../functions/createthread.h ../../functions/default.h
|
||||
ticket.o: ../../functions/download.h ../../functions/emacs.h
|
||||
ticket.o: ../../functions/last.h ../../functions/login.h
|
||||
ticket.o: ../../functions/logout.h ../../functions/ls.h
|
||||
ticket.o: ../../functions/mkdir.h ../../functions/mv.h ../../functions/node.h
|
||||
ticket.o: ../../functions/priv.h ../../functions/reload.h
|
||||
ticket.o: ../../functions/rm.h ../../functions/run.h
|
||||
ticket.o: ../../functions/subject.h ../../functions/funthread.h
|
||||
ticket.o: ../../functions/template.h ../../functions/tinymce.h
|
||||
ticket.o: ../../functions/uname.h ../../functions/upload.h
|
||||
ticket.o: ../../functions/uptime.h ../../functions/who.h
|
||||
ticket.o: ../../core/htmlfilter.h ../../templates/templates.h
|
||||
ticket.o: ../../templates/misc.h ../../templates/patterncacher.h
|
||||
ticket.o: ../../core/item.h ../../templates/ckeditorgetparser.h
|
||||
ticket.o: ../../core/httpsimpleparser.h ../../core/log.h
|
||||
ticket.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: ../../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: ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
ticketinfo.o: ../../core/textstream.h
|
1
plugins/ticket/Makefile.o.dep
Executable file
1
plugins/ticket/Makefile.o.dep
Executable file
@@ -0,0 +1 @@
|
||||
o = createticket.o editticket.o funticket.o init.o readticket.o tdb.o ticket.o ticketinfo.o
|
177
plugins/ticket/createticket.cpp
Executable file
177
plugins/ticket/createticket.cpp
Executable file
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "createticket.h"
|
||||
#include "readticket.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
|
||||
|
||||
CreateTicket::CreateTicket()
|
||||
{
|
||||
fun.url = "createticket";
|
||||
}
|
||||
|
||||
|
||||
void CreateTicket::SetTDb(TDb * ptdb)
|
||||
{
|
||||
tdb = ptdb;
|
||||
}
|
||||
|
||||
|
||||
void CreateTicket::SetTicketInfo(TicketInfo * pinfo)
|
||||
{
|
||||
ticket_info = pinfo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CreateTicket::Clear()
|
||||
{
|
||||
ticket_info->Clear();
|
||||
}
|
||||
|
||||
|
||||
// returning true if we can create a ticket in the current directory
|
||||
bool CreateTicket::HasAccess(bool check_root)
|
||||
{
|
||||
if( request->dir_tab.empty() )
|
||||
return false;
|
||||
|
||||
if( request->is_item )
|
||||
return false;
|
||||
|
||||
if( !system->HasWriteAccess(*request->dir_tab.back()) )
|
||||
return false;
|
||||
|
||||
if( !system->mounts.pmount || system->mounts.pmount->type != ticket_info->mount_type_ticket )
|
||||
return false;
|
||||
|
||||
|
||||
// checking for par_createticket_on mount option
|
||||
|
||||
if( !check_root && request->session && request->session->puser && request->session->puser->super_user )
|
||||
// super can create tickets regardless of the createticket_on option
|
||||
return true;
|
||||
|
||||
if( !system->mounts.pmount->IsPar(ticket_info->mount_par_createticket_on) )
|
||||
return true;
|
||||
|
||||
if( system->mounts.pmount->IsArg(ticket_info->mount_par_createticket_on, request->dir_tab.size()) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CreateTicket::HasAccess()
|
||||
{
|
||||
return HasAccess(false);
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
|
||||
request->status = tdb->AddTicket(ticket_info->ticket);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CreateTicket::PostFunCreateTicketLogAndRedirect()
|
||||
{
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
log << log2 << "CreateTicket: added a new ticket" << logend;
|
||||
system->RedirectToLastDir();
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "CreateTicket: problem with adding a new ticket, error code: "
|
||||
<< request->status << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateTicket::MakePost()
|
||||
{
|
||||
functions->ReadItem(request->item, Item::dir);
|
||||
functions->SetUser(request->item);
|
||||
|
||||
ReadTicket read_ticket;
|
||||
read_ticket.Read(system, request, ticket_info, &ticket_info->ticket);
|
||||
|
||||
request->item.privileges = 0777; // !! tymczasowo 777 aby wszyscy mogli wysylac posty
|
||||
|
||||
if( !FunCreateTicketCheckAbuse() )
|
||||
{
|
||||
functions->ReadItemContentWithType(request->item); // for correctly displaying the form
|
||||
return;
|
||||
}
|
||||
|
||||
request->status = system->dirs.AddDirectory(request->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;
|
||||
|
||||
request->status = system->AddFile(request->item);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
AddTicket();
|
||||
}
|
||||
|
||||
PostFunCreateTicketLogAndRedirect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
48
plugins/ticket/createticket.h
Executable file
48
plugins/ticket/createticket.h
Executable file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucontentcreateticket
|
||||
#define headerfilecmslucontentcreateticket
|
||||
|
||||
#include "tdb.h"
|
||||
#include "ticketinfo.h"
|
||||
#include "functions/functionbase.h"
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
|
||||
|
||||
class CreateTicket : public FunctionBase
|
||||
{
|
||||
public:
|
||||
|
||||
CreateTicket();
|
||||
void SetTDb(TDb * ptdb);
|
||||
void SetTicketInfo(TicketInfo * pinfo);
|
||||
|
||||
void Clear();
|
||||
bool HasAccess(bool check_root);
|
||||
bool HasAccess();
|
||||
void MakePost();
|
||||
|
||||
private:
|
||||
|
||||
bool FunCreateTicketCheckAbuse();
|
||||
void AddTicket();
|
||||
void PostFunCreateTicketLogAndRedirect();
|
||||
|
||||
TDb * tdb;
|
||||
TicketInfo * ticket_info;
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
233
plugins/ticket/editticket.cpp
Executable file
233
plugins/ticket/editticket.cpp
Executable file
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "editticket.h"
|
||||
#include "readticket.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
|
||||
EditTicket::EditTicket()
|
||||
{
|
||||
fun.url = "editticket";
|
||||
}
|
||||
|
||||
|
||||
void EditTicket::SetTDb(TDb * ptdb)
|
||||
{
|
||||
tdb = ptdb;
|
||||
}
|
||||
|
||||
|
||||
void EditTicket::SetTicketInfo(TicketInfo * pinfo)
|
||||
{
|
||||
ticket_info = pinfo;
|
||||
}
|
||||
|
||||
|
||||
void EditTicket::Clear()
|
||||
{
|
||||
ticket_info->Clear();
|
||||
}
|
||||
|
||||
|
||||
bool EditTicket::HasAccess()
|
||||
{
|
||||
// not logged users cannot edit tickets
|
||||
if( !request->session->puser )
|
||||
return false;
|
||||
|
||||
if( request->dir_tab.empty() )
|
||||
return false;
|
||||
|
||||
ticket_info->ReadTicket(request->dir_tab.back()->id);
|
||||
|
||||
if( request->is_item || !ticket_info->is_ticket )
|
||||
return false;
|
||||
|
||||
if( !system->HasWriteAccess(*request->dir_tab.back()) )
|
||||
return false;
|
||||
|
||||
if( !system->mounts.pmount || system->mounts.pmount->type != ticket_info->mount_type_ticket )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void EditTicket::EditTicketCheckFirstItem()
|
||||
{
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
|
||||
if( ticket_info->ticket.item_id == -1 )
|
||||
{
|
||||
// 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;
|
||||
item.privileges = 0644; // !! tymczasowo
|
||||
functions->SetUser(item);
|
||||
functions->PrepareUrl(item);
|
||||
|
||||
request->status = db->AddItem(item); // !! moze system->AddFile() tutaj?
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::EditTicketModTicket()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::EditTicketModDir()
|
||||
{
|
||||
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 )
|
||||
{
|
||||
dir.subject = request->item.subject;
|
||||
request->status = db->EditItemById(dir, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EditTicket::EditTicketModFirstItem()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::PostFunEditTicketLogAndRedirect()
|
||||
{
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
log << log2 << "Content: edited a ticket" << logend;
|
||||
system->RedirectToLastDir();
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Content: 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 !!!
|
||||
|
||||
if( !FunCreateTicketCheckAbuse() )
|
||||
{
|
||||
functions->ReadItemContentWithType(request->item); // for correctly displaying the form
|
||||
return;
|
||||
}
|
||||
|
||||
if( tdb->GetTicketByDirId(request->dir_tab.back()->id, ticket_info->ticket) != WINIX_ERR_OK )
|
||||
{
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
}
|
||||
|
||||
EditTicketCheckFirstItem();
|
||||
EditTicketModTicket();
|
||||
EditTicketModDir();
|
||||
EditTicketModFirstItem();
|
||||
PostFunEditTicketLogAndRedirect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::MakeGet()
|
||||
{
|
||||
db->GetItemById(ticket_info->ticket.item_id, request->item);
|
||||
|
||||
// the subject we get from the last directory
|
||||
request->item.subject = request->dir_tab.back()->subject;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace
|
52
plugins/ticket/editticket.h
Executable file
52
plugins/ticket/editticket.h
Executable file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucontenteditticket
|
||||
#define headerfilecmslucontenteditticket
|
||||
|
||||
#include "tdb.h"
|
||||
#include "ticket.h"
|
||||
#include "ticketinfo.h"
|
||||
#include "functions/functionbase.h"
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
|
||||
|
||||
class EditTicket : public FunctionBase
|
||||
{
|
||||
public:
|
||||
|
||||
EditTicket();
|
||||
void SetTDb(TDb * ptdb);
|
||||
void SetTicketInfo(TicketInfo * pinfo);
|
||||
|
||||
void Clear();
|
||||
bool HasAccess();
|
||||
void MakePost();
|
||||
void MakeGet();
|
||||
|
||||
private:
|
||||
|
||||
void EditTicketCheckFirstItem();
|
||||
void EditTicketModTicket();
|
||||
void EditTicketModDir();
|
||||
void EditTicketModFirstItem();
|
||||
void PostFunEditTicketLogAndRedirect();
|
||||
bool FunCreateTicketCheckAbuse();
|
||||
|
||||
TDb * tdb;
|
||||
TicketInfo * ticket_info;
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
97
plugins/ticket/funticket.cpp
Executable file
97
plugins/ticket/funticket.cpp
Executable file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "funticket.h"
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
|
||||
|
||||
|
||||
FunTicket::FunTicket()
|
||||
{
|
||||
fun.url = "ticket";
|
||||
}
|
||||
|
||||
|
||||
void FunTicket::SetTDb(TDb * ptdb)
|
||||
{
|
||||
tdb = ptdb;
|
||||
}
|
||||
|
||||
|
||||
void FunTicket::SetTicketInfo(TicketInfo * pinfo)
|
||||
{
|
||||
ticket_info = pinfo;
|
||||
}
|
||||
|
||||
|
||||
void FunTicket::Clear()
|
||||
{
|
||||
ticket_info->Clear();
|
||||
}
|
||||
|
||||
|
||||
bool FunTicket::HasAccess()
|
||||
{
|
||||
if( request->is_item || system->mounts.pmount->type != ticket_info->mount_type_ticket )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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->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);
|
||||
|
||||
TicketDeleteFirst();
|
||||
system->CheckAccessToItems(request->item_tab);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
45
plugins/ticket/funticket.h
Executable file
45
plugins/ticket/funticket.h
Executable file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucontentticket
|
||||
#define headerfilecmslucontentticket
|
||||
|
||||
#include "tdb.h"
|
||||
#include "ticketinfo.h"
|
||||
#include "core/item.h"
|
||||
#include "functions/functionbase.h"
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
|
||||
|
||||
class FunTicket : public FunctionBase
|
||||
{
|
||||
public:
|
||||
|
||||
FunTicket();
|
||||
void SetTDb(TDb * ptdb);
|
||||
void SetTicketInfo(TicketInfo * pinfo);
|
||||
|
||||
void Clear();
|
||||
bool HasAccess();
|
||||
void MakeGet();
|
||||
|
||||
private:
|
||||
|
||||
void TicketDeleteFirst();
|
||||
TDb * tdb;
|
||||
TicketInfo * ticket_info;
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
101
plugins/ticket/init.cpp
Executable file
101
plugins/ticket/init.cpp
Executable file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tdb.h"
|
||||
#include "funticket.h"
|
||||
#include "editticket.h"
|
||||
#include "createticket.h"
|
||||
#include "core/log.h"
|
||||
#include "core/plugin.h"
|
||||
|
||||
|
||||
extern "C" void Init(PluginInfo &);
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
const char plugin_name[] = "ticket";
|
||||
|
||||
TDb tdb;
|
||||
TicketInfo ticket_info;
|
||||
|
||||
FunTicket fun_ticket;
|
||||
CreateTicket fun_create_ticket;
|
||||
EditTicket fun_edit_ticket;
|
||||
|
||||
|
||||
|
||||
void AddFunctions(PluginInfo & info)
|
||||
{
|
||||
info.functions->Add(fun_ticket);
|
||||
info.functions->Add(fun_create_ticket);
|
||||
info.functions->Add(fun_edit_ticket);
|
||||
}
|
||||
|
||||
|
||||
void SelectDefaultFunction(PluginInfo & info)
|
||||
{
|
||||
if( info.system->mounts.pmount->type == ticket_info.mount_type_ticket )
|
||||
info.request->function = &fun_ticket;
|
||||
}
|
||||
|
||||
|
||||
void AddMounts(PluginInfo & info)
|
||||
{
|
||||
Mounts & m = info.system->mounts;
|
||||
|
||||
ticket_info.mount_type_ticket = m.AddMountType("ticket");
|
||||
ticket_info.mount_par_ticket = m.AddMountPar("ticket");
|
||||
ticket_info.mount_par_ticket_type = m.AddMountPar("ticket_type");
|
||||
ticket_info.mount_par_ticket_type_default = m.AddMountPar("ticket_type_default");
|
||||
ticket_info.mount_par_ticket_status = m.AddMountPar("ticket_status");
|
||||
ticket_info.mount_par_ticket_status_default = m.AddMountPar("ticket_status_default");
|
||||
ticket_info.mount_par_ticket_priority = m.AddMountPar("ticket_priority");
|
||||
ticket_info.mount_par_ticket_priority_default = m.AddMountPar("ticket_priority_default");
|
||||
ticket_info.mount_par_ticket_category = m.AddMountPar("ticket_category");
|
||||
ticket_info.mount_par_ticket_category_default = m.AddMountPar("ticket_category_default");
|
||||
ticket_info.mount_par_ticket_expected = m.AddMountPar("ticket_expected");
|
||||
ticket_info.mount_par_ticket_expected_default = m.AddMountPar("ticket_expected_default");
|
||||
ticket_info.mount_par_createticket_on = m.AddMountPar("createticket_on");
|
||||
}
|
||||
|
||||
|
||||
void AddEzcFunctions(PluginInfo & info);
|
||||
|
||||
} // namespace Ticket
|
||||
|
||||
|
||||
|
||||
void Init(PluginInfo & info)
|
||||
{
|
||||
using namespace Ticket;
|
||||
|
||||
plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions);
|
||||
plugin.Assign(WINIX_CREATE_FUNCTIONS, AddFunctions);
|
||||
plugin.Assign(WINIX_SELECT_DEFAULT_FUNCTION, SelectDefaultFunction);
|
||||
plugin.Assign(WINIX_ADD_MOUNTS, AddMounts);
|
||||
|
||||
tdb.SetConn(info.db->GetConn());
|
||||
|
||||
ticket_info.SetDb(info.db);
|
||||
ticket_info.SetTDb(&tdb);
|
||||
|
||||
fun_ticket.SetTDb(&tdb);
|
||||
fun_ticket.SetTicketInfo(&ticket_info);
|
||||
|
||||
fun_edit_ticket.SetTDb(&tdb);
|
||||
fun_edit_ticket.SetTicketInfo(&ticket_info);
|
||||
|
||||
fun_create_ticket.SetTDb(&tdb);
|
||||
fun_create_ticket.SetTicketInfo(&ticket_info);
|
||||
|
||||
info.p1 = (void*)plugin_name;
|
||||
}
|
||||
|
||||
|
129
plugins/ticket/readticket.cpp
Executable file
129
plugins/ticket/readticket.cpp
Executable file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* 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
|
48
plugins/ticket/readticket.h
Executable file
48
plugins/ticket/readticket.h
Executable file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucontentreadticket
|
||||
#define headerfilecmslucontentreadticket
|
||||
|
||||
#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
|
293
plugins/ticket/tdb.cpp
Executable file
293
plugins/ticket/tdb.cpp
Executable file
@@ -0,0 +1,293 @@
|
||||
|
||||
|
||||
#include "tdb.h"
|
||||
#include "core/log.h"
|
||||
//#include "core/misc.h"
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
|
||||
|
||||
|
||||
Error TDb::GetTicketByDirId(long dir_id, Ticket & ticket)
|
||||
{
|
||||
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.dir_id=") << dir_id << R(";");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_TUPLES_OK);
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
for(int i=0 ; i<rows ; ++i)
|
||||
{
|
||||
tc.SetTicket(r, i, ticket);
|
||||
ticket_tab.push_back(ticket);
|
||||
}
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
status = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
bool TDb::IsTicket(long dir_id)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
bool is_ticket = false;
|
||||
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << "select ticket.id from core.ticket "
|
||||
"where ticket.dir_id = '" << dir_id << "';";
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_TUPLES_OK);
|
||||
|
||||
is_ticket = (Rows(r) == 1);
|
||||
}
|
||||
catch(const Error &)
|
||||
{
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
return is_ticket;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
Error TDb::AddTicket(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");
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
status = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Error TDb::EditTicketById(Ticket & ticket)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error status = WINIX_ERR_OK;
|
||||
|
||||
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(";");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_COMMAND_OK);
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
status = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
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)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error status = WINIX_ERR_OK;
|
||||
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R("delete from core.ticket where dir_id=") << dir_id << R(";");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_COMMAND_OK);
|
||||
|
||||
long rows = AffectedRows(r);
|
||||
|
||||
if( rows > 0 )
|
||||
log << log2 << "Db: deleted " << rows << " rows from core.ticket" << logend;
|
||||
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
status = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
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
|
||||
|
60
plugins/ticket/tdb.h
Executable file
60
plugins/ticket/tdb.h
Executable file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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_tdb
|
||||
#define headerfile_winix_plugins_ticket_tdb
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include "ticket.h"
|
||||
#include "db/dbbase.h"
|
||||
#include "core/error.h"
|
||||
|
||||
|
||||
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 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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
#endif
|
||||
|
650
plugins/ticket/ticket.cpp
Executable file
650
plugins/ticket/ticket.cpp
Executable file
@@ -0,0 +1,650 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ezc.h"
|
||||
#include "ticketinfo.h"
|
||||
#include "editticket.h"
|
||||
#include "createticket.h"
|
||||
#include "core/request.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/plugin.h"
|
||||
#include "functions/functions.h"
|
||||
#include "templates/templates.h"
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
using Ezc::Info;
|
||||
using namespace TemplatesFunctions;
|
||||
using TemplatesFunctions::system;
|
||||
|
||||
extern TicketInfo ticket_info;
|
||||
extern CreateTicket fun_create_ticket;
|
||||
extern EditTicket fun_edit_ticket;
|
||||
|
||||
|
||||
|
||||
|
||||
int ticket_calc_progress_image_number(int percent)
|
||||
{
|
||||
percent = int( double(percent) / 10.0 + 0.5 ) * 10;
|
||||
|
||||
if( percent < 0 )
|
||||
percent = 0;
|
||||
|
||||
if( percent > 100 )
|
||||
percent = 100;
|
||||
|
||||
return percent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ticket_is(Info & i)
|
||||
{
|
||||
i.res = ticket_info.is_ticket;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ticket_item_content(Info & i)
|
||||
{
|
||||
HtmlEscape(i.out, ticket_info.item.content);
|
||||
}
|
||||
|
||||
|
||||
void ticket_item_content_type_is(Info & i)
|
||||
{
|
||||
item_content_type_is(ticket_info.item, i);
|
||||
}
|
||||
|
||||
|
||||
void ticket_item_print_content(Info & i)
|
||||
{
|
||||
item_print_content(i.out, ticket_info.item.content, ticket_info.item.content_type);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ticket_can_create(Info & i)
|
||||
{
|
||||
i.res = fun_create_ticket.HasAccess(true);
|
||||
}
|
||||
|
||||
|
||||
void ticket_can_edit(Info & i)
|
||||
{
|
||||
i.res = fun_edit_ticket.HasAccess();
|
||||
}
|
||||
|
||||
|
||||
void ticket_type(Info & i)
|
||||
{
|
||||
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]);
|
||||
}
|
||||
|
||||
|
||||
void ticket_status(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]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ticket_progress(Info & i)
|
||||
{
|
||||
i.out << ticket_info.ticket.progress;
|
||||
}
|
||||
|
||||
|
||||
void ticket_progress_image_number(Info & i)
|
||||
{
|
||||
int percent = ticket_info.ticket.progress;
|
||||
i.out << ticket_calc_progress_image_number(percent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
static size_t ticket_tab_index;
|
||||
|
||||
|
||||
|
||||
void ticket_tab(Info & i)
|
||||
{
|
||||
ticket_tab_index = i.iter;
|
||||
|
||||
i.res = ticket_tab_index < ticket_info.ticket_tab.size();
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_url(Info & i)
|
||||
{
|
||||
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 )
|
||||
{
|
||||
HtmlEscape(i.out, dir->url);
|
||||
}
|
||||
else
|
||||
{
|
||||
i.out << "<!-- unknown directory -->";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_subject(Info & i)
|
||||
{
|
||||
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 )
|
||||
{
|
||||
if( !dir->subject.empty() )
|
||||
HtmlEscape(i.out, dir->subject);
|
||||
else
|
||||
HtmlEscape(i.out, dir->url);
|
||||
}
|
||||
else
|
||||
{
|
||||
i.out << "<!-- unknown subject -->";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_subject_empty(Info & i)
|
||||
{
|
||||
i.res = 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 )
|
||||
i.res = dir->subject.empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
Ezc::Functions * fun = reinterpret_cast<Ezc::Functions*>(info.p1);
|
||||
|
||||
fun->Insert("ticket_is", ticket_is);
|
||||
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("ticket_type", ticket_type);
|
||||
fun->Insert("ticket_status", ticket_status);
|
||||
fun->Insert("ticket_priority", ticket_priority);
|
||||
fun->Insert("ticket_category", ticket_category);
|
||||
fun->Insert("ticket_expected", ticket_expected);
|
||||
fun->Insert("ticket_progress", ticket_progress);
|
||||
fun->Insert("ticket_progress_image_number", ticket_progress_image_number);
|
||||
|
||||
fun->Insert("ticket_tab", ticket_tab);
|
||||
fun->Insert("ticket_tab_url", ticket_tab_url);
|
||||
fun->Insert("ticket_tab_subject", ticket_tab_subject);
|
||||
fun->Insert("ticket_tab_subject_empty", ticket_tab_subject_empty);
|
||||
fun->Insert("ticket_tab_author", ticket_tab_author);
|
||||
fun->Insert("ticket_tab_type", ticket_tab_type);
|
||||
fun->Insert("ticket_tab_status", ticket_tab_status);
|
||||
fun->Insert("ticket_tab_priority", ticket_tab_priority);
|
||||
fun->Insert("ticket_tab_category", ticket_tab_category);
|
||||
fun->Insert("ticket_tab_expected", ticket_tab_expected);
|
||||
fun->Insert("ticket_tab_progress", ticket_tab_progress);
|
||||
fun->Insert("ticket_tab_progress_image_number",ticket_tab_progress_image_number);
|
||||
|
||||
fun->Insert("ticket_type_tab", ticket_type_tab);
|
||||
fun->Insert("ticket_type_tab_defined", ticket_type_tab_defined);
|
||||
fun->Insert("ticket_type_tab_isdefault", ticket_type_tab_isdefault);
|
||||
fun->Insert("ticket_type_tab_index", ticket_type_tab_index);
|
||||
fun->Insert("ticket_type_tab_name", ticket_type_tab_name);
|
||||
|
||||
fun->Insert("ticket_status_tab", ticket_status_tab);
|
||||
fun->Insert("ticket_status_tab_defined", ticket_status_tab_defined);
|
||||
fun->Insert("ticket_status_tab_isdefault", ticket_status_tab_isdefault);
|
||||
fun->Insert("ticket_status_tab_index", ticket_status_tab_index);
|
||||
fun->Insert("ticket_status_tab_name", ticket_status_tab_name);
|
||||
|
||||
fun->Insert("ticket_priority_tab", ticket_priority_tab);
|
||||
fun->Insert("ticket_priority_tab_defined", ticket_priority_tab_defined);
|
||||
fun->Insert("ticket_priority_tab_isdefault", ticket_priority_tab_isdefault);
|
||||
fun->Insert("ticket_priority_tab_index", ticket_priority_tab_index);
|
||||
fun->Insert("ticket_priority_tab_name", ticket_priority_tab_name);
|
||||
|
||||
fun->Insert("ticket_category_tab", ticket_category_tab);
|
||||
fun->Insert("ticket_category_tab_defined", ticket_category_tab_defined);
|
||||
fun->Insert("ticket_category_tab_isdefault", ticket_category_tab_isdefault);
|
||||
fun->Insert("ticket_category_tab_index", ticket_category_tab_index);
|
||||
fun->Insert("ticket_category_tab_name", ticket_category_tab_name);
|
||||
|
||||
fun->Insert("ticket_expected_tab", ticket_expected_tab);
|
||||
fun->Insert("ticket_expected_tab_defined", ticket_expected_tab_defined);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Ticket
|
||||
|
||||
|
||||
|
62
plugins/ticket/ticket.h
Executable file
62
plugins/ticket/ticket.h
Executable file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_plugins_ticket_ticket
|
||||
#define headerfile_winix_plugins_ticket_ticket
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
|
||||
struct Ticket
|
||||
{
|
||||
long id;
|
||||
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;
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Ticket()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
#endif
|
48
plugins/ticket/ticketinfo.cpp
Executable file
48
plugins/ticket/ticketinfo.cpp
Executable file
@@ -0,0 +1,48 @@
|
||||
#include "ticketinfo.h"
|
||||
#include "core/error.h"
|
||||
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
|
||||
|
||||
|
||||
TicketInfo::TicketInfo()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void TicketInfo::SetTDb(TDb * ptdb)
|
||||
{
|
||||
tdb = ptdb;
|
||||
}
|
||||
|
||||
|
||||
void TicketInfo::SetDb(Db * pdb)
|
||||
{
|
||||
db = pdb;
|
||||
}
|
||||
|
||||
|
||||
void TicketInfo::Clear()
|
||||
{
|
||||
item.Clear();
|
||||
is_ticket = false;
|
||||
ticket.Clear();
|
||||
ticket_tab.clear();
|
||||
}
|
||||
|
||||
|
||||
void TicketInfo::ReadTicket(long dir_id)
|
||||
{
|
||||
if( tdb->GetTicketByDirId(dir_id, ticket) == WINIX_ERR_OK )
|
||||
{
|
||||
is_ticket = true;
|
||||
db->GetItemById(ticket.item_id, item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
61
plugins/ticket/ticketinfo.h
Executable file
61
plugins/ticket/ticketinfo.h
Executable file
@@ -0,0 +1,61 @@
|
||||
#ifndef headerfilecmslucontenteditticket222
|
||||
#define headerfilecmslucontenteditticket222
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include "ticket.h"
|
||||
#include "core/item.h"
|
||||
#include "db/db.h"
|
||||
#include "tdb.h"
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
|
||||
|
||||
class TicketInfo
|
||||
{
|
||||
public:
|
||||
|
||||
TicketInfo();
|
||||
|
||||
void SetTDb(TDb * ptdb);
|
||||
void SetDb(Db * pdb);
|
||||
|
||||
void Clear();
|
||||
void ReadTicket(long dir_id);
|
||||
|
||||
|
||||
Item item;
|
||||
bool is_ticket;
|
||||
Ticket ticket;
|
||||
std::vector<Ticket> ticket_tab;
|
||||
|
||||
int mount_type_ticket;
|
||||
|
||||
int mount_par_ticket;
|
||||
int mount_par_ticket_type;
|
||||
int mount_par_ticket_type_default;
|
||||
int mount_par_ticket_status;
|
||||
int mount_par_ticket_status_default;
|
||||
int mount_par_ticket_priority;
|
||||
int mount_par_ticket_priority_default;
|
||||
int mount_par_ticket_category;
|
||||
int mount_par_ticket_category_default;
|
||||
int mount_par_ticket_expected;
|
||||
int mount_par_ticket_expected_default;
|
||||
|
||||
int mount_par_createticket_on;
|
||||
|
||||
private:
|
||||
TDb * tdb;
|
||||
Db * db;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user