fixed: find_ticket_value (in plugins/ticket/templates.cpp)

should find the first item (can be more than one item with the same 'param')

fixed: added sorting tickets params in ReadTicketParams() (in plugins/ticket/ticketinfo.cpp)

fixed: plugin should have its own 'PluginInfo info' struct
a plugin's function can call another plugin's functions

added: removing tickets files/images

added: removing threads

changed: rm function will call WINIX_FILE_REMOVED now when deleting directories





git-svn-id: svn://ttmath.org/publicrep/winix/trunk@710 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2011-01-23 23:23:24 +00:00
parent 915cabdf97
commit 3071df227a
47 changed files with 418 additions and 222 deletions

View File

@@ -214,7 +214,7 @@ showthreads.o: ../../core/synchro.h tdb.h thread.h ../../db/dbbase.h
showthreads.o: threadinfo.h
tdb.o: tdb.h thread.h ../../db/dbbase.h ../../core/error.h ../../core/log.h
tdb.o: ../../core/textstream.h ../../core/log.h
templates.o: threadinfo.h thread.h ../../core/item.h ../../core/system.h
templates.o: threadinfo.h ../../core/item.h ../../core/system.h
templates.o: ../../core/dirs.h ../../core/item.h ../../core/dircontainer.h
templates.o: ../../db/db.h ../../db/dbbase.h ../../db/dbconn.h
templates.o: ../../db/dbtextstream.h ../../core/textstream.h
@@ -240,15 +240,15 @@ templates.o: ../../core/mount.h ../../core/mountparser.h ../../core/config.h
templates.o: ../../core/confparser.h ../../core/htmlfilter.h
templates.o: ../../core/users.h ../../core/groups.h ../../core/group.h
templates.o: ../../core/loadavg.h ../../core/thumb.h ../../core/basethread.h
templates.o: reply.h ../../functions/functionbase.h ../../core/request.h
templates.o: thread.h tdb.h ../../db/dbbase.h reply.h
templates.o: ../../functions/functionbase.h ../../core/request.h
templates.o: ../../core/requesttypes.h ../../templates/htmltextstream.h
templates.o: ../../core/synchro.h tdb.h ../../db/dbbase.h funthread.h
templates.o: createthread.h showthreads.h ../../core/misc.h
templates.o: ../../core/plugin.h pluginmsg.h ../../core/system.h
templates.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h
templates.o: ../../functions/functions.h ../../functions/functionbase.h
templates.o: ../../functions/functionparser.h ../../core/cur.h
templates.o: ../../functions/adduser.h ../../functions/cat.h
templates.o: ../../core/synchro.h funthread.h createthread.h showthreads.h
templates.o: ../../core/misc.h ../../core/plugin.h pluginmsg.h
templates.o: ../../core/system.h ../../core/sessionmanager.h
templates.o: ../../core/sessioncontainer.h ../../functions/functions.h
templates.o: ../../functions/functionbase.h ../../functions/functionparser.h
templates.o: ../../core/cur.h ../../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
@@ -269,7 +269,7 @@ templates.o: ../../templates/patterncacher.h
templates.o: ../../templates/ckeditorgetparser.h
templates.o: ../../core/httpsimpleparser.h ../../core/log.h
templates.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h
threadinfo.o: threadinfo.h thread.h ../../core/item.h ../../core/system.h
threadinfo.o: threadinfo.h ../../core/item.h ../../core/system.h
threadinfo.o: ../../core/dirs.h ../../core/item.h ../../core/dircontainer.h
threadinfo.o: ../../db/db.h ../../db/dbbase.h ../../db/dbconn.h
threadinfo.o: ../../db/dbtextstream.h ../../core/textstream.h
@@ -295,3 +295,4 @@ threadinfo.o: ../../core/mount.h ../../core/mountparser.h ../../core/config.h
threadinfo.o: ../../core/confparser.h ../../core/htmlfilter.h
threadinfo.o: ../../core/users.h ../../core/groups.h ../../core/group.h
threadinfo.o: ../../core/loadavg.h ../../core/thumb.h ../../core/basethread.h
threadinfo.o: thread.h tdb.h ../../db/dbbase.h

View File

@@ -69,7 +69,7 @@ void CreateThread::MakePost()
if( cur->request->status == WINIX_ERR_OK )
{
thread.Clear();
thread.file_id = cur->request->item.id;
thread.file_id = cur->request->item.id;
cur->request->status = tdb->AddThread(thread);
}

View File

@@ -51,9 +51,6 @@ return true;
void FunThread::PrepareThread(long file_id)
{
thread_info->Clear();
//cur->request->status = tdb->GetThreadByFileId(file_id, thread);
cur->request->status = tdb->GetAnswers(file_id, id_tab);
if( !id_tab.empty() )
@@ -68,6 +65,7 @@ void FunThread::PrepareThread(long file_id)
iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
db->GetItems(thread_info->item_tab, iq);
system->CheckAccessToItems(thread_info->item_tab);
thread_info->item_sort_tab.resize(thread_info->item_tab.size());
@@ -75,8 +73,6 @@ void FunThread::PrepareThread(long file_id)
for(size_t i=0 ; i<thread_info->item_tab.size() ; ++i)
thread_info->item_sort_tab[i] = &thread_info->item_tab[i];
}
system->CheckAccessToItems(thread_info->item_tab);
}

