151 lines
2.3 KiB
C++
Executable File
151 lines
2.3 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include "templates.h"
|
|
#include "core/request.h"
|
|
#include "core/misc.h"
|
|
|
|
|
|
|
|
|
|
namespace TemplatesFunctions
|
|
{
|
|
|
|
|
|
|
|
void user_logged(Info & i)
|
|
{
|
|
i.res = cur->session->puser != 0;
|
|
}
|
|
|
|
|
|
void user_name(Info & i)
|
|
{
|
|
if( !cur->session->puser )
|
|
return;
|
|
|
|
i.out << cur->session->puser->name;
|
|
}
|
|
|
|
|
|
// should be at least in one group
|
|
// !! moze lepsza nazwa?
|
|
void user_is_in_group(Info & i)
|
|
{
|
|
if( !cur->session->puser || i.params.empty() )
|
|
return;
|
|
|
|
for(size_t a=0 ; a<i.params.size() ; ++a)
|
|
{
|
|
long gid = system->groups.GetGroupId(i.params[a]);
|
|
|
|
if( gid!=-1 && cur->session->puser->IsMemberOf(gid) )
|
|
{
|
|
i.res = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// !! moze lepsza nazwa?
|
|
void user_is_in_all_groups(Info & i)
|
|
{
|
|
if( !cur->session->puser || i.params.empty() )
|
|
return;
|
|
|
|
for(size_t a=0 ; a<i.params.size() ; ++a)
|
|
{
|
|
long gid = system->groups.GetGroupId(i.params[a]);
|
|
|
|
if( gid==-1 || !cur->session->puser->IsMemberOf(gid) )
|
|
return;
|
|
}
|
|
|
|
i.res = true;
|
|
}
|
|
|
|
|
|
void user_super_user(Info & i)
|
|
{
|
|
if( cur->session->puser && cur->session->puser->super_user )
|
|
i.res = true;
|
|
}
|
|
|
|
|
|
void user_can_use_html(Info & i)
|
|
{
|
|
if( !cur->session->puser )
|
|
i.res = false;
|
|
else
|
|
i.res = system->CanUseHtml(cur->session->puser->id);
|
|
}
|
|
|
|
|
|
void user_can_use_bbcode(Info & i)
|
|
{
|
|
if( !cur->session->puser )
|
|
i.res = false;
|
|
else
|
|
i.res = system->CanUseBBCode(cur->session->puser->id);
|
|
}
|
|
|
|
|
|
void user_can_use_raw(Info & i)
|
|
{
|
|
if( !cur->session->puser )
|
|
i.res = false;
|
|
else
|
|
i.res = system->CanUseRaw(cur->session->puser->id);
|
|
}
|
|
|
|
|
|
|
|
|
|
static size_t user_index = 0;
|
|
|
|
void user_tab(Info & i)
|
|
{
|
|
user_index = i.iter;
|
|
i.res = user_index < system->users.Size();
|
|
}
|
|
|
|
|
|
void user_tab_id(Info & i)
|
|
{
|
|
if( user_index < system->users.Size() )
|
|
i.out << system->users[user_index].id;
|
|
}
|
|
|
|
|
|
void user_tab_name(Info & i)
|
|
{
|
|
if( user_index < system->users.Size() )
|
|
i.out << system->users[user_index].name;
|
|
}
|
|
|
|
|
|
void user_tab_is_super_user(Info & i)
|
|
{
|
|
if( user_index < system->users.Size() )
|
|
i.res = system->users[user_index].super_user;
|
|
}
|
|
|
|
|
|
void user_tab_is_current(Info & i)
|
|
{
|
|
if( user_index < system->users.Size() && cur->session->puser )
|
|
i.res = (system->users[user_index].id == cur->session->puser->id);
|
|
}
|
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|
|
|