111 lines
1.6 KiB
C++
Executable File
111 lines
1.6 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 size_t user_index = 0;
|
|
|
|
|
|
|
|
void env_user_tab(Info & i)
|
|
{
|
|
if( cur->session->puser && cur->session->puser->super_user )
|
|
{
|
|
user_index = i.iter;
|
|
i.res = user_index < system->users.Size();
|
|
}
|
|
}
|
|
|
|
|
|
bool evn_user_tab_has_access()
|
|
{
|
|
return cur->session->puser &&
|
|
cur->session->puser->super_user &&
|
|
user_index < system->users.Size();
|
|
}
|
|
|
|
|
|
|
|
void env_user_tab_id(Info & i)
|
|
{
|
|
if( evn_user_tab_has_access() )
|
|
i.out << system->users[user_index].id;
|
|
}
|
|
|
|
|
|
void env_user_tab_name(Info & i)
|
|
{
|
|
if( evn_user_tab_has_access() )
|
|
i.out << system->users[user_index].name;
|
|
}
|
|
|
|
|
|
void env_user_tab_is_current(Info & i)
|
|
{
|
|
if( evn_user_tab_has_access() && functions->fun_env.GetUser() )
|
|
i.res = (system->users[user_index].id == functions->fun_env.GetUser()->id );
|
|
}
|
|
|
|
|
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|
|
|