the first part of reimplementing has been done
now we have app object and singletons are only: log logn plugin and app git-svn-id: svn://ttmath.org/publicrep/winix/trunk@628 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
149
functions/emacs.cpp
Executable file
149
functions/emacs.cpp
Executable file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "emacs.h"
|
||||
#include "templates/templates.h"
|
||||
#include "core/notify.h"
|
||||
#include "functions.h"
|
||||
|
||||
|
||||
|
||||
namespace Fun
|
||||
{
|
||||
|
||||
Emacs::Emacs()
|
||||
{
|
||||
fun.url = "emacs";
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Emacs::HasAccess(const Item & item)
|
||||
{
|
||||
if( request->session->puser && request->session->puser->super_user )
|
||||
// super user can use emacs everywhere
|
||||
return true;
|
||||
|
||||
if( !system->HasWriteAccess(item) )
|
||||
return false;
|
||||
|
||||
if( !system->mounts.pmount->IsPar(Mount::par_emacs_on) )
|
||||
return true;
|
||||
|
||||
if( system->mounts.pmount->IsArg(Mount::par_emacs_on, request->dir_table.size()) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Emacs::HasAccess()
|
||||
{
|
||||
if( !request->is_item )
|
||||
return HasAccess(*request->dir_table.back()); // adding a new item
|
||||
else
|
||||
return HasAccess(request->item); // editing an existing item
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool Emacs::PostEmacsCheckAbuse(bool adding)
|
||||
{
|
||||
if( !system->rebus.CheckRebus() )
|
||||
{
|
||||
request->status = WINIX_ERR_INCORRECT_REBUS;
|
||||
return false;
|
||||
}
|
||||
|
||||
// !! is tested in createthread once
|
||||
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 Emacs::PostFunEmacsModifyMountPoint(bool adding)
|
||||
{
|
||||
if( system->mounts.pmount->type == Mount::thread )
|
||||
{
|
||||
if( adding )
|
||||
db->EditThreadAddItem(request->dir_table.back()->id, request->item.id);
|
||||
|
||||
system->RedirectToLastDir();
|
||||
}
|
||||
else
|
||||
if( system->mounts.pmount->type == Mount::ticket )
|
||||
{
|
||||
system->RedirectToLastDir();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Mount::cms
|
||||
system->RedirectTo(request->item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Emacs::MakePost()
|
||||
{
|
||||
bool adding = !request->is_item;
|
||||
bool edit_with_url = functions->ReadItem(request->item, Item::file);
|
||||
|
||||
if( adding )
|
||||
functions->SetUser(request->item); // set user before checking the rebus
|
||||
|
||||
if( !PostEmacsCheckAbuse(adding) )
|
||||
return;
|
||||
|
||||
if( adding )
|
||||
{
|
||||
request->is_item = true;
|
||||
request->item.privileges = 0644; // !! tymczasowo, bedzie uzyte umask
|
||||
system->AddFile(request->item);
|
||||
}
|
||||
else
|
||||
{
|
||||
system->EditFile(request->item, edit_with_url);
|
||||
}
|
||||
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
PostFunEmacsModifyMountPoint(adding);
|
||||
system->CheckSpecialFile(request->item);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Content: PostFunEmacs: Error: "
|
||||
<< request->status << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
Reference in New Issue
Block a user