diff --git a/Makefile b/Makefile
index 13d0b13..d62dcfe 100755
--- a/Makefile
+++ b/Makefile
@@ -25,10 +25,11 @@ winix: FORCE
@cd functions ; $(MAKE) -e
@cd templates ; $(MAKE) -e
@cd notify ; $(MAKE) -e
- @cd plugins/stats ; $(MAKE) -e
- @cd plugins/thread ; $(MAKE) -e
- @cd plugins/ticket ; $(MAKE) -e
- @cd plugins/gallery ; $(MAKE) -e
+ @cd plugins/stats ; $(MAKE) -e
+ @cd plugins/thread ; $(MAKE) -e
+ @cd plugins/ticket ; $(MAKE) -e
+ @cd plugins/gallery ; $(MAKE) -e
+ @cd plugins/groupitem ; $(MAKE) -e
@cd ../ezc/src ; $(MAKE) -e
$(CXX) -shared -o winix.so $(CXXFLAGS) core/*.o db/*.o functions/*.o templates/*.o notify/*.o ../ezc/src/ezc.a -lfcgi -lpq -lz -lpthread -lfetch
@cd main ; $(MAKE) -e
@@ -43,10 +44,11 @@ clean:
@cd functions ; $(MAKE) -e clean
@cd templates ; $(MAKE) -e clean
@cd notify ; $(MAKE) -e clean
- @cd plugins/stats ; $(MAKE) -e clean
- @cd plugins/thread ; $(MAKE) -e clean
- @cd plugins/ticket ; $(MAKE) -e clean
- @cd plugins/gallery ; $(MAKE) -e clean
+ @cd plugins/stats ; $(MAKE) -e clean
+ @cd plugins/thread ; $(MAKE) -e clean
+ @cd plugins/ticket ; $(MAKE) -e clean
+ @cd plugins/gallery ; $(MAKE) -e clean
+ @cd plugins/groupitem ; $(MAKE) -e clean
@cd ../ezc/src ; $(MAKE) -e clean
@cd main ; $(MAKE) -e clean
rm -f winix.so
@@ -62,10 +64,11 @@ depend:
@cd functions ; $(MAKE) -e depend
@cd templates ; $(MAKE) -e depend
@cd notify ; $(MAKE) -e depend
- @cd plugins/stats ; $(MAKE) -e depend
- @cd plugins/thread ; $(MAKE) -e depend
- @cd plugins/ticket ; $(MAKE) -e depend
- @cd plugins/gallery ; $(MAKE) -e depend
+ @cd plugins/stats ; $(MAKE) -e depend
+ @cd plugins/thread ; $(MAKE) -e depend
+ @cd plugins/ticket ; $(MAKE) -e depend
+ @cd plugins/gallery ; $(MAKE) -e depend
+ @cd plugins/groupitem ; $(MAKE) -e depend
@cd ../ezc/src ; $(MAKE) -e depend
@cd main ; $(MAKE) -e depend
diff --git a/db/dbitemquery.cpp b/db/dbitemquery.cpp
index 8298dd6..dbaaa37 100755
--- a/db/dbitemquery.cpp
+++ b/db/dbitemquery.cpp
@@ -14,6 +14,12 @@
DbItemQuery::DbItemQuery()
+{
+ Clear();
+}
+
+
+void DbItemQuery::Clear()
{
sort_asc = true;
@@ -30,6 +36,7 @@ DbItemQuery::DbItemQuery()
limit = 0; // limit and offset not used by default
offset = 0;
+
}
diff --git a/db/dbitemquery.h b/db/dbitemquery.h
index 6b45872..a3bdca1 100755
--- a/db/dbitemquery.h
+++ b/db/dbitemquery.h
@@ -52,7 +52,8 @@ struct DbItemQuery
long offset;
DbItemQuery();
-
+ void Clear();
+
void SetAllSel(bool sel);
void SetAllWhere(bool where_);
void SetAll(bool sel, bool where_);
diff --git a/html/index_head_functions_add.html b/html/index_head_functions_add.html
index 92ceb11..6236749 100755
--- a/html/index_head_functions_add.html
+++ b/html/index_head_functions_add.html
@@ -32,6 +32,7 @@
[if winix_function_is "ticket"]
+[# !! dodac lightboxa tylko jesli tickety zawieraja obrazki ]
@@ -53,10 +54,5 @@
[end]
-
- [if gallery_mount_type_arg_is "galleriathumbwhite"]
-
-
- [end]
[end]
diff --git a/plugins/groupitem/Makefile b/plugins/groupitem/Makefile
new file mode 100755
index 0000000..eb09c03
--- /dev/null
+++ b/plugins/groupitem/Makefile
@@ -0,0 +1,27 @@
+include Makefile.o.dep
+
+name = groupitem.so
+
+
+all: $(o)
+ $(CXX) -shared -Wl,-soname,$(name).so -o $(name) $(CXXFLAGS) *.o
+
+
+
+.SUFFIXES: .cpp .o
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $<
+
+
+
+depend:
+ makedepend -Y. -I../.. -I../../../ezc/src -f- *.cpp > Makefile.dep
+ echo -n "o = " > Makefile.o.dep
+ ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
+
+clean:
+ rm -f *.o
+ rm -f $(name)
+
+include Makefile.dep
diff --git a/plugins/groupitem/Makefile.dep b/plugins/groupitem/Makefile.dep
new file mode 100755
index 0000000..9a51b27
--- /dev/null
+++ b/plugins/groupitem/Makefile.dep
@@ -0,0 +1,105 @@
+# DO NOT DELETE
+
+init.o: ../../core/log.h ../../core/textstream.h ../../core/misc.h
+init.o: ../../core/item.h ../../core/plugin.h ../../core/pluginmsg.h
+init.o: ../../core/log.h ../../core/plugindata.h ../../core/config.h
+init.o: ../../core/confparser.h ../../core/htmlfilter.h ../../core/request.h
+init.o: ../../core/requesttypes.h ../../core/error.h
+init.o: ../../templates/htmltextstream.h ../../core/textstream.h
+init.o: ../../core/system.h ../../core/dirs.h ../../core/dircontainer.h
+init.o: ../../db/db.h ../../db/dbbase.h ../../db/dbconn.h
+init.o: ../../db/dbtextstream.h ../../core/error.h ../../db/dbitemquery.h
+init.o: ../../core/item.h ../../db/dbitemcolumns.h ../../core/user.h
+init.o: ../../core/group.h ../../core/dircontainer.h ../../core/ugcontainer.h
+init.o: ../../notify/notify.h ../../notify/notifypool.h
+init.o: ../../templates/locale.h ../../core/confparser.h
+init.o: ../../templates/misc.h ../../templates/localefilter.h
+init.o: ../../templates/locale.h ../../../ezc/src/ezc.h
+init.o: ../../../ezc/src/utf8.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: ../../templates/htmltextstream.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/user.h ../../core/ugcontainer.h ../../core/lastcontainer.h
+init.o: ../../core/cur.h ../../core/session.h ../../core/rebus.h
+init.o: ../../core/mounts.h ../../core/mount.h ../../core/mountparser.h
+init.o: ../../core/users.h ../../core/groups.h ../../core/group.h
+init.o: ../../core/loadavg.h ../../core/thumb.h ../../core/basethread.h
+init.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h
+init.o: ../../functions/functions.h ../../functions/functionbase.h
+init.o: ../../core/request.h ../../core/system.h ../../core/synchro.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: ../../functions/chown.h ../../functions/ckeditor.h
+init.o: ../../functions/cp.h ../../functions/default.h
+init.o: ../../functions/download.h ../../functions/emacs.h
+init.o: ../../functions/last.h ../../functions/login.h
+init.o: ../../functions/logout.h ../../functions/ln.h ../../functions/ls.h
+init.o: ../../functions/mkdir.h ../../functions/mv.h ../../functions/node.h
+init.o: ../../functions/priv.h ../../functions/reload.h ../../functions/rm.h
+init.o: ../../functions/run.h ../../functions/specialdefault.h
+init.o: ../../functions/stat.h ../../functions/subject.h
+init.o: ../../functions/template.h ../../functions/tinymce.h
+init.o: ../../functions/uname.h ../../functions/upload.h
+init.o: ../../functions/uptime.h ../../functions/who.h ../../functions/vim.h
+init.o: ../../core/htmlfilter.h ../../templates/templates.h
+init.o: ../../templates/patterncacher.h ../../templates/ckeditorgetparser.h
+init.o: ../../core/httpsimpleparser.h ../../core/log.h
+init.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h
+templates.o: ../../templates/templates.h ../../../ezc/src/ezc.h
+templates.o: ../../../ezc/src/utf8.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 ../../core/misc.h
+templates.o: ../../templates/patterncacher.h ../../core/item.h
+templates.o: ../../templates/ckeditorgetparser.h
+templates.o: ../../core/httpsimpleparser.h ../../core/log.h
+templates.o: ../../templates/indexpatterns.h ../../templates/localefilter.h
+templates.o: ../../templates/locale.h ../../core/config.h ../../db/db.h
+templates.o: ../../db/dbbase.h ../../db/dbconn.h ../../db/dbtextstream.h
+templates.o: ../../core/textstream.h ../../core/error.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: ../../templates/htmltextstream.h ../../core/cur.h
+templates.o: ../../core/system.h ../../core/sessionmanager.h
+templates.o: ../../core/plugin.h ../../core/pluginmsg.h
+templates.o: ../../core/plugindata.h ../../core/config.h
+templates.o: ../../core/confparser.h ../../core/htmlfilter.h
+templates.o: ../../core/request.h ../../core/requesttypes.h
+templates.o: ../../core/error.h ../../core/textstream.h
+templates.o: ../../templates/htmltextstream.h ../../core/system.h
+templates.o: ../../core/dirs.h ../../core/dircontainer.h
+templates.o: ../../notify/notify.h ../../notify/notifypool.h
+templates.o: ../../templates/locale.h ../../core/confparser.h
+templates.o: ../../templates/misc.h ../../notify/notifythread.h
+templates.o: ../../core/basethread.h ../../core/synchro.h
+templates.o: ../../notify/templatesnotify.h ../../core/users.h
+templates.o: ../../core/user.h ../../core/ugcontainer.h
+templates.o: ../../core/lastcontainer.h ../../core/cur.h ../../core/session.h
+templates.o: ../../core/rebus.h ../../core/mounts.h ../../core/mount.h
+templates.o: ../../core/mountparser.h ../../core/users.h ../../core/groups.h
+templates.o: ../../core/group.h ../../core/loadavg.h ../../core/thumb.h
+templates.o: ../../core/basethread.h ../../core/sessionmanager.h
+templates.o: ../../core/sessioncontainer.h ../../functions/functions.h
+templates.o: ../../functions/functionbase.h ../../core/request.h
+templates.o: ../../core/synchro.h ../../functions/functionparser.h
+templates.o: ../../functions/adduser.h ../../functions/cat.h
+templates.o: ../../functions/chmod.h ../../functions/privchanger.h
+templates.o: ../../functions/chown.h ../../functions/ckeditor.h
+templates.o: ../../functions/cp.h ../../functions/default.h
+templates.o: ../../functions/download.h ../../functions/emacs.h
+templates.o: ../../functions/last.h ../../functions/login.h
+templates.o: ../../functions/logout.h ../../functions/ln.h
+templates.o: ../../functions/ls.h ../../functions/mkdir.h
+templates.o: ../../functions/mv.h ../../functions/node.h
+templates.o: ../../functions/priv.h ../../functions/reload.h
+templates.o: ../../functions/rm.h ../../functions/run.h
+templates.o: ../../functions/specialdefault.h ../../functions/stat.h
+templates.o: ../../functions/subject.h ../../functions/template.h
+templates.o: ../../functions/tinymce.h ../../functions/uname.h
+templates.o: ../../functions/upload.h ../../functions/uptime.h
+templates.o: ../../functions/who.h ../../functions/vim.h
+templates.o: ../../core/htmlfilter.h
diff --git a/plugins/groupitem/Makefile.o.dep b/plugins/groupitem/Makefile.o.dep
new file mode 100755
index 0000000..e9002ba
--- /dev/null
+++ b/plugins/groupitem/Makefile.o.dep
@@ -0,0 +1 @@
+o = init.o templates.o
diff --git a/plugins/groupitem/init.cpp b/plugins/groupitem/init.cpp
new file mode 100755
index 0000000..b7c709d
--- /dev/null
+++ b/plugins/groupitem/init.cpp
@@ -0,0 +1,50 @@
+/*
+ * This file is a part of Winix
+ * and is not publicly distributed
+ *
+ * Copyright (c) 2011, Tomasz Sowa
+ * All rights reserved.
+ *
+ */
+
+
+#include "core/log.h"
+#include "core/plugin.h"
+
+
+
+extern "C" void Init(PluginInfo &);
+
+
+
+
+namespace Groupitem
+{
+
+
+const wchar_t plugin_name[] = L"groupitem";
+
+
+
+
+
+
+void AddEzcFunctions(PluginInfo & info);
+
+} // namespace
+
+
+
+
+
+void Init(PluginInfo & info)
+{
+using namespace Groupitem;
+
+ plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions);
+
+
+ info.p1 = (void*)(plugin_name);
+}
+
+
diff --git a/plugins/groupitem/templates.cpp b/plugins/groupitem/templates.cpp
new file mode 100755
index 0000000..6771f12
--- /dev/null
+++ b/plugins/groupitem/templates.cpp
@@ -0,0 +1,37 @@
+/*
+ * This file is a part of Winix
+ * and is not publicly distributed
+ *
+ * Copyright (c) 2011, Tomasz Sowa
+ * All rights reserved.
+ *
+ */
+
+#include "templates/templates.h"
+#include "core/plugin.h"
+
+
+namespace Groupitem
+{
+using namespace TemplatesFunctions;
+using TemplatesFunctions::system;
+
+
+
+
+
+
+void AddEzcFunctions(PluginInfo & info)
+{
+ using TemplatesFunctions::EzcFun;
+ EzcFun * fun = reinterpret_cast(info.p1);
+
+// fun->Insert("gallery_tab", gallery_tab);
+}
+
+
+} // namespace
+
+
+
+
diff --git a/plugins/thread/init.cpp b/plugins/thread/init.cpp
index 2931417..4f37029 100755
--- a/plugins/thread/init.cpp
+++ b/plugins/thread/init.cpp
@@ -75,6 +75,7 @@ void AddMounts(PluginInfo & info)
void RemoveThread(PluginInfo & i)
{
thread_info.RemoveThread(i.l1);
+ thread_info.RemoveThreadAnswer(i.l1);
}
@@ -128,6 +129,18 @@ void EndRequest(PluginInfo & info)
}
+// !! temporarily
+void Rescan(PluginInfo & info)
+{
+ if( info.config->Bool(L"thread_rescan", false) == true )
+ {
+ log << log1 << "---------- rescanning thread db ------------- " << logend;
+ thread_info.Repair();
+ log << log1 << "---------- thread db rescanning is finished ------------- " << logend;
+ }
+}
+
+
} // namespace
@@ -152,6 +165,9 @@ using namespace Thread;
plugin.Assign(WINIX_PL_THREAD_SET_SORTTAB_INDEX, SetSortTabIndex);
plugin.Assign(WINIX_PL_THREAD_PREPARE_THREAD, PrepareThread);
+ // temporarily
+ plugin.Assign(WINIX_PLUGIN_INIT, Rescan);
+
tdb.SetConn(info.db->GetConn());
tdb.LogQueries(info.config->log_db_query);
diff --git a/plugins/thread/reply.cpp b/plugins/thread/reply.cpp
index 443a173..301f59e 100755
--- a/plugins/thread/reply.cpp
+++ b/plugins/thread/reply.cpp
@@ -75,7 +75,7 @@ void Reply::MakePost()
// !! jak bedzie dostepne assert
// ASSERT(files_dir)
- if( tdb->GetThreadByFileId(cur->request->item.id, thread) != WINIX_ERR_OK )
+ if( tdb->GetThread(cur->request->item.id, thread) != WINIX_ERR_OK )
{
thread.Clear();
thread.file_id = cur->request->item.id;
@@ -99,7 +99,7 @@ void Reply::MakePost()
cur->request->status = system->AddFile(answer);
if( cur->request->status == WINIX_ERR_OK )
- cur->request->status = tdb->EditThreadAddItem(cur->request->item.id, answer.id);
+ cur->request->status = tdb->AddAnswer(cur->request->item.id, answer.id);
if( cur->request->status == WINIX_ERR_OK )
diff --git a/plugins/thread/tdb.cpp b/plugins/thread/tdb.cpp
index 8d61d82..0414142 100755
--- a/plugins/thread/tdb.cpp
+++ b/plugins/thread/tdb.cpp
@@ -58,7 +58,7 @@ void TDb::SetThread(PGresult * r, int col, Thread & thread)
-Error TDb::GetThreadByFileId(long file_id, Thread & thread)
+Error TDb::GetThread(long file_id, Thread & thread)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
@@ -175,7 +175,7 @@ return status;
-Error TDb::EditThreadAddItem(long file_id, long answer_id)
+Error TDb::AddAnswer(long file_id, long answer_id)
{
query.Clear();
query << R("insert into plugins.thread_files (file_id, answer_id) values (")
@@ -200,7 +200,7 @@ return DoCommand(query);
-long TDb::FindLastItem(long file_id)
+long TDb::FindLastAnswer(long file_id)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
@@ -231,7 +231,7 @@ return last_item_id;
-Error TDb::EditThreadRemoveItem(long item_id)
+Error TDb::RemoveAnswer(long answer_id)
{
PGresult * r1 = 0;
PGresult * r2 = 0;
@@ -239,10 +239,10 @@ Error TDb::EditThreadRemoveItem(long item_id)
try
{
- // selecting files which have item_id as an answer
+ // selecting files which have answer_id as an answer
query.Clear();
query << R("select file_id from plugins.thread_files where answer_id = ")
- << item_id
+ << answer_id
<< R(";");
r1 = AssertQuery(query);
@@ -254,10 +254,11 @@ Error TDb::EditThreadRemoveItem(long item_id)
for(int i=0 ; i & file_id_tab)
+ query.Clear();
+ query << R("update plugins.thread set (replies, last_item) = (replies-1,")
+ << last_item_id
+ << R(") where file_id=")
+ << file_id
+ << R(";");
+
+return DoCommand(query);
+}
+
+
+
+Error TDb::RemoveAnswerRecalcLast(const std::vector & file_id_tab)
{
for(size_t i=0 ; i 0 )
+ log << log2 << "ThreadDb: deleted " << rows << " rows from plugins.thread_files" << logend;
+ }
+ catch(const Error & e)
+ {
+ status = e;
+ }
+
+ ClearResult(r);
+
+return status;
+}
+
+
+
+
+
+void TDb::GetAllThreadsId(std::vector & file_id)
+{
+ PGresult * r = 0;
+ file_id.clear();
+
+ try
+ {
+ query.Clear();
+ query << R("select file_id from plugins.thread;");
+
+ r = AssertQuery(query);
+ AssertResult(r, PGRES_TUPLES_OK);
+
+ int rows = Rows(r);
+ file_id.resize(rows);
+
+ for(int i=0 ; i & file_id_tab, std::vector & thread_tab);
- Error GetAnswers(long file_id, std::vector & answer_id_tab);
- Error EditThreadAddItem(long file_id, long answer_id);
- Error EditThreadRemoveItem(long file_id);
Error RemoveThread(long file_id);
- long FindLastItem(long file_id);
+
+ Error AddAnswer(long file_id, long answer_id);
+ Error GetAnswers(long file_id, std::vector & answer_id_tab);
+ Error RemoveAnswer(long answer_id);
+
+
+ /*
+ low level interface
+ */
+
+ // looking for the last answer in a thread (in 'thread_files' table)
+ // this is not the value from 'thread' table
+ long FindLastAnswer(long file_id);
+
+ // returning all threads id (file_id) (from 'thread' table)
+ void GetAllThreadsId(std::vector & file_id);
+
+ // removing only the answer in 'thread_files' table without updating 'thread' table
+ Error RemoveAnswerOnly(long answer_id);
+
+ // returning how many answers there are
+ // calculating from 'thread_files' table
+ // this is not the value from 'thread' table
+ long CalcAnswers(long file_id);
+
+ // recalculating last_item, replies in 'thread' table on a given thread
+ Error RecalcThread(long file_id);
+
private:
@@ -43,9 +71,10 @@ private:
Thread thread_temp;
std::vector file_id_tab;
- void SetThreadColumns(PGresult * r);
- void SetThread(PGresult * r, int col, Thread & thread);
- Error EditThreadRecalcFiles(const std::vector & file_id_tab);
+ void SetThreadColumns(PGresult * r);
+ void SetThread(PGresult * r, int col, Thread & thread);
+ Error RemoveAnswerRecalcLast(long file_id);
+ Error RemoveAnswerRecalcLast(const std::vector & file_id_tab);
};
diff --git a/plugins/thread/threadinfo.cpp b/plugins/thread/threadinfo.cpp
index 69b6398..9525f6e 100755
--- a/plugins/thread/threadinfo.cpp
+++ b/plugins/thread/threadinfo.cpp
@@ -71,6 +71,67 @@ void ThreadInfo::RemoveThread(long file_id)
+void ThreadInfo::RemoveThreadAnswer(long answer_id)
+{
+ tdb->RemoveAnswer(answer_id);
+}
+
+
+
+void ThreadInfo::RepairAnswer(long answer_id)
+{
+ iq.Clear();
+ iq.SetAll(false, false);
+ iq.WhereId(answer_id);
+ iq.WhereType(Item::file); // !! moze w przyszlosci pozwolic takze na symlinki?
+
+ if( db->GetItem(repair_item, iq) == WINIX_ERR_NO_ITEM )
+ {
+ log << log3 << "ThreadInfo: there is no a file for thread answer_id: " << answer_id << logend;
+ tdb->RemoveAnswerOnly(answer_id);
+ }
+}
+
+
+
+void ThreadInfo::RepairAnswers(long file_id)
+{
+ tdb->GetAnswers(file_id, repair_answer_tab);
+
+ for(size_t i=0 ; iGetItem(repair_item, iq) == WINIX_ERR_NO_ITEM )
+ {
+ log << log3 << "ThreadInfo: there is no a file for thread file_id: " << file_id << logend;
+ tdb->RemoveThread(file_id);
+ }
+ else
+ {
+ RepairAnswers(file_id);
+ tdb->RecalcThread(file_id);
+ }
+}
+
+
+void ThreadInfo::Repair()
+{
+ tdb->GetAllThreadsId(repair_id_tab);
+
+ for(size_t i=0 ; i out_dir_tab;
- std::vector remove_answer_id_tab;
- Item out_item;
+ std::vector remove_answer_id_tab, repair_id_tab, repair_answer_tab;
+ Item out_item, repair_item;
+ DbItemQuery iq;
+ void RepairAnswer(long answer_id);
+ void RepairAnswers(long file_id);
+ void Repair(long file_id);
};