2009-01-31 07:53:36 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2009-01-31 07:53:36 +01:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2010-02-28 22:33:06 +01:00
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
2009-01-31 07:53:36 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "templates.h"
|
2010-08-10 18:12:50 +02:00
|
|
|
#include "core/request.h"
|
|
|
|
#include "core/misc.h"
|
2009-01-31 07:53:36 +01:00
|
|
|
|
|
|
|
|
2009-04-21 22:50:55 +02:00
|
|
|
|
2009-01-31 07:53:36 +01:00
|
|
|
namespace TemplatesFunctions
|
|
|
|
{
|
|
|
|
|
|
|
|
static size_t who_reqid = 0;
|
|
|
|
|
|
|
|
SessionContainer::Iterator who_iterator;
|
|
|
|
size_t who_lp;
|
|
|
|
|
|
|
|
|
|
|
|
bool who_init()
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( who_reqid != cur->request->id )
|
2009-01-31 07:53:36 +01:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
who_reqid = cur->request->id;
|
2010-08-10 18:12:50 +02:00
|
|
|
who_iterator = session_manager->SessionBegin();
|
2009-01-31 07:53:36 +01:00
|
|
|
who_lp = 1;
|
|
|
|
}
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
return who_iterator != session_manager->SessionEnd();
|
2009-01-31 07:53:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void who_tab(Info & i)
|
|
|
|
{
|
|
|
|
who_init();
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
if( i.iter != 0 && who_iterator != session_manager->SessionEnd() )
|
2009-01-31 07:53:36 +01:00
|
|
|
{
|
|
|
|
++who_iterator;
|
|
|
|
++who_lp;
|
|
|
|
}
|
2010-11-23 22:52:25 +01:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
i.res = who_iterator != session_manager->SessionEnd();
|
2009-01-31 07:53:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void who_tab_lp(Info & i)
|
|
|
|
{
|
|
|
|
if( !who_init() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
i.out << who_lp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void who_tab_user(Info & i)
|
|
|
|
{
|
|
|
|
if( !who_init() )
|
|
|
|
return;
|
|
|
|
|
2010-11-23 22:52:25 +01:00
|
|
|
|
2009-01-31 07:53:36 +01:00
|
|
|
if( who_iterator->puser )
|
|
|
|
i.out << who_iterator->puser->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void who_tab_time(Info & i)
|
|
|
|
{
|
|
|
|
if( !who_init() )
|
|
|
|
return;
|
|
|
|
|
2009-03-23 00:54:15 +01:00
|
|
|
i.out << DateToStr( 0,
|
2012-05-24 23:09:37 +02:00
|
|
|
who_iterator->start_date.month,
|
|
|
|
who_iterator->start_date.day,
|
|
|
|
who_iterator->start_date.hour,
|
|
|
|
who_iterator->start_date.min,
|
|
|
|
who_iterator->start_date.sec );
|
2009-01-31 07:53:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void who_tab_last_time(Info & i)
|
|
|
|
{
|
|
|
|
if( !who_init() )
|
|
|
|
return;
|
|
|
|
|
2009-03-23 00:54:15 +01:00
|
|
|
i.out << DateToStr( 0,
|
2012-05-24 23:09:37 +02:00
|
|
|
who_iterator->last_date.month,
|
|
|
|
who_iterator->last_date.day,
|
|
|
|
who_iterator->last_date.hour,
|
|
|
|
who_iterator->last_date.min,
|
|
|
|
who_iterator->last_date.sec );
|
2009-01-31 07:53:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|
|
|
|
|
|
|
|
|