129 lines
1.8 KiB
C++
Executable File
129 lines
1.8 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2012, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include "templates.h"
|
|
#include "core/misc.h"
|
|
#include "functions/functions.h"
|
|
|
|
|
|
namespace TemplatesFunctions
|
|
{
|
|
|
|
|
|
void env_user_admin_env_str(Info & i)
|
|
{
|
|
// only an admin is able to see this variables
|
|
|
|
if( cur->session->puser && cur->session->puser->super_user )
|
|
{
|
|
User * puser = functions->fun_env.GetUser();
|
|
|
|
if( puser )
|
|
i.out << puser->aenv;
|
|
}
|
|
}
|
|
|
|
|
|
void env_user_env_str(Info & i)
|
|
{
|
|
User * puser = functions->fun_env.GetUser();
|
|
|
|
if( puser )
|
|
i.out << puser->env;
|
|
}
|
|
|
|
|
|
void env_user_id(Info & i)
|
|
{
|
|
User * puser = functions->fun_env.GetUser();
|
|
|
|
if( puser )
|
|
i.out << puser->id;
|
|
}
|
|
|
|
|
|
void env_user_name(Info & i)
|
|
{
|
|
User * puser = functions->fun_env.GetUser();
|
|
|
|
if( puser )
|
|
i.out << puser->name;
|
|
}
|
|
|
|
|
|
|
|
|
|
static Users::Iterator user_iter;
|
|
static size_t user_reqid = 0;
|
|
static size_t user_index; // only information
|
|
|
|
|
|
bool env_user_tab_init()
|
|
{
|
|
if( user_reqid != cur->request->id )
|
|
{
|
|
user_reqid = cur->request->id;
|
|
user_iter = system->users.End();
|
|
}
|
|
|
|
return user_iter != system->users.End();
|
|
}
|
|
|
|
|
|
void env_user_tab(Info & i)
|
|
{
|
|
env_user_tab_init();
|
|
|
|
if( cur->session->puser && cur->session->puser->super_user )
|
|
{
|
|
user_index = i.iter;
|
|
|
|
if( i.iter == 0 )
|
|
user_iter = system->users.Begin();
|
|
else
|
|
if( user_iter != system->users.End() )
|
|
++user_iter;
|
|
|
|
i.res = user_iter != system->users.End();
|
|
}
|
|
}
|
|
|
|
|
|
void env_user_tab_id(Info & i)
|
|
{
|
|
if( env_user_tab_init() )
|
|
i.out << user_iter->id;
|
|
}
|
|
|
|
|
|
void env_user_tab_name(Info & i)
|
|
{
|
|
if( env_user_tab_init() )
|
|
i.out << user_iter->name;
|
|
}
|
|
|
|
|
|
void env_user_tab_is_current(Info & i)
|
|
{
|
|
if( env_user_tab_init() )
|
|
{
|
|
User * puser = functions->fun_env.GetUser();
|
|
|
|
if( puser )
|
|
i.res = (user_iter->id == puser->id );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|
|
|