added: TextStream<> DbTextStream<> and HtmlTextStream<> have operator<<(Space&) now
added: to db: bool DbBase::AssertValueSpace(PGresult * r, int row, int col, Space & space, bool split_single) added: environment variables for users User::env (of type Space) and User::aenv (of type Space) for admin variables (can be changed only by a super user) added: winix function 'env' for changing User::env and User::aenv ('env' winix function with a 'a' parameter) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@790 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
110
templates/env.cpp
Executable file
110
templates/env.cpp
Executable file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user