added: forum
added: mount params can have arguments (in parentheses) added: mount params: withheader, withinfo, restrictcreatethread, only_root_can_remove, can_use_emacs_on(level), can_use_mkdir_on(level), added: table Item has 'subject' column now removed: column 'subject' from table Content git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@505 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -37,6 +37,12 @@ last.o: ../core/group.h ../core/functions.h ../core/function.h
|
||||
last.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
||||
last.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
last.o: ../core/done.h ../core/error.h ../core/thread.h ../core/misc.h
|
||||
mount.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h
|
||||
mount.o: ../app/templates.h ../core/data.h ../core/dirs.h ../core/item.h
|
||||
mount.o: ../core/dircontainer.h ../core/users.h ../core/user.h
|
||||
mount.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h
|
||||
mount.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h
|
||||
mount.o: ../core/mounts.h ../core/mount.h
|
||||
patterncacher.o: patterncacher.h ../core/item.h ../../ezc/src/ezc.h
|
||||
patterncacher.o: ../core/data.h ../core/dirs.h ../core/item.h
|
||||
patterncacher.o: ../core/dircontainer.h ../core/users.h ../core/user.h
|
||||
@@ -88,7 +94,7 @@ who.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h
|
||||
who.o: ../app/templates.h ../core/sessioncontainer.h ../core/session.h
|
||||
who.o: ../core/done.h ../core/item.h ../core/error.h ../core/log.h
|
||||
who.o: ../core/user.h ../core/requestcontroller.h ../content/content.h
|
||||
who.o: ../templates/templates.h ../core/sessionmanager.h
|
||||
who.o: ../templates/templates.h ../core/thread.h ../core/sessionmanager.h
|
||||
who.o: ../core/sessioncontainer.h ../core/functionparser.h
|
||||
who.o: ../core/requesttypes.h ../app/content.h ../core/data.h ../core/dirs.h
|
||||
who.o: ../core/dircontainer.h ../core/users.h ../core/ugcontainer.h
|
||||
|
@@ -1 +1 @@
|
||||
o = dir.o doc.o done.o item.o last.o patterncacher.o priv.o sys.o templates.o thread.o user.o who.o
|
||||
o = dir.o doc.o done.o item.o last.o mount.o patterncacher.o priv.o sys.o templates.o thread.o user.o who.o
|
||||
|
@@ -31,7 +31,8 @@ void dir(Info & i)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//!! moze wystarczy sprawdzac tylko ostatni katalog?
|
||||
// bo inaczej i tak bylo by 'access denied'
|
||||
void dir_can_read_exec(Info & i)
|
||||
{
|
||||
bool result = true;
|
||||
@@ -49,6 +50,52 @@ bool result = true;
|
||||
}
|
||||
|
||||
|
||||
void dir_can_write(Info & i)
|
||||
{
|
||||
i.result = request.HasWriteAccess(*request.dir_table.back());
|
||||
}
|
||||
|
||||
|
||||
void dir_can_remove(Info & i)
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
|
||||
if( request.dir_table.size() == 1 )
|
||||
{
|
||||
// rm for the root dir
|
||||
// only the superuser can do it
|
||||
if( !request.session->puser || !request.session->puser->super_user )
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Item * last_but_one_dir = *(--(--request.dir_table.end()));
|
||||
|
||||
if( !request.HasWriteAccess(*last_but_one_dir) )
|
||||
result = false;
|
||||
}
|
||||
|
||||
i.result = result;
|
||||
}
|
||||
|
||||
|
||||
void dir_can_use_emacs(Info & i)
|
||||
{
|
||||
if( !request.dir_table.empty() )
|
||||
i.result = request.CanUseEmacs(*request.dir_table.back(), true);
|
||||
else
|
||||
i.result = false;
|
||||
}
|
||||
|
||||
|
||||
void dir_can_use_mkdir(Info & i)
|
||||
{
|
||||
if( !request.dir_table.empty() )
|
||||
i.result = request.CanUseMkdir(*request.dir_table.back(), true);
|
||||
else
|
||||
i.result = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -133,7 +180,6 @@ void dir_last_default_item_init()
|
||||
dir_last_default_item_reqid = request.id;
|
||||
|
||||
dir_last_default_item.Clear();
|
||||
log << "inicjalizacja dir_last_default_item" << logend;
|
||||
|
||||
if( request.dir_table.empty() )
|
||||
return;
|
||||
@@ -174,6 +220,12 @@ void dir_last_default_item_url(Info & i)
|
||||
}
|
||||
|
||||
|
||||
void dir_last_subject(Info & i)
|
||||
{
|
||||
HtmlEscape(i.out, request.dir_table.back()->subject);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void dir_old(Info & i)
|
||||
{
|
||||
@@ -184,6 +236,8 @@ void dir_old(Info & i)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace TemplatesFunctions
|
||||
|
||||
|
||||
|
@@ -35,7 +35,7 @@ void doc_title(Info & i)
|
||||
|
||||
// from 1 means skipping the root directory
|
||||
for(a = 1 ; a<request.dir_table.size() ; ++a)
|
||||
i.out << " / " << request.dir_table[a]->url;
|
||||
i.out << " / " << request.dir_table[a]->subject;
|
||||
|
||||
if( request.is_item )
|
||||
i.out << " / " << request.item.subject;
|
||||
|
@@ -63,6 +63,36 @@ void item_content_noescape(Info & i)
|
||||
}
|
||||
|
||||
|
||||
void item_print_content(Info & i)
|
||||
{
|
||||
if( request.item.content_type == 0 ) // simple txt
|
||||
{
|
||||
HtmlEscape(i.out, request.item.content);
|
||||
}
|
||||
else
|
||||
if( request.item.content_type == 1 ) // formatted txt
|
||||
{
|
||||
HtmlEscapeFormTxt(i.out, request.item.content);
|
||||
}
|
||||
else
|
||||
if( request.item.content_type == 2 ) // html
|
||||
{
|
||||
if( request.CanUseHtml(request.item.user_id) )
|
||||
i.out << request.item.content;
|
||||
else
|
||||
HtmlEscape(i.out, request.item.content);
|
||||
}
|
||||
else
|
||||
if( request.item.content_type == 3 ) // bbcode
|
||||
{
|
||||
if( request.CanUseBBCode(request.item.user_id) )
|
||||
HtmlEscape(i.out, request.item.content); // tutaj bedzie parsowanie bbcodu i tworzenie odpowiadajacego mu html-a
|
||||
else
|
||||
i.out << request.item.content;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void item_privileges(Info & i)
|
||||
{
|
||||
i.out << std::setbase(8) << request.item.privileges << std::setbase(10);
|
||||
@@ -96,6 +126,11 @@ void item_can_read(Info & i)
|
||||
i.result = true;
|
||||
}
|
||||
|
||||
void item_can_write(Info & i)
|
||||
{
|
||||
if( request.HasWriteAccess(request.item) )
|
||||
i.result = true;
|
||||
}
|
||||
|
||||
void item_info(Info & i)
|
||||
{
|
||||
@@ -111,7 +146,7 @@ void item_user(Info & i)
|
||||
if( puser )
|
||||
HtmlEscape(i.out, puser->name);
|
||||
else
|
||||
i.out << "unknown";
|
||||
i.out << "~guest"; // !! dodac do konfiga
|
||||
}
|
||||
|
||||
|
||||
@@ -278,6 +313,41 @@ void item_tab_content_noescape(Info & i)
|
||||
}
|
||||
|
||||
|
||||
void item_tab_print_content(Info & i)
|
||||
{
|
||||
if( item_index >= request.item_table.size() )
|
||||
return;
|
||||
|
||||
int type = request.item_table[item_index].content_type;
|
||||
|
||||
if( type == 0 ) // simple txt
|
||||
{
|
||||
HtmlEscape(i.out, request.item_table[item_index].content);
|
||||
}
|
||||
else
|
||||
if( type == 1 ) // formatted txt
|
||||
{
|
||||
HtmlEscapeFormTxt(i.out, request.item_table[item_index].content);
|
||||
}
|
||||
else
|
||||
if( type == 2 ) // html
|
||||
{
|
||||
if( request.CanUseHtml(request.item_table[item_index].user_id) )
|
||||
i.out << request.item_table[item_index].content;
|
||||
else
|
||||
HtmlEscape(i.out, request.item_table[item_index].content);
|
||||
}
|
||||
else
|
||||
if( type == 3 ) // bbcode
|
||||
{
|
||||
if( request.CanUseBBCode(request.item_table[item_index].user_id) )
|
||||
HtmlEscape(i.out, request.item_table[item_index].content); // tutaj bedzie parsowanie bbcodu i tworzenie odpowiadajacego mu html-a
|
||||
else
|
||||
i.out << request.item_table[item_index].content;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void item_tab_privileges(Info & i)
|
||||
{
|
||||
if( item_index < request.item_table.size() )
|
||||
@@ -343,7 +413,7 @@ void item_tab_user(Info & i)
|
||||
if( puser )
|
||||
HtmlEscape(i.out, puser->name);
|
||||
else
|
||||
i.out << "unknown";
|
||||
i.out << "~guest"; // !! dodac do konfiga
|
||||
}
|
||||
}
|
||||
|
||||
|
39
templates/mount.cpp
Executable file
39
templates/mount.cpp
Executable file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "templates.h"
|
||||
#include "../core/data.h"
|
||||
|
||||
|
||||
|
||||
namespace TemplatesFunctions
|
||||
{
|
||||
|
||||
|
||||
void mount_param_withheader(Info & i)
|
||||
{
|
||||
i.result = data.mounts.CurrentMountIsParam(Mount::withheader);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void mount_param_withinfo(Info & i)
|
||||
{
|
||||
i.result = data.mounts.CurrentMountIsParam(Mount::withinfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace TemplatesFunctions
|
||||
|
||||
|
||||
|
@@ -25,7 +25,7 @@ static size_t priv_user_reqid = 0;
|
||||
|
||||
|
||||
|
||||
void priv_user_tab_init()
|
||||
void priv_user_tab_init(Item & item)
|
||||
{
|
||||
priv_user_reqid = request.id;
|
||||
priv_user_table.clear();
|
||||
@@ -33,7 +33,7 @@ void priv_user_tab_init()
|
||||
if( !request.session->puser )
|
||||
{
|
||||
// not logged
|
||||
priv_user_table.push_back(request.item.user_id);
|
||||
priv_user_table.push_back(item.user_id);
|
||||
}
|
||||
else
|
||||
if( request.session->puser->super_user )
|
||||
@@ -48,11 +48,20 @@ void priv_user_tab_init()
|
||||
else
|
||||
{
|
||||
// others
|
||||
priv_user_table.push_back(request.item.user_id);
|
||||
priv_user_table.push_back(item.user_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void priv_user_tab_init()
|
||||
{
|
||||
if( request.is_item )
|
||||
priv_user_tab_init(request.item);
|
||||
else
|
||||
priv_user_tab_init(*request.dir_table.back());
|
||||
}
|
||||
|
||||
|
||||
void priv_user_tab(Info & i)
|
||||
{
|
||||
if( priv_user_reqid != request.id )
|
||||
@@ -95,8 +104,16 @@ void priv_user_tab_isdefault(Info & i)
|
||||
{
|
||||
long uid = priv_user_table[priv_user_index];
|
||||
|
||||
if( uid == request.item.user_id )
|
||||
i.result = true;
|
||||
if( request.is_item )
|
||||
{
|
||||
if( uid == request.item.user_id )
|
||||
i.result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( uid == request.dir_table.back()->user_id )
|
||||
i.result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +130,7 @@ static size_t priv_group_reqid = 0;
|
||||
|
||||
|
||||
|
||||
void priv_group_tab_init()
|
||||
void priv_group_tab_init(Item & item)
|
||||
{
|
||||
priv_group_reqid = request.id;
|
||||
priv_group_table.clear();
|
||||
@@ -121,7 +138,7 @@ void priv_group_tab_init()
|
||||
if( !request.session->puser )
|
||||
{
|
||||
// not logged
|
||||
priv_group_table.push_back(request.item.group_id);
|
||||
priv_group_table.push_back(item.group_id);
|
||||
}
|
||||
else
|
||||
if( request.session->puser->super_user )
|
||||
@@ -134,7 +151,7 @@ void priv_group_tab_init()
|
||||
priv_group_table.push_back(-1);
|
||||
}
|
||||
else
|
||||
if( request.session->puser->id == request.item.user_id )
|
||||
if( request.session->puser->id == item.user_id )
|
||||
{
|
||||
bool was_current_group = false;
|
||||
// owner of the item -- is allowed to change only to a group in which he belongs to
|
||||
@@ -142,13 +159,13 @@ void priv_group_tab_init()
|
||||
{
|
||||
priv_group_table.push_back( request.session->puser->groups[i] );
|
||||
|
||||
if( request.item.group_id == request.session->puser->groups[i] )
|
||||
if( item.group_id == request.session->puser->groups[i] )
|
||||
was_current_group = true;
|
||||
}
|
||||
|
||||
// we're showing the item.group_id if it's different
|
||||
if( !was_current_group )
|
||||
priv_group_table.push_back(request.item.group_id);
|
||||
priv_group_table.push_back(item.group_id);
|
||||
|
||||
// switching to -1 is allowed too
|
||||
priv_group_table.push_back(-1);
|
||||
@@ -156,11 +173,20 @@ void priv_group_tab_init()
|
||||
else
|
||||
{
|
||||
// not the owner and not a super user -- the same as not logged
|
||||
priv_group_table.push_back(request.item.group_id);
|
||||
priv_group_table.push_back(item.group_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void priv_group_tab_init()
|
||||
{
|
||||
if( request.is_item )
|
||||
priv_group_tab_init(request.item);
|
||||
else
|
||||
priv_group_tab_init(*request.dir_table.back());
|
||||
}
|
||||
|
||||
|
||||
void priv_group_tab(Info & i)
|
||||
{
|
||||
if( priv_group_reqid != request.id )
|
||||
@@ -203,12 +229,28 @@ void priv_group_tab_isdefault(Info & i)
|
||||
{
|
||||
long gid = priv_group_table[priv_group_index];
|
||||
|
||||
if( gid == request.item.group_id )
|
||||
i.result = true;
|
||||
if( request.is_item )
|
||||
{
|
||||
if( gid == request.item.group_id )
|
||||
i.result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( gid == request.dir_table.back()->group_id )
|
||||
i.result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void priv_privileges(Info & i)
|
||||
{
|
||||
if( request.is_item )
|
||||
i.out << std::setbase(8) << request.item.privileges << std::setbase(10);
|
||||
else
|
||||
i.out << std::setbase(8) << request.dir_table.back()->privileges << std::setbase(10);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -145,6 +145,9 @@ Ezc::Pattern * p = 0;
|
||||
break;
|
||||
|
||||
case Error::permision_denied:
|
||||
case Error::cant_change_user:
|
||||
case Error::cant_change_group:
|
||||
case Error::cant_change_privileges:
|
||||
p = &pat_err_per_denied;
|
||||
break;
|
||||
|
||||
@@ -216,11 +219,13 @@ void Templates::CreateFunctions()
|
||||
functions.Insert("item_subject_noescape", item_subject_noescape);
|
||||
functions.Insert("item_content", item_content);
|
||||
functions.Insert("item_content_noescape", item_content_noescape);
|
||||
functions.Insert("item_print_content", item_print_content);
|
||||
functions.Insert("item_privileges", item_privileges);
|
||||
functions.Insert("item_dir", item_dir);
|
||||
functions.Insert("item_url", item_url);
|
||||
functions.Insert("item_link", item_link);
|
||||
functions.Insert("item_can_read", item_can_read);
|
||||
functions.Insert("item_can_write", item_can_write);
|
||||
functions.Insert("item_info", item_info);
|
||||
functions.Insert("item_user", item_user);
|
||||
functions.Insert("item_date_creation", item_date_creation);
|
||||
@@ -244,6 +249,7 @@ void Templates::CreateFunctions()
|
||||
functions.Insert("item_tab_subject_noescape", item_tab_subject_noescape);
|
||||
functions.Insert("item_tab_content", item_tab_content);
|
||||
functions.Insert("item_tab_content_noescape", item_tab_content_noescape);
|
||||
functions.Insert("item_tab_print_content", item_tab_print_content);
|
||||
functions.Insert("item_tab_privileges", item_tab_privileges);
|
||||
functions.Insert("item_tab_dir", item_tab_dir);
|
||||
functions.Insert("item_tab_url", item_tab_url);
|
||||
@@ -262,6 +268,10 @@ void Templates::CreateFunctions()
|
||||
*/
|
||||
functions.Insert("dir", dir);
|
||||
functions.Insert("dir_can_read_exec", dir_can_read_exec);
|
||||
functions.Insert("dir_can_write", dir_can_write);
|
||||
functions.Insert("dir_can_remove", dir_can_remove);
|
||||
functions.Insert("dir_can_use_emacs", dir_can_use_emacs);
|
||||
functions.Insert("dir_can_use_mkdir", dir_can_use_mkdir);
|
||||
|
||||
functions.Insert("dir_childs_tab", dir_childs_tab);
|
||||
functions.Insert("dir_childs_tab_url", dir_childs_tab_url);
|
||||
@@ -272,6 +282,7 @@ void Templates::CreateFunctions()
|
||||
|
||||
functions.Insert("dir_last_default_item_dir", dir_last_default_item_dir);
|
||||
functions.Insert("dir_last_default_item_url", dir_last_default_item_url);
|
||||
functions.Insert("dir_last_subject", dir_last_subject);
|
||||
|
||||
functions.Insert("dir_old", dir_old);
|
||||
|
||||
@@ -294,6 +305,8 @@ void Templates::CreateFunctions()
|
||||
functions.Insert("priv_group_tab_name", priv_group_tab_name);
|
||||
functions.Insert("priv_group_tab_isdefault", priv_group_tab_isdefault);
|
||||
|
||||
functions.Insert("priv_privileges", priv_privileges);
|
||||
|
||||
|
||||
/*
|
||||
done
|
||||
@@ -341,7 +354,24 @@ void Templates::CreateFunctions()
|
||||
/*
|
||||
thread
|
||||
*/
|
||||
functions.Insert("thread_subject", thread_subject);
|
||||
functions.Insert("thread_is", thread_is);
|
||||
functions.Insert("thread_subject", thread_subject);
|
||||
functions.Insert("thread_show_edit_subject", thread_show_edit_subject);
|
||||
functions.Insert("thread_tab", thread_tab);
|
||||
functions.Insert("thread_tab_url", thread_tab_url);
|
||||
functions.Insert("thread_tab_subject", thread_tab_subject);
|
||||
functions.Insert("thread_tab_author", thread_tab_author);
|
||||
functions.Insert("thread_tab_answers", thread_tab_answers);
|
||||
functions.Insert("thread_tab_last_item_date_modification", thread_tab_last_item_date_modification);
|
||||
functions.Insert("thread_tab_last_item_user", thread_tab_last_item_user);
|
||||
functions.Insert("thread_can_create", thread_can_create);
|
||||
|
||||
|
||||
/*
|
||||
mount
|
||||
*/
|
||||
functions.Insert("mount_param_withheader", mount_param_withheader);
|
||||
functions.Insert("mount_param_withinfo", mount_param_withinfo);
|
||||
|
||||
|
||||
|
||||
|
@@ -26,6 +26,8 @@ namespace TemplatesFunctions
|
||||
{
|
||||
using Ezc::Info;
|
||||
|
||||
extern bool thread_show_edit_subject_var;
|
||||
|
||||
extern PatternCacher pattern_cacher;
|
||||
extern Ezc::Functions functions;
|
||||
extern Ezc::Pattern pat_item_info;
|
||||
@@ -60,11 +62,13 @@ namespace TemplatesFunctions
|
||||
void item_subject_noescape(Info & i);
|
||||
void item_content(Info & i);
|
||||
void item_content_noescape(Info & i);
|
||||
void item_print_content(Info & i);
|
||||
void item_privileges(Info & i);
|
||||
void item_dir(Info & i); // the same as full_dir()
|
||||
void item_url(Info & i);
|
||||
void item_link(Info & i);
|
||||
void item_can_read(Info & i);
|
||||
void item_can_write(Info & i);
|
||||
void item_info(Info & i);
|
||||
void item_user(Info & i);
|
||||
void item_date_creation(Info & i);
|
||||
@@ -89,6 +93,7 @@ namespace TemplatesFunctions
|
||||
void item_tab_subject_noescape(Info & i);
|
||||
void item_tab_content(Info & i);
|
||||
void item_tab_content_noescape(Info & i);
|
||||
void item_tab_print_content(Info & i);
|
||||
void item_tab_privileges(Info & i);
|
||||
void item_tab_dir(Info & i);
|
||||
void item_tab_url(Info & i);
|
||||
@@ -107,6 +112,10 @@ namespace TemplatesFunctions
|
||||
*/
|
||||
void dir(Info & i);
|
||||
void dir_can_read_exec(Info & i);
|
||||
void dir_can_write(Info & i);
|
||||
void dir_can_remove(Info & i);
|
||||
void dir_can_use_emacs(Info & i);
|
||||
void dir_can_use_mkdir(Info & i);
|
||||
|
||||
void dir_childs_tab(Info & i);
|
||||
void dir_childs_tab_url(Info & i);
|
||||
@@ -117,7 +126,8 @@ namespace TemplatesFunctions
|
||||
|
||||
void dir_last_default_item_dir(Info &);
|
||||
void dir_last_default_item_url(Info & i);
|
||||
|
||||
void dir_last_subject(Info & i);
|
||||
|
||||
void dir_old(Info & i);
|
||||
|
||||
|
||||
@@ -140,7 +150,7 @@ namespace TemplatesFunctions
|
||||
void priv_group_tab_name(Info & i);
|
||||
void priv_group_tab_isdefault(Info & i);
|
||||
|
||||
|
||||
void priv_privileges(Info & i);
|
||||
|
||||
/*
|
||||
done
|
||||
@@ -185,8 +195,23 @@ namespace TemplatesFunctions
|
||||
/*
|
||||
thread
|
||||
*/
|
||||
void thread_is(Info & i);
|
||||
void thread_show_edit_subject(Info & i);
|
||||
void thread_subject(Info & i);
|
||||
void thread_tab(Info & i);
|
||||
void thread_tab_url(Info & i);
|
||||
void thread_tab_subject(Info & i);
|
||||
void thread_tab_author(Info & i);
|
||||
void thread_tab_answers(Info & i);
|
||||
void thread_tab_last_item_date_modification(Info & i);
|
||||
void thread_tab_last_item_user(Info & i);
|
||||
void thread_can_create(Info & i);
|
||||
|
||||
/*
|
||||
mount
|
||||
*/
|
||||
void mount_param_withheader(Info & i);
|
||||
void mount_param_withinfo(Info & i);
|
||||
|
||||
|
||||
} // namespace TemplatesFunctions
|
||||
|
@@ -17,10 +17,160 @@
|
||||
namespace TemplatesFunctions
|
||||
{
|
||||
|
||||
void thread_is(Info & i)
|
||||
{
|
||||
i.result = request.is_thread;
|
||||
}
|
||||
|
||||
|
||||
bool thread_show_edit_subject_var = false; // !! tymczasowe rozwiazanie, cos lepszego wymyslec
|
||||
|
||||
|
||||
void thread_show_edit_subject(Info & i)
|
||||
{
|
||||
i.result = thread_show_edit_subject_var;
|
||||
|
||||
thread_show_edit_subject_var = false;
|
||||
}
|
||||
|
||||
|
||||
void thread_subject(Info & i)
|
||||
{
|
||||
HtmlEscape(i.out, request.thread.subject);
|
||||
Item * dir = data.dirs.GetDir( request.thread.dir_id );
|
||||
|
||||
if( dir )
|
||||
{
|
||||
HtmlEscape(i.out, dir->subject);
|
||||
}
|
||||
else
|
||||
{
|
||||
i.out << "<!-- unknown subject -->";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static size_t thread_tab_index;
|
||||
|
||||
|
||||
|
||||
void thread_tab(Info & i)
|
||||
{
|
||||
thread_tab_index = i.iter;
|
||||
|
||||
i.result = thread_tab_index < request.thread_tab.size();
|
||||
}
|
||||
|
||||
|
||||
void thread_tab_url(Info & i)
|
||||
{
|
||||
if( thread_tab_index < request.thread_tab.size() )
|
||||
{
|
||||
Item * dir = data.dirs.GetDir( request.thread_tab[thread_tab_index].dir_id );
|
||||
|
||||
if( dir )
|
||||
{
|
||||
HtmlEscape(i.out, dir->url);
|
||||
}
|
||||
else
|
||||
{
|
||||
i.out << "<!-- unknown directory -->";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void thread_tab_subject(Info & i)
|
||||
{
|
||||
if( thread_tab_index < request.thread_tab.size() )
|
||||
{
|
||||
Item * dir = data.dirs.GetDir( request.thread_tab[thread_tab_index].dir_id );
|
||||
|
||||
if( dir )
|
||||
{
|
||||
HtmlEscape(i.out, dir->subject);
|
||||
}
|
||||
else
|
||||
{
|
||||
i.out << "<!-- unknown subject -->";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void thread_tab_answers(Info & i)
|
||||
{
|
||||
if( thread_tab_index < request.thread_tab.size() )
|
||||
{
|
||||
long a = request.thread_tab[thread_tab_index].items;
|
||||
|
||||
// the first is created by the author
|
||||
// we count only the rest
|
||||
if( a > 0 )
|
||||
--a;
|
||||
|
||||
i.out << a;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void thread_tab_author(Info & i)
|
||||
{
|
||||
bool unknown = true;
|
||||
|
||||
|
||||
if( thread_tab_index < request.thread_tab.size() )
|
||||
{
|
||||
Item * dir = data.dirs.GetDir( request.thread_tab[thread_tab_index].dir_id );
|
||||
|
||||
if( dir )
|
||||
{
|
||||
User * puser = data.users.GetUser(dir->user_id);
|
||||
unknown = false;
|
||||
|
||||
if( puser )
|
||||
HtmlEscape(i.out, puser->name);
|
||||
else
|
||||
HtmlEscape(i.out, "~guest"); // !! dodac to do data
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( unknown )
|
||||
{
|
||||
i.out << "<!-- unknown user -->";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void thread_tab_last_item_date_modification(Info & i)
|
||||
{
|
||||
if( thread_tab_index < request.thread_tab.size() )
|
||||
if( request.thread_tab[thread_tab_index].last_item.id != -1 )
|
||||
i.out << DateToStr( &request.thread_tab[thread_tab_index].last_item.date_modification );
|
||||
}
|
||||
|
||||
|
||||
void thread_tab_last_item_user(Info & i)
|
||||
{
|
||||
if( thread_tab_index < request.thread_tab.size() )
|
||||
{
|
||||
if( request.thread_tab[thread_tab_index].last_item.id != -1 )
|
||||
{
|
||||
User * puser = data.users.GetUser( request.thread_tab[thread_tab_index].last_item.user_id );
|
||||
|
||||
if( puser )
|
||||
HtmlEscape(i.out, puser->name);
|
||||
else
|
||||
HtmlEscape(i.out, "~guest"); // !! dodac to do data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void thread_can_create(Info & i)
|
||||
{
|
||||
i.result = request.CanCreateThread(true);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user