- 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:
@@ -35,7 +35,6 @@
|
||||
#include "templates.h"
|
||||
#include "core/misc.h"
|
||||
#include "functions/functions.h"
|
||||
#include "miscspace.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "templates.h"
|
||||
#include "core/misc.h"
|
||||
#include "functions/functions.h"
|
||||
#include "miscspace.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
@@ -121,7 +120,7 @@ bool result = true;
|
||||
{
|
||||
// rm for the root dir
|
||||
// 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;
|
||||
}
|
||||
else
|
||||
@@ -270,7 +269,7 @@ void dir_childs_tab_user(Info & i)
|
||||
User * puser = system->users.GetUser(user_id);
|
||||
|
||||
if( puser )
|
||||
i.out << puser->name;
|
||||
i.out << puser->login;
|
||||
else
|
||||
{
|
||||
i.out << "~";
|
||||
@@ -293,7 +292,7 @@ void dir_childs_tab_group(Info & i)
|
||||
Group * pgroup = system->groups.GetGroup(group_id);
|
||||
|
||||
if( pgroup )
|
||||
i.out << pgroup->name;
|
||||
i.out << pgroup->login;
|
||||
else
|
||||
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);
|
||||
|
||||
if( puser )
|
||||
i.out << puser->name;
|
||||
i.out << puser->login;
|
||||
else
|
||||
{
|
||||
i.out << "~";
|
||||
@@ -468,61 +467,61 @@ void dir_last_meta_str(Info & i)
|
||||
}
|
||||
|
||||
|
||||
void dir_last_meta(Info & i)
|
||||
{
|
||||
space_value(i, cur->request->dir_tab.back()->item_content.meta);
|
||||
}
|
||||
|
||||
|
||||
void dir_last_meta_tab(Info & i)
|
||||
{
|
||||
space_list_tab(i, cur->request->dir_tab.back()->item_content.meta);
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
//void dir_last_meta(Info & i)
|
||||
//{
|
||||
// space_value(i, cur->request->dir_tab.back()->item_content.meta);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//void dir_last_meta_tab(Info & i)
|
||||
//{
|
||||
// space_list_tab(i, cur->request->dir_tab.back()->item_content.meta);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//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");
|
||||
//}
|
||||
//
|
||||
//
|
||||
//
|
||||
//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");
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
void dir_last_admin_meta_str(Info & i)
|
||||
{
|
||||
cur->request->dir_tab.back()->item_content.meta_admin.serialize_to_space_stream(i.out, true);
|
||||
}
|
||||
|
||||
|
||||
void dir_last_admin_meta(Info & i)
|
||||
{
|
||||
space_value(i, cur->request->dir_tab.back()->item_content.meta_admin);
|
||||
}
|
||||
|
||||
|
||||
void dir_last_admin_meta_tab(Info & i)
|
||||
{
|
||||
space_list_tab(i, cur->request->dir_tab.back()->item_content.meta_admin);
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
//void dir_last_admin_meta_str(Info & i)
|
||||
//{
|
||||
// cur->request->dir_tab.back()->item_content.meta_admin.serialize_to_space_stream(i.out, true);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//void dir_last_admin_meta(Info & i)
|
||||
//{
|
||||
// space_value(i, cur->request->dir_tab.back()->item_content.meta_admin);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//void dir_last_admin_meta_tab(Info & i)
|
||||
//{
|
||||
// space_list_tab(i, cur->request->dir_tab.back()->item_content.meta_admin);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//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");
|
||||
//}
|
||||
//
|
||||
//
|
||||
//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");
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "core/misc.h"
|
||||
#include "core/bbcodeparser.h"
|
||||
#include "core/textstream.h"
|
||||
#include "miscspace.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
@@ -508,7 +508,7 @@ bool Locale::IsKeyByIndex(const std::wstring & key, size_t index, bool try_defau
|
||||
{
|
||||
if( index < locale_tab.size() )
|
||||
{
|
||||
if( locale_tab[index].get_object_field(key) != 0 )
|
||||
if( locale_tab[index].get_space(key) != 0 )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ void priv_user_tab_init(Item & item)
|
||||
priv_user_table.push_back(item.item_content.user_id);
|
||||
}
|
||||
else
|
||||
if( cur->session->puser->super_user )
|
||||
if( cur->session->puser->is_super_user )
|
||||
{
|
||||
// super user is allowed to change to any user
|
||||
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 );
|
||||
|
||||
if( puser )
|
||||
i.out << puser->name;
|
||||
i.out << puser->login;
|
||||
else
|
||||
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);
|
||||
}
|
||||
else
|
||||
if( cur->session->puser->super_user )
|
||||
if( cur->session->puser->is_super_user )
|
||||
{
|
||||
// super user is allowed to change to any group
|
||||
for(Groups::Iterator i=system->groups.Begin() ; i != system->groups.End() ; ++i)
|
||||
|
||||
@@ -308,15 +308,15 @@ void Templates::CreateFunctions()
|
||||
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_meta_str", dir_last_meta_str);
|
||||
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_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_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_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_has_next", dir_last_admin_meta_tab_has_next);
|
||||
// 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_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_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_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_has_next", dir_last_admin_meta_tab_has_next);
|
||||
|
||||
|
||||
/*
|
||||
@@ -342,24 +342,24 @@ void Templates::CreateFunctions()
|
||||
/*
|
||||
env
|
||||
*/
|
||||
ezc_functions.Insert("env_str", env_str);
|
||||
ezc_functions.Insert("env", env);
|
||||
ezc_functions.Insert("env_tab", env_tab);
|
||||
ezc_functions.Insert("env_tab_value", env_tab_value);
|
||||
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", env_admin);
|
||||
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_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_env_str", env_user_env_str);
|
||||
ezc_functions.Insert("env_user_id", env_user_id);
|
||||
ezc_functions.Insert("env_user_name", env_user_name);
|
||||
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_name", env_user_tab_name);
|
||||
ezc_functions.Insert("env_user_tab_is_current", env_user_tab_is_current);
|
||||
// ezc_functions.Insert("env_str", env_str);
|
||||
// ezc_functions.Insert("env", env);
|
||||
// ezc_functions.Insert("env_tab", env_tab);
|
||||
// ezc_functions.Insert("env_tab_value", env_tab_value);
|
||||
// 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", env_admin);
|
||||
// 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_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_env_str", env_user_env_str);
|
||||
// ezc_functions.Insert("env_user_id", env_user_id);
|
||||
// ezc_functions.Insert("env_user_name", env_user_name);
|
||||
// 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_name", env_user_tab_name);
|
||||
// ezc_functions.Insert("env_user_tab_is_current", env_user_tab_is_current);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -198,15 +198,15 @@ namespace TemplatesFunctions
|
||||
void dir_last_html_template(Info & i);
|
||||
void dir_last_has_html_template(Info & i);
|
||||
void dir_last_meta_str(Info & i);
|
||||
void dir_last_meta(Info & i);
|
||||
void dir_last_meta_tab(Info & i);
|
||||
void dir_last_meta_tab_value(Info & i);
|
||||
void dir_last_meta_tab_has_next(Info & i);
|
||||
void dir_last_admin_meta_str(Info & i);
|
||||
void dir_last_admin_meta(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_has_next(Info & i);
|
||||
// void dir_last_meta(Info & i);
|
||||
// void dir_last_meta_tab(Info & i);
|
||||
// void dir_last_meta_tab_value(Info & i);
|
||||
// void dir_last_meta_tab_has_next(Info & i);
|
||||
// void dir_last_admin_meta_str(Info & i);
|
||||
// void dir_last_admin_meta(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_has_next(Info & i);
|
||||
|
||||
|
||||
/*
|
||||
@@ -232,24 +232,24 @@ namespace TemplatesFunctions
|
||||
/*
|
||||
env
|
||||
*/
|
||||
void env_str(Info & i);
|
||||
void env(Info & i);
|
||||
void env_tab(Info & i);
|
||||
void env_tab_value(Info & i);
|
||||
void env_tab_has_next(Info & i);
|
||||
void env_admin_str(Info & i);
|
||||
void env_admin(Info & i);
|
||||
void env_admin_tab(Info & i);
|
||||
void env_admin_tab_value(Info & i);
|
||||
void env_admin_tab_has_next(Info & i);
|
||||
void env_user_admin_env_str(Info & i);
|
||||
void env_user_env_str(Info & i);
|
||||
void env_user_id(Info & i);
|
||||
void env_user_name(Info & i);
|
||||
void env_user_tab(Info & i);
|
||||
void env_user_tab_id(Info & i);
|
||||
void env_user_tab_name(Info & i);
|
||||
void env_user_tab_is_current(Info & i);
|
||||
// void env_str(Info & i);
|
||||
// void env(Info & i);
|
||||
// void env_tab(Info & i);
|
||||
// void env_tab_value(Info & i);
|
||||
// void env_tab_has_next(Info & i);
|
||||
// void env_admin_str(Info & i);
|
||||
// void env_admin(Info & i);
|
||||
// void env_admin_tab(Info & i);
|
||||
// void env_admin_tab_value(Info & i);
|
||||
// void env_admin_tab_has_next(Info & i);
|
||||
// void env_user_admin_env_str(Info & i);
|
||||
// void env_user_env_str(Info & i);
|
||||
// void env_user_id(Info & i);
|
||||
// void env_user_name(Info & i);
|
||||
// void env_user_tab(Info & i);
|
||||
// void env_user_tab_id(Info & i);
|
||||
// void env_user_tab_name(Info & i);
|
||||
// void env_user_tab_is_current(Info & i);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -61,7 +61,7 @@ void user_id(Info & i)
|
||||
void user_name(Info & i)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if( cur->session->puser && cur->session->puser->super_user )
|
||||
if( cur->session->puser && cur->session->puser->is_super_user )
|
||||
i.res = true;
|
||||
}
|
||||
|
||||
@@ -260,14 +260,14 @@ void user_tab_id(Info & i)
|
||||
void user_tab_name(Info & i)
|
||||
{
|
||||
if( user_tab_init() )
|
||||
i.out << user_iter->name;
|
||||
i.out << user_iter->login;
|
||||
}
|
||||
|
||||
|
||||
void user_tab_is_super_user(Info & i)
|
||||
{
|
||||
if( user_tab_init() )
|
||||
i.res = user_iter->super_user;
|
||||
i.res = user_iter->is_super_user;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ void who_tab_user(Info & i)
|
||||
|
||||
|
||||
if( who_iterator->puser )
|
||||
i.out << who_iterator->puser->name;
|
||||
i.out << who_iterator->puser->login;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user