added: issues ticket system
added functions: ticket, createticket, editticket (there is no 'rm' function working for tickets yet) changed: mount parser and mount points now we have more parameters (arguments in parameters) some refactoring in functions 'emacs' and 'mkdir' git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@554 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -7,72 +7,106 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <cstdio>
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/data.h"
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
void Content::FunUpload()
|
||||
|
||||
|
||||
bool Content::FunUploadCheckAccess()
|
||||
{
|
||||
if( request.is_item || !request.CanUseUpload(*request.dir_table.back()) )
|
||||
{
|
||||
request.status = Error::permission_denied;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// !! in the future the 'upload' can be used everywhere
|
||||
if( data.mounts.pmount->type != Mount::cms )
|
||||
{
|
||||
request.status = Error::permission_denied;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Content::UploadSaveFile()
|
||||
{
|
||||
static std::string path;
|
||||
struct stat sb;
|
||||
|
||||
request.MakePath(path);
|
||||
|
||||
if( stat(path.c_str(), &sb) < 0 )
|
||||
{
|
||||
if( !request.MakeDirsOnFS() )
|
||||
{
|
||||
request.status = Error::permission_denied;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( data.mounts.CurrentMountType() != Mount::cms )
|
||||
path += '/';
|
||||
path += request.item.url;
|
||||
const std::string & tmp_filename = request.post_file_table.begin()->second.tmp_filename;
|
||||
|
||||
if( rename(tmp_filename.c_str(), path.c_str()) == 0 )
|
||||
{
|
||||
log << log1 << "Content: uploaded a new file: " << path << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
// !! skasowac takze plik z bazy danych
|
||||
log << log1 << "Content: can't move the tmp file from: " << tmp_filename;
|
||||
log << log1 << ", to: " << path << logend;
|
||||
request.status = Error::permission_denied;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::PostFunUpload()
|
||||
{
|
||||
if( request.is_item || !request.CanUseUpload(*request.dir_table.back()) )
|
||||
{
|
||||
request.status = Error::permission_denied;
|
||||
if( !FunUploadCheckAccess() )
|
||||
return;
|
||||
}
|
||||
|
||||
if( data.mounts.CurrentMountType() != Mount::cms )
|
||||
{
|
||||
request.status = Error::permission_denied;
|
||||
return;
|
||||
}
|
||||
|
||||
if( request.post_file_table.empty() )
|
||||
{
|
||||
request.status = Error::permission_denied;
|
||||
return;
|
||||
}
|
||||
|
||||
// !! moze request.session->done_status trzeba ustawic na Error::ok na poczatku? (i podobnie w innych metodach, mkdir, emacs ...)
|
||||
ReadItem(request.item, Item::file);
|
||||
|
||||
// !! sprawdzanie rebusa?
|
||||
|
||||
// !! tutaj w zaleznosci od rozszerzenia dobrac odpowiedni static_auth
|
||||
request.item.static_auth = Item::static_other;
|
||||
|
||||
PostFunEmacs();
|
||||
PostFunEmacsAdd(); // always adding a new item
|
||||
|
||||
|
||||
if( request.session->done_status == Error::ok )
|
||||
{
|
||||
std::string path;
|
||||
UploadSaveFile();
|
||||
|
||||
if( request.MakeDirsOnFS(path) )
|
||||
{
|
||||
path += '/';
|
||||
path += request.item.url;
|
||||
const std::string & tmp_filename = request.post_file_table.begin()->second.tmp_filename;
|
||||
if( request.session->done_status == Error::ok )
|
||||
RedirectTo(request.item);
|
||||
}
|
||||
|
||||
if( rename(tmp_filename.c_str(), path.c_str()) < 0 )
|
||||
{
|
||||
// !! skasowac takze plik z bazy danych
|
||||
log << log1 << "Content: can't move the tmp file from: " << tmp_filename;
|
||||
log << log1 << ", to: " << path << logend;
|
||||
request.status = Error::permission_denied;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Content::FunUpload()
|
||||
{
|
||||
FunUploadCheckAccess();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user