changed: added Cur structure

we have there two pointers: 
 Request * request;
 Session * session;
these are the current request and the current session


the session GC was moved to SessionManager (was in SessionContainer)



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@708 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2011-01-23 14:15:30 +00:00
parent 61ac29b2de
commit 915cabdf97
171 changed files with 2822 additions and 2650 deletions

View File

@@ -35,15 +35,15 @@ Item * last;
Item * last_but_one = 0;
size_t dir_tab_size;
last = request->dir_tab.back();
dir_tab_size = request->dir_tab.size();
last = cur->request->dir_tab.back();
dir_tab_size = cur->request->dir_tab.size();
if( dir_tab_size <= 1 )
return false; // you cannot move the root directory
last_but_one = request->dir_tab[dir_tab_size - 2];
last_but_one = cur->request->dir_tab[dir_tab_size - 2];
if( request->method != Request::post )
if( cur->request->method != Request::post )
{
// used in GET or HEAD
// we don't now whether we move the last directory or the last but one
@@ -56,7 +56,7 @@ size_t dir_tab_size;
{
// used in POST when the moving is performed
if( request->IsPostVar(L"onlycontent") )
if( cur->request->IsPostVar(L"onlycontent") )
return system->HasWriteAccess(*last);
else
return system->HasWriteAccess(*last_but_one);
@@ -70,13 +70,13 @@ return true;
bool Mv::CheckAccessFrom()
{
if( request->is_item )
if( cur->request->is_item )
{
// moving a file
if( !system->HasWriteAccess(*request->dir_tab.back()) )
if( !system->HasWriteAccess(*cur->request->dir_tab.back()) )
{
request->status = WINIX_ERR_PERMISSION_DENIED;
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
}
@@ -84,7 +84,7 @@ bool Mv::CheckAccessFrom()
{
if( !CheckAccessFromToDir() )
{
request->status = WINIX_ERR_PERMISSION_DENIED;
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
}
@@ -99,7 +99,7 @@ bool Mv::CheckAccessTo()
!system->HasReadExecAccessToPath(dir_tab) ||
!system->HasWriteAccess(*dir_tab.back()) )
{
request->status = WINIX_ERR_PERMISSION_DENIED;
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
@@ -112,14 +112,14 @@ return true;
bool Mv::ParseDir()
{
const std::wstring & new_dir = request->PostVar(L"to");
int res = system->dirs.FollowLink(request->dir_tab, new_dir, dir_tab, file);
const std::wstring & new_dir = cur->request->PostVar(L"to");
int res = system->dirs.FollowLink(cur->request->dir_tab, new_dir, dir_tab, file);
if( res == 3 )
request->status = WINIX_ERR_NO_ROOT_DIR;
cur->request->status = WINIX_ERR_NO_ROOT_DIR;
else
if( res != 0 && res != 1 )
request->status = WINIX_ERR_INCORRECT_DIR;
cur->request->status = WINIX_ERR_INCORRECT_DIR;
return res == 0 || res == 1;
}
@@ -142,7 +142,7 @@ bool Mv::MoveStaticFile(const std::wstring & from, const std::wstring & to)
else
{
log << log1 << "Mv: can't move a file from: " << from << ", to: " << to << logend;
request->status = WINIX_ERR_PERMISSION_DENIED;
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
}
@@ -161,13 +161,13 @@ bool res1, res2, res3, res4, res5;
if( !res1 || !res2 || !res3 || !res4 || !res5 )
{
request->status = WINIX_ERR_PERMISSION_DENIED;
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
return;
}
if( MoveStaticFile(old_path, new_path) )
{
request->status = db->EditFileById(item, item.id);
cur->request->status = db->EditFileById(item, item.id);
if( item.has_thumb )
MoveStaticFile(old_path_thumb, new_path_thumb);
@@ -189,9 +189,9 @@ void Mv::MoveFileOrSymlink(Item & item)
}
item.parent_id = dir_tab.back()->id;
request->status = db->EditParentUrlById(item, item.id);
cur->request->status = db->EditParentUrlById(item, item.id);
if( request->status == WINIX_ERR_OK )
if( cur->request->status == WINIX_ERR_OK )
{
if( item.type == Item::file )
log << log3 << "Mv: file: ";
@@ -280,13 +280,13 @@ void Mv::MoveDir(Item & dir)
if( dst_dir_id == dir.id || system->dirs.HasParent(dst_dir_id, dir.id) )
{
log << log1 << "Mv: cannot move directory to inside it" << logend;
request->status = WINIX_ERR_INCORRECT_DIR;
cur->request->status = WINIX_ERR_INCORRECT_DIR;
return;
}
if( !system->dirs.ChangeParent(dir.id, dst_dir_id) )
{
request->status = WINIX_ERR_INCORRECT_DIR;
cur->request->status = WINIX_ERR_INCORRECT_DIR;
return;
}
@@ -299,9 +299,9 @@ void Mv::MoveDir(Item & dir)
file.clear();
}
request->status = db->EditParentUrlById(dir, dir.id);
cur->request->status = db->EditParentUrlById(dir, dir.id);
if( request->status == WINIX_ERR_OK )
if( cur->request->status == WINIX_ERR_OK )
{
log << log3 << "Mv: directory: " << old_url << " was moved to: ";
system->dirs.LogDir(dir_tab);
@@ -334,13 +334,13 @@ return false;
void Mv::PostMoveFile()
{
if( IsTheSameFile(request->item) )
if( IsTheSameFile(cur->request->item) )
return;
MoveFileOrSymlink(request->item);
MoveFileOrSymlink(cur->request->item);
if( request->status == WINIX_ERR_OK )
system->RedirectTo(request->item);
if( cur->request->status == WINIX_ERR_OK )
system->RedirectTo(cur->request->item);
}
@@ -349,14 +349,14 @@ void Mv::PostMoveDirContent()
{
if( !file.empty() )
{
request->status = WINIX_ERR_INCORRECT_DIR;
cur->request->status = WINIX_ERR_INCORRECT_DIR;
return;
}
if( request->dir_tab.back()->id == dir_tab.back()->id )
if( cur->request->dir_tab.back()->id == dir_tab.back()->id )
return; // nothing to do
MoveDirContent(*request->dir_tab.back());
MoveDirContent(*cur->request->dir_tab.back());
system->RedirectToLastDir();
}
@@ -364,7 +364,7 @@ void Mv::PostMoveDirContent()
void Mv::PostMoveDir()
{
Item & last_dir = *request->dir_tab.back();
Item & last_dir = *cur->request->dir_tab.back();
Item & new_dir = *dir_tab.back();
if( file.empty() && new_dir.id == last_dir.id )
@@ -372,7 +372,7 @@ void Mv::PostMoveDir()
MoveDir(last_dir);
if( request->status == WINIX_ERR_OK )
if( cur->request->status == WINIX_ERR_OK )
system->RedirectToLastDir();
}
@@ -387,13 +387,13 @@ void Mv::MakePost()
{
Prepare();
if( request->is_item )
if( cur->request->is_item )
{
PostMoveFile();
}
else
{
if( request->IsPostVar(L"onlycontent") )
if( cur->request->IsPostVar(L"onlycontent") )
PostMoveDirContent();
else
PostMoveDir();