refactoring
git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@523 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -110,7 +110,7 @@ void Content::MakeStandardFunction()
|
||||
if( !request.pfunction )
|
||||
SetDefaultFunction();
|
||||
|
||||
if( request.result == Request::redirect )
|
||||
if( !request.redirect_to.empty() )
|
||||
return;
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ void Content::Make()
|
||||
if( request.method == Request::post )
|
||||
MakePost();
|
||||
|
||||
if( request.result == Request::redirect )
|
||||
if( !request.redirect_to.empty() )
|
||||
return;
|
||||
|
||||
if( request.status == Error::ok )
|
||||
@@ -249,7 +249,7 @@ void Content::Make()
|
||||
request.status = Error::permision_denied;
|
||||
}
|
||||
|
||||
if( request.result == Request::redirect )
|
||||
if( !request.redirect_to.empty() )
|
||||
return;
|
||||
|
||||
if( request.dir_table.empty() )
|
||||
@@ -275,23 +275,22 @@ void Content::RedirectTo(const Item & item)
|
||||
{
|
||||
std::string path;
|
||||
|
||||
request.result = Request::redirect;
|
||||
request.str = data.base_url;
|
||||
request.redirect_to = data.base_url;
|
||||
|
||||
|
||||
if( item.type == Item::dir )
|
||||
{
|
||||
// item_id is pointing to a directory
|
||||
data.dirs.MakePath(item.id, path);
|
||||
request.str += path;
|
||||
request.redirect_to += path;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !data.dirs.MakePath(item.parent_id, path) )
|
||||
log << log1 << "Content: Can't redirect: no dirs for item id: " << item.id << logend;
|
||||
|
||||
request.str += path;
|
||||
request.str += item.url;
|
||||
request.redirect_to += path;
|
||||
request.redirect_to += item.url;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,16 +301,15 @@ void Content::RedirectTo(long item_id)
|
||||
std::string path;
|
||||
Item * pdir;
|
||||
|
||||
request.result = Request::redirect;
|
||||
request.str = data.base_url;
|
||||
pdir = data.dirs.GetDir(item_id);
|
||||
request.redirect_to = data.base_url;
|
||||
pdir = data.dirs.GetDir(item_id);
|
||||
|
||||
|
||||
if( pdir )
|
||||
{
|
||||
// item_id is pointing to a directory
|
||||
data.dirs.MakePath(pdir->id, path);
|
||||
request.str += path;
|
||||
request.redirect_to += path;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -324,7 +322,7 @@ Item * pdir;
|
||||
if( !data.dirs.MakePath(request.item_table[0].parent_id, path) )
|
||||
log << log1 << "Content: Can't redirect: no dirs for item id: " << request.item_table[0].id << ", requested directory id: " << request.item_table[0].parent_id << logend;
|
||||
|
||||
request.str += path + request.item_table[0].url;
|
||||
request.redirect_to += path + request.item_table[0].url;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -386,9 +384,9 @@ bool Content::CheckRebus()
|
||||
|
||||
try
|
||||
{
|
||||
std::string & answer = request.PostVar("rebus");
|
||||
std::string * answer = request.PostVar("rebus");
|
||||
|
||||
if( data.rebus.IsAnswerOk(request.session->rebus_item, answer) )
|
||||
if( answer && data.rebus.IsAnswerOk(request.session->rebus_item, *answer) )
|
||||
return true;
|
||||
}
|
||||
catch(const Error &)
|
||||
@@ -401,23 +399,16 @@ return false;
|
||||
}
|
||||
|
||||
|
||||
void Content::SetUser()
|
||||
void Content::SetUser(Item & item)
|
||||
{
|
||||
if( request.session->puser )
|
||||
{
|
||||
request.item.user_id = request.session->puser->id;
|
||||
request.item.guest_name.clear();
|
||||
item.user_id = request.session->puser->id;
|
||||
item.guest_name.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
request.item.user_id = -1;
|
||||
|
||||
try
|
||||
{
|
||||
request.item.guest_name = request.PostVar("guestname");
|
||||
}
|
||||
catch(const Error &)
|
||||
{
|
||||
}
|
||||
item.user_id = -1;
|
||||
request.PostVar("guestname", item.guest_name);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user