added: winix function: rmuser

changed: UGContainer<> now uses std::list as a storage
         (previously it was using std::vector with pointers)
removed: now we don't have the operator[] for UGContainer<>



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@816 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-03-09 02:36:25 +00:00
parent 6c2c12fe5e
commit 489310ba1c
51 changed files with 1146 additions and 602 deletions

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2012, Tomasz Sowa
* All rights reserved.
*
*/
@@ -153,7 +153,7 @@ bool SessionManager::SetSessionFromCookie(const std::string & cookie)
long id = Tol(cookie.c_str());
SessionContainer::Iterator s = session_tab.FindById(id);
if( s == session_tab.End() )
if( s == session_tab.End() || s->remove_me )
return false;
// that session is in the table
@@ -220,6 +220,18 @@ SessionContainer::Iterator SessionManager::SessionEnd()
void SessionManager::DeleteSessions()
{
SessionContainer::Iterator i;
for(i=session_tab.Begin() ; i!=session_tab.End() ; ++i)
{
if( i->puser && !i->remember_me )
{
cur->session = &(*i); // for correctly setting a session data in plugins
plugin.Call(WINIX_PREPARE_USER_TO_LOGOUT, i->puser);
last_container->UserLogout(i->puser->id, i->id);
}
}
session_tab.Clear();
}
@@ -300,7 +312,7 @@ void SessionManager::SaveSessions()
for( ; i!=session_tab.End() ; ++i )
{
if( i->id != 0 && i->puser )
if( i->id != 0 && i->puser && !i->remove_me )
{
file << i->id << ' ' << i->puser->id << ' ' << i->remember_me << ' ';
file << (long)i->time << ' ' << (long)i->last_time << std::endl;
@@ -330,6 +342,30 @@ Session * SessionManager::GetCurSession()
}
// returns how many sessions was marked to remove
size_t SessionManager::MarkAllSessionsToRemove(long user_id)
{
size_t how_many = 0;
SessionContainer::Iterator i;
Session * old_session = cur->session;
for(i=session_tab.Begin() ; i!=session_tab.End() ; ++i)
{
if( i->puser && i->puser->id == user_id )
{
cur->session = &(*i); // for correctly setting a session data in plugins
plugin.Call(WINIX_PREPARE_USER_TO_LOGOUT, i->puser);
last_container->UserLogout(i->puser->id, i->id);
i->remove_me = true;
i->puser = 0;
how_many += 1;
}
}
cur->session = old_session;
return how_many;
}
@@ -382,7 +418,7 @@ const int deleted_max_at_once = 10;
}
else
{
if( IsSessionOutdated(*i->second) )
if( i->second->remove_me || IsSessionOutdated(*i->second) )
{
DeleteSession(i++);
++deleted;