'tickets' can use 'threads' now
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@706 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -9,11 +9,14 @@
|
||||
|
||||
#include "createthread.h"
|
||||
#include "functions.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
|
||||
|
||||
namespace Thread
|
||||
{
|
||||
|
||||
|
||||
CreateThread::CreateThread()
|
||||
{
|
||||
fun.url = L"createthread";
|
||||
@@ -21,127 +24,65 @@ CreateThread::CreateThread()
|
||||
|
||||
|
||||
|
||||
void CreateThread::SetTDb(TDb * ptdb)
|
||||
{
|
||||
tdb = ptdb;
|
||||
}
|
||||
|
||||
void CreateThread::SetThreadInfo(ThreadInfo * pthread_info)
|
||||
{
|
||||
thread_info = pthread_info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// returning true if we can create a thread in the current directory
|
||||
bool CreateThread::HasAccess(bool check_root)
|
||||
{
|
||||
if( request->dir_tab.empty() )
|
||||
return false;
|
||||
|
||||
if( request->is_item )
|
||||
return false;
|
||||
|
||||
if( !system->HasWriteAccess(*request->dir_tab.back()) )
|
||||
return false;
|
||||
|
||||
if( !system->mounts.pmount || system->mounts.pmount->type != system->mounts.MountTypeThread() )
|
||||
return false;
|
||||
|
||||
if( !check_root && request->session && request->session->puser && request->session->puser->super_user )
|
||||
// super can create thread regardless of the restrictcreatethread option
|
||||
return true;
|
||||
|
||||
if( !system->mounts.pmount->IsPar(system->mounts.MountParCreatethreadOn()) )
|
||||
return true;
|
||||
|
||||
if( system->mounts.pmount->IsArg(system->mounts.MountParCreatethreadOn(), request->dir_tab.size()) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CreateThread::HasAccess()
|
||||
{
|
||||
return HasAccess(false);
|
||||
}
|
||||
|
||||
|
||||
bool CreateThread::FunCreateThreadCheckAbuse()
|
||||
{
|
||||
if( !system->rebus.CheckRebus() )
|
||||
{
|
||||
request->status = WINIX_ERR_INCORRECT_REBUS;
|
||||
if( request->is_item || !system->HasWriteAccess(*request->dir_tab.back()) )
|
||||
return false;
|
||||
}
|
||||
|
||||
functions->CheckGetPostTimes();
|
||||
|
||||
if( request->session->spam_score > 0 )
|
||||
{
|
||||
request->status = WINIX_ERR_SPAM;
|
||||
log << log1 << "Content: ignoring due to suspected spamming" << logend;
|
||||
if( system->mounts.pmount->type != thread_info->mount_type_thread )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateThread::ReadThread()
|
||||
{
|
||||
thread.parent_id = request->dir_tab.back()->id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateThread::AddThread()
|
||||
{
|
||||
thread.dir_id = request->dir_tab.back()->id;
|
||||
thread.closed = false;
|
||||
thread.items = 1;
|
||||
thread.last_item = request->item; // set by PostFunEmacsAdd()
|
||||
|
||||
request->status = db->AddThread(thread);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateThread::PostFunCreateThreadLogAndRedirect()
|
||||
{
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
log << log2 << "Content: added a new thread" << logend;
|
||||
system->RedirectToLastDir();
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Content: problem with adding a new thread, error code: "
|
||||
<< request->status << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateThread::MakePost()
|
||||
{
|
||||
functions->ReadItem(request->item, Item::dir);
|
||||
request->item.Clear();
|
||||
functions->ReadItem(request->item, Item::file);
|
||||
functions->SetUser(request->item);
|
||||
ReadThread();
|
||||
request->item.privileges = 0777; // !! tymczasowo 777 aby wszyscy mogli wysylac posty
|
||||
functions->PrepareUrl(request->item);
|
||||
request->item.parent_id = request->dir_tab.back()->id;
|
||||
request->item.privileges = 0644; // !! tymczasowo
|
||||
|
||||
if( !FunCreateThreadCheckAbuse() )
|
||||
{
|
||||
functions->ReadItemContentWithType(request->item); // for correctly displaying the form
|
||||
if( functions->CheckAbuse() )
|
||||
return;
|
||||
}
|
||||
|
||||
request->status = system->dirs.AddDirectory(request->item, true, 0, WINIX_NOTIFY_CODE_THREAD_ADD);
|
||||
request->status = system->AddFile(request->item);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
functions->ReadItemContentWithType(request->item);
|
||||
request->item.type = Item::file;
|
||||
request->item.privileges = 0644; // !! tymczasowo
|
||||
request->item.parent_id = request->dir_tab.back()->id;
|
||||
request->status = system->AddFile(request->item);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
AddThread();
|
||||
thread.Clear();
|
||||
thread.file_id = request->item.id;
|
||||
request->status = tdb->AddThread(thread);
|
||||
}
|
||||
|
||||
PostFunCreateThreadLogAndRedirect();
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
log << log2 << "CreateThread: added a new thread" << logend;
|
||||
system->RedirectTo(request->item);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "CreateThread: problem with adding a new thread, error code: "
|
||||
<< request->status << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user