Files
winix/functions/mkdir.cpp
Tomasz Sowa a45fb30e0a rewritten: plugin 'menu'
now we have a cache for the plugin
           (this limits the number of database requests)
added:     to plugin 'menu'
           menu_dir_tab can have a 'current' parameter (first argument)
           (it uses the last path from the previous menu_dir_tab) 
changed:   updated to the new EZC api
added:     new message to plugins: WINIX_DIR_ADDED


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@808 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-02-24 12:09:38 +00:00

97 lines
1.6 KiB
C++
Executable File

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2012, Tomasz Sowa
* All rights reserved.
*
*/
#include "mkdir.h"
#include "functions.h"
#include "core/plugin.h"
namespace Fun
{
Mkdir::Mkdir()
{
fun.url = L"mkdir";
}
bool Mkdir::HasAccess(const Item & item)
{
// you can create a directory only in a directory
if( item.type != Item::dir )
return false;
if( cur->session->puser && cur->session->puser->super_user )
// super user can use mkdir everywhere
return true;
if( !system->HasWriteAccess(item) )
return false;
if( !system->mounts.pmount->IsPar(system->mounts.MountParMkdirOn()) )
return true;
if( system->mounts.pmount->IsArg(system->mounts.MountParMkdirOn(), cur->request->dir_tab.size()) )
return true;
return false;
}
bool Mkdir::HasAccess()
{
if( cur->request->is_item || !HasAccess(*cur->request->dir_tab.back()) )
return false;
return true;
}
void Mkdir::PostFunMkdir(bool add_to_dir_tab, int privileges)
{
functions->ReadItem(cur->request->item, Item::dir);
functions->SetUser(cur->request->item);
cur->request->item.privileges = privileges;
Item * pdir;
cur->request->status = system->dirs.AddDirectory(cur->request->item, add_to_dir_tab, &pdir);
if( cur->request->status == WINIX_ERR_OK )
{
if( pdir )
plugin.Call(WINIX_DIR_ADDED, pdir);
system->RedirectTo(cur->request->item);
}
else
{
log << log1 << "Content: PostFunMkdir: Error: " << cur->request->status << logend;
}
}
void Mkdir::MakePost()
{
PostFunMkdir(false, system->NewDirPrivileges());
}
} // namespace