added: function: default
changes the default item in a directory git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@473 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
o = content.o privileges.o emacs.o login.o rm.o cat.o logout.o ls.o node.o mkdir.o
|
||||
o = content.o privileges.o emacs.o login.o rm.o cat.o logout.o ls.o node.o mkdir.o defaultitem.o
|
||||
|
||||
|
||||
all: content.a
|
||||
|
@@ -23,6 +23,19 @@ content.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
||||
content.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
content.o: ../core/log.h ../core/misc.h ../core/function.h
|
||||
content.o: ../core/functionparser.h ../core/request.h ../core/data.h
|
||||
defaultitem.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
defaultitem.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
||||
defaultitem.o: ../core/error.h ../core/dirs.h ../core/db.h
|
||||
defaultitem.o: ../core/dircontainer.h ../core/user.h ../core/group.h
|
||||
defaultitem.o: ../core/ugcontainer.h ../core/users.h ../core/groups.h
|
||||
defaultitem.o: ../core/functions.h ../core/function.h ../core/request.h
|
||||
defaultitem.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
defaultitem.o: ../core/getparser.h ../core/httpsimpleparser.h
|
||||
defaultitem.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
defaultitem.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||
defaultitem.o: ../core/users.h ../core/groups.h ../core/log.h ../core/misc.h
|
||||
defaultitem.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
||||
defaultitem.o: ../core/data.h
|
||||
emacs.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
emacs.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
||||
emacs.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
|
||||
|
@@ -102,6 +102,9 @@ void Content::MakeStandardFunction()
|
||||
if( request.pfunction->code == Function::mkdir )
|
||||
FunMkdir();
|
||||
else
|
||||
if( request.pfunction->code == Function::default_item )
|
||||
FunDefaultItem();
|
||||
else
|
||||
if( request.pfunction->code == Function::privileges )
|
||||
FunPrivileges();
|
||||
else
|
||||
@@ -136,6 +139,10 @@ void Content::MakePost()
|
||||
PostFunMkdir();
|
||||
break;
|
||||
|
||||
case Function::default_item:
|
||||
PostFunDefaultItem();
|
||||
break;
|
||||
|
||||
case Function::privileges:
|
||||
PostFunPrivileges();
|
||||
break;
|
||||
|
@@ -51,12 +51,15 @@ class Content
|
||||
void FunRm();
|
||||
void FunNode();
|
||||
void FunMkdir();
|
||||
void FunDefaultItem();
|
||||
|
||||
|
||||
void PostFunLogin();
|
||||
void PostFunEmacsAdd();
|
||||
void PostFunEmacsEdit(bool with_url);
|
||||
void PostFunEmacs();
|
||||
void PostFunMkdir();
|
||||
void PostFunDefaultItem();
|
||||
void PostFunPrivileges();
|
||||
|
||||
void RedirectTo(const Item & item);
|
||||
|
81
content/defaultitem.cpp
Executable file
81
content/defaultitem.cpp
Executable file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::PostFunDefaultItem()
|
||||
{
|
||||
Item * pdir;
|
||||
long fileid = -1;
|
||||
|
||||
request.session->done = Done::defaulted_dir;
|
||||
|
||||
|
||||
if( !request.HasWriteAccess(*request.dir_table.back()) )
|
||||
{
|
||||
request.status = Error::permision_denied;
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
std::string & path = request.PostVar("defaultitem");
|
||||
|
||||
if( !path.empty() )
|
||||
{
|
||||
std::string dir, file;
|
||||
Dirs::SplitPath(path, dir, file);
|
||||
|
||||
pdir = data.dirs.GetDir(dir);
|
||||
|
||||
if( !pdir )
|
||||
throw Error(Error::incorrect_dir);
|
||||
|
||||
fileid = db.GetFileId(pdir->id, file);
|
||||
|
||||
if( fileid == -1 )
|
||||
throw Error(Error::db_no_item);
|
||||
}
|
||||
|
||||
request.session->done_status = db.EditDefaultItem(request.dir_table.back()->id, fileid);
|
||||
|
||||
if( request.session->done_status == Error::ok )
|
||||
request.dir_table.back()->default_item = fileid;
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
request.session->done_status = e;
|
||||
}
|
||||
|
||||
|
||||
if( request.session->done_status == Error::ok )
|
||||
RedirectTo(*request.dir_table.back());
|
||||
else
|
||||
log << log1 << "Content: PostFunDefaultItem: Error: " << request.session->done_status << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::FunDefaultItem()
|
||||
{
|
||||
if( !request.HasWriteAccess(*request.dir_table.back()) )
|
||||
{
|
||||
request.status = Error::permision_denied;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user