added: to templates: an interface for getting information from Space
miscspace.h, miscspace.cpp changed: plugin ticket now as a config we use a PT::Space struct (not finished yet, only 'integer', 'select' and 'progress' are done) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@794 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
b2d3ca9543
commit
424618de38
22
core/log.cpp
22
core/log.cpp
|
@ -233,6 +233,28 @@ Log & Log::operator<<(double s)
|
|||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(const PT::Space * s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(const PT::Space & s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(LogManipulators m)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
@ -43,8 +43,11 @@ public:
|
|||
Log & operator<<(wchar_t s);
|
||||
Log & operator<<(size_t s);
|
||||
Log & operator<<(double s);
|
||||
Log & operator<<(const PT::Space * space);
|
||||
Log & operator<<(const PT::Space & space);
|
||||
Log & operator<<(LogManipulators m);
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void LogString(const StringType & value, size_t max_size);
|
||||
|
||||
|
|
|
@ -382,7 +382,10 @@ size_t Plugin::Size()
|
|||
}
|
||||
|
||||
|
||||
|
||||
// !! to nie jest dobre rozwiazanie
|
||||
// obsluga jednego komunikatu moze wywolac inny komunikat
|
||||
// i zmienne sie nadpisza
|
||||
// potrzebujemy cos ala stos wywolan
|
||||
int Plugin::True()
|
||||
{
|
||||
return ret_true;
|
||||
|
|
10
db/db.cpp
10
db/db.cpp
|
@ -245,7 +245,7 @@ Error Db::AddItemIntoItem(Item & item)
|
|||
query.Clear();
|
||||
query << R("insert into core.item (user_id, modification_user_id, group_id, privileges, "
|
||||
"date_creation, date_modification, type, parent_id, content_id, "
|
||||
"link_to, link_redirect, subject, guest_name, template, sort_index, url) values (")
|
||||
"link_to, link_redirect, subject, guest_name, template, sort_index, meta, url) values (")
|
||||
<< item.user_id
|
||||
<< item.modification_user_id
|
||||
<< item.group_id
|
||||
|
@ -260,7 +260,8 @@ Error Db::AddItemIntoItem(Item & item)
|
|||
<< item.subject
|
||||
<< item.guest_name
|
||||
<< item.html_template
|
||||
<< item.sort_index;
|
||||
<< item.sort_index
|
||||
<< item.meta;
|
||||
|
||||
url_without_id = AddItemCreateUrlSubject(item);
|
||||
|
||||
|
@ -402,7 +403,7 @@ Error Db::EditItemInItem(Item & item, bool with_url)
|
|||
query.Clear();
|
||||
query << R("update core.item set (user_id, modification_user_id, group_id, privileges, "
|
||||
"date_creation, date_modification, type, link_to, link_redirect, parent_id, subject, "
|
||||
"guest_name, template, sort_index");
|
||||
"guest_name, template, sort_index, meta");
|
||||
|
||||
if( with_url )
|
||||
query << R(", url");
|
||||
|
@ -421,7 +422,8 @@ Error Db::EditItemInItem(Item & item, bool with_url)
|
|||
<< item.subject
|
||||
<< item.guest_name
|
||||
<< item.html_template
|
||||
<< item.sort_index;
|
||||
<< item.sort_index
|
||||
<< item.meta;
|
||||
|
||||
if( with_url )
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
<td>
|
||||
|
||||
[if ticket_tab_is_select]
|
||||
[if ticket_tab_type_is "select"]
|
||||
<select name="ticketparam[ticket_tab_param_id]">
|
||||
[for ticket_tab_select_tab]
|
||||
<option [if ticket_tab_select_tab_is_selected]selected [end]value="[ticket_tab_select_tab_id]">[ticket_tab_select_tab_name]</option>
|
||||
|
@ -39,17 +39,17 @@
|
|||
[end]
|
||||
|
||||
|
||||
[if-one ticket_tab_is_integer ticket_tab_is_progress ticket_tab_is_string]
|
||||
[if-one ticket_tab_type_is "integer" ticket_tab_type_is "progress" ticket_tab_type_is "string"]
|
||||
<input type="text" name="ticketparam[ticket_tab_param_id]" value="[ticket_tab_value]">
|
||||
[end]
|
||||
|
||||
|
||||
[if ticket_tab_is_multistring]
|
||||
[if ticket_tab_type_is "multistring"]
|
||||
<textarea name="ticketparam[ticket_tab_param_id]">[ticket_tab_value]</textarea>
|
||||
[end]
|
||||
|
||||
|
||||
[if ticket_tab_is_images]
|
||||
[if ticket_tab_type_is "images"]
|
||||
[for ticket_tab_files_tab]
|
||||
<img src="[doc_base_url][ticket_tab_value]/-/thumb" alt="[ticket_tab_value]" height="150">
|
||||
[end]
|
||||
|
@ -59,7 +59,7 @@
|
|||
[end]
|
||||
|
||||
|
||||
[if ticket_tab_is_files]
|
||||
[if ticket_tab_type_is "files"]
|
||||
[for ticket_tab_files_tab]
|
||||
<a href="[doc_base_url][ticket_tab_value]/download">[ticket_tab_value]</a>
|
||||
[end]
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<tr>
|
||||
<th>{tickets_header_name}</th>
|
||||
[for ticket_tab]
|
||||
[if-any-no ticket_tab_is_images ticket_tab_is_files]
|
||||
[if-any-no ticket_tab_type_is "images" ticket_tab_type_is "files"]
|
||||
<th>[ticket_tab_param_name]</th>
|
||||
[end]
|
||||
[end]
|
||||
|
@ -31,8 +31,8 @@
|
|||
<tr>
|
||||
<td class="tickettabtitle"><a href="[doc_base_url][dir][tickets_tab_url]">[if-no tickets_tab_subject_empty][tickets_tab_subject][else]<[tickets_tab_url]>[end]</a></td>
|
||||
[for tickets_tab_conf_tab]
|
||||
[if-any-no tickets_tab_conf_tab_is_images tickets_tab_conf_tab_is_files]
|
||||
[if tickets_tab_conf_tab_is_progress]
|
||||
[if-any-no tickets_tab_conf_tab_type_is "images" tickets_tab_conf_tab_type_is "files"]
|
||||
[if tickets_tab_conf_tab_type_is "progress"]
|
||||
<td><img src="[doc_base_url_common]/{ticket_progress_image_path}/progress_[tickets_tab_conf_tab_progress_image_number].gif" alt="progress [tickets_tab_conf_tab_value]%"></td>
|
||||
[else]
|
||||
<td>[tickets_tab_conf_tab_value]</td>
|
||||
|
|
|
@ -11,19 +11,19 @@
|
|||
<th>[filter fil_firstup][ticket_tab_param_name]:[end]</th>
|
||||
<td>
|
||||
|
||||
[if ticket_tab_is_images]
|
||||
[if ticket_tab_type_is "images"]
|
||||
[for ticket_tab_files_tab]
|
||||
<a href="[doc_base_url][ticket_tab_value]" rel="lightbox\[a\]" class="picture"><img src="[doc_base_url][ticket_tab_value]/-/thumb" alt="[ticket_tab_value]" height="150"></a>
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[if ticket_tab_is_files]
|
||||
[if ticket_tab_type_is "files"]
|
||||
[for ticket_tab_files_tab]
|
||||
<a href="[doc_base_url][ticket_tab_value]/download">[ticket_tab_value]</a>
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[if-any-no ticket_tab_is_images ticket_tab_is_files]
|
||||
[if-any-no ticket_tab_type_is "images" ticket_tab_type_is "files"]
|
||||
[ticket_tab_value]
|
||||
[end]
|
||||
|
||||
|
|
|
@ -32,8 +32,7 @@ createticket.o: ../../core/crypt.h ../../core/run.h ../../core/users.h
|
|||
createticket.o: ../../core/groups.h ../../core/group.h ../../core/loadavg.h
|
||||
createticket.o: ../../core/image.h ../../core/basethread.h
|
||||
createticket.o: ../../core/threadmanager.h ../../core/synchro.h ticketinfo.h
|
||||
createticket.o: ticketparser.h ticketconf.h ../../functions/functions.h
|
||||
createticket.o: ../../functions/functionbase.h
|
||||
createticket.o: ../../functions/functions.h ../../functions/functionbase.h
|
||||
createticket.o: ../../functions/functionparser.h ../../core/cur.h
|
||||
createticket.o: ../../functions/adduser.h ../../functions/cat.h
|
||||
createticket.o: ../../functions/chmod.h ../../functions/privchanger.h
|
||||
|
@ -58,18 +57,17 @@ createticket.o: ../../core/plugindata.h ../../functions/rm.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/misc.h ../../core/item.h ../../core/requesttypes.h
|
||||
editticket.o: ../../core/error.h ticketinfo.h ticketparser.h ticketconf.h
|
||||
editticket.o: ../../core/item.h ../../core/system.h ../../core/dirs.h
|
||||
editticket.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h
|
||||
editticket.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h
|
||||
editticket.o: ../../core/user.h ../../core/group.h ../../core/dircontainer.h
|
||||
editticket.o: ../../core/ugcontainer.h ../../core/log.h
|
||||
editticket.o: ../../core/textstream.h ../../core/logmanipulators.h
|
||||
editticket.o: ../../core/slog.h ../../core/cur.h ../../core/request.h
|
||||
editticket.o: ../../core/error.h ../../core/config.h ../../core/htmlfilter.h
|
||||
editticket.o: ../../templates/htmltextstream.h ../../core/session.h
|
||||
editticket.o: ../../core/user.h ../../core/plugindata.h ../../core/rebus.h
|
||||
editticket.o: ../../core/mount.h ../../templates/locale.h
|
||||
editticket.o: ../../core/error.h ticketinfo.h ../../core/item.h
|
||||
editticket.o: ../../core/system.h ../../core/dirs.h ../../core/dircontainer.h
|
||||
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/dircontainer.h ../../core/ugcontainer.h
|
||||
editticket.o: ../../core/log.h ../../core/textstream.h
|
||||
editticket.o: ../../core/logmanipulators.h ../../core/slog.h ../../core/cur.h
|
||||
editticket.o: ../../core/request.h ../../core/error.h ../../core/config.h
|
||||
editticket.o: ../../core/htmlfilter.h ../../templates/htmltextstream.h
|
||||
editticket.o: ../../core/session.h ../../core/user.h ../../core/plugindata.h
|
||||
editticket.o: ../../core/rebus.h ../../core/mount.h ../../templates/locale.h
|
||||
editticket.o: ../../notify/notify.h ../../notify/notifypool.h
|
||||
editticket.o: ../../templates/patterns.h ../../templates/locale.h
|
||||
editticket.o: ../../templates/localefilter.h ../../../ezc/src/ezc.h
|
||||
|
@ -111,18 +109,17 @@ editticket.o: ../../functions/rm.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/misc.h ../../core/item.h ../../core/requesttypes.h
|
||||
funticket.o: ../../core/error.h ticketinfo.h ticketparser.h ticketconf.h
|
||||
funticket.o: ../../core/item.h ../../core/system.h ../../core/dirs.h
|
||||
funticket.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h
|
||||
funticket.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h
|
||||
funticket.o: ../../core/user.h ../../core/group.h ../../core/dircontainer.h
|
||||
funticket.o: ../../core/ugcontainer.h ../../core/log.h
|
||||
funticket.o: ../../core/textstream.h ../../core/logmanipulators.h
|
||||
funticket.o: ../../core/slog.h ../../core/cur.h ../../core/request.h
|
||||
funticket.o: ../../core/error.h ../../core/config.h ../../core/htmlfilter.h
|
||||
funticket.o: ../../templates/htmltextstream.h ../../core/session.h
|
||||
funticket.o: ../../core/user.h ../../core/plugindata.h ../../core/rebus.h
|
||||
funticket.o: ../../core/mount.h ../../templates/locale.h
|
||||
funticket.o: ../../core/error.h ticketinfo.h ../../core/item.h
|
||||
funticket.o: ../../core/system.h ../../core/dirs.h ../../core/dircontainer.h
|
||||
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/dircontainer.h ../../core/ugcontainer.h
|
||||
funticket.o: ../../core/log.h ../../core/textstream.h
|
||||
funticket.o: ../../core/logmanipulators.h ../../core/slog.h ../../core/cur.h
|
||||
funticket.o: ../../core/request.h ../../core/error.h ../../core/config.h
|
||||
funticket.o: ../../core/htmlfilter.h ../../templates/htmltextstream.h
|
||||
funticket.o: ../../core/session.h ../../core/user.h ../../core/plugindata.h
|
||||
funticket.o: ../../core/rebus.h ../../core/mount.h ../../templates/locale.h
|
||||
funticket.o: ../../notify/notify.h ../../notify/notifypool.h
|
||||
funticket.o: ../../templates/patterns.h ../../templates/locale.h
|
||||
funticket.o: ../../templates/localefilter.h ../../../ezc/src/ezc.h
|
||||
|
@ -168,33 +165,33 @@ funticket.o: ../../core/sessionmanager.h ../../plugins/thread/pluginmsg.h
|
|||
init.o: tdb.h ticket.h ../../db/dbbase.h ../../db/dbconn.h
|
||||
init.o: ../../db/dbtextstream.h ../../core/textstream.h ../../core/misc.h
|
||||
init.o: ../../core/item.h ../../core/requesttypes.h ../../core/error.h
|
||||
init.o: funticket.h ticketinfo.h ticketparser.h ticketconf.h
|
||||
init.o: ../../core/item.h ../../core/system.h ../../core/dirs.h
|
||||
init.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h
|
||||
init.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h ../../core/user.h
|
||||
init.o: ../../core/group.h ../../core/dircontainer.h ../../core/ugcontainer.h
|
||||
init.o: ../../core/log.h ../../core/textstream.h ../../core/logmanipulators.h
|
||||
init.o: ../../core/slog.h ../../core/cur.h ../../core/request.h
|
||||
init.o: ../../core/error.h ../../core/config.h ../../core/htmlfilter.h
|
||||
init.o: ../../templates/htmltextstream.h ../../core/session.h
|
||||
init.o: ../../core/user.h ../../core/plugindata.h ../../core/rebus.h
|
||||
init.o: ../../core/mount.h ../../templates/locale.h ../../notify/notify.h
|
||||
init.o: ../../notify/notifypool.h ../../templates/patterns.h
|
||||
init.o: ../../templates/locale.h ../../templates/localefilter.h
|
||||
init.o: ../../../ezc/src/ezc.h ../../../ezc/src/generator.h
|
||||
init.o: ../../../ezc/src/pattern.h ../../../ezc/src/functions.h
|
||||
init.o: ../../../ezc/src/funinfo.h ../../../ezc/src/stringconv.h
|
||||
init.o: ../../notify/notifythread.h ../../core/basethread.h
|
||||
init.o: ../../core/synchro.h ../../notify/templatesnotify.h
|
||||
init.o: ../../core/config.h ../../core/users.h ../../core/ugcontainer.h
|
||||
init.o: ../../core/lastcontainer.h ../../templates/misc.h
|
||||
init.o: ../../templates/htmltextstream.h ../../core/mounts.h
|
||||
init.o: ../../core/mountparser.h ../../core/crypt.h ../../core/run.h
|
||||
init.o: ../../core/users.h ../../core/groups.h ../../core/group.h
|
||||
init.o: ../../core/loadavg.h ../../core/image.h ../../core/basethread.h
|
||||
init.o: ../../core/threadmanager.h ../../functions/functions.h
|
||||
init.o: ../../functions/functionbase.h ../../functions/functionparser.h
|
||||
init.o: ../../core/cur.h ../../functions/adduser.h ../../functions/cat.h
|
||||
init.o: funticket.h ticketinfo.h ../../core/item.h ../../core/system.h
|
||||
init.o: ../../core/dirs.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/dircontainer.h
|
||||
init.o: ../../core/ugcontainer.h ../../core/log.h ../../core/textstream.h
|
||||
init.o: ../../core/logmanipulators.h ../../core/slog.h ../../core/cur.h
|
||||
init.o: ../../core/request.h ../../core/error.h ../../core/config.h
|
||||
init.o: ../../core/htmlfilter.h ../../templates/htmltextstream.h
|
||||
init.o: ../../core/session.h ../../core/user.h ../../core/plugindata.h
|
||||
init.o: ../../core/rebus.h ../../core/mount.h ../../templates/locale.h
|
||||
init.o: ../../notify/notify.h ../../notify/notifypool.h
|
||||
init.o: ../../templates/patterns.h ../../templates/locale.h
|
||||
init.o: ../../templates/localefilter.h ../../../ezc/src/ezc.h
|
||||
init.o: ../../../ezc/src/generator.h ../../../ezc/src/pattern.h
|
||||
init.o: ../../../ezc/src/functions.h ../../../ezc/src/funinfo.h
|
||||
init.o: ../../../ezc/src/stringconv.h ../../notify/notifythread.h
|
||||
init.o: ../../core/basethread.h ../../core/synchro.h
|
||||
init.o: ../../notify/templatesnotify.h ../../core/config.h ../../core/users.h
|
||||
init.o: ../../core/ugcontainer.h ../../core/lastcontainer.h
|
||||
init.o: ../../templates/misc.h ../../templates/htmltextstream.h
|
||||
init.o: ../../core/mounts.h ../../core/mountparser.h ../../core/crypt.h
|
||||
init.o: ../../core/run.h ../../core/users.h ../../core/groups.h
|
||||
init.o: ../../core/group.h ../../core/loadavg.h ../../core/image.h
|
||||
init.o: ../../core/basethread.h ../../core/threadmanager.h
|
||||
init.o: ../../functions/functions.h ../../functions/functionbase.h
|
||||
init.o: ../../functions/functionparser.h ../../core/cur.h
|
||||
init.o: ../../functions/adduser.h ../../functions/cat.h
|
||||
init.o: ../../functions/chmod.h ../../functions/privchanger.h
|
||||
init.o: ../../core/request.h ../../functions/chown.h
|
||||
init.o: ../../functions/ckeditor.h ../../functions/cp.h
|
||||
|
@ -227,8 +224,7 @@ showtickets.o: showtickets.h tdb.h ticket.h ../../db/dbbase.h
|
|||
showtickets.o: ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
showtickets.o: ../../core/textstream.h ../../core/misc.h ../../core/item.h
|
||||
showtickets.o: ../../core/requesttypes.h ../../core/error.h ticketinfo.h
|
||||
showtickets.o: ticketparser.h ticketconf.h ../../core/item.h
|
||||
showtickets.o: ../../core/system.h ../../core/dirs.h
|
||||
showtickets.o: ../../core/item.h ../../core/system.h ../../core/dirs.h
|
||||
showtickets.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h
|
||||
showtickets.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h
|
||||
showtickets.o: ../../core/user.h ../../core/group.h ../../core/dircontainer.h
|
||||
|
@ -291,24 +287,24 @@ templates.o: ../../../ezc/src/ezc.h ../../../ezc/src/generator.h
|
|||
templates.o: ../../../ezc/src/pattern.h ../../core/item.h
|
||||
templates.o: ../../../ezc/src/functions.h ../../../ezc/src/funinfo.h
|
||||
templates.o: ../../../ezc/src/stringconv.h ticketinfo.h ticket.h
|
||||
templates.o: ticketparser.h ticketconf.h ../../core/item.h
|
||||
templates.o: ../../core/system.h ../../core/dirs.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/dircontainer.h ../../core/ugcontainer.h
|
||||
templates.o: ../../core/log.h ../../core/textstream.h
|
||||
templates.o: ../../core/logmanipulators.h ../../core/slog.h ../../core/cur.h
|
||||
templates.o: ../../core/request.h ../../core/requesttypes.h
|
||||
templates.o: ../../core/error.h ../../core/config.h ../../core/htmlfilter.h
|
||||
templates.o: ../../templates/htmltextstream.h ../../core/textstream.h
|
||||
templates.o: ../../core/misc.h ../../core/session.h ../../core/user.h
|
||||
templates.o: ../../core/plugindata.h ../../core/rebus.h ../../core/mount.h
|
||||
templates.o: ../../templates/locale.h ../../notify/notify.h
|
||||
templates.o: ../../notify/notifypool.h ../../templates/patterns.h
|
||||
templates.o: ../../templates/locale.h ../../templates/localefilter.h
|
||||
templates.o: ../../notify/notifythread.h ../../core/basethread.h
|
||||
templates.o: ../../core/synchro.h ../../notify/templatesnotify.h
|
||||
templates.o: ../../core/config.h ../../core/users.h ../../core/ugcontainer.h
|
||||
templates.o: ../../core/item.h ../../core/system.h ../../core/dirs.h
|
||||
templates.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h
|
||||
templates.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h
|
||||
templates.o: ../../core/user.h ../../core/group.h ../../core/dircontainer.h
|
||||
templates.o: ../../core/ugcontainer.h ../../core/log.h
|
||||
templates.o: ../../core/textstream.h ../../core/logmanipulators.h
|
||||
templates.o: ../../core/slog.h ../../core/cur.h ../../core/request.h
|
||||
templates.o: ../../core/requesttypes.h ../../core/error.h ../../core/config.h
|
||||
templates.o: ../../core/htmlfilter.h ../../templates/htmltextstream.h
|
||||
templates.o: ../../core/textstream.h ../../core/misc.h ../../core/session.h
|
||||
templates.o: ../../core/user.h ../../core/plugindata.h ../../core/rebus.h
|
||||
templates.o: ../../core/mount.h ../../templates/locale.h
|
||||
templates.o: ../../notify/notify.h ../../notify/notifypool.h
|
||||
templates.o: ../../templates/patterns.h ../../templates/locale.h
|
||||
templates.o: ../../templates/localefilter.h ../../notify/notifythread.h
|
||||
templates.o: ../../core/basethread.h ../../core/synchro.h
|
||||
templates.o: ../../notify/templatesnotify.h ../../core/config.h
|
||||
templates.o: ../../core/users.h ../../core/ugcontainer.h
|
||||
templates.o: ../../core/lastcontainer.h ../../templates/misc.h
|
||||
templates.o: ../../templates/htmltextstream.h ../../core/mounts.h
|
||||
templates.o: ../../core/mountparser.h ../../core/crypt.h ../../core/run.h
|
||||
|
@ -345,12 +341,11 @@ templates.o: ../../templates/patterncacher.h ../../templates/indexpatterns.h
|
|||
templates.o: ../../templates/patterns.h ../../templates/changepatterns.h
|
||||
templates.o: ../../core/sessionmanager.h sessiondata.h
|
||||
templates.o: ../../core/plugindata.h ../../functions/rm.h
|
||||
templates.o: ../../plugins/thread/pluginmsg.h
|
||||
ticketconf.o: ticketconf.h
|
||||
ticketinfo.o: ticketinfo.h ticket.h ticketparser.h ticketconf.h
|
||||
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
|
||||
templates.o: ../../plugins/thread/pluginmsg.h ../../templates/miscspace.h
|
||||
templates.o: ../../templates/templates.h
|
||||
ticketinfo.o: ticketinfo.h ticket.h ../../core/item.h ../../core/system.h
|
||||
ticketinfo.o: ../../core/dirs.h ../../core/item.h ../../core/dircontainer.h
|
||||
ticketinfo.o: ../../db/db.h ../../db/dbbase.h ../../db/dbitemquery.h
|
||||
ticketinfo.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
|
||||
ticketinfo.o: ../../core/dircontainer.h ../../core/ugcontainer.h
|
||||
ticketinfo.o: ../../core/log.h ../../core/textstream.h
|
||||
|
@ -399,5 +394,3 @@ ticketinfo.o: ../../core/htmlfilter.h tdb.h ../../db/dbbase.h
|
|||
ticketinfo.o: ../../db/dbconn.h ../../db/dbtextstream.h ../../core/error.h
|
||||
ticketinfo.o: ../../core/log.h ../../core/misc.h sessiondata.h
|
||||
ticketinfo.o: ../../core/plugindata.h ../../functions/rm.h
|
||||
ticketparser.o: ticketparser.h ticketconf.h ../../core/log.h
|
||||
ticketparser.o: ../../core/misc.h
|
||||
|
|
|
@ -1 +1 @@
|
|||
o = createticket.o editticket.o funticket.o init.o sessiondata.o showtickets.o tdb.o templates.o ticketconf.o ticketinfo.o ticketparser.o
|
||||
o = createticket.o editticket.o funticket.o init.o sessiondata.o showtickets.o tdb.o templates.o ticketinfo.o
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
@ -43,7 +43,7 @@ bool CreateTicket::HasAccess()
|
|||
if( cur->request->is_item || !system->HasWriteAccess(*cur->request->dir_tab.back()) )
|
||||
return false;
|
||||
|
||||
if( !system->mounts.pmount || system->mounts.pmount->type != ticket_info->mount_type_ticket )
|
||||
if( cur->mount->type != ticket_info->mount_type_ticket )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -148,9 +148,10 @@ void CreateTicket::MakePost()
|
|||
Ticket & ticket = PrepareTicket();
|
||||
Item & item = cur->request->item;
|
||||
ticket_info->ticket = &ticket;
|
||||
ticket_info->item = &item;
|
||||
std::vector<long> & file_map = PrepareFileMap();
|
||||
|
||||
ticket_info->ReadTicketParams(ticket, false, &file_map);
|
||||
ticket_info->ReadTicketParams(ticket, false, file_map, item.meta);
|
||||
functions->ReadItem(item, Item::file);
|
||||
|
||||
if( !cur->request->IsPostVar(L"fileuploadsubmit") )
|
||||
|
@ -166,6 +167,7 @@ void CreateTicket::MakeGet()
|
|||
|
||||
Ticket & ticket = PrepareTicket();
|
||||
ticket_info->ticket = &ticket;
|
||||
ticket_info->item = &cur->request->item;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
@ -47,7 +47,7 @@ bool EditTicket::HasAccess()
|
|||
if( !cur->request->is_item || !system->HasWriteAccess(cur->request->item) )
|
||||
return false;
|
||||
|
||||
if( !system->mounts.pmount || system->mounts.pmount->type != ticket_info->mount_type_ticket )
|
||||
if( cur->mount->type != ticket_info->mount_type_ticket )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -98,6 +98,8 @@ void EditTicket::Submit(Ticket & ticket, Item & item)
|
|||
{
|
||||
log << log1 << "EditTicket: problem with editing a ticket, error code: "
|
||||
<< cur->request->status << logend;
|
||||
|
||||
// !! add session log
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +113,7 @@ void EditTicket::RemoveTmpTicket()
|
|||
|
||||
long file_id = cur->request->item.id;
|
||||
session_data->edit_ticket_map.erase(file_id);
|
||||
session_data->new_file_map.erase(file_id);
|
||||
session_data->edit_file_map.erase(file_id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -141,7 +143,7 @@ std::vector<long> & EditTicket::PrepareFileMap()
|
|||
cur->session->plugin_data.Get(ticket_info->plugin_id) );
|
||||
|
||||
long file_id = cur->request->item.id;
|
||||
std::vector<long> & file_map = session_data->GetFileTab(file_id, session_data->new_file_map);
|
||||
std::vector<long> & file_map = session_data->GetFileTab(file_id, session_data->edit_file_map);
|
||||
|
||||
return file_map;
|
||||
}
|
||||
|
@ -149,6 +151,7 @@ return file_map;
|
|||
|
||||
void EditTicket::MakePost()
|
||||
{
|
||||
ticket_info->Clear();
|
||||
ticket_info->FindCurrentConf();
|
||||
|
||||
Ticket & ticket = PrepareTicket();
|
||||
|
@ -156,8 +159,9 @@ void EditTicket::MakePost()
|
|||
old_url = item.url;
|
||||
std::vector<long> & file_map = PrepareFileMap();
|
||||
ticket_info->ticket = &ticket;
|
||||
ticket_info->item = &item;
|
||||
|
||||
ticket_info->ReadTicketParams(ticket, false, &file_map);
|
||||
ticket_info->ReadTicketParams(ticket, false, file_map, item.meta);
|
||||
functions->ReadItem(item, Item::file);
|
||||
|
||||
if( !cur->request->IsPostVar(L"fileuploadsubmit") )
|
||||
|
@ -168,10 +172,12 @@ void EditTicket::MakePost()
|
|||
|
||||
void EditTicket::MakeGet()
|
||||
{
|
||||
ticket_info->Clear();
|
||||
ticket_info->FindCurrentConf();
|
||||
|
||||
Ticket & ticket = PrepareTicket();
|
||||
ticket_info->ticket = &ticket;
|
||||
ticket_info->item = &cur->request->item;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ void FunTicket::MakeGet()
|
|||
ticket_info->Clear();
|
||||
ticket_info->FindCurrentConf();
|
||||
ticket_info->ticket = &ticket;
|
||||
ticket_info->item = &cur->request->item;
|
||||
|
||||
tdb->GetTicket(cur->request->item.id, ticket);
|
||||
|
||||
|
|
|
@ -88,6 +88,9 @@ void ProcessRequest(PluginInfo & info)
|
|||
|
||||
void RemoveTicket(PluginInfo & info)
|
||||
{
|
||||
// !! dodac nowy komunikat PREPERE_TO_REMOVE
|
||||
// i tam korzystajac z meta informacji w item
|
||||
// usunac odpowiednie pliki
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( item )
|
||||
|
|
|
@ -22,7 +22,7 @@ SessionData::SessionData()
|
|||
SessionData::~SessionData()
|
||||
{
|
||||
RemoveFileMap(create_file_map);
|
||||
RemoveFileMap(new_file_map);
|
||||
RemoveFileMap(edit_file_map);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
@ -48,7 +48,7 @@ struct SessionData : public PluginDataBase
|
|||
// temporary files for 'editticket' function
|
||||
// these files should be deleted if a user will not click on the submit button
|
||||
// !! zmienic nazwe na edit_file_map albo podobnie
|
||||
FileMap new_file_map;
|
||||
FileMap edit_file_map;
|
||||
|
||||
|
||||
// inserting and returning a new ticket or just returning the ticket if it exists
|
||||
|
@ -56,7 +56,10 @@ struct SessionData : public PluginDataBase
|
|||
|
||||
std::vector<long> & GetFileTab(long id, FileMap & file_map);
|
||||
|
||||
// for deleting new_file_map files
|
||||
// for deleting edit_file_map files
|
||||
// !! IMPROVE ME: when the program exits there can be a situation that
|
||||
// fun_rm was finished and then an object of this class exits and call fun_rm
|
||||
// so we should guarantee that all sessions object are removed first
|
||||
Fun::Rm * fun_rm;
|
||||
|
||||
void RemoveFileMap(FileMap & file_map);
|
||||
|
|
|
@ -82,6 +82,7 @@ void ShowTickets::ReadFiles()
|
|||
iq.sel_guest_name = true;
|
||||
iq.sel_privileges = true;
|
||||
iq.sel_date = true;
|
||||
iq.sel_meta = true;
|
||||
iq.WhereParentId(cur->request->dir_tab.back()->id);
|
||||
iq.WhereType(Item::file);
|
||||
iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
@ -43,6 +43,24 @@ return is;
|
|||
}
|
||||
|
||||
|
||||
void TDb::SetTicketColumns(PGresult * r)
|
||||
{
|
||||
cfileid = AssertColumn(r, "file_id");
|
||||
cparam = AssertColumn(r, "param");
|
||||
cintv = AssertColumn(r, "intv");
|
||||
cdecv = AssertColumn(r, "decv");
|
||||
}
|
||||
|
||||
|
||||
void TDb::ReadTicketPar(PGresult * r, Ticket::TicketParam & par, int row)
|
||||
{
|
||||
par.Clear();
|
||||
par.param = AssertValueInt(r, row, cparam);
|
||||
par.intv = AssertValueLong(r, row, cintv);
|
||||
AssertValueWide(r, row, cdecv, par.decv); // !! temporarily
|
||||
}
|
||||
|
||||
|
||||
Error TDb::GetTicket(long file_id, Ticket & ticket)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
|
@ -53,33 +71,26 @@ Error TDb::GetTicket(long file_id, Ticket & ticket)
|
|||
{
|
||||
// they should be sorted by param (they are used in a binary search later)
|
||||
query.Clear();
|
||||
query << R("select file_id, param, int_value, str_value from plugins.ticket "
|
||||
query << R("select file_id, param, intv, decv from plugins.ticket "
|
||||
"where ticket.file_id=") << file_id << R(" order by param asc;");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_TUPLES_OK);
|
||||
SetTicketColumns(r);
|
||||
|
||||
int rows = Rows(r);
|
||||
|
||||
if( rows == 0 )
|
||||
throw Error(WINIX_ERR_NO_TICKET);
|
||||
|
||||
Ticket::TicketParam par;
|
||||
ticket.file_id = file_id;
|
||||
|
||||
int cparam = AssertColumn(r, "param");
|
||||
int cintvalue = AssertColumn(r, "int_value");
|
||||
int cstrvalue = AssertColumn(r, "str_value");
|
||||
if( rows == 0 )
|
||||
throw Error(WINIX_ERR_NO_TICKET); // !! do we need this kind or error?
|
||||
|
||||
// !! mozna dodac uzycie ticket.par_tab.reserve()
|
||||
if( ticket.par_tab.capacity() < ticket.par_tab.size() + rows )
|
||||
ticket.par_tab.reserve(ticket.par_tab.size() + rows);
|
||||
|
||||
for(int i=0 ; i<rows ; ++i)
|
||||
{
|
||||
par.param = AssertValueInt(r, i, cparam);
|
||||
par.int_value = AssertValueLong(r, i, cintvalue);
|
||||
AssertValueWide(r, i, cstrvalue, par.str_value);
|
||||
|
||||
ticket.par_tab.push_back(par);
|
||||
ReadTicketPar(r, tic_par, i);
|
||||
ticket.par_tab.push_back(tic_par);
|
||||
}
|
||||
}
|
||||
catch(const Error & e)
|
||||
|
@ -97,11 +108,13 @@ return status;
|
|||
|
||||
|
||||
|
||||
Error TDb::GetTickets(const std::vector<long> & file_id_tab, std::vector<Ticket> & ticket_tab)
|
||||
Error TDb::GetTickets(const std::vector<long> & file_id_tab, std::vector<Ticket> & ticket_tab, bool clear_tab)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error status = WINIX_ERR_OK;
|
||||
ticket_tab.clear();
|
||||
|
||||
if( clear_tab )
|
||||
ticket_tab.clear();
|
||||
|
||||
if( file_id_tab.empty() )
|
||||
return status;
|
||||
|
@ -111,40 +124,30 @@ Error TDb::GetTickets(const std::vector<long> & file_id_tab, std::vector<Ticket>
|
|||
// ticket_tab must be sorted by file_id (they are used in a binary search later)
|
||||
// and items in a ticket should be sorted by param (they are used in a binary search later too)
|
||||
query.Clear();
|
||||
CreateIdList(file_id_tab, file_list);
|
||||
query << R("select file_id, param, int_value, str_value from plugins.ticket "
|
||||
"where ticket.file_id in ") << R(file_list) << R(" order by file_id, param;");
|
||||
|
||||
// !! moze dodac operator <<(std::vector(long)) do query?
|
||||
query << R("select file_id, param, intv, decv from plugins.ticket "
|
||||
"where ticket.file_id in ") << file_id_tab << R(" order by file_id, param;");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_TUPLES_OK);
|
||||
SetTicketColumns(r);
|
||||
|
||||
int rows = Rows(r);
|
||||
Ticket::TicketParam par;
|
||||
|
||||
int cfile_id = AssertColumn(r, "file_id");
|
||||
int cparam = AssertColumn(r, "param");
|
||||
int cintvalue = AssertColumn(r, "int_value");
|
||||
int cstrvalue = AssertColumn(r, "str_value");
|
||||
long last_file_id = -1;
|
||||
empty_ticket.Clear();
|
||||
|
||||
for(int i=0 ; i<rows ; ++i)
|
||||
{
|
||||
long file_id = AssertValueLong(r, i, cfile_id);
|
||||
long file_id = AssertValueLong(r, i, cfileid);
|
||||
|
||||
if( i==0 || last_file_id != file_id )
|
||||
{
|
||||
ticket_tab.push_back(Ticket());
|
||||
ticket_tab.push_back(empty_ticket);
|
||||
ticket_tab.back().file_id = file_id;
|
||||
last_file_id = file_id;
|
||||
}
|
||||
|
||||
par.param = AssertValueInt(r, i, cparam);
|
||||
par.int_value = AssertValueLong(r, i, cintvalue);
|
||||
AssertValueWide(r, i, cstrvalue, par.str_value);
|
||||
|
||||
ticket_tab.back().par_tab.push_back(par);
|
||||
ReadTicketPar(r, tic_par, i);
|
||||
ticket_tab.back().par_tab.push_back(tic_par);
|
||||
}
|
||||
}
|
||||
catch(const Error & e)
|
||||
|
@ -153,7 +156,6 @@ Error TDb::GetTickets(const std::vector<long> & file_id_tab, std::vector<Ticket>
|
|||
}
|
||||
|
||||
ClearResult(r);
|
||||
file_list.clear();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
@ -171,11 +173,11 @@ Error TDb::AddTicket(const Ticket & ticket)
|
|||
for(size_t i=0 ; i<ticket.par_tab.size() ; ++i)
|
||||
{
|
||||
query.Clear();
|
||||
query << R("insert into plugins.ticket (file_id, param, int_value, str_value) values (")
|
||||
query << R("insert into plugins.ticket (file_id, param, intv) values (")
|
||||
<< ticket.file_id
|
||||
<< ticket.par_tab[i].param
|
||||
<< ticket.par_tab[i].int_value
|
||||
<< ticket.par_tab[i].str_value
|
||||
<< ticket.par_tab[i].intv
|
||||
//<< ticket.par_tab[i].decv
|
||||
<< R(");");
|
||||
|
||||
r = AssertQuery(query);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
@ -27,7 +27,7 @@ public:
|
|||
|
||||
bool IsTicket(long file_id);
|
||||
Error GetTicket(long file_id, Ticket & ticket);
|
||||
Error GetTickets(const std::vector<long> & file_id_tab, std::vector<Ticket> & ticket_tab);
|
||||
Error GetTickets(const std::vector<long> & file_id_tab, std::vector<Ticket> & ticket_tab, bool clear_tab = true);
|
||||
Error AddTicket(const Ticket & ticket);
|
||||
Error RemoveAddTicket(const Ticket & ticket); // first removing and then adding a ticket
|
||||
Error RemoveTicket(long file_id);
|
||||
|
@ -36,7 +36,16 @@ public:
|
|||
private:
|
||||
|
||||
DbTextStream query;
|
||||
std::wstring file_list;
|
||||
Ticket empty_ticket;
|
||||
Ticket::TicketParam tic_par;
|
||||
|
||||
int cfileid;
|
||||
int cparam;
|
||||
int cintv;
|
||||
int cdecv;
|
||||
|
||||
void SetTicketColumns(PGresult * r);
|
||||
void ReadTicketPar(PGresult * r, Ticket::TicketParam & par, int row);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
@ -18,7 +18,8 @@
|
|||
#include "templates/templates.h"
|
||||
#include "sessiondata.h"
|
||||
#include "plugins/thread/pluginmsg.h"
|
||||
|
||||
#include "templates/miscspace.h"
|
||||
#include "confparser/space.h"
|
||||
|
||||
|
||||
namespace Ticket
|
||||
|
@ -47,10 +48,31 @@ return percent;
|
|||
}
|
||||
|
||||
|
||||
PT::Space & find_add_meta_for_param(PT::Space & meta, long param_id)
|
||||
{
|
||||
for(size_t i=0 ; i<meta.spaces.size() ; ++i)
|
||||
{
|
||||
PT::Space & sp = *meta.spaces[i];
|
||||
|
||||
// !! moze lepiej najpierw zamienic na string i pozniej tylko stringi porownywac (performance)
|
||||
|
||||
if( sp.name == L"param" && sp.Long(L"id") == param_id )
|
||||
{
|
||||
return sp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PT::Space & sp = meta.AddSpace(L"param");
|
||||
sp.Add(L"id", param_id);
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// binary search for param in ticket.par_tab (ticket.par_tab must be sorted by 'param')
|
||||
// !! zmienic nazwe na find_ticket_param
|
||||
bool find_ticket_value(long param, const Ticket & ticket, size_t & ticket_par_index)
|
||||
bool find_ticket_param(long param, const Ticket & ticket, size_t & ticket_par_index)
|
||||
{
|
||||
if( ticket.par_tab.empty() )
|
||||
return false;
|
||||
|
@ -69,6 +91,8 @@ bool find_ticket_value(long param, const Ticket & ticket, size_t & ticket_par_in
|
|||
|
||||
if( ticket.par_tab[o2].param == param )
|
||||
{
|
||||
// looking for the first param
|
||||
// (there can be more params with the same 'param' value)
|
||||
while( o2 > 0 && ticket.par_tab[o2-1].param == param )
|
||||
--o2;
|
||||
|
||||
|
@ -105,36 +129,38 @@ return false;
|
|||
|
||||
|
||||
|
||||
void ticket_print_value(Info & i, size_t conf_index, const Ticket::TicketParam & ticket_param)
|
||||
void ticket_print_value(Info & i, PT::Space & space, const Ticket::TicketParam & ticket_param, PT::Space & meta)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
{
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_index];
|
||||
std::wstring & type = space.Text(L"type");
|
||||
|
||||
if( conf_item.type == TicketConf::TicketItem::TypeInteger ||
|
||||
conf_item.type == TicketConf::TicketItem::TypeProgress )
|
||||
if( type == L"integer" || type == L"progress" )
|
||||
{
|
||||
i.out << ticket_param.intv;
|
||||
}
|
||||
else
|
||||
if( type == L"select" )
|
||||
{
|
||||
for(size_t a=0 ; a<space.spaces.size() ; ++a)
|
||||
{
|
||||
i.out << ticket_param.int_value;
|
||||
}
|
||||
else
|
||||
if( conf_item.type == TicketConf::TicketItem::TypeSelect )
|
||||
{
|
||||
if( ticket_param.int_value < (int)conf_item.select.size() )
|
||||
i.out << conf_item.select[ticket_param.int_value].name;
|
||||
}
|
||||
else
|
||||
if( conf_item.type == TicketConf::TicketItem::TypeString ||
|
||||
conf_item.type == TicketConf::TicketItem::TypeMultistring )
|
||||
{
|
||||
i.out << ticket_param.str_value;
|
||||
}
|
||||
else
|
||||
if( conf_item.type == TicketConf::TicketItem::TypeImages ||
|
||||
conf_item.type == TicketConf::TicketItem::TypeFiles )
|
||||
{
|
||||
i.out << ticket_param.str_value;
|
||||
PT::Space & sp = *space.spaces[a];
|
||||
|
||||
if( sp.name == L"option" && Tol(sp.Text(L"id")) == ticket_param.intv )
|
||||
{
|
||||
i.out << sp.Text(L"value");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if( type == L"string" || type == L"multistring" )
|
||||
{
|
||||
i.out << meta.Text(L"value");
|
||||
}
|
||||
else
|
||||
if( type == L"images" || type == L"files" )
|
||||
{
|
||||
i.out << meta.Text(L"value");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,7 +186,7 @@ namespace ns_tickets_tab
|
|||
static size_t item_sort_index; // index for: ticket_info.item_sort_tab
|
||||
static size_t ticket_index; // index for: ticket_info.ticket_tab
|
||||
static size_t par_index; // index for: ticket_info.ticket_tab[ticket_index].par_tab
|
||||
static size_t conf_tab_index; // index for: ticket_info.cur_conf->tab
|
||||
static size_t conf_tab_index; // index for: ticket_info.cur_conf->spaces
|
||||
static bool has_ticket;
|
||||
static bool has_value;
|
||||
|
||||
|
@ -249,6 +275,7 @@ void tickets_tab_subject(Info & i)
|
|||
}
|
||||
|
||||
|
||||
// !! do czego to w ogole sluzy?
|
||||
void tickets_tab_has_value(Info & i)
|
||||
{
|
||||
if( has_ticket && ticket_index < ticket_info.ticket_tab.size() )
|
||||
|
@ -257,37 +284,43 @@ void tickets_tab_has_value(Info & i)
|
|||
long id = Tol(i.par);
|
||||
Ticket & ticket = ticket_info.ticket_tab[ticket_index];
|
||||
|
||||
if( find_ticket_value(id, ticket, par_index) )
|
||||
// !! dodac takze sprawdzanie czy jest wartosc w ticket_info.ticket->meta
|
||||
|
||||
if( find_ticket_param(id, ticket, par_index) )
|
||||
i.res = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// !! czy to w ogole jest gdzies uzywane?
|
||||
void tickets_tab_value_int(Info & i)
|
||||
{
|
||||
if( has_ticket && ticket_index < ticket_info.ticket_tab.size() )
|
||||
{
|
||||
size_t par_index;
|
||||
long id = Tol(i.par);
|
||||
long param = Tol(i.par);
|
||||
Ticket & ticket = ticket_info.ticket_tab[ticket_index];
|
||||
|
||||
if( find_ticket_value(id, ticket, par_index) )
|
||||
i.out << ticket.par_tab[par_index].int_value;
|
||||
if( find_ticket_param(param, ticket, par_index) )
|
||||
i.out << ticket.par_tab[par_index].intv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void tickets_tab_value_str(Info & i)
|
||||
// !! czy to w ogole jest gdzies uzywane?
|
||||
void tickets_tab_value_meta(Info & i)
|
||||
{
|
||||
if( has_ticket && ticket_index < ticket_info.ticket_tab.size() )
|
||||
if( has_ticket &&
|
||||
item_sort_index < ticket_info.item_sort_tab.size() &&
|
||||
ticket_index < ticket_info.ticket_tab.size() )
|
||||
{
|
||||
size_t par_index;
|
||||
long id = Tol(i.par);
|
||||
Ticket & ticket = ticket_info.ticket_tab[ticket_index];
|
||||
long param = Tol(i.par);
|
||||
|
||||
if( find_ticket_value(id, ticket, par_index) )
|
||||
i.out << ticket.par_tab[par_index].str_value;
|
||||
PT::Space & meta = ticket_info.item_sort_tab[item_sort_index]->meta.FindAddSpace(L"ticket");
|
||||
PT::Space & sp = find_add_meta_for_param(meta, param);
|
||||
|
||||
// !! to nie zadziala bo pierwszy parametr w i.par to jest param_id
|
||||
space(i, sp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,14 +335,24 @@ void tickets_tab_conf_tab(Info & i)
|
|||
item_sort_index < ticket_info.item_sort_tab.size() &&
|
||||
ticket_index < ticket_info.ticket_tab.size() )
|
||||
{
|
||||
conf_tab_index = i.iter;
|
||||
i.res = conf_tab_index < ticket_info.cur_conf->tab.size();
|
||||
if( i.iter == 0 )
|
||||
conf_tab_index = 0;
|
||||
else
|
||||
conf_tab_index += 1;
|
||||
|
||||
PT::Space & space = *ticket_info.cur_conf;
|
||||
|
||||
for( ; conf_tab_index < space.spaces.size() ; conf_tab_index++)
|
||||
if( space.spaces[conf_tab_index]->name == L"param" )
|
||||
break;
|
||||
|
||||
i.res = conf_tab_index < space.spaces.size();
|
||||
|
||||
if( i.res )
|
||||
{
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_tab_index];
|
||||
PT::Space & sp = *space.spaces[conf_tab_index];
|
||||
const Ticket & ticket = ticket_info.ticket_tab[ticket_index];
|
||||
has_value = find_ticket_value(conf_item.id, ticket, par_index);
|
||||
has_value = find_ticket_param(sp.Long(L"id"), ticket, par_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -324,82 +367,30 @@ void tickets_tab_conf_tab_has_value(Info & i)
|
|||
void tickets_tab_conf_tab_value(Info & i)
|
||||
{
|
||||
if( has_value &&
|
||||
item_sort_index < ticket_info.item_sort_tab.size() &&
|
||||
ticket_index < ticket_info.ticket_tab.size() &&
|
||||
conf_tab_index < ticket_info.cur_conf->spaces.size() &&
|
||||
item_sort_index < ticket_info.item_sort_tab.size() &&
|
||||
ticket_index < ticket_info.ticket_tab.size() &&
|
||||
par_index < ticket_info.ticket_tab[ticket_index].par_tab.size() )
|
||||
{
|
||||
ticket_print_value(i, conf_tab_index, ticket_info.ticket_tab[ticket_index].par_tab[par_index]);
|
||||
PT::Space & space = *ticket_info.cur_conf->spaces[conf_tab_index];
|
||||
|
||||
// !! to mozna jakos gdzies zapamietac
|
||||
// aby nie wyszukiwac ciagle
|
||||
PT::Space & meta_ticket = ticket_info.item_sort_tab[item_sort_index]->meta.FindAddSpace(L"ticket");
|
||||
PT::Space & meta = find_add_meta_for_param(meta_ticket, space.Long(L"id"));
|
||||
|
||||
ticket_print_value(i, space, ticket_info.ticket_tab[ticket_index].par_tab[par_index], meta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void tickets_tab_conf_tab_is_integer(Info & i)
|
||||
void tickets_tab_conf_tab_type_is(Info & i)
|
||||
{
|
||||
if( conf_tab_index < ticket_info.cur_conf->tab.size() )
|
||||
if( conf_tab_index < ticket_info.cur_conf->spaces.size() )
|
||||
{
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_tab_index];
|
||||
i.res = conf_item.type == TicketConf::TicketItem::TypeInteger;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void tickets_tab_conf_tab_is_progress(Info & i)
|
||||
{
|
||||
if( conf_tab_index < ticket_info.cur_conf->tab.size() )
|
||||
{
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_tab_index];
|
||||
i.res = conf_item.type == TicketConf::TicketItem::TypeProgress;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void tickets_tab_conf_tab_is_select(Info & i)
|
||||
{
|
||||
if( conf_tab_index < ticket_info.cur_conf->tab.size() )
|
||||
{
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_tab_index];
|
||||
i.res = conf_item.type == TicketConf::TicketItem::TypeSelect;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void tickets_tab_conf_tab_is_string(Info & i)
|
||||
{
|
||||
if( conf_tab_index < ticket_info.cur_conf->tab.size() )
|
||||
{
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_tab_index];
|
||||
i.res = conf_item.type == TicketConf::TicketItem::TypeString;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void tickets_tab_conf_tab_is_multistring(Info & i)
|
||||
{
|
||||
if( conf_tab_index < ticket_info.cur_conf->tab.size() )
|
||||
{
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_tab_index];
|
||||
i.res = conf_item.type == TicketConf::TicketItem::TypeMultistring;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void tickets_tab_conf_tab_is_images(Info & i)
|
||||
{
|
||||
if( conf_tab_index < ticket_info.cur_conf->tab.size() )
|
||||
{
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_tab_index];
|
||||
i.res = conf_item.type == TicketConf::TicketItem::TypeImages;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void tickets_tab_conf_tab_is_files(Info & i)
|
||||
{
|
||||
if( conf_tab_index < ticket_info.cur_conf->tab.size() )
|
||||
{
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_tab_index];
|
||||
i.res = conf_item.type == TicketConf::TicketItem::TypeFiles;
|
||||
PT::Space & space = *ticket_info.cur_conf->spaces[conf_tab_index];
|
||||
i.res = (space.Text(L"type") == i.par);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,7 +401,7 @@ void tickets_tab_conf_tab_progress_image_number(Info & i)
|
|||
ticket_index < ticket_info.ticket_tab.size() &&
|
||||
par_index < ticket_info.ticket_tab[ticket_index].par_tab.size() )
|
||||
{
|
||||
int progress = ticket_info.ticket_tab[ticket_index].par_tab[par_index].int_value;
|
||||
int progress = ticket_info.ticket_tab[ticket_index].par_tab[par_index].intv;
|
||||
i.out << ticket_calc_progress_image_number(progress);
|
||||
}
|
||||
}
|
||||
|
@ -425,8 +416,8 @@ void tickets_tab_conf_tab_progress_image_number(Info & i)
|
|||
|
||||
namespace ns_ticket_tab
|
||||
{
|
||||
static size_t conf_index; // index for: ticket_info.cur_conf->tab
|
||||
static size_t select_index; // index for: ticket_info.cur_conf->tab[conf_index].select
|
||||
static size_t conf_index; // index for: ticket_info.cur_conf->spaces
|
||||
static size_t select_index; // index for: ticket_info.cur_conf->spaces[conf_index]->spaces
|
||||
static size_t par_index; // index for: ticket_info.ticket->par_tab
|
||||
static size_t files_number;
|
||||
static bool has_value;
|
||||
|
@ -435,13 +426,23 @@ static bool has_value;
|
|||
|
||||
void ticket_tab(Info & i)
|
||||
{
|
||||
conf_index = i.iter;
|
||||
i.res = conf_index < ticket_info.cur_conf->tab.size();
|
||||
if( i.iter == 0 )
|
||||
conf_index = 0;
|
||||
else
|
||||
conf_index += 1;
|
||||
|
||||
PT::Space & space = *ticket_info.cur_conf;
|
||||
|
||||
for( ; conf_index < space.spaces.size() ; conf_index++)
|
||||
if( space.spaces[conf_index]->name == L"param" )
|
||||
break;
|
||||
|
||||
i.res = conf_index < space.spaces.size();
|
||||
|
||||
if( i.res )
|
||||
{
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_index];
|
||||
has_value = find_ticket_value(conf_item.id, *ticket_info.ticket, par_index);
|
||||
PT::Space & sp = *space.spaces[conf_index];
|
||||
has_value = find_ticket_param(sp.Long(L"id"), *ticket_info.ticket, par_index);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,110 +450,98 @@ void ticket_tab(Info & i)
|
|||
|
||||
void ticket_tab_param_id(Info & i)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
i.out << ticket_info.cur_conf->tab[conf_index].id;
|
||||
if( conf_index < ticket_info.cur_conf->spaces.size() )
|
||||
i.out << ticket_info.cur_conf->spaces[conf_index]->Long(L"id");
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_param_name(Info & i)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
i.out << ticket_info.cur_conf->tab[conf_index].name;
|
||||
if( conf_index < ticket_info.cur_conf->spaces.size() )
|
||||
i.out << ticket_info.cur_conf->spaces[conf_index]->Text(L"name");
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_value(Info & i)
|
||||
{
|
||||
if( has_value && par_index < ticket_info.ticket->par_tab.size() )
|
||||
ticket_print_value(i, conf_index, ticket_info.ticket->par_tab[par_index]);
|
||||
// !! has_value mowi tylko czy opcja byla w tabeli tickets
|
||||
// nalezy dodac aby has_value mialo obsluge meta (albo sie pozbyc go w ogole...)
|
||||
|
||||
if( has_value && par_index < ticket_info.ticket->par_tab.size() &&
|
||||
conf_index < ticket_info.cur_conf->spaces.size() )
|
||||
{
|
||||
PT::Space & space = *ticket_info.cur_conf->spaces[conf_index];
|
||||
PT::Space & meta = find_add_meta_for_param(ticket_info.item->meta.FindAddSpace(L"ticket"), space.Long(L"id"));
|
||||
|
||||
ticket_print_value(i, space, ticket_info.ticket->par_tab[par_index], meta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_value_int(Info & i)
|
||||
{
|
||||
if( has_value && par_index < ticket_info.ticket->par_tab.size() )
|
||||
i.out << ticket_info.ticket->par_tab[par_index].int_value;
|
||||
i.out << ticket_info.ticket->par_tab[par_index].intv;
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_value_str(Info & i)
|
||||
void ticket_tab_value_meta(Info & i)
|
||||
{
|
||||
if( has_value && par_index < ticket_info.ticket->par_tab.size() )
|
||||
i.out << ticket_info.ticket->par_tab[par_index].str_value;
|
||||
{
|
||||
PT::Space & sp = *ticket_info.cur_conf->spaces[conf_index];
|
||||
PT::Space & meta = find_add_meta_for_param(ticket_info.item->meta.FindAddSpace(L"ticket"), sp.Long(L"id"));
|
||||
|
||||
space(i, meta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_is_integer(Info & i)
|
||||
void ticket_tab_type_is(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_is_progress(Info & i)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
i.res = ticket_info.cur_conf->tab[conf_index].type == TicketConf::TicketItem::TypeProgress;
|
||||
}
|
||||
|
||||
|
||||
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_string(Info & i)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
i.res = ticket_info.cur_conf->tab[conf_index].type == TicketConf::TicketItem::TypeString;
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_is_multistring(Info & i)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
i.res = ticket_info.cur_conf->tab[conf_index].type == TicketConf::TicketItem::TypeMultistring;
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_is_images(Info & i)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
i.res = ticket_info.cur_conf->tab[conf_index].type == TicketConf::TicketItem::TypeImages;
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_is_files(Info & i)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
i.res = ticket_info.cur_conf->tab[conf_index].type == TicketConf::TicketItem::TypeFiles;
|
||||
if( conf_index < ticket_info.cur_conf->spaces.size() )
|
||||
{
|
||||
PT::Space & space = *ticket_info.cur_conf->spaces[conf_index];
|
||||
i.res = (space.Text(L"type") == i.par);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_select_tab(Info & i)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() )
|
||||
if( conf_index < ticket_info.cur_conf->spaces.size() )
|
||||
{
|
||||
select_index = i.iter;
|
||||
i.res = select_index < ticket_info.cur_conf->tab[conf_index].select.size();
|
||||
if( i.iter == 0 )
|
||||
select_index = 0;
|
||||
else
|
||||
select_index += 1;
|
||||
|
||||
PT::Space & sp = *ticket_info.cur_conf->spaces[conf_index];
|
||||
|
||||
for( ; select_index < sp.spaces.size() ; ++select_index)
|
||||
if( sp.spaces[select_index]->name == L"option" )
|
||||
break;
|
||||
|
||||
i.res = (select_index < sp.spaces.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_select_tab_is_selected(Info & i)
|
||||
{
|
||||
if( has_value && par_index < ticket_info.ticket->par_tab.size() )
|
||||
if( conf_index < ticket_info.cur_conf->spaces.size() &&
|
||||
select_index < ticket_info.cur_conf->spaces[conf_index]->spaces.size() )
|
||||
{
|
||||
i.res = select_index == (size_t)ticket_info.ticket->par_tab[par_index].int_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() &&
|
||||
select_index < ticket_info.cur_conf->tab[conf_index].select.size() )
|
||||
PT::Space & sp = *ticket_info.cur_conf->spaces[conf_index];
|
||||
long id = sp.spaces[select_index]->Long(L"id");
|
||||
|
||||
if( has_value && par_index < ticket_info.ticket->par_tab.size() )
|
||||
{
|
||||
i.res = select_index == ticket_info.cur_conf->tab[conf_index].select_default;
|
||||
i.res = (id == ticket_info.ticket->par_tab[par_index].intv);
|
||||
}
|
||||
else
|
||||
{
|
||||
i.res = (id == sp.Long(L"default"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -560,20 +549,20 @@ void ticket_tab_select_tab_is_selected(Info & i)
|
|||
|
||||
void ticket_tab_select_tab_name(Info & i)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() &&
|
||||
select_index < ticket_info.cur_conf->tab[conf_index].select.size() )
|
||||
if( conf_index < ticket_info.cur_conf->spaces.size() &&
|
||||
select_index < ticket_info.cur_conf->spaces[conf_index]->spaces.size() )
|
||||
{
|
||||
i.out << ticket_info.cur_conf->tab[conf_index].select[select_index].name;
|
||||
i.out << ticket_info.cur_conf->spaces[conf_index]->spaces[select_index]->Text(L"value");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ticket_tab_select_tab_id(Info & i)
|
||||
{
|
||||
if( conf_index < ticket_info.cur_conf->tab.size() &&
|
||||
select_index < ticket_info.cur_conf->tab[conf_index].select.size() )
|
||||
if( conf_index < ticket_info.cur_conf->spaces.size() &&
|
||||
select_index < ticket_info.cur_conf->spaces[conf_index]->spaces.size() )
|
||||
{
|
||||
i.out << ticket_info.cur_conf->tab[conf_index].select[select_index].id;
|
||||
i.out << ticket_info.cur_conf->spaces[conf_index]->spaces[select_index]->Text(L"id");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -584,7 +573,7 @@ void ticket_tab_files_tab(Info & i)
|
|||
{
|
||||
files_number = i.iter;
|
||||
|
||||
if( has_value && conf_index < ticket_info.cur_conf->tab.size() )
|
||||
if( has_value && conf_index < ticket_info.cur_conf->spaces.size() )
|
||||
{
|
||||
if( i.iter == 0 )
|
||||
{
|
||||
|
@ -595,11 +584,13 @@ void ticket_tab_files_tab(Info & i)
|
|||
else
|
||||
{
|
||||
// next iteration, we are looking for the next par_index
|
||||
const TicketConf::TicketItem & conf_item = ticket_info.cur_conf->tab[conf_index];
|
||||
PT::Space & sp = *ticket_info.cur_conf->spaces[conf_index];
|
||||
|
||||
long param = sp.Long(L"id");
|
||||
|
||||
for(++par_index ; par_index < ticket_info.ticket->par_tab.size() ; ++par_index)
|
||||
{
|
||||
if( ticket_info.ticket->par_tab[par_index].param == conf_item.id )
|
||||
if( ticket_info.ticket->par_tab[par_index].param == param )
|
||||
{
|
||||
i.res = true;
|
||||
return;
|
||||
|
@ -646,19 +637,13 @@ using namespace ns_ticket_tab;
|
|||
// you should provide an id (param) as a first parameter
|
||||
fun->Insert("tickets_tab_has_value", tickets_tab_has_value);
|
||||
fun->Insert("tickets_tab_value_int", tickets_tab_value_int);
|
||||
fun->Insert("tickets_tab_value_str", tickets_tab_value_str);
|
||||
fun->Insert("tickets_tab_value_meta", tickets_tab_value_meta);
|
||||
|
||||
fun->Insert("tickets_tab_conf_tab", tickets_tab_conf_tab);
|
||||
fun->Insert("tickets_tab_conf_tab_has_value", tickets_tab_conf_tab_has_value);
|
||||
fun->Insert("tickets_tab_conf_tab_value", tickets_tab_conf_tab_value);
|
||||
|
||||
fun->Insert("tickets_tab_conf_tab_is_integer", tickets_tab_conf_tab_is_integer);
|
||||
fun->Insert("tickets_tab_conf_tab_is_progress", tickets_tab_conf_tab_is_progress);
|
||||
fun->Insert("tickets_tab_conf_tab_is_select", tickets_tab_conf_tab_is_select);
|
||||
fun->Insert("tickets_tab_conf_tab_is_string", tickets_tab_conf_tab_is_string);
|
||||
fun->Insert("tickets_tab_conf_tab_is_multistring", tickets_tab_conf_tab_is_multistring);
|
||||
fun->Insert("tickets_tab_conf_tab_is_images", tickets_tab_conf_tab_is_images);
|
||||
fun->Insert("tickets_tab_conf_tab_is_files", tickets_tab_conf_tab_is_files);
|
||||
fun->Insert("tickets_tab_conf_tab_type_is", tickets_tab_conf_tab_type_is);
|
||||
fun->Insert("tickets_tab_conf_tab_progress_image_number", tickets_tab_conf_tab_progress_image_number);
|
||||
|
||||
|
||||
|
@ -669,15 +654,8 @@ using namespace ns_ticket_tab;
|
|||
fun->Insert("ticket_tab_param_name", ticket_tab_param_name);
|
||||
fun->Insert("ticket_tab_value", ticket_tab_value);
|
||||
fun->Insert("ticket_tab_value_int", ticket_tab_value_int);
|
||||
fun->Insert("ticket_tab_value_str", ticket_tab_value_str);
|
||||
|
||||
fun->Insert("ticket_tab_is_integer", ticket_tab_is_integer);
|
||||
fun->Insert("ticket_tab_is_progress", ticket_tab_is_progress);
|
||||
fun->Insert("ticket_tab_is_select", ticket_tab_is_select);
|
||||
fun->Insert("ticket_tab_is_string", ticket_tab_is_string);
|
||||
fun->Insert("ticket_tab_is_multistring", ticket_tab_is_multistring);
|
||||
fun->Insert("ticket_tab_is_images", ticket_tab_is_images);
|
||||
fun->Insert("ticket_tab_is_files", ticket_tab_is_files);
|
||||
fun->Insert("ticket_tab_value_meta", ticket_tab_value_meta);
|
||||
fun->Insert("ticket_tab_type_is", ticket_tab_type_is);
|
||||
|
||||
fun->Insert("ticket_tab_select_tab", ticket_tab_select_tab);
|
||||
fun->Insert("ticket_tab_select_tab_is_selected", ticket_tab_select_tab_is_selected);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
@ -22,15 +22,15 @@ struct Ticket
|
|||
{
|
||||
struct TicketParam
|
||||
{
|
||||
int param;
|
||||
long int_value; // changed to long (from int)
|
||||
std::wstring str_value;
|
||||
long param;
|
||||
long intv;
|
||||
std::wstring decv; // !! temporarily as a string (in the future there'll be a Dec type from ttmath)
|
||||
|
||||
void Clear()
|
||||
{
|
||||
param = 0;
|
||||
int_value = 0;
|
||||
str_value.clear();
|
||||
param = 0;
|
||||
intv = 0;
|
||||
decv.clear();
|
||||
}
|
||||
|
||||
TicketParam()
|
||||
|
@ -43,15 +43,16 @@ struct Ticket
|
|||
std::vector<TicketParam> par_tab;
|
||||
|
||||
// auxiliary object used during sorting
|
||||
unsigned long sort_id;
|
||||
//unsigned long sort_id;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
file_id = -1;
|
||||
file_id = -1;
|
||||
par_tab.clear();
|
||||
sort_id = 0;
|
||||
//sort_id = 0;
|
||||
}
|
||||
|
||||
|
||||
struct Sort
|
||||
{
|
||||
bool operator()(const TicketParam & par1, const TicketParam & par2)
|
||||
|
@ -60,12 +61,15 @@ struct Ticket
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
void SortParTab()
|
||||
{
|
||||
std::sort(par_tab.begin(), par_tab.end(), Sort());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Ticket()
|
||||
{
|
||||
Clear();
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <limits>
|
||||
#include "ticketconf.h"
|
||||
|
||||
|
||||
TicketConf::TicketItem::TicketItem()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void TicketConf::TicketItem::Clear()
|
||||
{
|
||||
id = 0;
|
||||
name.clear();
|
||||
type = TypeInteger;
|
||||
integer_min = std::numeric_limits<long>::min();
|
||||
integer_max = std::numeric_limits<long>::max();
|
||||
max_files = 0;
|
||||
upload_dir.clear();
|
||||
select.clear();
|
||||
select_default = 0;
|
||||
}
|
||||
|
||||
void TicketConf::Clear()
|
||||
{
|
||||
tab.clear();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,60 +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_ticketconf
|
||||
#define headerfile_winix_plugins_ticket_ticketconf
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
|
||||
struct TicketConf
|
||||
{
|
||||
struct TicketItem
|
||||
{
|
||||
struct Select
|
||||
{
|
||||
std::wstring name;
|
||||
int id;
|
||||
};
|
||||
|
||||
TicketItem();
|
||||
void Clear();
|
||||
|
||||
enum Type { TypeInteger, TypeProgress, TypeSelect, TypeString, TypeMultistring, TypeImages, TypeFiles };
|
||||
|
||||
int id;
|
||||
|
||||
std::wstring name;
|
||||
Type type;
|
||||
|
||||
// used when type is TypeInteger or TypeProgress
|
||||
int integer_min, integer_max;
|
||||
|
||||
// used when type is TypeSelect
|
||||
std::vector<Select> select;
|
||||
size_t select_default;
|
||||
|
||||
// used when type is TypeImages or TypeFiles
|
||||
// 0 - unlimited
|
||||
int max_files;
|
||||
std::wstring upload_dir;
|
||||
};
|
||||
|
||||
typedef std::vector<TicketItem> Table;
|
||||
Table tab;
|
||||
|
||||
void Clear();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
@ -15,7 +15,6 @@
|
|||
#include "core/misc.h"
|
||||
#include "sessiondata.h"
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
|
||||
|
@ -67,6 +66,9 @@ void TicketInfo::SetFunctions(Functions * pfunctions)
|
|||
void TicketInfo::Clear()
|
||||
{
|
||||
ticket = &ticket_empty;
|
||||
item = &item_empty;
|
||||
item->Clear();
|
||||
// we use meta from item which should not be const
|
||||
|
||||
cur_conf_wrap = &cur_conf_wrap_empty;
|
||||
cur_conf = &cur_conf_empty;
|
||||
|
@ -126,10 +128,46 @@ bool TicketInfo::ParseTicketConf(long mount_dir_id, const std::wstring & path)
|
|||
{
|
||||
log << log3 << "Ticket: parsing conf file: " << path << logend;
|
||||
|
||||
int code = ticket_parser.Parse(config_file.content, conf_tab[mount_dir_id].conf);
|
||||
conf_tab[mount_dir_id].file_name = path;
|
||||
log << log1 << config_file.content << logend;
|
||||
|
||||
return code == WINIX_TICKET_ERR_OK;
|
||||
conf_tab[mount_dir_id].file_name = path;
|
||||
conf_parser.UTF8(true);
|
||||
conf_parser.SetSpace(conf_tab[mount_dir_id].conf);
|
||||
conf_parser.SplitSingle(true);
|
||||
conf_tab[mount_dir_id].conf.Clear();
|
||||
|
||||
//log << log1 << "status: " << conf_parser.Parse(config_file.content) << logend;
|
||||
|
||||
return (conf_parser.ParseString(config_file.content) == PT::ConfParser::ok);
|
||||
}
|
||||
|
||||
|
||||
void TicketInfo::ReadTicketConf(const Mount & mount, bool skip_existing_configs)
|
||||
{
|
||||
if( mount.param[mount_par_ticket_conf].defined &&
|
||||
mount.param[mount_par_ticket_conf].arg.size() == 1 )
|
||||
{
|
||||
const std::wstring & file_name = mount.param[mount_par_ticket_conf].arg[0];
|
||||
ConfTab::iterator c = conf_tab.find(mount.dir_id);
|
||||
bool exists = (c != conf_tab.end() && c->second.file_name == file_name);
|
||||
|
||||
if( exists )
|
||||
c->second.to_delete = false;
|
||||
|
||||
if( !(skip_existing_configs && exists) )
|
||||
{
|
||||
if( GetConfContent(file_name) )
|
||||
{
|
||||
if( !ParseTicketConf(mount.dir_id, file_name) )
|
||||
conf_tab[mount.dir_id].to_delete = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( exists )
|
||||
c->second.to_delete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -143,31 +181,7 @@ void TicketInfo::ReadTicketConf(Mounts & mounts, bool skip_existing_configs)
|
|||
for(i=mtab->begin() ; i!=mtab->end() ; ++i)
|
||||
{
|
||||
const Mount & mount = i->second;
|
||||
|
||||
if( mount.param[mount_par_ticket_conf].defined &&
|
||||
mount.param[mount_par_ticket_conf].arg.size() == 1 )
|
||||
{
|
||||
const std::wstring & file_name = mount.param[mount_par_ticket_conf].arg[0];
|
||||
ConfTab::iterator c = conf_tab.find(mount.dir_id);
|
||||
bool exists = (c != conf_tab.end() && c->second.file_name == file_name);
|
||||
|
||||
if( exists )
|
||||
c->second.to_delete = false;
|
||||
|
||||
if( !(skip_existing_configs && exists) )
|
||||
{
|
||||
if( GetConfContent(file_name) )
|
||||
{
|
||||
if( !ParseTicketConf(mount.dir_id, file_name) )
|
||||
conf_tab[mount.dir_id].to_delete = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( exists )
|
||||
c->second.to_delete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
ReadTicketConf(mount, skip_existing_configs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,10 +198,7 @@ void TicketInfo::ReadTicketConf(bool skip_existing_configs)
|
|||
|
||||
void TicketInfo::FindCurrentConf()
|
||||
{
|
||||
if( !system->mounts.pmount )
|
||||
return;
|
||||
|
||||
long dir_id = system->mounts.pmount->dir_id;
|
||||
long dir_id = cur->mount->dir_id;
|
||||
ConfTab::iterator i = conf_tab.find(dir_id);
|
||||
|
||||
if( i != conf_tab.end() )
|
||||
|
@ -197,62 +208,103 @@ void TicketInfo::FindCurrentConf()
|
|||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Ticket: there is no ticket_conf parameter in the mount point (an empty used)" << logend;
|
||||
log << log1 << "Ticket: there is no a ticket_conf parameter in the mount point (an empty config used)" << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TicketInfo::CheckMinMaxValue(const TicketConf::TicketItem & conf_item, Ticket::TicketParam & par)
|
||||
{
|
||||
if( conf_item.type == TicketConf::TicketItem::TypeInteger ||
|
||||
conf_item.type == TicketConf::TicketItem::TypeProgress )
|
||||
{
|
||||
if( par.int_value < conf_item.integer_min )
|
||||
par.int_value = conf_item.integer_min;
|
||||
|
||||
if( par.int_value > conf_item.integer_max )
|
||||
par.int_value = conf_item.integer_max;
|
||||
|
||||
void TicketInfo::CheckMinMaxValue(PT::Space & space, Ticket::TicketParam & par)
|
||||
{
|
||||
if( space.Text(L"type") == L"integer" )
|
||||
{
|
||||
std::wstring * min_str = space.GetValue(L"min");
|
||||
std::wstring * max_str = space.GetValue(L"min");
|
||||
|
||||
if( min_str )
|
||||
{
|
||||
long minv = Tol(*min_str);
|
||||
|
||||
if( par.intv < minv )
|
||||
par.intv = minv;
|
||||
}
|
||||
|
||||
if( max_str )
|
||||
{
|
||||
long maxv = Tol(*max_str);
|
||||
|
||||
if( par.intv > maxv )
|
||||
par.intv = maxv;
|
||||
}
|
||||
}
|
||||
else
|
||||
if( conf_item.type == TicketConf::TicketItem::TypeSelect )
|
||||
if( space.Text(L"type") == L"progress" )
|
||||
{
|
||||
for(size_t a=0 ; a<conf_item.select.size() ; ++a)
|
||||
// !! dodac tez min/max
|
||||
if( par.intv < 0 )
|
||||
par.intv = 0;
|
||||
|
||||
if( par.intv > 100 )
|
||||
par.intv = 100;
|
||||
}
|
||||
else
|
||||
if( space.Text(L"type") == L"select" )
|
||||
{
|
||||
for(size_t a=0 ; a<space.spaces.size() ; ++a)
|
||||
{
|
||||
if( conf_item.select[a].id == par.int_value )
|
||||
PT::Space & sp = *space.spaces[a];
|
||||
|
||||
if( sp.name == L"option" && sp.Long(L"id") == par.intv )
|
||||
return;
|
||||
}
|
||||
|
||||
if( conf_item.select_default < conf_item.select.size() )
|
||||
par.int_value = conf_item.select[conf_item.select_default].id;
|
||||
else
|
||||
par.int_value = 0;
|
||||
par.intv = Tol(space.Text(L"default"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool TicketInfo::ReadTicketValue(const TicketConf::TicketItem & conf_item, Ticket::TicketParam & par, const std::wstring & value)
|
||||
PT::Space & TicketInfo::FindAddMetaByParam(PT::Space & meta, long param)
|
||||
{
|
||||
if( conf_item.type == TicketConf::TicketItem::TypeInteger ||
|
||||
conf_item.type == TicketConf::TicketItem::TypeProgress ||
|
||||
conf_item.type == TicketConf::TicketItem::TypeSelect )
|
||||
for(size_t i=0 ; i<meta.spaces.size() ; ++i)
|
||||
{
|
||||
par.int_value = Tol(value);
|
||||
par.str_value.clear();
|
||||
CheckMinMaxValue(conf_item, par);
|
||||
PT::Space & sp = *meta.spaces[i];
|
||||
|
||||
if( sp.name == L"param" && sp.Long(L"id") == param )
|
||||
return sp;
|
||||
}
|
||||
|
||||
PT::Space & sp = meta.AddSpace(L"param");
|
||||
sp.Add(L"id", param);
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool TicketInfo::ReadTicketValue(PT::Space & space, long param_id, Ticket::TicketParam & par, const std::wstring & value, PT::Space & meta)
|
||||
{
|
||||
if( space.Text(L"type") == L"integer" ||
|
||||
space.Text(L"type") == L"progress" ||
|
||||
space.Text(L"type") == L"select" )
|
||||
{
|
||||
par.intv = Tol(value);
|
||||
par.decv.clear();
|
||||
CheckMinMaxValue(space, par);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if( conf_item.type == TicketConf::TicketItem::TypeString ||
|
||||
conf_item.type == TicketConf::TicketItem::TypeMultistring )
|
||||
if( space.Text(L"type") == L"string" ||
|
||||
space.Text(L"type") == L"multistring" )
|
||||
{
|
||||
par.int_value = 0;
|
||||
par.str_value = value;
|
||||
// !! dodac cos co sprawdzi czy string nie zawiera znakow konca linii
|
||||
PT::Space & sp = FindAddMetaByParam(meta, param_id);
|
||||
sp.Add(L"value", value);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
if( conf_item.type == TicketConf::TicketItem::TypeImages ||
|
||||
conf_item.type == TicketConf::TicketItem::TypeFiles )
|
||||
if( space.Text(L"type") == L"images" ||
|
||||
space.Text(L"type") == L"files" )
|
||||
{
|
||||
if( !value.empty() )
|
||||
{
|
||||
|
@ -260,148 +312,152 @@ bool TicketInfo::ReadTicketValue(const TicketConf::TicketItem & conf_item, Ticke
|
|||
}
|
||||
else
|
||||
{
|
||||
// an empty field from the html form
|
||||
// an empty field from the html form (ignoring)
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// !! dodac obsluge komunikatow
|
||||
// niech zostanie wyslany komunikat o dodawaniu nieznanego parametru
|
||||
// i jesli nic nie odpowie na ten komunikat to wtedy zglaszamy blad
|
||||
log << log1 << "Ticket: incorrect parameter, param: " << par.param << ", value: " << value << " (ignored)" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// file_map can be null
|
||||
bool TicketInfo::ReadTicketValue(const TicketConf::TicketItem & conf_item,
|
||||
Ticket::TicketParam & par, const PostFile & value, std::vector<long> * file_map)
|
||||
{
|
||||
bool add = false;
|
||||
|
||||
if( conf_item.type == TicketConf::TicketItem::TypeImages ||
|
||||
conf_item.type == TicketConf::TicketItem::TypeFiles )
|
||||
void TicketInfo::ReadTicketValue(PT::Space & space,
|
||||
long param_id,
|
||||
const PostFile & value,
|
||||
std::vector<long> & file_map,
|
||||
PT::Space & meta,
|
||||
Item & upload_dir)
|
||||
{
|
||||
file.Clear(); // clearing and setting date
|
||||
file.parent_id = upload_dir.id;
|
||||
file.type = Item::file;
|
||||
file.privileges = 0644; // !! tymczasowo
|
||||
file.file_type = SelectFileType(value.filename);
|
||||
file.url = value.filename;
|
||||
functions->PrepareUrl(file);
|
||||
functions->SetUser(file);
|
||||
functions->fun_upload.UploadFile(file, value.tmp_filename);
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
{
|
||||
Item * upload_dir = system->dirs.GetDir(conf_item.upload_dir);
|
||||
PT::Space & sp = meta.AddSpace(L"param");
|
||||
|
||||
sp.Add(L"id", param_id);
|
||||
|
||||
if( file.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
sp.Add(L"type", L"image");
|
||||
else
|
||||
sp.Add(L"type", L"file");
|
||||
|
||||
sp.Add(L"file_id", file.id);
|
||||
system->MakePath(file, file_path);
|
||||
sp.Add(L"path", file_path);
|
||||
|
||||
file_map.push_back(file.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Ticket: problem with uploading" << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TicketInfo::ReadTicketValue(PT::Space & space,
|
||||
long param_id, const PostFile & value, std::vector<long> & file_map, PT::Space & meta)
|
||||
{
|
||||
if( space.Text(L"type") == L"images" ||
|
||||
space.Text(L"type") == L"files" )
|
||||
{
|
||||
std::wstring & upload_path = space.Text(L"upload_dir");
|
||||
Item * upload_dir = system->dirs.GetDir(upload_path);
|
||||
|
||||
if( upload_dir )
|
||||
{
|
||||
file.Clear(); // clearing and setting date
|
||||
file.parent_id = upload_dir->id;
|
||||
file.type = Item::file;
|
||||
file.privileges = 0644; // !! tymczasowo
|
||||
file.file_type = SelectFileType(value.filename);
|
||||
file.url = value.filename;
|
||||
functions->PrepareUrl(file);
|
||||
functions->SetUser(file);
|
||||
functions->fun_upload.UploadFile(file, value.tmp_filename);
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
{
|
||||
add = true;
|
||||
par.int_value = file.id;
|
||||
system->MakePath(file, par.str_value);
|
||||
|
||||
if( file_map )
|
||||
file_map->push_back(file.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Ticket: problem with uploading" << logend;
|
||||
}
|
||||
ReadTicketValue(space, param_id, value, file_map, meta, *upload_dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Ticket: there is no upload dir: " << conf_item.upload_dir << logend;
|
||||
log << log1 << "Ticket: there is no an upload directory: " << upload_path << logend;
|
||||
}
|
||||
}
|
||||
|
||||
if( !add )
|
||||
log << log1 << "Ticket: file parameter, param: " << par.param << " ignored" << logend;
|
||||
|
||||
return add;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// if the ticket has param_id already then the parameter is changed
|
||||
// if no then it is added
|
||||
void TicketInfo::ReadTicketParam(Ticket & ticket, int param_id, const std::wstring & value)
|
||||
// adding a new parameter only if it not exists in ticket.par_tab
|
||||
void TicketInfo::ReadTicketParam(PT::Space & space, Ticket & ticket, long param_id, const std::wstring & value, PT::Space & meta)
|
||||
{
|
||||
bool exists = false;
|
||||
ticket_param.param = param_id;
|
||||
|
||||
ticket_param.Clear();
|
||||
|
||||
for(size_t i=0 ; i<cur_conf->tab.size() ; ++i)
|
||||
for(size_t i2=0 ; i2<ticket.par_tab.size() ; ++i2)
|
||||
{
|
||||
if( param_id == cur_conf->tab[i].id )
|
||||
if( ticket.par_tab[i2].param == param_id )
|
||||
{
|
||||
for(size_t i2=0 ; i2<ticket.par_tab.size() ; ++i2)
|
||||
{
|
||||
if( ticket.par_tab[i2].param == param_id )
|
||||
{
|
||||
// parameter exists
|
||||
exists = true;
|
||||
ticket_param.param = param_id;
|
||||
// parameter param_id already exists in ticket.par_tab
|
||||
// (overwritting)
|
||||
|
||||
if( ReadTicketValue(cur_conf->tab[i], ticket_param, value) )
|
||||
ticket.par_tab[i2] = ticket_param;
|
||||
if( ReadTicketValue(space, param_id, ticket_param, value, meta) )
|
||||
ticket.par_tab[i2] = ticket_param;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !exists )
|
||||
{
|
||||
// adding a new parameter
|
||||
exists = true;
|
||||
ticket_param.param = param_id;
|
||||
|
||||
if( ReadTicketValue(cur_conf->tab[i], ticket_param, value) )
|
||||
ticket.par_tab.push_back(ticket_param);
|
||||
}
|
||||
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( !exists )
|
||||
log << log1 << "Ticket: skipped incorrect parameter: " << param_id << " (not defined in the config)" << logend;
|
||||
// adding a new parameter param_id
|
||||
if( ReadTicketValue(space, param_id, ticket_param, value, meta) )
|
||||
ticket.par_tab.push_back(ticket_param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const std::wstring & value, PT::Space & meta)
|
||||
{
|
||||
ticket_param.Clear();
|
||||
|
||||
for(size_t i=0 ; i<cur_conf->spaces.size() ; ++i)
|
||||
{
|
||||
PT::Space & space = *cur_conf->spaces[i];
|
||||
|
||||
if( space.name == L"param" && Tol(space.Text(L"id")) == param_id )
|
||||
{
|
||||
ReadTicketParam(space, ticket, param_id, value, meta);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
log << log1 << "Ticket: skipped incorrect parameter: " << param_id << " (not defined in the config)" << logend;
|
||||
}
|
||||
|
||||
|
||||
// always adds a new parameter
|
||||
// file_map can be null
|
||||
void TicketInfo::ReadTicketParam(Ticket & ticket, int param_id, const PostFile & value, std::vector<long> * file_map)
|
||||
void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const PostFile & value, std::vector<long> & file_map, PT::Space & meta)
|
||||
{
|
||||
bool exists = false;
|
||||
|
||||
ticket_param.Clear();
|
||||
|
||||
for(size_t i=0 ; i<cur_conf->tab.size() ; ++i)
|
||||
for(size_t i=0 ; i<cur_conf->spaces.size() ; ++i)
|
||||
{
|
||||
if( param_id == cur_conf->tab[i].id )
|
||||
PT::Space & space = *cur_conf->spaces[i];
|
||||
|
||||
if( space.name == L"param" && Tol(space.Text(L"id")) == param_id )
|
||||
{
|
||||
exists = true;
|
||||
ticket_param.param = param_id;
|
||||
|
||||
if( ReadTicketValue(cur_conf->tab[i], ticket_param , value, file_map) )
|
||||
ticket.par_tab.push_back(ticket_param);
|
||||
|
||||
break;
|
||||
ReadTicketValue(space, param_id, value, file_map, meta);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( !exists )
|
||||
log << log1 << "Ticket: skipped incorrect parameter: " << param_id << " (not defined in the config)" << logend;
|
||||
log << log1 << "Ticket: skipped incorrect parameter: " << param_id << " (not defined in the config)" << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TicketInfo::ReadTicketParams(Ticket & ticket, bool clear_ticket, std::vector<long> * file_map)
|
||||
void TicketInfo::ReadTicketParams(Ticket & ticket, bool clear_ticket, std::vector<long> & file_map, PT::Space & meta)
|
||||
{
|
||||
PostTab::iterator i;
|
||||
PostFileTab::iterator i2;
|
||||
|
@ -409,16 +465,18 @@ PostFileTab::iterator i2;
|
|||
if( clear_ticket )
|
||||
ticket.Clear();
|
||||
|
||||
PT::Space & ticket_meta = meta.FindAddSpace(L"ticket");
|
||||
|
||||
for(i=cur->request->post_tab.begin() ; i!=cur->request->post_tab.end() ; ++i)
|
||||
{
|
||||
if( IsSubString(config->ticket_form_prefix, i->first) )
|
||||
ReadTicketParam(ticket, Toi(i->first.c_str() + config->ticket_form_prefix.size()), i->second);
|
||||
ReadTicketParam(ticket, Tol(i->first.c_str() + config->ticket_form_prefix.size()), i->second, ticket_meta);
|
||||
}
|
||||
|
||||
for(i2=cur->request->post_file_tab.begin() ; i2!=cur->request->post_file_tab.end() ; ++i2)
|
||||
{
|
||||
if( IsSubString(config->ticket_form_prefix, i2->first) )
|
||||
ReadTicketParam(ticket, Toi(i2->first.c_str() + config->ticket_form_prefix.size()), i2->second, file_map);
|
||||
ReadTicketParam(ticket, Tol(i2->first.c_str() + config->ticket_form_prefix.size()), i2->second, file_map, ticket_meta);
|
||||
}
|
||||
|
||||
ticket.SortParTab();
|
||||
|
@ -431,11 +489,16 @@ void TicketInfo::RemoveTicket(long file_id)
|
|||
{
|
||||
if( tdb->GetTicket(file_id, rm_ticket) == WINIX_ERR_OK )
|
||||
{
|
||||
// !! WTF?
|
||||
/*
|
||||
for(size_t i=0 ; i<rm_ticket.par_tab.size(); ++i)
|
||||
{
|
||||
long id = rm_ticket.par_tab[i].int_value;
|
||||
functions->fun_rm.RemoveItemById(id);
|
||||
}
|
||||
*/
|
||||
|
||||
//
|
||||
|
||||
tdb->RemoveTicket(file_id);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
@ -13,12 +13,12 @@
|
|||
|
||||
#include <vector>
|
||||
#include "ticket.h"
|
||||
#include "ticketparser.h"
|
||||
#include "core/item.h"
|
||||
#include "core/system.h"
|
||||
#include "functions/functions.h"
|
||||
#include "db/db.h"
|
||||
#include "tdb.h"
|
||||
#include "confparser/confparser.h"
|
||||
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ struct TicketConfWrap
|
|||
{
|
||||
bool to_delete;
|
||||
std::wstring file_name;
|
||||
TicketConf conf;
|
||||
PT::Space conf;
|
||||
|
||||
TicketConfWrap()
|
||||
{
|
||||
|
@ -57,8 +57,11 @@ public:
|
|||
// current ticket for templates
|
||||
const Ticket * ticket;
|
||||
|
||||
// current item for templates
|
||||
Item * item;
|
||||
|
||||
// for displaying all tickets in a directory
|
||||
std::vector<Item> item_tab;
|
||||
std::vector<Item> item_tab; // !! in the future we'll use cur->request->item_tab[number] (an array of arrays)
|
||||
std::vector<Ticket> ticket_tab;
|
||||
std::vector<Item*> item_sort_tab;
|
||||
|
||||
|
@ -69,8 +72,8 @@ public:
|
|||
|
||||
// current ticket config
|
||||
// will be set by FindCurrentConf()
|
||||
const TicketConfWrap * cur_conf_wrap;
|
||||
const TicketConf * cur_conf;
|
||||
TicketConfWrap * cur_conf_wrap;
|
||||
PT::Space * cur_conf;
|
||||
|
||||
// default: "progress"
|
||||
// can be set in config in option: ticket_form_progress_prefix
|
||||
|
@ -90,9 +93,7 @@ public:
|
|||
|
||||
void ReadTicketConf(bool skip_existing_configs = false);
|
||||
void FindCurrentConf();
|
||||
void CheckMinMaxValue(const TicketConf::TicketItem & conf_item, Ticket::TicketParam & par);
|
||||
void ReadTicketParams(Ticket & ticket, bool clear_ticket = true, std::vector<long> * file_map = 0);
|
||||
|
||||
void ReadTicketParams(Ticket & ticket, bool clear_ticket, std::vector<long> & file_map, PT::Space & meta);
|
||||
void RemoveTicket(long file_id);
|
||||
|
||||
private:
|
||||
|
@ -109,17 +110,19 @@ private:
|
|||
|
||||
// for adding a new image/file to a ticket
|
||||
Item file;
|
||||
std::wstring file_path;
|
||||
|
||||
// for reading config file
|
||||
TicketParser ticket_parser;
|
||||
PT::ConfParser conf_parser;
|
||||
std::vector<Item*> config_dir_tab;
|
||||
Item config_file;
|
||||
|
||||
// for Clearing
|
||||
// (we don't want to use empty pointers)
|
||||
const TicketConfWrap cur_conf_wrap_empty;
|
||||
const TicketConf cur_conf_empty;
|
||||
const Ticket ticket_empty;
|
||||
TicketConfWrap cur_conf_wrap_empty;
|
||||
PT::Space cur_conf_empty;
|
||||
const Ticket ticket_empty;
|
||||
Item item_empty;
|
||||
|
||||
// for removing a ticket
|
||||
Ticket rm_ticket;
|
||||
|
@ -129,12 +132,17 @@ private:
|
|||
void ReadTicketConf(Mounts & mounts, bool skip_existing_configs);
|
||||
void MarkAllConfToDelete();
|
||||
void DeleteAllMarkedConf();
|
||||
void ReadTicketConf(const Mount & mount, bool skip_existing_configs);
|
||||
PT::Space & FindAddMetaByParam(PT::Space & meta, long param);
|
||||
|
||||
|
||||
bool ReadTicketValue(const TicketConf::TicketItem & conf_item, Ticket::TicketParam & par, const std::wstring & value);
|
||||
bool ReadTicketValue(const TicketConf::TicketItem & conf_item, Ticket::TicketParam & par, const PostFile & value, std::vector<long> * file_map);
|
||||
void ReadTicketParam(Ticket & ticket, int param_id, const std::wstring & value);
|
||||
void ReadTicketParam(Ticket & ticket, int param_id, const PostFile & value, std::vector<long> * file_map);
|
||||
void CheckMinMaxValue(PT::Space & space, Ticket::TicketParam & par);
|
||||
bool ReadTicketValue(PT::Space & space, long param_id, Ticket::TicketParam & par, const std::wstring & value, PT::Space & meta);
|
||||
void ReadTicketValue(PT::Space & space, long param_id, const PostFile & value, std::vector<long> & file_map, PT::Space & meta, Item & upload_dir);
|
||||
void ReadTicketValue(PT::Space & space, long param_id, const PostFile & value, std::vector<long> & file_map, PT::Space & meta);
|
||||
void ReadTicketParam(PT::Space & space, Ticket & ticket, long param_id, const std::wstring & value, PT::Space & meta);
|
||||
void ReadTicketParam(Ticket & ticket, long param_id, const std::wstring & value, PT::Space & meta);
|
||||
void ReadTicketParam(Ticket & ticket, long param_id, const PostFile & value, std::vector<long> & file_map, PT::Space & meta);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1,436 +0,0 @@
|
|||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ticketparser.h"
|
||||
#include "core/log.h"
|
||||
#include "core/misc.h"
|
||||
|
||||
|
||||
|
||||
|
||||
bool TicketParser::IsWhite(int c)
|
||||
{
|
||||
return (c==' ' || c=='\t' || c==13);
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::SkipLine()
|
||||
{
|
||||
while( *pchar!=0 && *pchar!=10 )
|
||||
pchar += 1;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::SkipWhite()
|
||||
{
|
||||
while( IsWhite(*pchar) || *pchar=='#' )
|
||||
{
|
||||
if( *pchar=='#' )
|
||||
SkipLine();
|
||||
else
|
||||
pchar += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::SkipWhiteLines()
|
||||
{
|
||||
while( IsWhite(*pchar) || *pchar == 10 || *pchar=='#' )
|
||||
{
|
||||
if( *pchar=='#' )
|
||||
SkipLine();
|
||||
else
|
||||
pchar += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::ReadTextQuoted(std::wstring & text)
|
||||
{
|
||||
pchar += 1;
|
||||
|
||||
while( *pchar!=0 && *pchar!=10 && *pchar!='\"' )
|
||||
{
|
||||
if( *pchar == '\\' )
|
||||
pchar += 1;
|
||||
|
||||
text += *pchar;
|
||||
pchar += 1;
|
||||
}
|
||||
|
||||
if( *pchar == '\"' )
|
||||
pchar += 1;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::ReadTextSimple(std::wstring & text, bool comma_separator)
|
||||
{
|
||||
while( *pchar!=0 && *pchar!=10 && !IsWhite(*pchar) && *pchar!='(' && *pchar!=')' &&
|
||||
(!comma_separator || *pchar!=',' ) )
|
||||
{
|
||||
text += *pchar;
|
||||
pchar += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::ReadText(std::wstring & text, bool comma_separator)
|
||||
{
|
||||
SkipWhite();
|
||||
text.clear();
|
||||
|
||||
if( *pchar == '\"' )
|
||||
ReadTextQuoted(text);
|
||||
else
|
||||
ReadTextSimple(text, comma_separator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void TicketParser::CheckId(int & id, bool & def)
|
||||
{
|
||||
if( *pchar != '(' )
|
||||
return;
|
||||
|
||||
// dont set id and def here
|
||||
// there are only changed if exists
|
||||
pchar += 1;
|
||||
|
||||
while( *pchar!=0 && *pchar!=10 && *pchar!=')' )
|
||||
{
|
||||
ReadText(id_str, true);
|
||||
|
||||
if( id_str == L"def" )
|
||||
def = true;
|
||||
else
|
||||
id = Toi(id_str);
|
||||
|
||||
if( *pchar == ',' )
|
||||
pchar += 1;
|
||||
}
|
||||
|
||||
if( *pchar == ')' )
|
||||
pchar += 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool TicketParser::ReadItemType()
|
||||
{
|
||||
ReadText(type);
|
||||
|
||||
if( type.empty() )
|
||||
return false;
|
||||
|
||||
if( type == L"integer" )
|
||||
item.type = TicketConf::TicketItem::TypeInteger;
|
||||
else
|
||||
if( type == L"progress" )
|
||||
item.type = TicketConf::TicketItem::TypeProgress;
|
||||
else
|
||||
if( type == L"select" )
|
||||
item.type = TicketConf::TicketItem::TypeSelect;
|
||||
else
|
||||
if( type == L"string" )
|
||||
item.type = TicketConf::TicketItem::TypeString;
|
||||
else
|
||||
if( type == L"multistring" ) // !! nie skonczone jeszcze?
|
||||
item.type = TicketConf::TicketItem::TypeMultistring;
|
||||
else
|
||||
if( type == L"images" )
|
||||
item.type = TicketConf::TicketItem::TypeImages;
|
||||
else
|
||||
if( type == L"files" )
|
||||
item.type = TicketConf::TicketItem::TypeFiles;
|
||||
else
|
||||
{
|
||||
error = WINIX_TICKET_ERR_UKNOWN_TYPE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::SetItemId()
|
||||
{
|
||||
int id;
|
||||
bool def;
|
||||
|
||||
id = (!pconf->tab.empty()) ? pconf->tab.back().id + 1 : 0;
|
||||
CheckId(id, def);
|
||||
|
||||
item.id = id;
|
||||
}
|
||||
|
||||
|
||||
bool TicketParser::ReadItemName()
|
||||
{
|
||||
ReadText(item.name);
|
||||
|
||||
if( item.name.empty() )
|
||||
{
|
||||
error = WINIX_TICKET_ERR_NO_ITEM_NAME;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::ReadItemInteger()
|
||||
{
|
||||
ReadText(int_min);
|
||||
ReadText(int_max);
|
||||
|
||||
if( !int_min.empty() )
|
||||
item.integer_min = Toi(int_min);
|
||||
|
||||
if( !int_max.empty() )
|
||||
item.integer_max = Toi(int_max);
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::ReadItemSelect()
|
||||
{
|
||||
bool def;
|
||||
|
||||
while( *pchar!=0 && *pchar!=10 )
|
||||
{
|
||||
ReadText(select.name);
|
||||
select.id = (!item.select.empty()) ? item.select.back().id + 1 : 0;
|
||||
def = false;
|
||||
CheckId(select.id, def);
|
||||
|
||||
if( !select.name.empty() )
|
||||
{
|
||||
item.select.push_back(select);
|
||||
|
||||
if( def )
|
||||
item.select_default = item.select.size() - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::ReadItemString()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool TicketParser::ReadItemFiles()
|
||||
{
|
||||
ReadText(item.upload_dir);
|
||||
|
||||
if( item.upload_dir.empty() )
|
||||
{
|
||||
error = WINIX_TICKET_ERR_NO_UPLOAD_DIR;
|
||||
return false;
|
||||
}
|
||||
|
||||
ReadText(int_max);
|
||||
|
||||
if( !int_max.empty() )
|
||||
item.max_files = Toi(int_max);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TicketParser::CheckEndLine()
|
||||
{
|
||||
SkipWhite();
|
||||
|
||||
if( *pchar != 0 && *pchar != 10 )
|
||||
{
|
||||
error = WINIX_TICKET_ERR_SYNTAX_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TicketParser::ReadItem()
|
||||
{
|
||||
SkipWhiteLines();
|
||||
item.Clear();
|
||||
|
||||
if( !ReadItemType() )
|
||||
return false;
|
||||
|
||||
SetItemId();
|
||||
|
||||
if( !ReadItemName() )
|
||||
return false;
|
||||
|
||||
if( item.type == TicketConf::TicketItem::TypeInteger )
|
||||
ReadItemInteger();
|
||||
else
|
||||
if( item.type == TicketConf::TicketItem::TypeProgress )
|
||||
ReadItemInteger();
|
||||
else
|
||||
if( item.type == TicketConf::TicketItem::TypeSelect )
|
||||
ReadItemSelect();
|
||||
else
|
||||
if( item.type == TicketConf::TicketItem::TypeString || item.type == TicketConf::TicketItem::TypeMultistring )
|
||||
ReadItemString();
|
||||
else
|
||||
if( item.type == TicketConf::TicketItem::TypeImages || item.type == TicketConf::TicketItem::TypeFiles )
|
||||
if( !ReadItemFiles() )
|
||||
return false;
|
||||
|
||||
if( !CheckEndLine() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::LogItemInteger(TicketConf::TicketItem & item)
|
||||
{
|
||||
log << log3 << "TicketParser: item_type: integer"
|
||||
<< ", item_name: " << item.name
|
||||
<< ", item_id: " << item.id
|
||||
<< ", min: " << item.integer_min
|
||||
<< ", max: " << item.integer_max
|
||||
<< logend;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::LogItemProgress(TicketConf::TicketItem & item)
|
||||
{
|
||||
log << log3 << "TicketParser: item_type: progress"
|
||||
<< ", item_name: " << item.name
|
||||
<< ", item_id: " << item.id
|
||||
<< ", min: " << item.integer_min
|
||||
<< ", max: " << item.integer_max
|
||||
<< logend;
|
||||
}
|
||||
|
||||
void TicketParser::LogItemSelect(TicketConf::TicketItem & item)
|
||||
{
|
||||
log << log3 << "TicketParser: item_type: select"
|
||||
<< ", item_name: " << item.name
|
||||
<< ", item_id: " << item.id
|
||||
<< ", options: ";
|
||||
|
||||
for(size_t i=0 ; i<item.select.size() ; ++i)
|
||||
{
|
||||
log << item.select[i].name << "(" << item.select[i].id;
|
||||
|
||||
if( item.select_default == i )
|
||||
log << ", def";
|
||||
|
||||
log << ")";
|
||||
|
||||
if( i+1 < item.select.size() )
|
||||
log << ", ";
|
||||
}
|
||||
|
||||
log << logend;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::LogItemString(TicketConf::TicketItem & item)
|
||||
{
|
||||
log << log3 << "TicketParser: item_type: string"
|
||||
<< ", item_name: " << item.name
|
||||
<< ", item_id: " << item.id
|
||||
<< logend;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::LogItemMultistring(TicketConf::TicketItem & item)
|
||||
{
|
||||
log << log3 << "TicketParser: item_type: multistring"
|
||||
<< ", item_name: " << item.name
|
||||
<< ", item_id: " << item.id
|
||||
<< logend;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::LogItemImages(TicketConf::TicketItem & item)
|
||||
{
|
||||
log << log3 << "TicketParser: item_type: images"
|
||||
<< ", item_name: " << item.name
|
||||
<< ", item_id: " << item.id
|
||||
<< ", item_upload_dir: " << item.upload_dir
|
||||
<< logend;
|
||||
}
|
||||
|
||||
|
||||
void TicketParser::LogItemFiles(TicketConf::TicketItem & item)
|
||||
{
|
||||
log << log3 << "TicketParser: item_type: files"
|
||||
<< ", item_name: " << item.name
|
||||
<< ", item_id: " << item.id
|
||||
<< ", item_upload_dir: " << item.upload_dir
|
||||
<< logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TicketParser::LogItem(TicketConf::TicketItem & item)
|
||||
{
|
||||
if( item.type == TicketConf::TicketItem::TypeInteger )
|
||||
LogItemInteger(item);
|
||||
else
|
||||
if( item.type == TicketConf::TicketItem::TypeProgress )
|
||||
LogItemProgress(item);
|
||||
else
|
||||
if( item.type == TicketConf::TicketItem::TypeSelect )
|
||||
LogItemSelect(item);
|
||||
else
|
||||
if( item.type == TicketConf::TicketItem::TypeString )
|
||||
LogItemString(item);
|
||||
else
|
||||
if( item.type == TicketConf::TicketItem::TypeMultistring )
|
||||
LogItemMultistring(item);
|
||||
else
|
||||
if( item.type == TicketConf::TicketItem::TypeImages )
|
||||
LogItemImages(item);
|
||||
else
|
||||
if( item.type == TicketConf::TicketItem::TypeFiles )
|
||||
LogItemFiles(item);
|
||||
else
|
||||
log << log1 << "TicketParser: unknown item type" << logend;
|
||||
}
|
||||
|
||||
|
||||
int TicketParser::Parse(const wchar_t * str, TicketConf & conf)
|
||||
{
|
||||
pchar = str;
|
||||
pconf = &conf;
|
||||
error = WINIX_TICKET_ERR_OK;
|
||||
conf.Clear();
|
||||
|
||||
while( ReadItem() )
|
||||
{
|
||||
conf.tab.push_back(item);
|
||||
LogItem(item);
|
||||
}
|
||||
|
||||
if( error != WINIX_TICKET_ERR_OK )
|
||||
{
|
||||
log << log1 << "TicketParser: some errors occured during parsing the config (clearing the table)" << logend;
|
||||
conf.Clear();
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int TicketParser::Parse(const std::wstring & str, TicketConf & conf)
|
||||
{
|
||||
return Parse(str.c_str(), conf);
|
||||
}
|
|
@ -1,73 +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_ticketparser
|
||||
#define headerfile_winix_plugins_ticket_ticketparser
|
||||
|
||||
|
||||
#include "ticketconf.h"
|
||||
|
||||
#define WINIX_TICKET_ERR_OK 0
|
||||
#define WINIX_TICKET_ERR_UKNOWN_TYPE 1
|
||||
#define WINIX_TICKET_ERR_NO_ITEM_NAME 2
|
||||
#define WINIX_TICKET_ERR_SYNTAX_ERROR 3
|
||||
#define WINIX_TICKET_ERR_NO_UPLOAD_DIR 4
|
||||
|
||||
|
||||
|
||||
class TicketParser
|
||||
{
|
||||
public:
|
||||
|
||||
int Parse(const wchar_t * str, TicketConf & conf);
|
||||
int Parse(const std::wstring & str, TicketConf & conf);
|
||||
|
||||
private:
|
||||
|
||||
TicketConf * pconf;
|
||||
const wchar_t * pchar;
|
||||
int error; // last error code
|
||||
TicketConf::TicketItem item;
|
||||
std::wstring type;
|
||||
std::wstring id_str;
|
||||
std::wstring int_min, int_max;
|
||||
TicketConf::TicketItem::Select select;
|
||||
|
||||
bool IsWhite(int c);
|
||||
void SkipWhite();
|
||||
void SkipWhiteLines();
|
||||
void SkipLine();
|
||||
void ReadTextQuoted(std::wstring & text);
|
||||
void ReadTextSimple(std::wstring & text, bool comma_separator);
|
||||
void ReadText(std::wstring & text, bool comma_separator = false);
|
||||
|
||||
void CheckId(int & id, bool & def);
|
||||
void SetItemId();
|
||||
bool CheckEndLine();
|
||||
|
||||
bool ReadItemType();
|
||||
bool ReadItemName();
|
||||
void ReadItemInteger();
|
||||
void ReadItemSelect();
|
||||
void ReadItemString();
|
||||
bool ReadItemFiles();
|
||||
bool ReadItem();
|
||||
|
||||
void LogItemInteger(TicketConf::TicketItem & item);
|
||||
void LogItemProgress(TicketConf::TicketItem & item);
|
||||
void LogItemSelect(TicketConf::TicketItem & item);
|
||||
void LogItemString(TicketConf::TicketItem & item);
|
||||
void LogItemMultistring(TicketConf::TicketItem & item);
|
||||
void LogItemImages(TicketConf::TicketItem & item);
|
||||
void LogItemFiles(TicketConf::TicketItem & item);
|
||||
void LogItem(TicketConf::TicketItem & item);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -248,7 +248,7 @@ item.o: ../core/users.h ../core/groups.h ../core/group.h ../core/loadavg.h
|
|||
item.o: ../core/image.h ../core/basethread.h ../core/threadmanager.h
|
||||
item.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h
|
||||
item.o: ../core/htmlfilter.h ../core/request.h ../core/misc.h
|
||||
item.o: ../core/bbcodeparser.h
|
||||
item.o: ../core/bbcodeparser.h miscspace.h
|
||||
last.o: templates.h ../../ezc/src/ezc.h ../../ezc/src/generator.h
|
||||
last.o: ../../ezc/src/pattern.h ../../ezc/src/item.h ../../ezc/src/funinfo.h
|
||||
last.o: ../../ezc/src/functions.h ../../ezc/src/stringconv.h misc.h
|
||||
|
@ -393,6 +393,34 @@ misc.o: ../core/users.h ../core/groups.h ../core/group.h ../core/loadavg.h
|
|||
misc.o: ../core/image.h ../core/basethread.h ../core/threadmanager.h
|
||||
misc.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h
|
||||
misc.o: ../core/htmlfilter.h ../core/misc.h ../core/request.h
|
||||
miscspace.o: templates.h ../../ezc/src/ezc.h ../../ezc/src/generator.h
|
||||
miscspace.o: ../../ezc/src/pattern.h ../../ezc/src/item.h
|
||||
miscspace.o: ../../ezc/src/funinfo.h ../../ezc/src/functions.h
|
||||
miscspace.o: ../../ezc/src/stringconv.h misc.h localefilter.h locale.h
|
||||
miscspace.o: htmltextstream.h ../core/textstream.h patterncacher.h
|
||||
miscspace.o: ../core/item.h indexpatterns.h patterns.h changepatterns.h
|
||||
miscspace.o: ../core/config.h ../core/htmlfilter.h ../core/cur.h
|
||||
miscspace.o: ../core/request.h ../core/requesttypes.h ../core/error.h
|
||||
miscspace.o: ../core/config.h ../core/textstream.h
|
||||
miscspace.o: ../templates/htmltextstream.h ../core/session.h ../core/user.h
|
||||
miscspace.o: ../core/plugindata.h ../core/rebus.h ../core/mount.h
|
||||
miscspace.o: ../core/system.h ../core/dirs.h ../core/dircontainer.h
|
||||
miscspace.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
miscspace.o: ../core/error.h ../db/dbitemquery.h ../db/dbitemcolumns.h
|
||||
miscspace.o: ../core/user.h ../core/group.h ../core/dircontainer.h
|
||||
miscspace.o: ../core/ugcontainer.h ../core/log.h ../core/logmanipulators.h
|
||||
miscspace.o: ../core/slog.h ../core/cur.h ../templates/locale.h
|
||||
miscspace.o: ../notify/notify.h ../notify/notifypool.h
|
||||
miscspace.o: ../templates/patterns.h ../notify/notifythread.h
|
||||
miscspace.o: ../core/basethread.h ../core/synchro.h
|
||||
miscspace.o: ../notify/templatesnotify.h ../core/users.h
|
||||
miscspace.o: ../core/ugcontainer.h ../core/lastcontainer.h
|
||||
miscspace.o: ../templates/misc.h ../core/mounts.h ../core/mountparser.h
|
||||
miscspace.o: ../core/crypt.h ../core/run.h ../core/users.h ../core/groups.h
|
||||
miscspace.o: ../core/group.h ../core/loadavg.h ../core/image.h
|
||||
miscspace.o: ../core/basethread.h ../core/threadmanager.h
|
||||
miscspace.o: ../core/sessionmanager.h ../core/sessioncontainer.h
|
||||
miscspace.o: ../core/system.h ../core/htmlfilter.h
|
||||
mount.o: templates.h ../../ezc/src/ezc.h ../../ezc/src/generator.h
|
||||
mount.o: ../../ezc/src/pattern.h ../../ezc/src/item.h ../../ezc/src/funinfo.h
|
||||
mount.o: ../../ezc/src/functions.h ../../ezc/src/stringconv.h misc.h
|
||||
|
|
|
@ -1 +1 @@
|
|||
o = adduser.o changepatterns.o config.o dir.o doc.o env.o filters.o htmltextstream.o indexpatterns.o insert.o item.o last.o locale.o localefilter.o login.o ls.o man.o misc.o mount.o patterncacher.o patterns.o priv.o rebus.o slog.o stat.o sys.o template.o templates.o upload.o uptime.o user.o who.o winix.o
|
||||
o = adduser.o changepatterns.o config.o dir.o doc.o env.o filters.o htmltextstream.o indexpatterns.o insert.o item.o last.o locale.o localefilter.o login.o ls.o man.o misc.o miscspace.o mount.o patterncacher.o patterns.o priv.o rebus.o slog.o stat.o sys.o template.o templates.o upload.o uptime.o user.o who.o winix.o
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "core/misc.h"
|
||||
#include "core/bbcodeparser.h"
|
||||
#include "core/textstream.h"
|
||||
#include "miscspace.h"
|
||||
|
||||
|
||||
|
||||
|
@ -373,6 +374,33 @@ void item_meta_str(Info & i)
|
|||
}
|
||||
|
||||
|
||||
void item_meta(Info & i)
|
||||
{
|
||||
space(i, cur->request->last_item->meta);
|
||||
}
|
||||
|
||||
|
||||
void item_meta_tab(Info & i)
|
||||
{
|
||||
spaces_tab(i, cur->request->last_item->meta);
|
||||
}
|
||||
|
||||
|
||||
void item_meta_tab_value(Info & i)
|
||||
{
|
||||
spaces_tab_value(i, cur->request->last_item->meta);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_meta_tab_has_next(Info & i)
|
||||
{
|
||||
spaces_tab_has_next(i, cur->request->last_item->meta);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static size_t item_index;
|
||||
|
|
|
@ -0,0 +1,351 @@
|
|||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "templates.h"
|
||||
|
||||
|
||||
namespace TemplatesFunctions
|
||||
{
|
||||
|
||||
|
||||
bool are_spaces_the_same(const std::vector<std::wstring> & params, const std::vector<std::wstring> & spaces)
|
||||
{
|
||||
// last value from params is the parameter name (not a space)
|
||||
if( spaces.size() + 1 != params.size() )
|
||||
return false;
|
||||
|
||||
for(size_t i=0 ; i<spaces.size() ; ++i)
|
||||
if( spaces[i] != params[i] )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void copy_space(const std::vector<std::wstring> & params, std::vector<std::wstring> & spaces)
|
||||
{
|
||||
if( !params.empty() )
|
||||
{
|
||||
spaces.resize(params.size() - 1);
|
||||
|
||||
for(size_t i=0 ; i<params.size() - 1 ; ++i)
|
||||
spaces[i] = params[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
spaces.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PT::Space * find_space(const std::vector<std::wstring> & params, PT::Space & space, size_t level = 0)
|
||||
{
|
||||
if( level + 1 < params.size() )
|
||||
{
|
||||
for(size_t i=0 ; i<space.spaces.size() ; ++i)
|
||||
{
|
||||
if( space.spaces[i]->name == params[level] )
|
||||
return find_space(params, *space.spaces[i], level+1);
|
||||
}
|
||||
|
||||
// there is no such a space
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return &space;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct SpaceInfo
|
||||
{
|
||||
bool inited;
|
||||
PT::Space * last_space;
|
||||
std::vector<std::wstring> spaces;
|
||||
|
||||
SpaceInfo()
|
||||
{
|
||||
inited = false;
|
||||
last_space = 0;
|
||||
}
|
||||
};
|
||||
|
||||
static std::map<PT::Space*, SpaceInfo> spaces_map;
|
||||
static size_t space_reqid = 0;
|
||||
|
||||
|
||||
|
||||
void space_init(const std::vector<std::wstring> & params, PT::Space & space, SpaceInfo & space_info)
|
||||
{
|
||||
if( !space_info.inited || !are_spaces_the_same(params, space_info.spaces) )
|
||||
{
|
||||
space_info.inited = true;
|
||||
copy_space(params, space_info.spaces);
|
||||
space_info.last_space = find_space(params, space);
|
||||
}
|
||||
else
|
||||
{
|
||||
// !! temp
|
||||
log << log1 << "taking space from the cache" << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void space_check_reqid()
|
||||
{
|
||||
if( space_reqid != cur->request->id )
|
||||
{
|
||||
space_reqid = cur->request->id;
|
||||
spaces_map.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void space(Info & i, PT::Space & space)
|
||||
{
|
||||
space_check_reqid();
|
||||
|
||||
if( !i.params.empty() )
|
||||
{
|
||||
SpaceInfo & space_info = spaces_map[&space];
|
||||
space_init(i.params, space, space_info);
|
||||
|
||||
if( space_info.last_space )
|
||||
{
|
||||
const std::wstring & param = i.params.back();
|
||||
const std::wstring * value = space_info.last_space->GetValue(param);
|
||||
|
||||
if( value )
|
||||
i.out << *value;
|
||||
else
|
||||
log << log1 << "nie ma takiej wartosci" << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
stack item for [for] statement
|
||||
*/
|
||||
struct SpaceStackItem
|
||||
{
|
||||
// names of the spaces
|
||||
std::vector<std::wstring> spaces;
|
||||
|
||||
// table of values
|
||||
std::vector<std::wstring> values;
|
||||
|
||||
// an index to 'values' which is incremented every each [for]
|
||||
size_t value_index;
|
||||
|
||||
|
||||
SpaceStackItem()
|
||||
{
|
||||
value_index = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
each Space has its own SpacesTabInfo struct
|
||||
*/
|
||||
struct SpacesTabInfo
|
||||
{
|
||||
// a stack for [for] statements
|
||||
std::vector<SpaceStackItem> stack_tab;
|
||||
|
||||
// current item from 'stack_tab'
|
||||
size_t cur_stack;
|
||||
|
||||
SpacesTabInfo()
|
||||
{
|
||||
cur_stack = 0;
|
||||
}
|
||||
};
|
||||
|
||||
static std::map<PT::Space*, SpacesTabInfo> spaces_tab_info_map;
|
||||
static size_t spaces_tab_reqid = 0;
|
||||
|
||||
|
||||
|
||||
bool spaces_tab_find_stack_item(std::vector<std::wstring> & params, SpacesTabInfo & spaces_tab_info)
|
||||
{
|
||||
bool found = false;
|
||||
spaces_tab_info.cur_stack = spaces_tab_info.stack_tab.size();
|
||||
|
||||
for(size_t i=0 ; i<spaces_tab_info.stack_tab.size() ; ++i)
|
||||
{
|
||||
if( are_spaces_the_same(params, spaces_tab_info.stack_tab[i].spaces) )
|
||||
{
|
||||
spaces_tab_info.cur_stack = i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
void spaces_tab_add_to_stack(std::vector<std::wstring> & params, PT::Space & space, SpacesTabInfo & spaces_tab_info)
|
||||
{
|
||||
if( !params.empty() )
|
||||
{
|
||||
// adding a new item at the end (with the default constructor)
|
||||
spaces_tab_info.stack_tab.resize(spaces_tab_info.stack_tab.size() + 1);
|
||||
spaces_tab_info.cur_stack = spaces_tab_info.stack_tab.size() - 1;
|
||||
|
||||
SpaceStackItem & stack_item = spaces_tab_info.stack_tab.back();
|
||||
|
||||
copy_space(params, stack_item.spaces);
|
||||
space.ListText(params.back(), stack_item.values);
|
||||
stack_item.value_index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void spaces_tab_check_reqid()
|
||||
{
|
||||
if( spaces_tab_reqid != cur->request->id )
|
||||
{
|
||||
spaces_tab_reqid = cur->request->id;
|
||||
spaces_tab_info_map.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void spaces_tab_init(std::vector<std::wstring> & params, PT::Space & space, SpacesTabInfo & spaces_tab_info)
|
||||
{
|
||||
PT::Space * child_space = find_space(params, space);
|
||||
|
||||
if( child_space )
|
||||
{
|
||||
if( !spaces_tab_find_stack_item(params, spaces_tab_info) )
|
||||
{
|
||||
// add a new value to the stack
|
||||
spaces_tab_add_to_stack(params, *child_space, spaces_tab_info);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is not such a space
|
||||
spaces_tab_info.cur_stack = spaces_tab_info.stack_tab.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void spaces_tab(Info & i, PT::Space & space)
|
||||
{
|
||||
spaces_tab_check_reqid();
|
||||
|
||||
if( !i.params.empty() )
|
||||
{
|
||||
SpacesTabInfo & spaces_tab_info = spaces_tab_info_map[&space];
|
||||
spaces_tab_init(i.params, space, spaces_tab_info);
|
||||
|
||||
if( spaces_tab_info.cur_stack < spaces_tab_info.stack_tab.size() )
|
||||
{
|
||||
SpaceStackItem & stack_item = spaces_tab_info.stack_tab[spaces_tab_info.cur_stack];
|
||||
|
||||
// i.iter is different for each [for] statement (implemented in EZC)
|
||||
// so we don't have to remember it in our stack
|
||||
// for each the same space we have only one item in the stack, e.g.
|
||||
// [for item_meta "space1" "space2" "value"]
|
||||
// [for item_meta "space1" "space2" "value"]
|
||||
// [end]
|
||||
// [end]
|
||||
// above two [for]s use the same item on our stack
|
||||
stack_item.value_index = i.iter;
|
||||
|
||||
i.res = stack_item.value_index < stack_item.values.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void spaces_tab_value_print(HtmlTextStream & out, SpacesTabInfo & spaces_tab_info)
|
||||
{
|
||||
if( spaces_tab_info.cur_stack < spaces_tab_info.stack_tab.size() )
|
||||
{
|
||||
SpaceStackItem & stack_item = spaces_tab_info.stack_tab[spaces_tab_info.cur_stack];
|
||||
out << stack_item.values[stack_item.value_index];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void spaces_tab_value(Info & i, PT::Space & space)
|
||||
{
|
||||
spaces_tab_check_reqid();
|
||||
SpacesTabInfo & spaces_tab_info = spaces_tab_info_map[&space];
|
||||
|
||||
if( i.params.empty() )
|
||||
{
|
||||
// value from last [for ...] statement
|
||||
spaces_tab_value_print(i.out, spaces_tab_info);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t cur_stack_old = spaces_tab_info.cur_stack;
|
||||
|
||||
if( spaces_tab_find_stack_item(i.params, spaces_tab_info) )
|
||||
spaces_tab_value_print(i.out, spaces_tab_info);
|
||||
|
||||
spaces_tab_info.cur_stack = cur_stack_old;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool spaces_tab_has_next(SpacesTabInfo & spaces_tab_info)
|
||||
{
|
||||
if( spaces_tab_info.cur_stack < spaces_tab_info.stack_tab.size() )
|
||||
{
|
||||
SpaceStackItem & val = spaces_tab_info.stack_tab[spaces_tab_info.cur_stack];
|
||||
return val.value_index + 1 < val.values.size();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void spaces_tab_has_next(Info & i, PT::Space & space)
|
||||
{
|
||||
spaces_tab_check_reqid();
|
||||
SpacesTabInfo & spaces_tab_info = spaces_tab_info_map[&space];
|
||||
|
||||
if( i.params.empty() )
|
||||
{
|
||||
// value from last [for ...] statement
|
||||
i.res = spaces_tab_has_next(spaces_tab_info);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t cur_stack_old = spaces_tab_info.cur_stack;
|
||||
|
||||
if( spaces_tab_find_stack_item(i.params, spaces_tab_info) )
|
||||
i.res = spaces_tab_has_next(spaces_tab_info);
|
||||
|
||||
spaces_tab_info.cur_stack = cur_stack_old;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace TemplatesFunctions
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "templates.h"
|
||||
|
||||
|
||||
|
||||
namespace TemplatesFunctions
|
||||
{
|
||||
|
||||
void space(Info & i, PT::Space & space);
|
||||
|
||||
void spaces_tab(Info & i, PT::Space & space);
|
||||
void spaces_tab_value(Info & i, PT::Space & space);
|
||||
void spaces_tab_has_next(Info & i, PT::Space & space);
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace TemplatesFunctions
|
||||
|
||||
|
|
@ -300,6 +300,10 @@ void Templates::CreateFunctions()
|
|||
ezc_functions.Insert("item_file_size", item_file_size);
|
||||
ezc_functions.Insert("item_sort", item_sort);
|
||||
ezc_functions.Insert("item_meta_str", item_meta_str);
|
||||
ezc_functions.Insert("item_meta", item_meta);
|
||||
ezc_functions.Insert("item_meta_tab", item_meta_tab);
|
||||
ezc_functions.Insert("item_meta_tab_value", item_meta_tab_value);
|
||||
ezc_functions.Insert("item_meta_tab_has_next", item_meta_tab_has_next);
|
||||
|
||||
ezc_functions.Insert("item_tab", item_tab);
|
||||
ezc_functions.Insert("item_tab_index", item_tab_index);
|
||||
|
|
|
@ -223,6 +223,10 @@ namespace TemplatesFunctions
|
|||
void item_file_size(Info & i);
|
||||
void item_sort(Info & i);
|
||||
void item_meta_str(Info & i);
|
||||
void item_meta(Info & i);
|
||||
void item_meta_tab(Info & i);
|
||||
void item_meta_tab_value(Info & i);
|
||||
void item_meta_tab_has_next(Info & i);
|
||||
|
||||
void item_tab(Info & i);
|
||||
void item_tab_index(Info & i);
|
||||
|
|
Loading…
Reference in New Issue