View File

@@ -74,7 +74,7 @@ void AddMounts(PluginInfo & info)
void RemoveThread(PluginInfo & i)
{
thread_info.RemoveThread(i.l1);
}
@@ -97,6 +97,9 @@ void SetSortTab(PluginInfo & info)
typedef std::vector<Item*> SortTab;
SortTab * psort_tab = reinterpret_cast<SortTab*>(info.p1);
// !! dodac jakies czyszczenie tej tablicy wskaznikow na koncu przetwarzania requestu
// aby kiedys przypadkowo nie odwolac sie do nie istniejacego obiektu
// poprzez bezposrednie uzycie jakiejs funkcji z ezc
thread_info.item_sort_tab = *psort_tab;
}
@@ -130,23 +133,25 @@ void Init(PluginInfo & info)
{
using namespace Thread;
plugin.Assign(WINIX_CREATE_FUNCTIONS, AddFunctions);
plugin.Assign(WINIX_SELECT_DEFAULT_FUNCTION, SelectDefaultFunction);
plugin.Assign(WINIX_ADD_MOUNTS, AddMounts);
plugin.Assign(WINIX_FILE_REMOVED, RemoveThread);
plugin.Assign(WINIX_NOTIFY_ADD_TEMPLATE, AddNotifyTemplate);
plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions);
plugin.Assign(WINIX_CREATE_FUNCTIONS, AddFunctions);
plugin.Assign(WINIX_SELECT_DEFAULT_FUNCTION, SelectDefaultFunction);
plugin.Assign(WINIX_ADD_MOUNTS, AddMounts);
plugin.Assign(WINIX_FILE_REMOVED, RemoveThread);
plugin.Assign(WINIX_NOTIFY_ADD_TEMPLATE, AddNotifyTemplate);
plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions);
// for other plugins
plugin.Assign(WINIX_PL_THREAD_SET_SORTTAB, SetSortTab);
plugin.Assign(WINIX_PL_THREAD_READ_THREADS, ReadThreads);
plugin.Assign(WINIX_PL_THREAD_SET_SORTTAB, SetSortTab);
plugin.Assign(WINIX_PL_THREAD_READ_THREADS, ReadThreads);
plugin.Assign(WINIX_PL_THREAD_SET_SORTTAB_INDEX, SetSortTabIndex);
plugin.Assign(WINIX_PL_THREAD_PREPARE_THREAD, PrepareThread);
plugin.Assign(WINIX_PL_THREAD_PREPARE_THREAD, PrepareThread);
tdb.SetConn(info.db->GetConn());
tdb.LogQueries(info.config->log_db_query);
// thread_info and fun_show_threads are used in 'ticket' plugins too
thread_info.SetDb(info.db);
thread_info.SetTDb(&tdb);
thread_info.SetSystem(info.system);
thread_info.plugin_id = info.plugin_id;

View File

@@ -12,11 +12,13 @@
#define WINIX_PL_THREAD_SET_SORTTAB 4000
#define WINIX_PL_THREAD_READ_THREADS 4001
#define WINIX_PL_THREAD_SET_SORTTAB_INDEX 4002
#define WINIX_PL_THREAD_CAN_USE_REPLY 4003
#define WINIX_PL_THREAD_PREPARE_THREAD 4004
#define WINIX_PL_THREAD_SET_SORTTAB 4000
#define WINIX_PL_THREAD_READ_THREADS 4001
#define WINIX_PL_THREAD_SET_SORTTAB_INDEX 4002
#define WINIX_PL_THREAD_PREPARE_THREAD 4003
#endif

View File

