moved some thread files to plugins/thread
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@705 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1 +1 @@
|
||||
o = adduser.o cat.o chmod.o chown.o ckeditor.o cp.o createthread.o default.o download.o emacs.o functionbase.o functionparser.o functions.o funthread.o last.o ln.o login.o logout.o ls.o mkdir.o mv.o node.o priv.o privchanger.o reload.o rm.o run.o specialdefault.o stat.o subject.o template.o tinymce.o uname.o upload.o uptime.o vim.o who.o
|
||||
o = adduser.o cat.o chmod.o chown.o ckeditor.o cp.o default.o download.o emacs.o functionbase.o functionparser.o functions.o last.o ln.o login.o logout.o ls.o mkdir.o mv.o node.o priv.o privchanger.o reload.o rm.o run.o specialdefault.o stat.o subject.o template.o tinymce.o uname.o upload.o uptime.o vim.o who.o
|
||||
|
||||
@@ -1,154 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "createthread.h"
|
||||
#include "functions.h"
|
||||
|
||||
|
||||
namespace Thread
|
||||
{
|
||||
|
||||
CreateThread::CreateThread()
|
||||
{
|
||||
fun.url = L"createthread";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 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;
|
||||
return false;
|
||||
}
|
||||
|
||||
functions->CheckGetPostTimes();
|
||||
|
||||
if( request->session->spam_score > 0 )
|
||||
{
|
||||
request->status = WINIX_ERR_SPAM;
|
||||
log << log1 << "Content: ignoring due to suspected spamming" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void 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);
|
||||
functions->SetUser(request->item);
|
||||
ReadThread();
|
||||
request->item.privileges = 0777; // !! tymczasowo 777 aby wszyscy mogli wysylac posty
|
||||
|
||||
if( !FunCreateThreadCheckAbuse() )
|
||||
{
|
||||
functions->ReadItemContentWithType(request->item); // for correctly displaying the form
|
||||
return;
|
||||
}
|
||||
|
||||
request->status = system->dirs.AddDirectory(request->item, true, 0, WINIX_NOTIFY_CODE_THREAD_ADD);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
PostFunCreateThreadLogAndRedirect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
@@ -1,43 +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_thread_createthread
|
||||
#define headerfile_winix_plugins_thread_createthread
|
||||
|
||||
#include "functions/functionbase.h"
|
||||
|
||||
|
||||
|
||||
namespace Thread
|
||||
{
|
||||
|
||||
|
||||
class CreateThread : public FunctionBase
|
||||
{
|
||||
public:
|
||||
|
||||
CreateThread();
|
||||
bool HasAccess(bool check_root);
|
||||
bool HasAccess();
|
||||
void MakePost();
|
||||
|
||||
private:
|
||||
|
||||
Thread thread;
|
||||
|
||||
bool FunCreateThreadCheckAbuse();
|
||||
void ReadThread();
|
||||
void AddThread();
|
||||
void PostFunCreateThreadLogAndRedirect();
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include "core/misc.h"
|
||||
#include "funthread.h"
|
||||
|
||||
|
||||
namespace Thread
|
||||
{
|
||||
|
||||
FunThread::FunThread()
|
||||
{
|
||||
fun.url = L"thread";
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FunThread::HasAccess()
|
||||
{
|
||||
return !request->is_item;
|
||||
}
|
||||
|
||||
|
||||
void FunThread::Clear()
|
||||
{
|
||||
thread.Clear();
|
||||
thread_tab.clear();
|
||||
}
|
||||
|
||||
|
||||
void FunThread::CreateSortIndexByDate()
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < thread_tab.size() ; ++i)
|
||||
{
|
||||
Item * pdir = system->dirs.GetDir(thread_tab[i].dir_id);
|
||||
|
||||
if( pdir )
|
||||
thread_tab[i].sort = (unsigned long)Time(pdir->date_creation);
|
||||
else
|
||||
thread_tab[i].sort = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FunThread::FunThreadSort(const Thread & t1, const Thread & t2)
|
||||
{
|
||||
return t1.sort > t2.sort;
|
||||
}
|
||||
|
||||
|
||||
void FunThread::MakeGet()
|
||||
{
|
||||
is_thread = (db->GetThreadByDirId(request->dir_tab.back()->id, thread) == WINIX_ERR_OK);
|
||||
|
||||
DbItemQuery iq;
|
||||
|
||||
if( system->mounts.pmount->IsArg(system->mounts.MountParThread(), L"sort_desc") )
|
||||
iq.sort_asc = false;
|
||||
|
||||
iq.WhereParentId(request->dir_tab.back()->id);
|
||||
iq.WhereType(Item::file);
|
||||
iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
|
||||
|
||||
db->GetItems(request->item_tab, iq);
|
||||
db->GetThreads(request->dir_tab.back()->id, thread_tab);
|
||||
|
||||
system->CheckAccessToItems(request->item_tab);
|
||||
|
||||
CreateSortIndexByDate();
|
||||
std::sort(thread_tab.begin(), thread_tab.end(), FunThreadSort);
|
||||
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
@@ -1,45 +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_thread_funthread
|
||||
#define headerfile_winix_plugins_thread_funthread
|
||||
|
||||
#include "functions/functionbase.h"
|
||||
#include "core/thread.h"
|
||||
|
||||
|
||||
namespace Thread
|
||||
{
|
||||
|
||||
|
||||
class FunThread : public FunctionBase
|
||||
{
|
||||
public:
|
||||
|
||||
FunThread();
|
||||
bool HasAccess();
|
||||
void MakeGet();
|
||||
|
||||
// current thread (if exists)
|
||||
bool is_thread;
|
||||
Thread thread;
|
||||
std::vector<Thread> thread_tab;
|
||||
|
||||
private:
|
||||
|
||||
static bool FunThreadSort(const Thread & t1, const Thread & t2);
|
||||
void CreateSortIndexByDate();
|
||||
void Clear();
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user