2008-12-30 02:05:03 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2008-12-30 02:05:03 +01:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2010-02-28 22:33:06 +01:00
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
2008-12-30 02:05:03 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "templates.h"
|
2011-01-23 15:15:30 +01:00
|
|
|
#include "core/request.h"
|
|
|
|
#include "core/misc.h"
|
2009-04-21 22:50:55 +02:00
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
namespace TemplatesFunctions
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void user_logged(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = cur->session->puser != 0;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void user_name(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( !cur->session->puser )
|
2008-12-30 02:05:03 +01:00
|
|
|
return;
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
i.out << cur->session->puser->name;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-06 02:37:30 +01:00
|
|
|
// should be at least in one group
|
|
|
|
// !! moze lepsza nazwa?
|
2010-09-18 02:51:12 +02:00
|
|
|
void user_is_in_group(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( !cur->session->puser || i.params.empty() )
|
2010-09-18 02:51:12 +02:00
|
|
|
return;
|
|
|
|
|
2010-12-06 02:37:30 +01:00
|
|
|
for(size_t a=0 ; a<i.params.size() ; ++a)
|
|
|
|
{
|
|
|
|
long gid = system->groups.GetGroupId(i.params[a]);
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
if( gid!=-1 && cur->session->puser->IsMemberOf(gid) )
|
2010-12-06 02:37:30 +01:00
|
|
|
{
|
|
|
|
i.res = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-09-18 02:51:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-06 02:37:30 +01:00
|
|
|
// !! moze lepsza nazwa?
|
|
|
|
void user_is_in_all_groups(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( !cur->session->puser || i.params.empty() )
|
2010-12-06 02:37:30 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
for(size_t a=0 ; a<i.params.size() ; ++a)
|
|
|
|
{
|
|
|
|
long gid = system->groups.GetGroupId(i.params[a]);
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
if( gid==-1 || !cur->session->puser->IsMemberOf(gid) )
|
2010-12-06 02:37:30 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
i.res = true;
|
|
|
|
}
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
void user_super_user(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( cur->session->puser && cur->session->puser->super_user )
|
2010-05-30 23:07:46 +02:00
|
|
|
i.res = true;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-11 15:47:52 +01:00
|
|
|
void user_can_use_html(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( !cur->session->puser )
|
2010-05-30 23:07:46 +02:00
|
|
|
i.res = false;
|
2010-01-11 15:47:52 +01:00
|
|
|
else
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = system->CanUseHtml(cur->session->puser->id);
|
2010-01-11 15:47:52 +01:00
|
|
|
}
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
2010-01-11 15:47:52 +01:00
|
|
|
void user_can_use_bbcode(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( !cur->session->puser )
|
2010-05-30 23:07:46 +02:00
|
|
|
i.res = false;
|
2010-01-11 15:47:52 +01:00
|
|
|
else
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = system->CanUseBBCode(cur->session->puser->id);
|
2010-01-11 15:47:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void user_can_use_raw(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( !cur->session->puser )
|
2010-05-30 23:07:46 +02:00
|
|
|
i.res = false;
|
2010-01-11 15:47:52 +01:00
|
|
|
else
|
2011-01-23 15:15:30 +01:00
|
|
|
i.res = system->CanUseRaw(cur->session->puser->id);
|
2010-01-11 15:47:52 +01:00
|
|
|
}
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|
|
|
|
|
|
|
|
|