2009-04-20 00:13:21 +02:00
|
|
|
/*
|
|
|
|
* This file is a part of CMSLU -- Content Management System like Unix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2009-04-21 22:50:55 +02:00
|
|
|
* Copyright (c) 2008-2009, Tomasz Sowa
|
2009-04-20 00:13:21 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "content.h"
|
2009-04-21 22:50:55 +02:00
|
|
|
#include "../core/request.h"
|
|
|
|
#include "../core/error.h"
|
|
|
|
#include "../core/db.h"
|
|
|
|
#include "../core/mount.h"
|
|
|
|
#include "../core/data.h"
|
2009-04-20 00:13:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-21 01:49:28 +02:00
|
|
|
bool Content::FunCreateThreadCheckAccess()
|
2009-04-20 00:13:21 +02:00
|
|
|
{
|
2009-04-21 01:49:28 +02:00
|
|
|
Mount mount = data.mounts.GetCurrentMountPoint();
|
|
|
|
|
|
|
|
if( mount.type != Mount::thread )
|
|
|
|
{
|
|
|
|
request.status = Error::permision_denied;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-04-20 00:13:21 +02:00
|
|
|
if( !request.HasWriteAccess(*request.dir_table.back()) || request.is_item )
|
|
|
|
{
|
|
|
|
request.status = Error::permision_denied;
|
2009-04-21 01:49:28 +02:00
|
|
|
return false;
|
2009-04-20 00:13:21 +02:00
|
|
|
}
|
2009-04-21 01:49:28 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Content::PostFunCreateThread()
|
|
|
|
{
|
|
|
|
if( !FunCreateThreadCheckAccess() )
|
|
|
|
return;
|
|
|
|
|
2009-04-20 00:13:21 +02:00
|
|
|
|
|
|
|
PostFunMkdir(true);
|
|
|
|
|
|
|
|
if( request.session->done_status == Error::ok )
|
|
|
|
{
|
2009-04-21 01:49:28 +02:00
|
|
|
request.thread.dir_id = request.dir_table.back()->id;
|
|
|
|
request.thread.subject = request.PostVar("subject");
|
|
|
|
request.thread.closed = false;
|
|
|
|
|
|
|
|
request.session->done_status = db.AddThread(request.thread);
|
2009-04-20 00:13:21 +02:00
|
|
|
|
|
|
|
if( request.session->done_status == Error::ok )
|
|
|
|
{
|
2009-04-21 01:49:28 +02:00
|
|
|
PostFunEmacs();
|
|
|
|
|
|
|
|
if( request.session->done_status == Error::ok )
|
|
|
|
{
|
|
|
|
request.session->done = Done::added_thread;
|
|
|
|
RedirectTo(*request.dir_table.back());
|
|
|
|
}
|
2009-04-20 00:13:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Content::FunCreateThread()
|
|
|
|
{
|
2009-04-21 01:49:28 +02:00
|
|
|
FunCreateThreadCheckAccess();
|
2009-04-20 00:13:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|