@@ -21,6 +21,7 @@ namespace Thread
Reply::Reply()
{
fun.url = L"reply";
files_dir = 0;
}
@@ -37,22 +38,18 @@ void Reply::SetThreadInfo(ThreadInfo * pthread_info)
}
/*
we can use 'reply' function everywhere where 'thread_dir' mount option is defined
if there is no such a thread in 'thread' table it will be added automatically
*/
bool Reply::HasAccess()
{
if( !cur->request->is_item )
return false;
Item * dir = thread_info->FindThreadDir();
files_dir = thread_info->FindThreadDir();
if( !dir || !system->HasWriteAccess(*dir) )
return false;
plugin.Call(WINIX_PL_THREAD_CAN_USE_REPLY);
if( plugin.True() > 0 )
return true;
if( system->mounts.pmount->type != thread_info->mount_type_thread )
if( !files_dir || !system->HasWriteAccess(*files_dir) )
return false;
return true;
@@ -62,13 +59,8 @@ return true;
void Reply::MakePost()
{
Item * dir = thread_info->FindThreadDir();
if( !dir )
{
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
return;
}
// !! jak bedzie dostepne assert
// ASSERT(files_dir)
if( tdb->GetThreadByFileId(cur->request->item.id, thread) != WINIX_ERR_OK )
{
@@ -85,7 +77,7 @@ void Reply::MakePost()
functions->ReadItem(answer, Item::file);
functions->SetUser(answer);
functions->PrepareUrl(answer);
answer.parent_id = dir->id;
answer.parent_id = files_dir->id;
answer.privileges = 0644; // !! tymczasowo
if( functions->CheckAbuse() )

View File

@@ -38,6 +38,7 @@ private:
ThreadInfo * thread_info;
Item answer;
Thread thread;
Item * files_dir;
};

View File

@@ -96,17 +96,6 @@ void ShowThreads::ReadFiles()
}
void ShowThreads::ReadThreads()
{
// reading threads for the files
file_id_tab.resize(thread_info->item_sort_tab.size());
for(size_t i=0 ; i<thread_info->item_sort_tab.size() ; ++i)
file_id_tab[i] = thread_info->item_sort_tab[i]->id;
tdb->GetThreads(file_id_tab, thread_info->thread_tab);
}
void ShowThreads::CreatePointers()
{
@@ -118,7 +107,6 @@ void ShowThreads::CreatePointers()
}
void ShowThreads::SortPointers()
{
int sort_type = 1;
@@ -132,6 +120,19 @@ void ShowThreads::SortPointers()
void ShowThreads::ReadThreads()
{
// reading threads for the files
file_id_tab.resize(thread_info->item_sort_tab.size());
for(size_t i=0 ; i<thread_info->item_sort_tab.size() ; ++i)
file_id_tab[i] = thread_info->item_sort_tab[i]->id;
tdb->GetThreads(file_id_tab, thread_info->thread_tab);
}
void ShowThreads::MakeGet()
{
thread_info->Clear();

View File

@@ -175,12 +175,12 @@ return status;
Error TDb::EditThreadAddItem(long file_id, long item_id)
Error TDb::EditThreadAddItem(long file_id, long answer_id)
{
query.Clear();
query << R("insert into plugins.thread_files (file_id, answer_id) values (")
<< file_id
<< item_id
<< answer_id
<< R(");");
Error status = DoCommand(query);
@@ -190,7 +190,7 @@ Error TDb::EditThreadAddItem(long file_id, long item_id)
query.Clear();
query << R("update plugins.thread set (last_item, replies) = (")
<< item_id
<< answer_id
<< R(", replies+1) where file_id=")
<< file_id
<< R(";");

View File

@@ -17,6 +17,7 @@
#include "core/error.h"
namespace Thread
{
@@ -29,7 +30,7 @@ public:
Error GetThreadByFileId(long file_id, Thread & thread);
Error GetThreads(const std::vector<long> & file_id_tab, std::vector<Thread> & thread_tab);
Error GetAnswers(long file_id, std::vector<long> & answer_id_tab);
Error EditThreadAddItem(long file_id, long item_id);
Error EditThreadAddItem(long file_id, long answer_id);
Error EditThreadRemoveItem(long file_id);
Error RemoveThread(long file_id);
long FindLastItem(long file_id);

View File

@@ -472,6 +472,14 @@ void thread_can_create(Info & i)
void thread_mount_arg_is(Info & i)
{
if( system->mounts.pmount )
i.res = system->mounts.pmount->IsArg(thread_info.mount_par_thread, i.par);
}
void AddEzcFunctions(PluginInfo & info)
@@ -518,6 +526,7 @@ void AddEzcFunctions(PluginInfo & info)
fun->Insert("thread_can_reply", thread_can_reply);
fun->Insert("thread_can_create", thread_can_create);
fun->Insert("thread_mount_arg_is", thread_mount_arg_is);
}

View File

@@ -14,6 +14,17 @@
namespace Thread
{
void ThreadInfo::SetDb(Db * pdb)
{
db = pdb;
}
void ThreadInfo::SetTDb(TDb * ptdb)
{
tdb = ptdb;
}
void ThreadInfo::SetSystem(System * psystem)
{
@@ -47,6 +58,18 @@ return out_dir_tab.back();
void ThreadInfo::RemoveThread(long file_id)
{
if( tdb->GetAnswers(file_id, remove_answer_id_tab) == WINIX_ERR_OK )
{
for(size_t i=0 ; i<remove_answer_id_tab.size() ; ++i)
db->DelFileById(remove_answer_id_tab[i]);
}
tdb->RemoveThread(file_id);
}
} // namespace

View File

@@ -11,10 +11,11 @@
#define headerfile_winix_plugins_thread_threadinfo
#include <vector>
#include "thread.h"
#include "core/item.h"
#include "core/system.h"
#include "db/db.h"
#include "thread.h"
#include "tdb.h"
@@ -26,10 +27,14 @@ class ThreadInfo
public:
void SetDb(Db * pdb);
void SetTDb(TDb * ptdb);
void SetSystem(System * psystem);
void Clear();
Item * FindThreadDir();
// id of a mount type
int mount_type_thread;
@@ -57,11 +62,18 @@ public:
// template index for notifications
size_t template_index;
void RemoveThread(long file_id);
private:
Db * db;
TDb * tdb;
System * system;
std::vector<Item*> out_dir_tab;
std::vector<long> remove_answer_id_tab;
Item out_item;