added: function: mkdir
git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@471 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
3e328932fc
commit
114b5724f8
|
@ -1,4 +1,4 @@
|
|||
o = content.o privileges.o emacs.o login.o rm.o cat.o logout.o ls.o node.o
|
||||
o = content.o privileges.o emacs.o login.o rm.o cat.o logout.o ls.o node.o mkdir.o
|
||||
|
||||
|
||||
all: content.a
|
||||
|
|
|
@ -70,6 +70,18 @@ ls.o: ../core/cookieparser.h ../core/item.h ../core/db.h ../core/error.h
|
|||
ls.o: ../core/user.h ../core/group.h ../core/users.h ../core/groups.h
|
||||
ls.o: ../core/log.h ../core/misc.h ../core/function.h
|
||||
ls.o: ../core/functionparser.h ../core/request.h ../core/data.h
|
||||
mkdir.o: content.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
mkdir.o: ../core/data.h ../core/misc.h ../core/log.h ../core/item.h
|
||||
mkdir.o: ../core/error.h ../core/dirs.h ../core/db.h ../core/dircontainer.h
|
||||
mkdir.o: ../core/user.h ../core/group.h ../core/ugcontainer.h ../core/users.h
|
||||
mkdir.o: ../core/groups.h ../core/functions.h ../core/function.h
|
||||
mkdir.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
mkdir.o: ../core/done.h ../core/getparser.h ../core/httpsimpleparser.h
|
||||
mkdir.o: ../core/postparser.h ../core/cookieparser.h ../core/item.h
|
||||
mkdir.o: ../core/db.h ../core/error.h ../core/user.h ../core/group.h
|
||||
mkdir.o: ../core/users.h ../core/groups.h ../core/log.h ../core/misc.h
|
||||
mkdir.o: ../core/function.h ../core/functionparser.h ../core/request.h
|
||||
mkdir.o: ../core/data.h
|
||||
node.o: content.h ../templates/templates.h ../../ezc/src/ezc.h ../core/data.h
|
||||
node.o: ../core/misc.h ../core/log.h ../core/item.h ../core/error.h
|
||||
node.o: ../core/dirs.h ../core/db.h ../core/dircontainer.h ../core/user.h
|
||||
|
|
|
@ -99,6 +99,9 @@ void Content::MakeStandardFunction()
|
|||
if( request.pfunction->code == Function::emacs )
|
||||
FunEmacs();
|
||||
else
|
||||
if( request.pfunction->code == Function::mkdir )
|
||||
FunMkdir();
|
||||
else
|
||||
if( request.pfunction->code == Function::privileges )
|
||||
FunPrivileges();
|
||||
else
|
||||
|
@ -129,6 +132,10 @@ void Content::MakePost()
|
|||
PostFunEmacs();
|
||||
break;
|
||||
|
||||
case Function::mkdir:
|
||||
PostFunMkdir();
|
||||
break;
|
||||
|
||||
case Function::privileges:
|
||||
PostFunPrivileges();
|
||||
break;
|
||||
|
|
|
@ -50,11 +50,13 @@ class Content
|
|||
void FunPrivileges();
|
||||
void FunRm();
|
||||
void FunNode();
|
||||
void FunMkdir();
|
||||
|
||||
void PostFunLogin();
|
||||
void PostFunEmacsAdd();
|
||||
void PostFunEmacsEdit(bool with_url);
|
||||
void PostFunEmacs();
|
||||
void PostFunMkdir();
|
||||
void PostFunPrivileges();
|
||||
|
||||
void RedirectTo(const Item & item);
|
||||
|
|
|
@ -36,12 +36,5 @@ void Data::SetHttpHost()
|
|||
if( strncmp(base_url.c_str(), "https://", 8) == 0 )
|
||||
base_url_http_host = base_url.substr(8);
|
||||
else
|
||||
base_url_http_host.clear();
|
||||
|
||||
if( base_url_http_host.empty() )
|
||||
return;
|
||||
|
||||
// removing the last slash (if it is present)
|
||||
if( base_url_http_host[ base_url_http_host.size() - 1 ] == '/' )
|
||||
base_url_http_host.erase( base_url_http_host.end() - 1 );
|
||||
base_url_http_host.clear(); // if empty the RequestController::BaseUrlRedirect() returns false and no redirecting will be done
|
||||
}
|
||||
|
|
10
core/db.cpp
10
core/db.cpp
|
@ -401,13 +401,14 @@ Error Db::AddItemIntoItem(Item & item)
|
|||
{
|
||||
AssertConnection();
|
||||
std::ostringstream query;
|
||||
query << "insert into core.item (user_id, group_id, privileges, type, parent_id, content_id, url) values (";
|
||||
query << "insert into core.item (user_id, group_id, privileges, type, parent_id, content_id, default_item, url) values (";
|
||||
query << '\'' << item.user_id << "', ";
|
||||
query << '\'' << item.group_id << "', ";
|
||||
query << '\'' << item.privileges << "', ";
|
||||
query << '\'' << static_cast<int>(item.type) << "', ";
|
||||
query << '\'' << item.parent_id << "', ";
|
||||
query << '\'' << item.content_id << "', ";
|
||||
query << '\'' << item.default_item << "', ";
|
||||
|
||||
url_without_id = AddItemCreateUrlSubject(item);
|
||||
|
||||
|
@ -473,7 +474,12 @@ return result;
|
|||
|
||||
Error Db::AddItem(Item & item)
|
||||
{
|
||||
Error result = AddItemIntoContent(item);
|
||||
Error result = Error::ok;
|
||||
|
||||
if( item.type == Item::file )
|
||||
result = AddItemIntoContent(item);
|
||||
else
|
||||
item.content_id = -1;
|
||||
|
||||
if( result == Error::ok )
|
||||
result = AddItemIntoItem(item);
|
||||
|
|
|
@ -72,7 +72,7 @@ bool rebuild_indexes = false;
|
|||
}
|
||||
|
||||
table.push_back(item);
|
||||
log << log2 << "DirCont: added item, id: " << item.id << ", parent_id: " << item.parent_id << logend;
|
||||
log << log2 << "DirCont: added dir, url: " << item.url << ", id: " << item.id << ", parent_id: " << item.parent_id << logend;
|
||||
|
||||
|
||||
if( rebuild_indexes )
|
||||
|
@ -113,7 +113,7 @@ void DirContainer::AddIndexes(Iterator item)
|
|||
table_id.insert( std::make_pair(item->id, item) );
|
||||
table_parent.insert( std::make_pair(item->parent_id, item) );
|
||||
|
||||
log << log2 << "DirCont: added indexes to item, id: " << item->id << ", parent_id: " << item->parent_id << logend;
|
||||
log << log2 << "DirCont: added indexes to dir, id: " << item->id << ", parent_id: " << item->parent_id << logend;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -335,3 +335,11 @@ Item * Dirs::GetDir(long id)
|
|||
return &(*i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Dirs::AddDir(const Item & item)
|
||||
{
|
||||
dir_table.PushBack(item);
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
Item * GetDir(const std::string & path);
|
||||
Item * GetDir(long id);
|
||||
|
||||
|
||||
void AddDir(const Item & item);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ public:
|
|||
edited_item,
|
||||
deleted_item,
|
||||
privileged_item,
|
||||
added_dir,
|
||||
loggedout
|
||||
};
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
cat,
|
||||
node,
|
||||
emacs,
|
||||
mkdir,
|
||||
privileges,
|
||||
rm,
|
||||
login,
|
||||
|
|
|
@ -51,6 +51,10 @@ void Functions::ReadFunctions()
|
|||
f.item.url = "edytuj";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = Function::mkdir;
|
||||
f.item.url = "mkdir";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = Function::privileges;
|
||||
f.item.url = "uprawnienia";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
|
|
@ -52,6 +52,7 @@ long default_item;
|
|||
|
||||
|
||||
// used by the database
|
||||
// !! moze da sie w ogole z tego zrezygnowac?
|
||||
long content_id;
|
||||
|
||||
|
||||
|
|
|
@ -113,15 +113,16 @@ return true;
|
|||
|
||||
bool RequestController::BaseUrlRedirect()
|
||||
{
|
||||
if( request.env_request_uri[0] == 0 )
|
||||
if( data.base_url_http_host.empty() )
|
||||
return false;
|
||||
|
||||
if( data.base_url_http_host == request.env_http_host )
|
||||
return false;
|
||||
|
||||
request.result = Request::redirect;
|
||||
request.str = data.base_url + (request.env_request_uri + 1); // +1 means skipping the first slash from env_request_uri
|
||||
request.str = data.base_url + request.env_request_uri;
|
||||
|
||||
log << log3 << "RC: BaseUrlRedirect from: " << request.env_http_host << logend;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ int attempts = 100;
|
|||
|
||||
request.session = const_cast<Session*>( &(*res.first) );
|
||||
request.SetCookie(data.http_session_id_name.c_str(), request.session->id);
|
||||
log << log1 << "created a new session: " << s.id << logend;
|
||||
log << log2 << "SM: created a new session: " << s.id << logend;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ int attempts = 100;
|
|||
// there is a problem with generating a new session id
|
||||
// we do not set a session cookie
|
||||
CreateTemporarySession();
|
||||
log << log1 << "cannot create a session id (temporary used: with id 0)" << logend;
|
||||
log << log1 << "SM: cannot create a session id (temporary used: with id 0)" << logend;
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,7 +127,7 @@ void SessionManager::SetSession()
|
|||
{
|
||||
// that session is in the table
|
||||
request.session = const_cast<Session*>( &(*s) );
|
||||
log << log1 << "session: " << s->id << logend;
|
||||
log << log1 << "SM: session: " << s->id << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -66,6 +66,15 @@ void done_loggedout(Info & i)
|
|||
|
||||
|
||||
|
||||
|
||||
void done_added_dir(Info & i)
|
||||
{
|
||||
i.result = request.session->done == Done::added_dir;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace TemplatesFunctions
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ Ezc::Pattern pat_index;
|
|||
Ezc::Pattern pat_fun_cat;
|
||||
Ezc::Pattern pat_fun_ls;
|
||||
Ezc::Pattern pat_fun_emacs;
|
||||
Ezc::Pattern pat_fun_mkdir;
|
||||
Ezc::Pattern pat_fun_privileges;
|
||||
Ezc::Pattern pat_fun_rm;
|
||||
Ezc::Pattern pat_err_item_required;
|
||||
|
@ -75,6 +76,10 @@ Ezc::Pattern * p = 0;
|
|||
p = &pat_fun_emacs;
|
||||
break;
|
||||
|
||||
case Function::mkdir:
|
||||
p = &pat_fun_mkdir;
|
||||
break;
|
||||
|
||||
case Function::privileges:
|
||||
p = &pat_fun_privileges;
|
||||
break;
|
||||
|
@ -245,6 +250,7 @@ void Templates::CreateFunctions()
|
|||
functions.Insert("done_deleted_item", done_deleted_item);
|
||||
functions.Insert("done_privileged_item", done_privileged_item);
|
||||
functions.Insert("done_loggedout", done_loggedout);
|
||||
functions.Insert("done_added_dir", done_added_dir);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -289,6 +295,9 @@ void Templates::Read()
|
|||
pat_fun_emacs.Directory(data.templates);
|
||||
pat_fun_emacs.ParseFile("fun_emacs.html");
|
||||
|
||||
pat_fun_mkdir.Directory(data.templates);
|
||||
pat_fun_mkdir.ParseFile("fun_mkdir.html");
|
||||
|
||||
pat_fun_privileges.Directory(data.templates);
|
||||
pat_fun_privileges.ParseFile("fun_privileges.html");
|
||||
|
||||
|
|
|
@ -133,12 +133,13 @@ namespace TemplatesFunctions
|
|||
void done_edited_item(Info & i);
|
||||
void done_deleted_item(Info & i);
|
||||
void done_privileged_item(Info & i);
|
||||
|
||||
void done_added_dir(Info & i);
|
||||
|
||||
void done_loggedout(Info & i);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace TemplatesFunctions
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue