- updated to the new pikotools api (child spaces were removed)

some plugins need to be fixed yet: ticket, gallery, group, menu
- added current user to default models as "user"
- renamed in User: super_user -> is_super_user, env -> admin_env, pass_hash_salted -> is_pass_hash_salted
- now Users class has a WinixModel as a base class
  some plugin calls have to be fixed yet
- added UserWrapper model with a pointer to User class
- removed from ItemContent: methods for accessing 'meta' and 'admin_meta', now ezc can iterate through Space classes
- fixed in env winix function: if there is "changeuser" parameter then we should only switch the user (not save anything)
This commit is contained in:
Tomasz Sowa 2021-06-27 23:31:50 +02:00
parent 472490c239
commit 1d18b7fa12
59 changed files with 1419 additions and 1607 deletions

View File

@ -881,6 +881,11 @@ void App::AddDefaultModels()
{ {
cur.request->models.Add(L"request", cur.request); cur.request->models.Add(L"request", cur.request);
if( cur.session && cur.session->puser )
{
cur.request->models.Add(L"user", *cur.session->puser);
}
if( cur.request->is_item ) if( cur.request->is_item )
{ {
cur.request->models.Add(L"item", cur.request->item); cur.request->models.Add(L"item", cur.request->item);

View File

@ -270,7 +270,7 @@ bool Crypt::RSA(bool encrypt, const std::wstring & keypath, const std::string &
bool Crypt::PassHash(const std::wstring & salt, User & user) bool Crypt::PassHash(const std::wstring & salt, User & user)
{ {
bool result = true; bool result = true;
user.pass_hash_salted = false; user.is_pass_hash_salted = false;
if( user.pass_type != WINIX_CRYPT_HASH_NONE ) if( user.pass_type != WINIX_CRYPT_HASH_NONE )
{ {
@ -281,7 +281,7 @@ bool Crypt::PassHash(const std::wstring & salt, User & user)
if( HashHex(user.pass_type, pass_salted, user.password) ) if( HashHex(user.pass_type, pass_salted, user.password) )
{ {
if( !salt.empty() ) if( !salt.empty() )
user.pass_hash_salted = true; user.is_pass_hash_salted = true;
} }
else else
{ {

View File

@ -71,7 +71,7 @@ void Groups::ReadGroups(Db * db)
for(Group & group : groups_tmp) for(Group & group : groups_tmp)
{ {
table.PushBack(group); table.PushBack(group, group.name);
} }
} }

View File

@ -241,7 +241,7 @@ void SessionManager::SetSessionPutLogInfo(Session & ses, bool has_index, unsigne
main_log << ", index difference: " << (size_t)difference; main_log << ", index difference: " << (size_t)difference;
if( ses.puser ) if( ses.puser )
main_log << log2 << ", user: " << ses.puser->name << ", id: " << ses.puser->id; main_log << log2 << ", user: " << ses.puser->login << ", id: " << ses.puser->id;
main_log << log2 << logend; main_log << log2 << logend;
} }

View File

@ -135,7 +135,7 @@ void SessionParser::MakeSession(long id, long user_id, SessionContainer & contai
// !! IMPROVE ME we do not save last_time_get // !! IMPROVE ME we do not save last_time_get
users->IncrementLoggedUsers(); users->IncrementLoggedUsers();
log << log2 << "SP: read session id: " << id << " for user: " << puser->name << logend; log << log2 << "SP: read session id: " << id << " for user: " << puser->login << logend;
} }
else else
{ {

View File

@ -87,7 +87,8 @@ void System::set_dependency(WinixModelDeprecated * winix_model)
dirs.set_dependency(this); dirs.set_dependency(this);
mounts.set_dependency(this); mounts.set_dependency(this);
users.set_dependency(this); //users.set_dependency(this);
users.set_connector(model_connector);
groups.set_dependency(this); groups.set_dependency(this);
rebus.set_dependency(this); rebus.set_dependency(this);
load_avg.set_dependency(this); load_avg.set_dependency(this);
@ -140,8 +141,9 @@ void System::Init()
mounts.CreateMounts(); mounts.CreateMounts();
mounts.ReadMounts(); mounts.ReadMounts();
users.SetCur(cur); // users.SetCur(cur);
users.SetSessionManager(session_manager); // users.SetSessionManager(session_manager);
users.set_connector(model_connector);
users.ReadUsers(db); users.ReadUsers(db);
groups.ReadGroups(db); // !! chwilowe przekazanie argumentu, db bedzie zmienione groups.ReadGroups(db); // !! chwilowe przekazanie argumentu, db bedzie zmienione
@ -533,7 +535,7 @@ bool System::CanChangeUser(const Item & item, long new_user_id)
// session must be set // session must be set
return false; return false;
if( cur->session->puser && cur->session->puser->super_user ) if( cur->session->puser && cur->session->puser->is_super_user )
// super user is allowed everything // super user is allowed everything
return true; return true;
@ -553,7 +555,7 @@ bool System::CanChangeGroup(const Item & item, long new_group_id)
// session must be set // session must be set
return false; return false;
if( cur->session->puser && cur->session->puser->super_user ) if( cur->session->puser && cur->session->puser->is_super_user )
// super user is allowed everything // super user is allowed everything
return true; return true;
@ -587,7 +589,7 @@ bool System::CanChangePrivileges(const Item & item, int new_priv)
// session must be set // session must be set
return false; return false;
if( cur->session->puser && cur->session->puser->super_user ) if( cur->session->puser && cur->session->puser->is_super_user )
// super user is allowed everything // super user is allowed everything
return true; return true;
@ -751,7 +753,7 @@ bool System::CanRemoveRenameChild(const Item & dir, long child_item_user_id)
if( cur->session->puser ) if( cur->session->puser )
{ {
if( cur->session->puser->super_user ) if( cur->session->puser->is_super_user )
return true; return true;
if( dir.item_content.user_id != -1 && cur->session->puser->id != -1 && child_item_user_id != -1 ) if( dir.item_content.user_id != -1 && cur->session->puser->id != -1 && child_item_user_id != -1 )
@ -811,7 +813,7 @@ bool System::IsSuperUser(long user_id)
if( !puser ) if( !puser )
return false; return false;
return puser->super_user; return puser->is_super_user;
} }

View File

@ -258,7 +258,7 @@ bool TimeZone::SetTzDst(pt::Space & year)
Dst dst; Dst dst;
int year_int = 0; int year_int = 0;
std::wstring * year_name = year.find_child_space_name(); std::wstring * year_name = year.get_wstr(L"year");
if( year_name ) if( year_name )
year_int = Toi(*year_name); year_int = Toi(*year_name);
@ -297,7 +297,7 @@ bool TimeZone::SetTz(pt::Space & space)
bool result = true; bool result = true;
name.clear(); name.clear();
std::wstring * space_name = space.find_child_space_name(); std::wstring * space_name = space.get_wstr(L"name");
if( space_name ) if( space_name )
name = *space_name; name = *space_name;
@ -309,21 +309,16 @@ bool TimeZone::SetTz(pt::Space & space)
if( offset < -h24 || offset > h24 ) if( offset < -h24 || offset > h24 )
result = false; result = false;
pt::Space * dst = space.find_child_space(L"dst"); pt::Space::TableType * dst = space.get_table(L"dst");
if( dst ) if( dst )
{ {
pt::Space::TableType * child_table = dst->find_child_space_table(); for(pt::Space * dst_space : *dst)
if( child_table )
{ {
for(pt::Space * year : *child_table) if( !SetTzDst(*dst_space) )
{ {
if( !SetTzDst(*year) ) result = false;
{ break;
result = false;
break;
}
} }
} }
} }

View File

@ -123,11 +123,11 @@ bool TimeZones::Empty() const
void TimeZones::ParseZones() void TimeZones::ParseZones()
{ {
pt::Space::TableType * child_table = temp_space.find_child_space_table(); pt::Space::TableType * timezones_table = temp_space.get_table(L"timezones");
if( child_table ) if( timezones_table )
{ {
for(pt::Space * zone : *child_table) for(pt::Space * zone : *timezones_table)
{ {
temp_zone.Clear(); temp_zone.Clear();
@ -155,7 +155,7 @@ void TimeZones::ParseZones()
else else
{ {
log << log1 << "System: problem with reading time zone info from time zone: " log << log1 << "System: problem with reading time zone info from time zone: "
<< zone->get_child_space_name() << " (skipping) " << logend; << zone->to_wstr(L"name") << " (skipping) " << logend;
} }
} }
} }

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2014, Tomasz Sowa * Copyright (c) 2008-2021, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -65,7 +65,7 @@ public:
Iterator End(); Iterator End();
SizeType Size(); SizeType Size();
bool Empty(); bool Empty();
Iterator PushBack(const Type & type); // can return End() if the user already exists Iterator PushBack(const Type & type, const std::wstring & name); // can return End() if the user already exists
void Clear(); void Clear();
bool Is(long id); bool Is(long id);
@ -78,17 +78,20 @@ public:
// main table
Table table;
private: private:
// don't copy these objects // don't copy these objects
UGContainer(const UGContainer<Type> &); UGContainer(const UGContainer<Type> &);
UGContainer<Type> & operator=(const UGContainer<Type> &); UGContainer<Type> & operator=(const UGContainer<Type> &);
void AddIndexes(Iterator iter); void AddIndexes(Iterator iter, const std::wstring & name);
void RebuildIndexes(); void RebuildIndexes();
// main table
Table table;
// table.size() has O(n) complexity // table.size() has O(n) complexity
size_t table_size; size_t table_size;
@ -163,16 +166,16 @@ bool UGContainer<Type>::Empty()
template<class Type> template<class Type>
typename UGContainer<Type>::Iterator UGContainer<Type>::PushBack(const Type & type) typename UGContainer<Type>::Iterator UGContainer<Type>::PushBack(const Type & type, const std::wstring & name)
{ {
if( Is(type.id) || Is(type.name) ) if( Is(type.id) || Is(name) )
return End(); return End();
table.push_back(type); table.push_back(type);
table_size += 1; table_size += 1;
Iterator i = --table.end(); Iterator i = --table.end();
log << log3 << "UGCont: added, id: " << type.id << ", name: " << type.name << logend; log << log3 << "UGCont: added, id: " << type.id << ", name: " << name << logend;
AddIndexes(i); AddIndexes(i, name);
return i; return i;
} }
@ -242,12 +245,12 @@ return i->second;
template<class Type> template<class Type>
void UGContainer<Type>::AddIndexes(UGContainer<Type>::Iterator iter) void UGContainer<Type>::AddIndexes(UGContainer<Type>::Iterator iter, const std::wstring & name)
{ {
table_id.insert( std::make_pair(iter->id, iter) ); table_id.insert( std::make_pair(iter->id, iter) );
table_name.insert( std::make_pair(iter->name, iter) ); table_name.insert( std::make_pair(name, iter) );
log << log4 << "UGCont: added indexes to: id: " << iter->id << ", name: " << iter->name << logend; log << log4 << "UGCont: added indexes to: id: " << iter->id << ", name: " << name << logend;
} }
@ -286,14 +289,15 @@ bool UGContainer<Type>::Remove(long id)
{ {
if( n->second == i->second ) if( n->second == i->second )
{ {
log << log4 << "UGCont: removed index_name to: id: " << i->second->id << ", name: " << n->first << logend;
table_name.erase(n); table_name.erase(n);
log << log4 << "UGCont: removed index_id to: id: " << i->second->id << ", name: " << i->second->name << logend;
break; break;
} }
} }
log << log4 << "UGCont: removed index_name to: id: " << i->second->id << ", name: " << i->second->name << logend; log << log4 << "UGCont: removed index_id to: id: " << i->second->id << logend;
log << log3 << "UGCont: removed: id: " << i->second->id << ", name: " << i->second->name << logend; log << log3 << "UGCont: removed: id: " << i->second->id << logend;
table.erase(i->second); table.erase(i->second);
table_id.erase(i); table_id.erase(i);
result = true; result = true;

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2018, Tomasz Sowa * Copyright (c) 2008-2021, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -35,6 +35,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include "users.h" #include "users.h"
#include "sessionmanager.h" #include "sessionmanager.h"
#include "slog.h"
namespace Winix namespace Winix
@ -45,29 +46,38 @@ namespace Winix
Users::Users() Users::Users()
{ {
how_many_logged = 0; // !! CHECK ME may it should be moved to Clear() method? how_many_logged = 0; // !! CHECK ME may it should be moved to Clear() method?
table.set_dependency(this); // table.set_dependency(this);
Clear(); Clear();
} }
void Users::set_dependency(WinixModelDeprecated * winix_model)
void Users::fields()
{ {
WinixModelDeprecated::set_dependency(winix_model); field(L"users", table.table);
table.set_dependency(winix_model);
last.set_dependency(winix_model);
} }
void Users::SetCur(Cur * pcur)
{
cur = pcur;
}
void Users::SetSessionManager(SessionManager * sm) //void Users::set_dependency(WinixModelDeprecated * winix_model)
{ //{
session_manager = sm; // WinixModelDeprecated::set_dependency(winix_model);
} // table.set_dependency(winix_model);
// last.set_dependency(winix_model);
//}
//void Users::SetCur(Cur * pcur)
//{
// cur = pcur;
//}
//void Users::SetSessionManager(SessionManager * sm)
//{
// session_manager = sm;
//}
void Users::Clear() void Users::Clear()
@ -89,7 +99,7 @@ void Users::ReadUsers(Db * db)
for(User & user : users_tmp) for(User & user : users_tmp)
{ {
table.PushBack(user); table.PushBack(user, user.login);
} }
} }
@ -98,7 +108,7 @@ void Users::ReadUsers(Db * db)
bool Users::AddUser(const User & user) bool Users::AddUser(const User & user)
{ {
Table::Iterator i = table.PushBack(user); Table::Iterator i = table.PushBack(user, user.login);
return (i != table.End()); return (i != table.End());
} }
@ -173,11 +183,11 @@ bool Users::Remove(long user_id)
if( puser ) if( puser )
{ {
LogoutUser(user_id); LogoutUser(user_id);
plugin->Call(WINIX_PREPARE_TO_REMOVE_USER, puser); // plugin->Call(WINIX_PREPARE_TO_REMOVE_USER, puser); FIXME
result = table.Remove(user_id); result = table.Remove(user_id);
if( result ) // if( result )
plugin->Call(WINIX_USER_REMOVED, user_id); // plugin->Call(WINIX_USER_REMOVED, user_id); FIXME
} }
return result; return result;
@ -187,15 +197,20 @@ return result;
// private // private
bool Users::LoginUserCheckSession(bool use_ses_log) bool Users::LoginUserCheckSession(bool use_ses_log)
{ {
if( !cur->session ) Session * session = get_session();
Log * log = get_logger();
SLog * slog = get_session_logger();
if( !session )
return false; return false;
if( cur->session->id == 0 ) if( session->id == 0 )
{ {
log << log1 << "Users: I cannot login a user on a temporary session" << logend; if( log )
(*log) << log1 << "Users: I cannot login a user on a temporary session" << logend;
// if( use_ses_log ) if( slog && use_ses_log )
// slog << logerror << T(L"service_unavailable") << logend; (*slog) << logerror << T(L"service_unavailable") << logend;
return false; return false;
} }
@ -208,34 +223,35 @@ return true;
User * Users::LoginUserCheckStatus(long user_id, bool use_ses_log) User * Users::LoginUserCheckStatus(long user_id, bool use_ses_log)
{ {
User * puser = GetUser(user_id); User * puser = GetUser(user_id);
Log * log = get_logger();
SLog * slog = get_session_logger();
if( !puser ) if( !puser )
{ {
log << log1 << "Users: user id: " << user_id << " is not in system.users table" << logend; if( log )
(*log) << log1 << "Users: user id: " << user_id << " is not in system.users table" << logend;
// if( use_ses_log ) if( slog && use_ses_log )
// slog << logerror << T(L"service_unavailable") << logend; (*slog) << logerror << T(L"service_unavailable") << logend;
return 0; return 0;
} }
if( puser->status != WINIX_ACCOUNT_READY ) if( puser->status != WINIX_ACCOUNT_READY )
{ {
log << log1 << "Users: user id: " << user_id << " is not ready for logging in (status: " (*log) << log1 << "Users: user id: " << user_id << " is not ready for logging in (status: "
<< puser->status << ")" << logend; << puser->status << ")" << logend;
if( use_ses_log ) if( slog && use_ses_log )
{ {
/*
if( puser->status == WINIX_ACCOUNT_NOT_ACTIVATED ) if( puser->status == WINIX_ACCOUNT_NOT_ACTIVATED )
slog << logerror << T(L"account_not_activated") << logend; (*slog) << logerror << T(L"account_not_activated") << logend;
else else
if( puser->status == WINIX_ACCOUNT_SUSPENDED ) if( puser->status == WINIX_ACCOUNT_SUSPENDED )
slog << logerror << T(L"account_suspended") << logend; (*slog) << logerror << T(L"account_suspended") << logend;
else else
if( puser->status == WINIX_ACCOUNT_BLOCKED ) if( puser->status == WINIX_ACCOUNT_BLOCKED )
slog << logerror << T(L"account_banned") << logend; (*slog) << logerror << T(L"account_banned") << logend;
*/
} }
return 0; return 0;
@ -252,34 +268,43 @@ bool Users::LoginUser(long user_id, bool remember_me, bool use_ses_log)
return false; return false;
User * puser = LoginUserCheckStatus(user_id, use_ses_log); User * puser = LoginUserCheckStatus(user_id, use_ses_log);
Log * log = get_logger();
Session * session = get_session();
SessionManager * session_manager = get_session_manager();
Request * request = get_request();
if( !puser ) if( !puser || !session || !session_manager || !request )
return false; return false;
PluginRes res = plugin->Call(WINIX_PREPARE_USER_TO_LOGIN, puser); PluginRes res;
//PluginRes res = plugin->Call(WINIX_PREPARE_USER_TO_LOGIN, puser); FIXME
if( res.res_false > 0 ) if( res.res_false > 0 )
{ {
log << log3 << "Users: login prevented by a plugin" << logend; if( log )
(*log) << log3 << "Users: login prevented by a plugin" << logend;
return false; return false;
} }
if( cur->session->puser ) if( session->puser )
LogoutCurrentUser(); LogoutCurrentUser();
cur->session->puser = puser; session->puser = puser;
cur->session->spam_score = 0; session->spam_score = 0;
cur->session->remember_me = remember_me; session->remember_me = remember_me;
// change session id before last.UserLogin() // change session id before last.UserLogin()
if( !cur->session->new_session ) if( !session->new_session )
session_manager->ChangeSessionId(cur->session->id); session_manager->ChangeSessionId(session->id);
last.UserLogin(user_id, cur->session->puser->name, cur->request->ip, cur->session->id); last.UserLogin(user_id, session->puser->login, request->ip, session->id);
how_many_logged += 1; how_many_logged += 1;
log << log2 << "Users: user " << cur->session->puser->name << " (id: " << user_id << ") logged" << logend; if( log )
plugin->Call(WINIX_USER_LOGGED); (*log) << log2 << "Users: user " << session->puser->login << " (id: " << user_id << ") logged" << logend;
//plugin->Call(WINIX_USER_LOGGED); FIXME
return true; return true;
} }
@ -289,18 +314,26 @@ size_t Users::LogoutUser(long user_id)
{ {
size_t how_many = 0; size_t how_many = 0;
User * puser = GetUser(user_id); User * puser = GetUser(user_id);
Log * log = get_logger();
SessionManager * session_manager = get_session_manager();
if( puser ) if( puser && session_manager )
{ {
log << log2 << "Users: logging out user " << puser->name << ", id: " if( log )
<< puser->id << " from all sessions" << logend; {
(*log) << log2 << "Users: logging out user " << puser->login << ", id: "
<< puser->id << " from all sessions" << logend;
}
// WINIX_PREPARE_USER_TO_LOGOUT will be sent by MarkAllSessionsToRemove() // WINIX_PREPARE_USER_TO_LOGOUT will be sent by MarkAllSessionsToRemove()
how_many = session_manager->MarkAllSessionsToRemove(user_id); how_many = session_manager->MarkAllSessionsToRemove(user_id);
how_many_logged -= how_many; how_many_logged -= how_many;
if( how_many ) if( how_many )
log << log3 << "Users: " << how_many << " user(s) were logged out" << logend; {
if( log )
(*log) << log3 << "Users: " << how_many << " user(s) were logged out" << logend;
}
} }
return how_many; return how_many;
@ -310,20 +343,26 @@ return how_many;
void Users::LogoutCurrentUser() void Users::LogoutCurrentUser()
{ {
if( !cur->session || !cur->session->puser ) Log * log = get_logger();
Session * session = get_session();
if( !session || !session->puser )
return; return;
log << log2 << "Users: user " << cur->session->puser->name << ", id: " if( log )
<< cur->session->puser->id << " logged out" << logend; {
(*log) << log2 << "Users: user " << session->puser->login << ", id: "
<< session->puser->id << " logged out" << logend;
}
plugin->Call(WINIX_PREPARE_USER_TO_LOGOUT, cur->session->puser); //plugin->Call(WINIX_PREPARE_USER_TO_LOGOUT, cur->session->puser); // FIXME
last.UserLogout(cur->session->puser->id, cur->session->id); last.UserLogout(session->puser->id, session->id);
if( how_many_logged > 0 ) // for safety if( how_many_logged > 0 ) // for safety
how_many_logged -= 1; how_many_logged -= 1;
cur->session->puser = 0; session->puser = 0;
cur->session->remember_me = false; session->remember_me = false;
} }

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2008-2018, Tomasz Sowa * Copyright (c) 2008-2021, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -41,7 +41,7 @@
#include "lastcontainer.h" #include "lastcontainer.h"
#include "cur.h" #include "cur.h"
#include "db/db.h" #include "db/db.h"
#include "winixmodeldeprecated.h" #include "models/winixmodel.h"
@ -53,13 +53,13 @@ namespace Winix
class SessionManager; class SessionManager;
class Users : public WinixModelDeprecated class Users : public WinixModel
{ {
typedef UGContainer<User> Table; typedef UGContainer<User> Table;
public: public:
void set_dependency(WinixModelDeprecated * winix_model); //void set_dependency(WinixModelDeprecated * winix_model);
typedef Table::Iterator Iterator; typedef Table::Iterator Iterator;
@ -69,8 +69,8 @@ public:
Users(); Users();
void SetCur(Cur * pcur); // void SetCur(Cur * pcur);
void SetSessionManager(SessionManager * sm); // void SetSessionManager(SessionManager * sm);
void Clear(); void Clear();
void ReadUsers(Db * db); void ReadUsers(Db * db);
@ -91,12 +91,17 @@ public:
void IncrementLoggedUsers(); void IncrementLoggedUsers();
long HowManyLogged(); long HowManyLogged();
protected:
void fields();
private: private:
Table table; Table table;
Cur * cur; //Cur * cur;
SessionManager * session_manager; //SessionManager * session_manager;
long how_many_logged; long how_many_logged;
bool LoginUserCheckSession(bool use_ses_log); bool LoginUserCheckSession(bool use_ses_log);

File diff suppressed because it is too large Load Diff

View File

@ -55,18 +55,18 @@ Account::Account()
bool Account::ActivateAccount(User * puser, long code, bool use_ses_log) bool Account::ActivateAccount(User * puser, long code, bool use_ses_log)
{ {
std::wstring * user_code_str = puser->aenv.get_wstr(L"activation_code"); std::wstring * user_code_str = puser->admin_env.get_wstr(L"activation_code");
if( user_code_str ) if( user_code_str )
{ {
if( Tol(*user_code_str) == code ) if( Tol(*user_code_str) == code )
{ {
puser->status = WINIX_ACCOUNT_READY; puser->status = WINIX_ACCOUNT_READY;
puser->aenv.remove(L"activation_code"); puser->admin_env.remove(L"activation_code");
if( puser->update() ) if( puser->update() )
{ {
log << log2 << "Account: account: " << puser->name << " activated" << logend; log << log2 << "Account: account: " << puser->login << " activated" << logend;
if( use_ses_log ) if( use_ses_log )
slog << loginfo << T(L"account_activated") << logend; slog << loginfo << T(L"account_activated") << logend;

View File

@ -170,12 +170,12 @@ bool AddUser::AddNewUser(User & user, const std::wstring & pass)
{ {
if( system->users.AddUser(user) ) if( system->users.AddUser(user) )
{ {
log << log2 << "AddUser: added a new user: " << user.name << logend; log << log2 << "AddUser: added a new user: " << user.login << logend;
return true; return true;
} }
else else
{ {
log << log1 << "AddUser: I can't add to system->users: " << user.name log << log1 << "AddUser: I can't add to system->users: " << user.login
<< " but the user was added to the db correctly" << logend; << " but the user was added to the db correctly" << logend;
} }
} }
@ -217,9 +217,9 @@ bool AddUser::AddNewUser(const std::wstring & login,
user.clear(); user.clear();
//user.Clear(); //user.Clear();
user.name = login; user.login = login;
user.email = email; user.email = email;
user.super_user = false; user.is_super_user = false;
user.notify = 0; user.notify = 0;
user.locale_id = config->locale_default_id; user.locale_id = config->locale_default_id;
user.time_zone_id = config->time_zone_default_id; user.time_zone_id = config->time_zone_default_id;
@ -232,7 +232,7 @@ bool AddUser::AddNewUser(const std::wstring & login,
if( user.status == WINIX_ACCOUNT_NOT_ACTIVATED ) if( user.status == WINIX_ACCOUNT_NOT_ACTIVATED )
{ {
code = std::rand(); code = std::rand();
user.aenv.add(L"activation_code", code); user.admin_env.add(L"activation_code", code);
} }
if( AddNewUser(user, pass) ) if( AddNewUser(user, pass) )
@ -240,13 +240,13 @@ bool AddUser::AddNewUser(const std::wstring & login,
if( try_login && !cur->session->puser && user.status == WINIX_ACCOUNT_READY ) if( try_login && !cur->session->puser && user.status == WINIX_ACCOUNT_READY )
{ {
system->users.LoginUser(user.id, false); system->users.LoginUser(user.id, false);
log << log2 << "AddUser: now logged as: " << user.name << logend; log << log2 << "AddUser: now logged as: " << user.login << logend;
plugin->Call(WINIX_USER_LOGGED); plugin->Call(WINIX_USER_LOGGED);
} }
if( user.status == WINIX_ACCOUNT_NOT_ACTIVATED ) if( user.status == WINIX_ACCOUNT_NOT_ACTIVATED )
{ {
system->notify.ActivateAccount(user.name, user.email, code); system->notify.ActivateAccount(user.login, user.email, code);
if( use_ses_log ) if( use_ses_log )
slog << loginfo << T(L"account_email_sent") << logend; slog << loginfo << T(L"account_email_sent") << logend;
@ -277,7 +277,7 @@ void AddUser::MakePost()
!functions->fun_passwd.IsPasswordCorrect(pass, conf_pass, true) ) !functions->fun_passwd.IsPasswordCorrect(pass, conf_pass, true) )
return; return;
if( cur->session->puser && cur->session->puser->super_user ) if( cur->session->puser && cur->session->puser->is_super_user )
{ {
autoactivate = cur->request->IsPostVar(L"autoactivate"); autoactivate = cur->request->IsPostVar(L"autoactivate");

View File

@ -54,7 +54,7 @@ Emacs::Emacs()
bool Emacs::HasAccess(const Item & item) bool Emacs::HasAccess(const Item & item)
{ {
if( cur->session->puser && cur->session->puser->super_user ) if( cur->session->puser && cur->session->puser->is_super_user )
// super user can use emacs everywhere // super user can use emacs everywhere
return true; return true;

View File

@ -46,7 +46,6 @@ namespace Fun
Env::Env() Env::Env()
{ {
fun.url = L"env"; fun.url = L"env";
puser = 0;
} }
@ -59,7 +58,7 @@ bool Env::HasAccess()
{ {
// show/change admin environment variables for a user // show/change admin environment variables for a user
if( !cur->session->puser->super_user ) if( !cur->session->puser->is_super_user )
return false; return false;
} }
@ -78,16 +77,16 @@ bool Env::EditAdminEnv(const std::wstring & env_str, bool use_ses_log)
{ {
if( Parse(env_str) ) if( Parse(env_str) )
{ {
puser->aenv = space; user_wrapper.user->admin_env = space;
if( puser->update() ) if( user_wrapper.user->update() )
{ {
return true; return true;
} }
else else
{ {
log << log1 << "Evn: a database problem with changing admin environment variables for user: " log << log1 << "Evn: a database problem with changing admin environment variables for user: "
<< puser->name << ", id: " << puser->id << logend; << user_wrapper.user->login << ", id: " << user_wrapper.user->id << logend;
} }
} }
else else
@ -106,16 +105,16 @@ bool Env::EditEnv(const std::wstring & env_str, bool use_ses_log)
{ {
if( Parse(env_str) ) if( Parse(env_str) )
{ {
puser->env = space; user_wrapper.user->env = space;
if( puser->update() ) if( user_wrapper.user->update() )
{ {
return true; return true;
} }
else else
{ {
log << log1 << "Evn: a database problem with changing admin environment variables for user: " log << log1 << "Evn: a database problem with changing admin environment variables for user: "
<< puser->name << ", id: " << puser->id << logend; << user_wrapper.user->login << ", id: " << user_wrapper.user->id << logend;
} }
} }
else else
@ -138,61 +137,89 @@ void Env::SaveEnv()
if( cur->request->IsParam(L"a") ) if( cur->request->IsParam(L"a") )
{ {
if( cur->session->puser->super_user ) if( cur->session->puser->is_super_user )
{
status = EditAdminEnv(env_str, true); status = EditAdminEnv(env_str, true);
if( status )
{
slog << loginfo << T(L"env_admin_changed_successfully") << logend;
}
}
} }
else else
{ {
status = EditEnv(env_str, true); status = EditEnv(env_str, true);
}
if( status ) if( status )
system->RedirectToLastItem(); {
slog << loginfo << T(L"env_changed_successfully") << logend;
}
}
}
void Env::RegisterModels()
{
cur->request->models.Add(L"users", system->users);
cur->request->models.Add(L"env_user", user_wrapper);
} }
void Env::MakePost() void Env::MakePost()
{ {
puser = nullptr; user_wrapper.user = nullptr;
user_wrapper.set_connector(model_connector);
if( cur->session->puser ) if( cur->session->puser )
{ {
puser = cur->session->puser; user_wrapper.user = cur->session->puser;
if( cur->request->IsPostVar(L"changeuser") ) if( cur->session->puser->is_super_user && cur->request->IsPostVar(L"userid") )
{ {
// show environments variables for the specified user long id = Tol(cur->request->PostVar(L"userid"));
if( puser->super_user && cur->request->IsPostVar(L"userid") ) user_wrapper.user = system->users.GetUser(id);
{
long id = Tol(cur->request->PostVar(L"userid"));
puser = system->users.GetUser(id);
if( puser ) if( user_wrapper.user->id != cur->session->puser->id )
{ {
log << log2 << "Env: changing user to: " << puser->name << ", id: " << puser->id << logend; log << log2 << "Env: changing user to: " << user_wrapper.user->login << ", id: " << user_wrapper.user->id << logend;
}
} }
} }
if( puser ) if( !cur->request->IsPostVar(L"changeuser") )
{ {
/* if( user_wrapper.user )
* this puser should be set in a new struct (based on Model) {
* and put to templates SaveEnv();
* }
*/ else
{
SaveEnv(); cur->request->status = WINIX_ERR_PERMISSION_DENIED;
} }
else
{
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
} }
} }
RegisterModels();
} }
void Env::MakeGet()
{
user_wrapper.user = cur->session->puser;
user_wrapper.set_connector(model_connector);
RegisterModels();
}
void Env::Clear()
{
user_wrapper.user = nullptr;
}
} // namespace } // namespace

View File

@ -35,9 +35,11 @@
#ifndef headerfile_winix_functions_env #ifndef headerfile_winix_functions_env
#define headerfile_winix_functions_env #define headerfile_winix_functions_env
#include "models/userwrapper.h"
#include "functionbase.h" #include "functionbase.h"
#include "space/spaceparser.h" #include "space/spaceparser.h"
namespace Winix namespace Winix
{ {
@ -54,13 +56,15 @@ public:
bool HasAccess(); bool HasAccess();
void MakePost(); void MakePost();
void MakeGet();
void Clear();
private: private:
pt::SpaceParser conf_parser; pt::SpaceParser conf_parser;
pt::Space space; pt::Space space;
User * puser; UserWrapper user_wrapper;
bool EditAdminEnv(const std::wstring & env_str, bool use_ses_log = false); bool EditAdminEnv(const std::wstring & env_str, bool use_ses_log = false);
bool EditEnv(const std::wstring & env_str, bool use_ses_log = false); bool EditEnv(const std::wstring & env_str, bool use_ses_log = false);
@ -68,6 +72,8 @@ private:
bool Parse(const std::wstring & env_str); bool Parse(const std::wstring & env_str);
void SaveEnv(); void SaveEnv();
void RegisterModels();
}; };

View File

@ -615,7 +615,7 @@ void Functions::ReadItemFilterHtml(Item & item)
void Functions::ReadItemContent(Item & item, const std::wstring & content_type) void Functions::ReadItemContent(Item & item, const std::wstring & content_type)
{ {
bool is_root = cur->session->puser && cur->session->puser->super_user; bool is_root = cur->session->puser && cur->session->puser->is_super_user;
bool filter_html = (content_type == L"2") && config->editors_html_safe_mode; bool filter_html = (content_type == L"2") && config->editors_html_safe_mode;
if( filter_html && is_root && config->editors_html_safe_mode_skip_root ) if( filter_html && is_root && config->editors_html_safe_mode_skip_root )

View File

@ -58,7 +58,7 @@ IPBanFun::IPBanFun()
bool IPBanFun::HasAccess() bool IPBanFun::HasAccess()
{ {
return cur->session->puser && cur->session->puser->super_user; return cur->session->puser && cur->session->puser->is_super_user;
} }

View File

@ -81,7 +81,7 @@ bool Login::CheckPasswords(User & user, const std::wstring & password)
std::wstring password_from_db = user.password; std::wstring password_from_db = user.password;
user.password = password; user.password = password;
if( user.pass_hash_salted ) if( user.is_pass_hash_salted )
salt = config->pass_hash_salt; salt = config->pass_hash_salt;
else else
salt.clear(); salt.clear();

View File

@ -53,7 +53,7 @@ Meta::Meta()
bool Meta::HasAccess() bool Meta::HasAccess()
{ {
if( cur->request->IsParam(L"a") ) if( cur->request->IsParam(L"a") )
return cur->session->puser && cur->session->puser->super_user; return cur->session->puser && cur->session->puser->is_super_user;
else else
return system->HasWriteAccess(*cur->request->last_item); return system->HasWriteAccess(*cur->request->last_item);
} }
@ -134,7 +134,7 @@ void Meta::ChangeAdminMeta()
{ {
// IMPROVE ME we need to show an error msg if the user is not an admin // IMPROVE ME we need to show an error msg if the user is not an admin
if( cur->session->puser && cur->session->puser->super_user ) if( cur->session->puser && cur->session->puser->is_super_user )
{ {
const std::wstring & meta_str = cur->request->PostVar(L"itemmeta"); const std::wstring & meta_str = cur->request->PostVar(L"itemmeta");

View File

@ -60,7 +60,7 @@ bool Mkdir::HasAccess(const Item & item)
if( item.type != Item::dir ) if( item.type != Item::dir )
return false; return false;
if( cur->session->puser && cur->session->puser->super_user ) if( cur->session->puser && cur->session->puser->is_super_user )
// super user can use mkdir everywhere // super user can use mkdir everywhere
return true; return true;

View File

@ -53,7 +53,7 @@ Mount::Mount()
bool Mount::HasAccess() bool Mount::HasAccess()
{ {
if( cur->session->puser && cur->session->puser->super_user ) if( cur->session->puser && cur->session->puser->is_super_user )
return true; return true;
return false; return false;

View File

@ -117,7 +117,7 @@ bool result = false;
result = puser->update(); result = puser->update();
if( result ) if( result )
log << log2 << "Passwd: password for user " << puser->name << " has been changed" << logend; log << log2 << "Passwd: password for user " << puser->login << " has been changed" << logend;
else else
log << log1 << "Passwd: I cannot change password -- database problem" << logend; log << log1 << "Passwd: I cannot change password -- database problem" << logend;
} }
@ -140,7 +140,7 @@ long user_id;
const std::wstring & pass_new = cur->request->PostVar(L"passwordnew"); const std::wstring & pass_new = cur->request->PostVar(L"passwordnew");
const std::wstring & pass_conf = cur->request->PostVar(L"passwordconfirm"); const std::wstring & pass_conf = cur->request->PostVar(L"passwordconfirm");
if( !cur->session->puser->super_user && !functions->fun_login.CheckUserPass(puser->name, pass_cur, user_id) ) if( !cur->session->puser->is_super_user && !functions->fun_login.CheckUserPass(puser->login, pass_cur, user_id) )
{ {
log << log3 << "Passwd: incorrect current password" << logend; log << log3 << "Passwd: incorrect current password" << logend;
slog << logerror << T("passwd_err_bad_current_password") << logend; slog << logerror << T("passwd_err_bad_current_password") << logend;
@ -190,7 +190,7 @@ return result;
bool Passwd::ResetPassword(User * puser, long code, bool use_ses_log, bool only_check_access) bool Passwd::ResetPassword(User * puser, long code, bool use_ses_log, bool only_check_access)
{ {
std::wstring * user_code_str = puser->aenv.get_wstr(L"password_change_code"); std::wstring * user_code_str = puser->admin_env.get_wstr(L"password_change_code");
if( user_code_str ) if( user_code_str )
{ {
@ -230,7 +230,7 @@ bool Passwd::ResetPassword(const std::wstring & login, long code, bool use_ses_l
{ {
long t = static_cast<long>(cur->request->start_time); long t = static_cast<long>(cur->request->start_time);
if( puser->aenv.to_long(L"password_change_time") + config->reset_password_code_expiration_time > t ) if( puser->admin_env.to_long(L"password_change_time") + config->reset_password_code_expiration_time > t )
{ {
result = ResetPassword(puser, code, use_ses_log, only_check_access); result = ResetPassword(puser, code, use_ses_log, only_check_access);
} }
@ -297,10 +297,10 @@ const std::wstring * plogin;
if( cur->session->puser ) if( cur->session->puser )
{ {
if( cur->session->puser->super_user ) if( cur->session->puser->is_super_user )
plogin = &cur->request->PostVar(L"login"); plogin = &cur->request->PostVar(L"login");
else else
plogin = &cur->session->puser->name; plogin = &cur->session->puser->login;
User * puser = system->users.GetUser(*plogin); User * puser = system->users.GetUser(*plogin);

View File

@ -156,7 +156,7 @@ void PrivChanger::PrivLogStart(const wchar_t * what, long user, long group, int
log << "new user: "; log << "new user: ";
if( puser ) if( puser )
log << puser->name; log << puser->login;
else else
log << "id: " << user; log << "id: " << user;

View File

@ -53,7 +53,7 @@ Reload::Reload()
bool Reload::HasAccess() bool Reload::HasAccess()
{ {
return cur->session->puser && cur->session->puser->super_user; return cur->session->puser && cur->session->puser->is_super_user;
} }
@ -74,7 +74,7 @@ void Reload::MakeGet()
{ {
// !! temporarily only an admin has access // !! temporarily only an admin has access
if( !cur->session->puser || !cur->session->puser->super_user ) if( !cur->session->puser || !cur->session->puser->is_super_user )
{ {
log << log1 << "Content: Only an admin has access to reload function" << logend; log << log1 << "Content: Only an admin has access to reload function" << logend;
cur->request->status = WINIX_ERR_PERMISSION_DENIED; cur->request->status = WINIX_ERR_PERMISSION_DENIED;

View File

@ -55,7 +55,7 @@ RmUser::RmUser()
bool RmUser::HasAccess() bool RmUser::HasAccess()
{ {
return cur->session->puser && cur->session->puser->super_user; return cur->session->puser && cur->session->puser->is_super_user;
} }
@ -66,7 +66,7 @@ bool RmUser::RemoveUser(long user_id)
if( puser ) if( puser )
{ {
name = puser->name; name = puser->login;
if( system->users.Remove(user_id) ) if( system->users.Remove(user_id) )
{ {
@ -88,7 +88,7 @@ void RmUser::MakePost()
{ {
long user_id; long user_id;
if( cur->session->puser->super_user ) if( cur->session->puser->is_super_user )
user_id = Tol(cur->request->PostVar(L"userid")); user_id = Tol(cur->request->PostVar(L"userid"));
else else
user_id = cur->session->puser->id; user_id = cur->session->puser->id;

View File

@ -53,7 +53,7 @@ Subject::Subject()
bool Subject::SubjectCheckAccess() bool Subject::SubjectCheckAccess()
{ {
// super user can always // super user can always
if( cur->session->puser && cur->session->puser->super_user ) if( cur->session->puser && cur->session->puser->is_super_user )
return true; return true;
bool access; bool access;

View File

@ -58,7 +58,7 @@ bool Template::HasAccess()
if( config->template_only_root_use_template_fun ) if( config->template_only_root_use_template_fun )
{ {
// only root is allowed to change the template // only root is allowed to change the template
return (cur->session->puser && cur->session->puser->super_user); return (cur->session->puser && cur->session->puser->is_super_user);
} }

View File

@ -74,7 +74,7 @@ bool Upload::HasAccess(const Item & item)
return false; return false;
} }
if( cur->session->puser && cur->session->puser->super_user ) if( cur->session->puser && cur->session->puser->is_super_user )
// super user can use upload everywhere // super user can use upload everywhere
return true; return true;

View File

@ -139,6 +139,8 @@ env_header = Environment variables for a user
env_change_env_for_user = Change environment variables for user env_change_env_for_user = Change environment variables for user
env_change_admin_env_for_user = Change admin environment variables for user env_change_admin_env_for_user = Change admin environment variables for user
env_change_user = Change user env_change_user = Change user
env_admin_changed_successfully = Admin environments variables have been changed successfully
env_changed_successfully = Environments variables have been changed successfully
default_header = Default item in a directory default_header = Default item in a directory
default_make_redirect = Make redirect default_make_redirect = Make redirect

View File

@ -145,6 +145,8 @@ env_header = Zmienne środowiskowe
env_change_env_for_user = Zmień zmienne środowiskowe dla użytkownika env_change_env_for_user = Zmień zmienne środowiskowe dla użytkownika
env_change_admin_env_for_user = Zmień zmienne środowiskowe administracyjne dla użytkownika env_change_admin_env_for_user = Zmień zmienne środowiskowe administracyjne dla użytkownika
env_change_user = Zmień użytkownika env_change_user = Zmień użytkownika
env_admin_changed_successfully = Zmienne środowiskowe administracyjne zostały zmienione
env_changed_successfully = Zmienne środowiskowe zostały zmienione
default_header = Domyślny element w katalogu default_header = Domyślny element w katalogu

View File

@ -206,6 +206,7 @@ using Winix::app;
if( !app.Init() ) if( !app.Init() )
{ {
Winix::RemovePidFile(); Winix::RemovePidFile();
log << Winix::logsave;
return 1; return 1;
} }

View File

@ -327,7 +327,7 @@ bool Item::can_remove_child(const User * current_user, long child_user_id) const
if( type == Type::dir ) if( type == Type::dir )
{ {
if( current_user && current_user->super_user ) if( current_user && current_user->is_super_user )
{ {
res = true; res = true;
} }

View File

@ -40,7 +40,6 @@
#include "core/request.h" #include "core/request.h"
#include "core/users.h" #include "core/users.h"
#include "core/groups.h" #include "core/groups.h"
#include "templates/miscspace.h"
namespace Winix namespace Winix
@ -104,20 +103,6 @@ void ItemContent::fields()
field(L"has_thumb", &ItemContent::has_thumb); field(L"has_thumb", &ItemContent::has_thumb);
field(L"display_user_name", &ItemContent::display_user_name); field(L"display_user_name", &ItemContent::display_user_name);
field(L"meta_to_str", &ItemContent::meta_to_str);
field(L"meta_prop", &ItemContent::meta_prop);
field(L"meta_prop_no_escape", &ItemContent::meta_prop_no_escape);
field(L"meta_prop_tab", &ItemContent::meta_prop_tab);
field(L"meta_prop_tab_value", &ItemContent::meta_prop_tab_value);
field(L"meta_prop_tab_has_next",&ItemContent::meta_prop_tab_has_next);
field(L"admin_meta_to_str", &ItemContent::admin_meta_to_str);
field(L"admin_meta_prop", &ItemContent::admin_meta_prop);
field(L"admin_meta_prop_no_escape", &ItemContent::admin_meta_prop_no_escape);
field(L"admin_meta_prop_tab", &ItemContent::admin_meta_prop_tab);
field(L"admin_meta_prop_tab_value", &ItemContent::admin_meta_prop_tab_value);
field(L"admin_meta_prop_tab_has_next", &ItemContent::admin_meta_prop_tab_has_next);
// IMPROVEME prepare a setter functions which tests whether content_raw_type_helper and content_parsed_type_helper are correct values // IMPROVEME prepare a setter functions which tests whether content_raw_type_helper and content_parsed_type_helper are correct values
content_raw_type = static_cast<ContentType>(content_raw_type_helper); content_raw_type = static_cast<ContentType>(content_raw_type_helper);
@ -268,16 +253,7 @@ bool ItemContent::do_migration_to_3()
}; };
size_t len = sizeof(str) / sizeof(const char*); size_t len = sizeof(str) / sizeof(const char*);
return db_query(str, len);
for(size_t i=0 ; i < len ; ++i)
{
if( !db_query(str[i]) )
{
return false;
}
}
return true;
} }
@ -285,7 +261,7 @@ bool ItemContent::has_access(const User * current_user, int mask) const
{ {
if( current_user ) if( current_user )
{ {
if( current_user->super_user ) if( current_user->is_super_user )
{ {
// super user is allowed everything // super user is allowed everything
return true; return true;
@ -332,7 +308,7 @@ bool ItemContent::has_read_write_access(const User * current_user) const
bool ItemContent::has_read_exec_access(const User * current_user) const bool ItemContent::has_read_exec_access(const User * current_user) const
{ {
if( current_user && current_user->super_user ) if( current_user && current_user->is_super_user )
{ {
// there must be at least one 'x' (for the root) // there must be at least one 'x' (for the root)
// !! CHECK ME: is it applicable to directories too? // !! CHECK ME: is it applicable to directories too?
@ -492,23 +468,30 @@ void ItemContent::group(morm::ModelWrapper ** model_wrapper)
} }
bool ItemContent::content_type_is(const std::wstring & type)
{
if( content_raw_type == ItemContent::ct_text && type == L"text" )
return true;
else
if( content_raw_type == ItemContent::ct_formatted_text && type == L"formatted text" )
return true;
else
if( content_raw_type == ItemContent::ct_html && type == L"html" )
return true;
else
if( content_raw_type == ItemContent::ct_bbcode && type == L"bbcode" )
return true;
else
if( content_raw_type == ItemContent::ct_other && type == L"other" )
return true;
return false;
}
void ItemContent::type_is(EzcEnv & env) void ItemContent::type_is(EzcEnv & env)
{ {
if( content_raw_type == ItemContent::ct_text && env.par == L"text" ) env.res = content_type_is(env.par);
env.res = true;
else
if( content_raw_type == ItemContent::ct_formatted_text && env.par == L"formatted text" )
env.res = true;
else
if( content_raw_type == ItemContent::ct_html && env.par == L"html" )
env.res = true;
else
if( content_raw_type == ItemContent::ct_bbcode && env.par == L"bbcode" )
env.res = true;
else
if( content_raw_type == ItemContent::ct_other && env.par == L"other" )
env.res = true;
} }
@ -603,79 +586,6 @@ void ItemContent::display_user_name(EzcEnv & env)
} }
/*
* IMPROVEME may it would be better to browse by Space struct in the same way as in Models?
* so Model should have support for it
*
*/
void ItemContent::meta_to_str(EzcEnv & env)
{
meta.serialize_to_space_stream(env.out, true);
}
void ItemContent::meta_prop(EzcEnv & env)
{
TemplatesFunctions::space_value(env, meta);
}
void ItemContent::meta_prop_no_escape(EzcEnv & env)
{
TemplatesFunctions::space_value(env, meta, false);
}
void ItemContent::meta_prop_tab(EzcEnv & env)
{
TemplatesFunctions::space_list_tab(env, meta);
}
void ItemContent::meta_prop_tab_value(EzcEnv & env)
{
// FIXME there is no "item_meta_tab" now
TemplatesFunctions::space_list_tab_value(env, meta, L"item_meta_tab");
}
void ItemContent::meta_prop_tab_has_next(EzcEnv & env)
{
// FIXME there is no "item_meta_tab" now
TemplatesFunctions::space_list_tab_has_next(env, meta, L"item_meta_tab");
}
void ItemContent::admin_meta_to_str(EzcEnv & env)
{
meta_admin.serialize_to_space_stream(env.out, true);
}
void ItemContent::admin_meta_prop(EzcEnv & env)
{
TemplatesFunctions::space_value(env, meta_admin);
}
void ItemContent::admin_meta_prop_no_escape(EzcEnv & env)
{
TemplatesFunctions::space_value(env, meta_admin, false);
}
void ItemContent::admin_meta_prop_tab(EzcEnv & env)
{
TemplatesFunctions::space_list_tab(env, meta_admin);
}
void ItemContent::admin_meta_prop_tab_value(EzcEnv & env)
{
// FIXME there is no "item_admin_meta_tab" now
TemplatesFunctions::space_list_tab_value(env, meta_admin, L"item_admin_meta_tab");
}
void ItemContent::admin_meta_prop_tab_has_next(EzcEnv & env)
{
// FIXME there is no "item_admin_meta_tab" now
TemplatesFunctions::space_list_tab_has_next(env, meta_admin, L"item_admin_meta_tab");
}
} // namespace Winix } // namespace Winix

View File

@ -280,6 +280,7 @@ protected:
bool do_migration_to_3(); bool do_migration_to_3();
bool has_access(const User * current_user, int mask) const; bool has_access(const User * current_user, int mask) const;
bool content_type_is(const std::wstring & type);
void print_content(EzcEnv & env); void print_content(EzcEnv & env);
void has_static_file(EzcEnv & env); void has_static_file(EzcEnv & env);
@ -294,18 +295,7 @@ protected:
void file_type_is_sound(EzcEnv & env); void file_type_is_sound(EzcEnv & env);
void has_thumb(EzcEnv & env); void has_thumb(EzcEnv & env);
void display_user_name(EzcEnv & env); void display_user_name(EzcEnv & env);
void meta_to_str(EzcEnv & env);
void meta_prop(EzcEnv & env);
void meta_prop_no_escape(EzcEnv & env);
void meta_prop_tab(EzcEnv & env);
void meta_prop_tab_value(EzcEnv & env);
void meta_prop_tab_has_next(EzcEnv & env);
void admin_meta_to_str(EzcEnv & env);
void admin_meta_prop(EzcEnv & env);
void admin_meta_prop_no_escape(EzcEnv & env);
void admin_meta_prop_tab(EzcEnv & env);
void admin_meta_prop_tab_value(EzcEnv & env);
void admin_meta_prop_tab_has_next(EzcEnv & env);
MORM_MEMBER_FIELD(ItemContent) MORM_MEMBER_FIELD(ItemContent)

View File

@ -53,22 +53,28 @@ User::User()
void User::fields() void User::fields()
{ {
field(L"id", id, morm::FT::no_insertable | morm::FT::no_updatable | morm::FT::primary_key); field(L"id", id, morm::FT::no_insertable | morm::FT::no_updatable | morm::FT::primary_key);
field(L"login", name); // IMPROVEME set the same name, either 'login' or 'name' field(L"login", login);
field(L"super_user", super_user); // IMPROVEME rename to is_super_user field(L"is_super_user", is_super_user);
field(L"has_pass", has_pass); field(L"has_pass", has_pass);
field(L"pass_type", pass_type); field(L"pass_type", pass_type);
field(L"password", L"", password); field(L"password", L"", password);
field(L"pass_encrypted", L"", pass_encrypted, morm::FT::binary); field(L"pass_encrypted", L"", pass_encrypted, morm::FT::binary);
field(L"pass_hash_salted", pass_hash_salted); // IMPROVEME rename to pass_is_hash_salted or is_pass_hash_salted field(L"is_pass_hash_salted", is_pass_hash_salted);
field(L"email", email); field(L"email", email);
field(L"notify", notify); field(L"notify", notify);
field(L"env", env); field(L"env", env);
field(L"aenv", aenv); // IMPROVEME rename to admin_env field(L"admin_env", admin_env);
field(L"status", status); field(L"status", status);
field(L"locale_id", locale_id); field(L"locale_id", locale_id);
field(L"time_zone_id", time_zone_id); field(L"time_zone_id", time_zone_id);
field(L"", L"id_is", &User::id_is);
field(L"", L"is_guest", &User::is_guest);
field(L"", L"is_env_object", &User::is_env_object);
field(L"", L"is_admin_env_object", &User::is_admin_env_object);
} }
@ -95,20 +101,20 @@ void User::after_insert()
void User::Clear() void User::Clear()
{ {
id = -1; id = -1;
name.clear(); login.clear();
super_user = false; is_super_user = false;
groups.clear(); groups.clear();
email.clear(); email.clear();
notify = 0; notify = 0;
env.clear(); env.clear();
aenv.clear(); admin_env.clear();
status = WINIX_ACCOUNT_BLOCKED; status = WINIX_ACCOUNT_BLOCKED;
locale_id = 0; locale_id = 0;
time_zone_id = 0; time_zone_id = 0;
has_pass = false; has_pass = false;
pass_type = 0; pass_type = 0;
pass_hash_salted = false; is_pass_hash_salted = false;
clear_passwords(); clear_passwords();
} }
@ -143,6 +149,7 @@ bool User::do_migration(int & current_table_version)
bool ok = true; bool ok = true;
ok = ok && morm::Model::do_migration(current_table_version, 1, this, &User::do_migration_to_1); ok = ok && morm::Model::do_migration(current_table_version, 1, this, &User::do_migration_to_1);
ok = ok && morm::Model::do_migration(current_table_version, 2, this, &User::do_migration_to_2);
return ok; return ok;
} }
@ -160,11 +167,11 @@ bool User::do_migration_to_1()
email character varying(255), email character varying(255),
notify integer, notify integer,
pass_type integer, pass_type integer,
pass_hash_salted boolean, is_pass_hash_salted boolean,
pass_encrypted bytea, pass_encrypted bytea,
super_user boolean, is_super_user boolean,
env text, env text,
aenv text, admin_env text,
status integer, status integer,
locale_id integer, locale_id integer,
time_zone_id integer, time_zone_id integer,
@ -177,18 +184,57 @@ bool User::do_migration_to_1()
} }
bool User::do_migration_to_2()
{
const char * str[] = {
"alter table core.user rename column aenv to admin_env",
"alter table core.user rename column super_user to is_super_user",
"alter table core.user rename column pass_hash_salted to is_pass_hash_salted",
};
size_t len = sizeof(str) / sizeof(const char*);
return db_query(str, len);
}
void User::display_name(EzcEnv & env) void User::display_name(EzcEnv & env)
{ {
std::wstring * dname = aenv.get_wstr(L"display_name"); std::wstring * dname = admin_env.get_wstr(L"display_name");
if( dname && !IsWhite(*dname, true) ) if( dname && !IsWhite(*dname, true) )
env.out << *dname; env.out << *dname;
else else
env.out << name; env.out << login;
} }
void User::id_is(EzcEnv & env)
{
if( !env.par.empty() )
{
long par_user_id = pt::Tol(env.par.c_str());
env.res = id == par_user_id;
}
}
bool User::is_guest()
{
return id == -1;
}
bool User::is_env_object()
{
return env.is_object();
}
bool User::is_admin_env_object()
{
return admin_env.is_object();
}
} // namespace Winix } // namespace Winix

View File

@ -41,6 +41,7 @@
#include "space/space.h" #include "space/space.h"
#include "date/date.h" #include "date/date.h"
#include "templates/misc.h" #include "templates/misc.h"
#include "winixmodel.h"
namespace Winix namespace Winix
@ -86,13 +87,13 @@ namespace Winix
(when the pointer is not null then winix do not check what the value of 'status' is -- (when the pointer is not null then winix do not check what the value of 'status' is --
the status is only tested in 'login' function) the status is only tested in 'login' function)
*/ */
class User : public morm::Model class User : public WinixModel
{ {
public: public:
long id; long id;
std::wstring name; std::wstring login;
bool super_user; bool is_super_user;
bool has_pass; // true if the user has a password set bool has_pass; // true if the user has a password set
@ -100,7 +101,7 @@ public:
int pass_type; // the kind of hash (WINIX_CRYPT_HASH_* see crypt.h) int pass_type; // the kind of hash (WINIX_CRYPT_HASH_* see crypt.h)
std::wstring password; // password hashed or plain text if pass_type==0 std::wstring password; // password hashed or plain text if pass_type==0
std::string pass_encrypted; // password encrypted std::string pass_encrypted; // password encrypted
bool pass_hash_salted; // true when the hash was salted (plain text passwords are never salted) bool is_pass_hash_salted; // true when the hash was salted (plain text passwords are never salted)
std::wstring email; std::wstring email;
@ -113,7 +114,7 @@ public:
// environment variables set only by an administrator // environment variables set only by an administrator
// an administrator can use 'env' winix function with 'a' parameter // an administrator can use 'env' winix function with 'a' parameter
// IMPROVEME rename me to something better (env_admin?) // IMPROVEME rename me to something better (env_admin?)
pt::Space aenv; pt::Space admin_env;
// account status // account status
// WINIX_ACCOUNT_* // WINIX_ACCOUNT_*
@ -149,11 +150,21 @@ public:
void display_name(EzcEnv & env); void display_name(EzcEnv & env);
bool is_env_object();
bool is_admin_env_object();
private: private:
bool do_migration_to_1(); bool do_migration_to_1();
bool do_migration_to_2();
void id_is(EzcEnv & env); // takes one argument as a user id
bool is_guest();
MORM_MEMBER_FIELD(User)
}; };

View File

@ -0,0 +1,88 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_winix_models_userhelper
#define headerfile_winix_models_userhelper
#include "user.h"
namespace Winix
{
class UserWrapper : public WinixModel
{
public:
User * user;
UserWrapper()
{
user = nullptr;
}
void fields()
{
field(L"", L"user", &UserWrapper::get_user);
field(L"", L"has_user", &UserWrapper::has_user);
}
protected:
void get_user(morm::ModelWrapper ** model_wrapper)
{
if( user )
{
*model_wrapper = new morm::ModelWrapperModel(user);
}
}
bool has_user()
{
return user != nullptr;
}
MORM_MEMBER_FIELD(UserWrapper)
};
} // namespace Winix
#endif

View File

@ -147,7 +147,7 @@ bool res = false;
{ {
if( (i->notify & TemplatesNotifyFunctions::notify_msg.code) != 0 ) if( (i->notify & TemplatesNotifyFunctions::notify_msg.code) != 0 )
{ {
msg.name = i->name; msg.name = i->login;
msg.email = i->email; msg.email = i->email;
msg.lang = config->locale_default_id; // !! IMPROVE ME bedzie osobno dla kazdego uzytkownika msg.lang = config->locale_default_id; // !! IMPROVE ME bedzie osobno dla kazdego uzytkownika

View File

@ -330,16 +330,21 @@ void ExportInfo::SendAllFilesFromDir(long dir_id)
void ExportInfo::AdditionalExport(const Item & item) void ExportInfo::AdditionalExport(const Item & item)
{ {
const pt::Space::TableType * child_table = item.item_content.meta.find_child_space_table(); const pt::Space * export_space = item.item_content.meta.get_space(L"export");// CHECK ME it was find_child_space_table();
if( child_table ) if( export_space )
{ {
for(const pt::Space * child : *child_table) AdditionalExport(item, *export_space);
{
if( child->is_child_space_name(L"export") )
AdditionalExport(item, *child);
}
} }
// if( export_space )
// {
// for(const pt::Space * child : *export_space)
// {
// if( child->is_child_space_name(L"export") )
// AdditionalExport(item, *child);
// }
// }
} }

View File

@ -37,7 +37,6 @@
#include "core/log.h" #include "core/log.h"
#include "core/misc.h" #include "core/misc.h"
#include "cache.h" #include "cache.h"
#include "templates/miscspace.h"
#include "registermail_info.h" #include "registermail_info.h"
#include "models/item.h" #include "models/item.h"

View File

@ -55,7 +55,7 @@ Seo::Seo()
bool Seo::HasAccess() bool Seo::HasAccess()
{ {
if( cur->session->puser && cur->session->puser->super_user ) if( cur->session->puser && cur->session->puser->is_super_user )
return true; return true;
return system->HasWriteAccess(*cur->request->last_item); return system->HasWriteAccess(*cur->request->last_item);
@ -77,7 +77,7 @@ void Seo::MakePost()
item.subject = subject; item.subject = subject;
pt::Space & seo = item.item_content.meta.find_add_child_space(L"seo"); pt::Space & seo = item.item_content.meta.get_add_space(L"seo");
seo.add(L"description", description); seo.add(L"description", description);
seo.add(L"keywords", keywords); seo.add(L"keywords", keywords);

View File

@ -80,7 +80,7 @@ bool Reply::HasAccess()
return false; return false;
pt::Space * thread_space = cur->request->item.item_content.meta_admin.find_child_space(L"thread"); pt::Space * thread_space = cur->request->item.item_content.meta_admin.get_space(L"thread");
if( thread_space ) if( thread_space )
{ {

View File

@ -185,7 +185,7 @@ pt::Space & EditTicket::PrepareSpace()
if( is_new ) if( is_new )
{ {
pt::Space * ticket_space = cur->request->item.item_content.meta.find_child_space(L"ticket"); pt::Space * ticket_space = cur->request->item.item_content.meta.get_space(L"ticket"); // CHECKME it was find_child_space(L"ticket");
if( ticket_space ) if( ticket_space )
{ {
@ -203,10 +203,10 @@ bool EditTicket::CloseTicket()
{ {
cur->request->item.propagate_connector(); cur->request->item.propagate_connector();
pt::Space & ticket_space = cur->request->item.item_content.meta_admin.find_add_child_space(L"ticket"); pt::Space & ticket_space = cur->request->item.item_content.meta_admin.get_add_space(L"ticket"); //CHECKME it was find_add_child_space(L"ticket");
ticket_space.add(L"closed", true); ticket_space.add(L"closed", true);
pt::Space & thread_space = cur->request->item.item_content.meta_admin.find_add_child_space(L"thread"); pt::Space & thread_space = cur->request->item.item_content.meta_admin.get_add_space(L"thread"); //CHECKME it was find_add_child_space(L"thread");
thread_space.add(L"closed", true); thread_space.add(L"closed", true);
//if( db->EditAdminMetaById(cur->request->item.ameta, cur->request->item.id) == WINIX_ERR_OK ) //if( db->EditAdminMetaById(cur->request->item.ameta, cur->request->item.id) == WINIX_ERR_OK )

View File

@ -144,13 +144,13 @@ void SessionData::BuildFileList(std::vector<long> & file_tab, pt::Space & space)
{ {
file_tab.clear(); file_tab.clear();
pt::Space::TableType * child_table = space.find_child_space_table(); pt::Space::TableType * child_table = space.get_table(L"params"); // CHECKME it was space.find_child_space_table();
if( child_table ) if( child_table )
{ {
for(pt::Space * sp : *child_table) for(pt::Space * sp : *child_table)
{ {
if( sp->is_child_space_name(L"param") ) if( sp->is_equal(L"name", L"param") )
CheckFile(file_tab, *sp); CheckFile(file_tab, *sp);
} }
} }
@ -159,13 +159,13 @@ void SessionData::BuildFileList(std::vector<long> & file_tab, pt::Space & space)
void SessionData::CheckFile(std::vector<long> & file_tab, pt::Space & space) void SessionData::CheckFile(std::vector<long> & file_tab, pt::Space & space)
{ {
pt::Space::TableType * child_table = space.find_child_space_table(); pt::Space::TableType * child_table = space.get_table(L"files"); // CHECKME it was space.find_child_space_table();
if( child_table ) if( child_table )
{ {
for(pt::Space * sp : *child_table) for(pt::Space * sp : *child_table)
{ {
if( sp->is_child_space_name(L"file") ) if( sp->is_equal(L"name", L"file") )
{ {
file_tab.push_back(sp->to_long(L"itemid")); file_tab.push_back(sp->to_long(L"itemid"));
} }

View File

@ -302,13 +302,13 @@ void TicketInfo::CheckMinMaxValue(pt::Space & space, Ticket::TicketParam & par)
else else
if( *type == L"select" ) if( *type == L"select" )
{ {
pt::Space::TableType * child_table = space.find_child_space_table(); pt::Space::TableType * child_table = space.get_table(L"ticket_params"); // CHECKME it was space.find_child_space_table();
if( child_table ) if( child_table )
{ {
for(pt::Space * sp : *child_table) for(pt::Space * sp : *child_table)
{ {
if( sp->is_child_space_name(L"option") ) if( sp->is_equal(L"name", L"option") )
{ {
if( sp->to_long(L"id") == par.intv ) if( sp->to_long(L"id") == par.intv )
{ {
@ -329,13 +329,13 @@ void TicketInfo::CheckMinMaxValue(pt::Space & space, Ticket::TicketParam & par)
pt::Space & TicketInfo::FindAddMetaByParam(pt::Space & meta, long param) pt::Space & TicketInfo::FindAddMetaByParam(pt::Space & meta, long param)
{ {
pt::Space::TableType * child_table = meta.find_child_space_table(); pt::Space * child_table = meta.get_space(L"params"); // CHECKME it was meta.find_child_space_table();
if( child_table ) if( child_table && child_table->is_table() )
{ {
for(pt::Space * sp : *child_table) for(pt::Space * sp : *child_table->get_table() )
{ {
if( sp->is_child_space_name(L"param") ) if( sp->is_equal(L"name", L"param") )
{ {
if( sp->to_long(L"id") == param ) if( sp->to_long(L"id") == param )
{ {
@ -344,8 +344,14 @@ pt::Space & TicketInfo::FindAddMetaByParam(pt::Space & meta, long param)
} }
} }
} }
else
if( !child_table )
{
child_table = &meta.add_empty_space(L"params");
}
pt::Space & sp = meta.add_child_space(L"param"); pt::Space & sp = child_table->add_empty_space();
sp.add(L"name", L"param");
sp.add(L"id", param); sp.add(L"id", param);
return sp; return sp;
@ -419,7 +425,7 @@ void TicketInfo::ReadTicketValue(pt::Space & space,
if( cur->request->status == WINIX_ERR_OK ) if( cur->request->status == WINIX_ERR_OK )
{ {
pt::Space & space = FindAddMetaByParam(meta, param_id); pt::Space & space = FindAddMetaByParam(meta, param_id);
pt::Space & file_space = space.add_child_space(L"file"); pt::Space & file_space = space.get_add_space(L"file"); // CHECKME it was space.add_child_space(L"file");
if( file.item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE ) if( file.item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
file_space.add(L"type", L"image"); file_space.add(L"type", L"image");
@ -493,14 +499,13 @@ void TicketInfo::ReadTicketParam(pt::Space & space, Ticket & ticket, long param_
void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const std::wstring & value, pt::Space & meta) void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const std::wstring & value, pt::Space & meta)
{ {
ticket_param.Clear(); ticket_param.Clear();
pt::Space::TableType * child_table = cur_conf->get_table(L"params"); // CHECKME it was cur_conf->find_child_space_table();
pt::Space::TableType * child_table = cur_conf->find_child_space_table();
if( child_table ) if( child_table )
{ {
for(pt::Space * space : *child_table) for(pt::Space * space : *child_table)
{ {
if( space->is_child_space_name(L"param") && space->to_long(L"id") == param_id ) if( space->is_equal(L"name", L"param") && space->to_long(L"id") == param_id )
{ {
ReadTicketParam(*space, ticket, param_id, value, meta); ReadTicketParam(*space, ticket, param_id, value, meta);
return; return;
@ -515,13 +520,13 @@ void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const std::wstr
// always adds a new parameter // always adds a new parameter
void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, pt::Space & meta) void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, pt::Space & meta)
{ {
pt::Space::TableType * child_table = cur_conf->find_child_space_table(); pt::Space::TableType * child_table = cur_conf->get_table(L"params"); // CHECKME it was cur_conf->find_child_space_table();
if( child_table ) if( child_table )
{ {
for(pt::Space * sp : *child_table) for(pt::Space * sp : *child_table)
{ {
if( sp->is_child_space_name(L"param") ) if( sp->is_equal(L"name", L"param") )
{ {
if( sp->to_long(L"id") == param_id ) if( sp->to_long(L"id") == param_id )
{ {
@ -541,6 +546,8 @@ void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, pt::Spac
bool TicketInfo::DeleteTicketFile(Ticket & ticket, long file_id, pt::Space & meta) bool TicketInfo::DeleteTicketFile(Ticket & ticket, long file_id, pt::Space & meta)
{ {
// FIXME !!!!!!!!!!!!!!1
/*
pt::Space::TableType * meta_child_table = meta.find_child_space_table(); pt::Space::TableType * meta_child_table = meta.find_child_space_table();
if( meta_child_table ) if( meta_child_table )
@ -572,7 +579,9 @@ bool TicketInfo::DeleteTicketFile(Ticket & ticket, long file_id, pt::Space & met
} }
} }
*/
return false; return false;
} }
@ -642,7 +651,7 @@ void TicketInfo::RemoveTicket(long file_id)
void TicketInfo::CopyTicketSpace(pt::Space & ticket_space, Item & item) void TicketInfo::CopyTicketSpace(pt::Space & ticket_space, Item & item)
{ {
pt::Space & ticket_meta = item.item_content.meta.find_add_child_space(L"ticket"); pt::Space & ticket_meta = item.item_content.meta.get_add_space(L"ticket");
ticket_meta = ticket_space; ticket_meta = ticket_space;
} }

View File

@ -35,7 +35,6 @@
#include "templates.h" #include "templates.h"
#include "core/misc.h" #include "core/misc.h"
#include "functions/functions.h" #include "functions/functions.h"
#include "miscspace.h"
namespace Winix namespace Winix
{ {

View File

@ -35,7 +35,6 @@
#include "templates.h" #include "templates.h"
#include "core/misc.h" #include "core/misc.h"
#include "functions/functions.h" #include "functions/functions.h"
#include "miscspace.h"
namespace Winix namespace Winix
{ {
@ -121,7 +120,7 @@ bool result = true;
{ {
// rm for the root dir // rm for the root dir
// only the superuser can do it // only the superuser can do it
if( !cur->session->puser || !cur->session->puser->super_user ) if( !cur->session->puser || !cur->session->puser->is_super_user )
result = false; result = false;
} }
else else
@ -270,7 +269,7 @@ void dir_childs_tab_user(Info & i)
User * puser = system->users.GetUser(user_id); User * puser = system->users.GetUser(user_id);
if( puser ) if( puser )
i.out << puser->name; i.out << puser->login;
else else
{ {
i.out << "~"; i.out << "~";
@ -293,7 +292,7 @@ void dir_childs_tab_group(Info & i)
Group * pgroup = system->groups.GetGroup(group_id); Group * pgroup = system->groups.GetGroup(group_id);
if( pgroup ) if( pgroup )
i.out << pgroup->name; i.out << pgroup->login;
else else
i.out << group_id; i.out << group_id;
} }
@ -370,7 +369,7 @@ void dir_last_user(Info & i)
User * puser = system->users.GetUser(cur->request->dir_tab.back()->item_content.user_id); User * puser = system->users.GetUser(cur->request->dir_tab.back()->item_content.user_id);
if( puser ) if( puser )
i.out << puser->name; i.out << puser->login;
else else
{ {
i.out << "~"; i.out << "~";
@ -468,61 +467,61 @@ void dir_last_meta_str(Info & i)
} }
void dir_last_meta(Info & i) //void dir_last_meta(Info & i)
{ //{
space_value(i, cur->request->dir_tab.back()->item_content.meta); // space_value(i, cur->request->dir_tab.back()->item_content.meta);
} //}
//
//
void dir_last_meta_tab(Info & i) //void dir_last_meta_tab(Info & i)
{ //{
space_list_tab(i, cur->request->dir_tab.back()->item_content.meta); // space_list_tab(i, cur->request->dir_tab.back()->item_content.meta);
} //}
//
//
void dir_last_meta_tab_value(Info & i) //void dir_last_meta_tab_value(Info & i)
{ //{
space_list_tab_value(i, cur->request->dir_tab.back()->item_content.meta, L"dir_last_meta_tab"); // space_list_tab_value(i, cur->request->dir_tab.back()->item_content.meta, L"dir_last_meta_tab");
} //}
//
//
//
void dir_last_meta_tab_has_next(Info & i) //void dir_last_meta_tab_has_next(Info & i)
{ //{
space_list_tab_has_next(i, cur->request->dir_tab.back()->item_content.meta, L"dir_last_meta_tab"); // space_list_tab_has_next(i, cur->request->dir_tab.back()->item_content.meta, L"dir_last_meta_tab");
} //}
void dir_last_admin_meta_str(Info & i) //void dir_last_admin_meta_str(Info & i)
{ //{
cur->request->dir_tab.back()->item_content.meta_admin.serialize_to_space_stream(i.out, true); // cur->request->dir_tab.back()->item_content.meta_admin.serialize_to_space_stream(i.out, true);
} //}
//
//
void dir_last_admin_meta(Info & i) //void dir_last_admin_meta(Info & i)
{ //{
space_value(i, cur->request->dir_tab.back()->item_content.meta_admin); // space_value(i, cur->request->dir_tab.back()->item_content.meta_admin);
} //}
//
//
void dir_last_admin_meta_tab(Info & i) //void dir_last_admin_meta_tab(Info & i)
{ //{
space_list_tab(i, cur->request->dir_tab.back()->item_content.meta_admin); // space_list_tab(i, cur->request->dir_tab.back()->item_content.meta_admin);
} //}
//
//
void dir_last_admin_meta_tab_value(Info & i) //void dir_last_admin_meta_tab_value(Info & i)
{ //{
space_list_tab_value(i, cur->request->dir_tab.back()->item_content.meta_admin, L"dir_last_admin_meta_tab"); // space_list_tab_value(i, cur->request->dir_tab.back()->item_content.meta_admin, L"dir_last_admin_meta_tab");
} //}
//
//
void dir_last_admin_meta_tab_has_next(Info & i) //void dir_last_admin_meta_tab_has_next(Info & i)
{ //{
space_list_tab_has_next(i, cur->request->dir_tab.back()->item_content.meta_admin, L"dir_last_admin_meta_tab"); // space_list_tab_has_next(i, cur->request->dir_tab.back()->item_content.meta_admin, L"dir_last_admin_meta_tab");
} //}

View File

@ -1,297 +0,0 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2012-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "templates.h"
#include "core/misc.h"
#include "functions/functions.h"
#include "miscspace.h"
namespace Winix
{
namespace TemplatesFunctions
{
void env_str(Info & i)
{
User * puser = cur->session->puser;
if( puser )
puser->env.serialize_to_space_stream(i.out, true);
}
void env(Info & i)
{
User * puser = cur->session->puser;
if( puser )
space_value(i, puser->env);
}
void env_tab(Info & i)
{
User * puser = cur->session->puser;
if( puser )
space_list_tab(i, puser->env);
}
void env_tab_value(Info & i)
{
User * puser = cur->session->puser;
if( puser )
space_list_tab_value(i, puser->env, L"env_tab");
}
void env_tab_has_next(Info & i)
{
User * puser = cur->session->puser;
if( puser )
space_list_tab_has_next(i, puser->env, L"env_tab");
}
void env_admin_str(Info & i)
{
User * puser = cur->session->puser;
if( puser )
puser->aenv.serialize_to_space_stream(i.out, true);
}
void env_admin(Info & i)
{
User * puser = cur->session->puser;
if( puser )
space_value(i, puser->aenv);
}
void env_admin_tab(Info & i)
{
User * puser = cur->session->puser;
if( puser )
space_list_tab(i, puser->aenv);
}
void env_admin_tab_value(Info & i)
{
User * puser = cur->session->puser;
if( puser )
space_list_tab_value(i, puser->aenv, L"env_admin_tab");
}
void env_admin_tab_has_next(Info & i)
{
User * puser = cur->session->puser;
if( puser )
space_list_tab_has_next(i, puser->aenv, L"env_admin_tab");
}
static size_t req_id = 0;
static User * puser = nullptr;
/*
* IMPROVEME
* in the future the user pointer will be set by the env controller
* a new struct will be added and put to templates (when new ezc object templates will be ready)
*
*/
User * env_get_user()
{
if( cur->request->id != req_id )
{
req_id = cur->request->id;
puser = 0;
if( cur->session->puser )
{
if( cur->session->puser->super_user && cur->request->IsPostVar(L"userid") )
{
long id = Tol(cur->request->PostVar(L"userid"));
puser = system->users.GetUser(id);
}
else
{
puser = cur->session->puser;
}
}
}
return puser;
}
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 = env_get_user();
if( puser )
i.out << puser->aenv;
}
}
void env_user_env_str(Info & i)
{
User * puser = env_get_user();
if( puser )
i.out << puser->env;
}
void env_user_id(Info & i)
{
User * puser = env_get_user();
if( puser )
i.out << puser->id;
}
void env_user_name(Info & i)
{
User * puser = env_get_user();
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 = env_get_user();
if( puser )
i.res = (user_iter->id == puser->id );
}
}
} // namespace TemplatesFunctions
} // namespace Winix

View File

@ -38,7 +38,6 @@
#include "core/misc.h" #include "core/misc.h"
#include "core/bbcodeparser.h" #include "core/bbcodeparser.h"
#include "core/textstream.h" #include "core/textstream.h"
#include "miscspace.h"
namespace Winix namespace Winix
{ {

View File

@ -508,7 +508,7 @@ bool Locale::IsKeyByIndex(const std::wstring & key, size_t index, bool try_defau
{ {
if( index < locale_tab.size() ) if( index < locale_tab.size() )
{ {
if( locale_tab[index].get_object_field(key) != 0 ) if( locale_tab[index].get_space(key) != 0 )
return true; return true;
} }

View File

@ -1,239 +0,0 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2012-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "templates.h"
namespace Winix
{
namespace TemplatesFunctions
{
bool are_spaces_the_same(const std::vector<Ezc::Var> & params, const std::vector<std::wstring> & spaces)
{
// last value from params is the parameter name (not a space)
if( spaces.size() + 1 != params.size() )
return false;
for(size_t i=0 ; i<spaces.size() ; ++i)
if( spaces[i] != params[i].str )
return false;
return true;
}
void copy_space(const std::vector<Ezc::Var> & params, std::vector<std::wstring> & spaces)
{
if( !params.empty() )
{
spaces.resize(params.size() - 1);
for(size_t i=0 ; i<params.size() - 1 ; ++i)
spaces[i] = params[i].str;
}
else
{
spaces.clear();
}
}
pt::Space * find_space(const std::vector<Ezc::Var> & params, pt::Space & space, size_t level = 0)
{
pt::Space::TableType * child_table = space.find_child_space_table();
if( level + 1 < params.size() && child_table )
{
for(pt::Space * child : *child_table)
{
if( child->is_child_space_name(params[level].str.c_str()) )
return find_space(params, *child, level+1);
}
// there is no such a space
return nullptr;
}
else
{
return &space;
}
}
/*
*
* IMPROVE ME
* add a private namespace?
*
*/
struct SpaceInfo
{
bool inited;
pt::Space * last_space;
std::vector<std::wstring> spaces;
SpaceInfo()
{
inited = false;
last_space = 0;
}
};
static std::map<pt::Space*, SpaceInfo> spaces_map;
static size_t space_reqid = 0;
void space_init(const std::vector<Ezc::Var> & params, pt::Space & space, SpaceInfo & space_info)
{
if( !space_info.inited || !are_spaces_the_same(params, space_info.spaces) )
{
space_info.inited = true;
copy_space(params, space_info.spaces);
space_info.last_space = find_space(params, space);
}
}
void space_check_reqid()
{
if( space_reqid != cur->request->id )
{
space_reqid = cur->request->id;
spaces_map.clear();
}
}
void space_value(Info & i, pt::Space & space, bool escape)
{
space_check_reqid();
if( !i.params.empty() )
{
SpaceInfo & space_info = spaces_map[&space];
space_init(i.params, space, space_info);
if( space_info.last_space )
{
const std::wstring & param = i.params.back().str;
const std::wstring * value = space_info.last_space->get_wstr(param.c_str());
if( value )
{
if( escape )
i.out << *value;
else
i.out << R(*value);
}
}
}
}
struct SpaceTabStackItem : public Ezc::FunData
{
std::vector<std::wstring> values;
};
void space_list_tab(Info & i, pt::Space & space)
{
if( !i.stack.fun_data )
{
if( !i.params.empty() )
{
SpaceTabStackItem * stack_item = new SpaceTabStackItem();
i.stack.fun_data = stack_item;
pt::Space * dst_space = find_space(i.params, space);
if( dst_space )
dst_space->to_list(i.params.back().str, stack_item->values);
i.res = i.iter < stack_item->values.size();
}
}
else
{
auto stack_item = reinterpret_cast<SpaceTabStackItem*>(i.stack.fun_data);
i.res = i.iter < stack_item->values.size();
}
}
void space_list_tab_value(Info & i, pt::Space & space, const std::wstring & function_name)
{
Ezc::Stack * stack;
auto user_object = i.FindUserObject<SpaceTabStackItem>(function_name, &stack);
if( user_object && stack->iter < user_object->values.size() )
i.out << user_object->values[stack->iter];
}
void space_list_tab_has_next(Info & i, pt::Space & space, const std::wstring & function_name)
{
Ezc::Stack * stack;
auto user_object = i.FindUserObject<SpaceTabStackItem>(function_name, &stack);
if( user_object && stack->iter + 1 < user_object->values.size() )
i.res = true;
}
} // namespace TemplatesFunctions
} // namespace Winix

View File

@ -1,94 +0,0 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2012-2016, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "templates.h"
namespace Winix
{
namespace TemplatesFunctions
{
/*
* return a value from a space
* you can define you own ezc function e.g. my_space_value(Info &i) in such a way:
*
* void my_space_value(Info & i)
* {
* space_value(i, the_space_object_i_am_interested_in);
* }
*
* and now you can call it from ezc template:
* [my_space_value "foo"] -> looking for parameter "foo" in the global space of the_space_object_i_am_interest_in
* [my_space_value "foo" "bar"] -> first looking for a space with "foo" name then looking for "bar" parameter
*
*
* there is some built-in optimization made:
* if you are looking for parameters from the same space e.g.
* [my_space_value "foo" "foo2" "param1"]
* [my_space_value "foo" "foo2" "param2"]
* [my_space_value "foo" "foo2" "param3"]
* after looking for param1 the address of foo2 space is cached in a local map (first we're looking for foo and then for foo2)
* and when looking for param2 and param3 the address of foo2 is taken from the map
*
*
*/
void space_value(Info & i, pt::Space & space, bool escape = true);
// !! IMPROVE ME
// add
// void space_list_tab_size(Info & i, pt::Space & space);
void space_list_tab(Info & i, pt::Space & space);
void space_list_tab_value(Info & i, pt::Space & space, const std::wstring & function_name);
void space_list_tab_has_next(Info & i, pt::Space & space, const std::wstring & function_name);
// !! IMPROVE ME
// !! add space_tab (iteration through spaces)
} // namespace TemplatesFunctions
} // namespace Winix

View File

@ -63,7 +63,7 @@ void priv_user_tab_init(Item & item)
priv_user_table.push_back(item.item_content.user_id); priv_user_table.push_back(item.item_content.user_id);
} }
else else
if( cur->session->puser->super_user ) if( cur->session->puser->is_super_user )
{ {
// super user is allowed to change to any user // super user is allowed to change to any user
for(Users::Iterator i=system->users.Begin() ; i != system->users.End() ; ++i) for(Users::Iterator i=system->users.Begin() ; i != system->users.End() ; ++i)
@ -112,7 +112,7 @@ void priv_user_tab_name(Info & i)
User * puser = system->users.GetUser( uid ); User * puser = system->users.GetUser( uid );
if( puser ) if( puser )
i.out << puser->name; i.out << puser->login;
else else
i.out << "user_id: " << uid; i.out << "user_id: " << uid;
} }
@ -168,7 +168,7 @@ void priv_group_tab_init(Item & item)
priv_group_table.push_back(item.item_content.group_id); priv_group_table.push_back(item.item_content.group_id);
} }
else else
if( cur->session->puser->super_user ) if( cur->session->puser->is_super_user )
{ {
// super user is allowed to change to any group // super user is allowed to change to any group
for(Groups::Iterator i=system->groups.Begin() ; i != system->groups.End() ; ++i) for(Groups::Iterator i=system->groups.Begin() ; i != system->groups.End() ; ++i)

View File

@ -308,15 +308,15 @@ void Templates::CreateFunctions()
ezc_functions.Insert("dir_last_html_template", dir_last_html_template); ezc_functions.Insert("dir_last_html_template", dir_last_html_template);
ezc_functions.Insert("dir_last_has_html_template", dir_last_has_html_template); ezc_functions.Insert("dir_last_has_html_template", dir_last_has_html_template);
ezc_functions.Insert("dir_last_meta_str", dir_last_meta_str); ezc_functions.Insert("dir_last_meta_str", dir_last_meta_str);
ezc_functions.Insert("dir_last_meta", dir_last_meta); // ezc_functions.Insert("dir_last_meta", dir_last_meta);
ezc_functions.Insert("dir_last_meta_tab", dir_last_meta_tab); // ezc_functions.Insert("dir_last_meta_tab", dir_last_meta_tab);
ezc_functions.Insert("dir_last_meta_tab_value", dir_last_meta_tab_value); // ezc_functions.Insert("dir_last_meta_tab_value", dir_last_meta_tab_value);
ezc_functions.Insert("dir_last_meta_tab_has_next", dir_last_meta_tab_has_next); // ezc_functions.Insert("dir_last_meta_tab_has_next", dir_last_meta_tab_has_next);
ezc_functions.Insert("dir_last_admin_meta_str", dir_last_admin_meta_str); // ezc_functions.Insert("dir_last_admin_meta_str", dir_last_admin_meta_str);
ezc_functions.Insert("dir_last_admin_meta", dir_last_admin_meta); // ezc_functions.Insert("dir_last_admin_meta", dir_last_admin_meta);
ezc_functions.Insert("dir_last_admin_meta_tab", dir_last_admin_meta_tab); // ezc_functions.Insert("dir_last_admin_meta_tab", dir_last_admin_meta_tab);
ezc_functions.Insert("dir_last_admin_meta_tab_value", dir_last_admin_meta_tab_value); // ezc_functions.Insert("dir_last_admin_meta_tab_value", dir_last_admin_meta_tab_value);
ezc_functions.Insert("dir_last_admin_meta_tab_has_next", dir_last_admin_meta_tab_has_next); // ezc_functions.Insert("dir_last_admin_meta_tab_has_next", dir_last_admin_meta_tab_has_next);
/* /*
@ -342,24 +342,24 @@ void Templates::CreateFunctions()
/* /*
env env
*/ */
ezc_functions.Insert("env_str", env_str); // ezc_functions.Insert("env_str", env_str);
ezc_functions.Insert("env", env); // ezc_functions.Insert("env", env);
ezc_functions.Insert("env_tab", env_tab); // ezc_functions.Insert("env_tab", env_tab);
ezc_functions.Insert("env_tab_value", env_tab_value); // ezc_functions.Insert("env_tab_value", env_tab_value);
ezc_functions.Insert("env_tab_has_next", env_tab_has_next); // ezc_functions.Insert("env_tab_has_next", env_tab_has_next);
ezc_functions.Insert("env_admin_str", env_admin_str); // ezc_functions.Insert("env_admin_str", env_admin_str);
ezc_functions.Insert("env_admin", env_admin); // ezc_functions.Insert("env_admin", env_admin);
ezc_functions.Insert("env_admin_tab", env_admin_tab); // ezc_functions.Insert("env_admin_tab", env_admin_tab);
ezc_functions.Insert("env_admin_tab_value", env_admin_tab_value); // ezc_functions.Insert("env_admin_tab_value", env_admin_tab_value);
ezc_functions.Insert("env_admin_tab_has_next", env_admin_tab_has_next); // ezc_functions.Insert("env_admin_tab_has_next", env_admin_tab_has_next);
ezc_functions.Insert("env_user_admin_env_str", env_user_admin_env_str); // ezc_functions.Insert("env_user_admin_env_str", env_user_admin_env_str);
ezc_functions.Insert("env_user_env_str", env_user_env_str); // ezc_functions.Insert("env_user_env_str", env_user_env_str);
ezc_functions.Insert("env_user_id", env_user_id); // ezc_functions.Insert("env_user_id", env_user_id);
ezc_functions.Insert("env_user_name", env_user_name); // ezc_functions.Insert("env_user_name", env_user_name);
ezc_functions.Insert("env_user_tab", env_user_tab); // ezc_functions.Insert("env_user_tab", env_user_tab);
ezc_functions.Insert("env_user_tab_id", env_user_tab_id); // ezc_functions.Insert("env_user_tab_id", env_user_tab_id);
ezc_functions.Insert("env_user_tab_name", env_user_tab_name); // ezc_functions.Insert("env_user_tab_name", env_user_tab_name);
ezc_functions.Insert("env_user_tab_is_current", env_user_tab_is_current); // ezc_functions.Insert("env_user_tab_is_current", env_user_tab_is_current);
/* /*

View File

@ -198,15 +198,15 @@ namespace TemplatesFunctions
void dir_last_html_template(Info & i); void dir_last_html_template(Info & i);
void dir_last_has_html_template(Info & i); void dir_last_has_html_template(Info & i);
void dir_last_meta_str(Info & i); void dir_last_meta_str(Info & i);
void dir_last_meta(Info & i); // void dir_last_meta(Info & i);
void dir_last_meta_tab(Info & i); // void dir_last_meta_tab(Info & i);
void dir_last_meta_tab_value(Info & i); // void dir_last_meta_tab_value(Info & i);
void dir_last_meta_tab_has_next(Info & i); // void dir_last_meta_tab_has_next(Info & i);
void dir_last_admin_meta_str(Info & i); // void dir_last_admin_meta_str(Info & i);
void dir_last_admin_meta(Info & i); // void dir_last_admin_meta(Info & i);
void dir_last_admin_meta_tab(Info & i); // void dir_last_admin_meta_tab(Info & i);
void dir_last_admin_meta_tab_value(Info & i); // void dir_last_admin_meta_tab_value(Info & i);
void dir_last_admin_meta_tab_has_next(Info & i); // void dir_last_admin_meta_tab_has_next(Info & i);
/* /*
@ -232,24 +232,24 @@ namespace TemplatesFunctions
/* /*
env env
*/ */
void env_str(Info & i); // void env_str(Info & i);
void env(Info & i); // void env(Info & i);
void env_tab(Info & i); // void env_tab(Info & i);
void env_tab_value(Info & i); // void env_tab_value(Info & i);
void env_tab_has_next(Info & i); // void env_tab_has_next(Info & i);
void env_admin_str(Info & i); // void env_admin_str(Info & i);
void env_admin(Info & i); // void env_admin(Info & i);
void env_admin_tab(Info & i); // void env_admin_tab(Info & i);
void env_admin_tab_value(Info & i); // void env_admin_tab_value(Info & i);
void env_admin_tab_has_next(Info & i); // void env_admin_tab_has_next(Info & i);
void env_user_admin_env_str(Info & i); // void env_user_admin_env_str(Info & i);
void env_user_env_str(Info & i); // void env_user_env_str(Info & i);
void env_user_id(Info & i); // void env_user_id(Info & i);
void env_user_name(Info & i); // void env_user_name(Info & i);
void env_user_tab(Info & i); // void env_user_tab(Info & i);
void env_user_tab_id(Info & i); // void env_user_tab_id(Info & i);
void env_user_tab_name(Info & i); // void env_user_tab_name(Info & i);
void env_user_tab_is_current(Info & i); // void env_user_tab_is_current(Info & i);
/* /*

View File

@ -61,7 +61,7 @@ void user_id(Info & i)
void user_name(Info & i) void user_name(Info & i)
{ {
if( cur->session->puser ) if( cur->session->puser )
i.out << cur->session->puser->name; i.out << cur->session->puser->login;
} }
@ -105,7 +105,7 @@ void user_is_in_all_groups(Info & i)
void user_super_user(Info & i) void user_super_user(Info & i)
{ {
if( cur->session->puser && cur->session->puser->super_user ) if( cur->session->puser && cur->session->puser->is_super_user )
i.res = true; i.res = true;
} }
@ -260,14 +260,14 @@ void user_tab_id(Info & i)
void user_tab_name(Info & i) void user_tab_name(Info & i)
{ {
if( user_tab_init() ) if( user_tab_init() )
i.out << user_iter->name; i.out << user_iter->login;
} }
void user_tab_is_super_user(Info & i) void user_tab_is_super_user(Info & i)
{ {
if( user_tab_init() ) if( user_tab_init() )
i.res = user_iter->super_user; i.res = user_iter->is_super_user;
} }

View File

@ -93,7 +93,7 @@ void who_tab_user(Info & i)
if( who_iterator->puser ) if( who_iterator->puser )
i.out << who_iterator->puser->name; i.out << who_iterator->puser->login;
} }