some ezc functions from templates/item.cpp moved to Item and ItemContent
methods HasAccess() HasReadAccess() and similar moved from System to Item and ItemContent
This commit is contained in:
parent
ebd791a256
commit
ec94dff7d7
|
@ -118,6 +118,9 @@ App::App()
|
||||||
plugin.SetWinixRequest(&winix_request);
|
plugin.SetWinixRequest(&winix_request);
|
||||||
|
|
||||||
req.SetConfig(&config);
|
req.SetConfig(&config);
|
||||||
|
req.set_connector(&model_connector);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
functions.set_dependency(&winix_request);
|
functions.set_dependency(&winix_request);
|
||||||
// functions.set_config(&config);
|
// functions.set_config(&config);
|
||||||
|
@ -337,6 +340,7 @@ bool App::Init()
|
||||||
model_connector.set_winix_users(&system.users);
|
model_connector.set_winix_users(&system.users);
|
||||||
model_connector.set_winix_groups(&system.groups);
|
model_connector.set_winix_groups(&system.groups);
|
||||||
model_connector.set_winix_session_logger(nullptr); // will be set for each request
|
model_connector.set_winix_session_logger(nullptr); // will be set for each request
|
||||||
|
model_connector.set_winix_session(nullptr); // will be set for each request
|
||||||
|
|
||||||
if( !TryToMakeDatabaseMigration() )
|
if( !TryToMakeDatabaseMigration() )
|
||||||
return false;
|
return false;
|
||||||
|
@ -564,8 +568,13 @@ void App::ProcessRequestThrow()
|
||||||
cur.mount = system.mounts.CalcCurMount();
|
cur.mount = system.mounts.CalcCurMount();
|
||||||
|
|
||||||
cur.session = session_manager.PrepareSession();
|
cur.session = session_manager.PrepareSession();
|
||||||
|
model_connector.set_winix_session(cur.session);
|
||||||
|
|
||||||
functions.CheckFunctionAndSymlink(); // here a function can be changed
|
functions.CheckFunctionAndSymlink(); // here a function can be changed
|
||||||
|
|
||||||
cur.session = session_manager.CheckIfFunctionRequireSession();
|
cur.session = session_manager.CheckIfFunctionRequireSession();
|
||||||
|
model_connector.set_winix_session(cur.session);
|
||||||
|
|
||||||
SetLocale();
|
SetLocale();
|
||||||
|
|
||||||
if( cur.session->new_session )
|
if( cur.session->new_session )
|
||||||
|
@ -624,6 +633,9 @@ void App::ProcessRequest()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
cur.request->set_connector(model_connector);
|
||||||
|
model_connector.set_winix_request(cur.request);
|
||||||
|
|
||||||
cur.request->RequestStarts();
|
cur.request->RequestStarts();
|
||||||
system.load_avg.StartRequest();
|
system.load_avg.StartRequest();
|
||||||
log << log2 << config.log_delimiter << logend;
|
log << log2 << config.log_delimiter << logend;
|
||||||
|
@ -680,7 +692,11 @@ void App::ClearAfterRequest()
|
||||||
system.mounts.pmount = cur.mount; // IMPROVE ME system.mounts.pmount will be removed
|
system.mounts.pmount = cur.mount; // IMPROVE ME system.mounts.pmount will be removed
|
||||||
// send_data_buf doesn't have to be cleared and it is better to not clear it (optimizing)
|
// send_data_buf doesn't have to be cleared and it is better to not clear it (optimizing)
|
||||||
|
|
||||||
cur.request->item.set_connector(nullptr);
|
model_connector.set_winix_request(nullptr);
|
||||||
|
model_connector.set_winix_session(nullptr);
|
||||||
|
model_connector.set_winix_session_logger(nullptr);
|
||||||
|
|
||||||
|
cur.request->item.set_connector(nullptr); // it is needed?
|
||||||
|
|
||||||
log << logendrequest;
|
log << logendrequest;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,13 +81,13 @@ return var_iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DirContainer::Iterator DirContainer::Begin()
|
DirContainer::ConstIterator DirContainer::Begin() const
|
||||||
{
|
{
|
||||||
return table.begin();
|
return table.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DirContainer::Iterator DirContainer::End()
|
DirContainer::ConstIterator DirContainer::End() const
|
||||||
{
|
{
|
||||||
return table.end();
|
return table.end();
|
||||||
}
|
}
|
||||||
|
@ -255,6 +255,17 @@ return i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DirContainer::ConstIterator DirContainer::FindId(long id) const
|
||||||
|
{
|
||||||
|
TableId::const_iterator i = table_id.find(id);
|
||||||
|
|
||||||
|
if( i == table_id.end() )
|
||||||
|
return table.end();
|
||||||
|
|
||||||
|
return i->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DirContainer::ParentIterator DirContainer::ParentBegin()
|
DirContainer::ParentIterator DirContainer::ParentBegin()
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,6 +52,7 @@ class DirContainer : public WinixBase
|
||||||
public:
|
public:
|
||||||
typedef std::list<Item> Table;
|
typedef std::list<Item> Table;
|
||||||
typedef Table::iterator Iterator;
|
typedef Table::iterator Iterator;
|
||||||
|
typedef Table::const_iterator ConstIterator;
|
||||||
typedef Table::size_type SizeType;
|
typedef Table::size_type SizeType;
|
||||||
|
|
||||||
typedef std::map<long, Iterator> TableId;
|
typedef std::map<long, Iterator> TableId;
|
||||||
|
@ -66,8 +67,8 @@ public:
|
||||||
Iterator GetEtc();
|
Iterator GetEtc();
|
||||||
Iterator GetVar();
|
Iterator GetVar();
|
||||||
|
|
||||||
Iterator Begin();
|
ConstIterator Begin() const;
|
||||||
Iterator End();
|
ConstIterator End() const;
|
||||||
SizeType Size();
|
SizeType Size();
|
||||||
bool Empty();
|
bool Empty();
|
||||||
Iterator PushBack(const Item & item);
|
Iterator PushBack(const Item & item);
|
||||||
|
@ -75,6 +76,7 @@ public:
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
Iterator FindId(long id);
|
Iterator FindId(long id);
|
||||||
|
ConstIterator FindId(long id) const;
|
||||||
|
|
||||||
bool DelById(long id);
|
bool DelById(long id);
|
||||||
|
|
||||||
|
|
|
@ -456,9 +456,20 @@ Item * Dirs::GetDir(long id)
|
||||||
DirContainer::Iterator i = dir_tab.FindId(id);
|
DirContainer::Iterator i = dir_tab.FindId(id);
|
||||||
|
|
||||||
if( i == dir_tab.End() )
|
if( i == dir_tab.End() )
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
return &(*i);
|
return &(*i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Item * Dirs::GetDir(long id) const
|
||||||
|
{
|
||||||
|
DirContainer::ConstIterator i = dir_tab.FindId(id);
|
||||||
|
|
||||||
|
if( i == dir_tab.End() )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return &(*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,8 @@ public:
|
||||||
Item * GetDir(long id);
|
Item * GetDir(long id);
|
||||||
Item * AddDir(const Item & item);
|
Item * AddDir(const Item & item);
|
||||||
|
|
||||||
|
const Item * GetDir(long id) const;
|
||||||
|
|
||||||
void CheckRootDir();
|
void CheckRootDir();
|
||||||
|
|
||||||
Item * CreateVarDir();
|
Item * CreateVarDir();
|
||||||
|
|
|
@ -77,7 +77,7 @@ class WinixRequest;
|
||||||
|
|
||||||
|
|
||||||
class Plugin;
|
class Plugin;
|
||||||
struct Session;
|
class Session;
|
||||||
|
|
||||||
|
|
||||||
// move me to a different file
|
// move me to a different file
|
||||||
|
|
|
@ -55,7 +55,10 @@ Request::Request()
|
||||||
|
|
||||||
void Request::fields()
|
void Request::fields()
|
||||||
{
|
{
|
||||||
field(L"", L"dirs", dir_tab);
|
field(L"dirs", dir_tab);
|
||||||
|
field(L"is_item", is_item);
|
||||||
|
|
||||||
|
field(L"current_dir", &Request::current_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -362,6 +365,13 @@ const std::wstring & Request::ParamValue(const std::wstring & param_name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Request::current_dir(morm::ModelWrapper ** model_wrapper)
|
||||||
|
{
|
||||||
|
*model_wrapper = new morm::ModelWrapperModel(dir_tab.back());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace Winix
|
} // namespace Winix
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,11 @@ class FunctionBase;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct Request : public WinixModel
|
class Request : public WinixModel
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
// how many input headers can be put to in_headers struct
|
// how many input headers can be put to in_headers struct
|
||||||
static const size_t MAX_INPUT_HEADERS = 32;
|
static const size_t MAX_INPUT_HEADERS = 32;
|
||||||
|
|
||||||
|
@ -413,6 +416,12 @@ private:
|
||||||
|
|
||||||
void ClearOutputStreams();
|
void ClearOutputStreams();
|
||||||
|
|
||||||
|
|
||||||
|
void current_dir(morm::ModelWrapper ** model_wrapper);
|
||||||
|
|
||||||
|
|
||||||
|
MORM_MEMBER_FIELD(Request)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -456,6 +465,8 @@ void Request::AddCookie(const NameType & name, const ValueType & value, pt::Date
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace Winix
|
} // namespace Winix
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -53,8 +53,9 @@ namespace Winix
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct Session
|
class Session
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
Session();
|
Session();
|
||||||
Session(const Session & ses);
|
Session(const Session & ses);
|
||||||
|
|
|
@ -606,69 +606,31 @@ return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// private
|
// DEPRACATED
|
||||||
bool System::HasAccess(const Item & item, int mask)
|
|
||||||
{
|
|
||||||
if( !cur->session )
|
|
||||||
// session must be set
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if( cur->session->puser && cur->session->puser->super_user )
|
|
||||||
// super user is allowed everything
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if( cur->session->puser && item.item_content.user_id != -1 && cur->session->puser->id == item.item_content.user_id )
|
|
||||||
{
|
|
||||||
// the owner
|
|
||||||
return ((item.item_content.privileges >> 9) & mask) == mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( cur->session->puser && item.item_content.group_id != -1 && cur->session->puser->IsMemberOf(item.item_content.group_id) )
|
|
||||||
{
|
|
||||||
// group
|
|
||||||
return ((item.item_content.privileges >> 6) & mask) == mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( cur->session->puser )
|
|
||||||
{
|
|
||||||
// others -- others logged people
|
|
||||||
return ((item.item_content.privileges >> 3) & mask) == mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
// guests -- not logged people
|
|
||||||
|
|
||||||
return (item.item_content.privileges & mask) == mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool System::HasReadAccess(const Item & item)
|
bool System::HasReadAccess(const Item & item)
|
||||||
{
|
{
|
||||||
return HasAccess(item, 4);
|
return item.item_content.has_read_access();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// DEPRACATED
|
||||||
bool System::HasWriteAccess(const Item & item)
|
bool System::HasWriteAccess(const Item & item)
|
||||||
{
|
{
|
||||||
return HasAccess(item, 2);
|
return item.item_content.has_write_access();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// DEPRACATED
|
||||||
bool System::HasReadWriteAccess(const Item & item)
|
bool System::HasReadWriteAccess(const Item & item)
|
||||||
{
|
{
|
||||||
return HasAccess(item, 6); // r+w
|
return item.item_content.has_read_write_access();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// DEPRACATED
|
||||||
bool System::HasReadExecAccess(const Item & item)
|
bool System::HasReadExecAccess(const Item & item)
|
||||||
{
|
{
|
||||||
if( cur->session && cur->session->puser && cur->session->puser->super_user )
|
return item.item_content.has_read_exec_access();
|
||||||
{
|
|
||||||
// there must be at least one 'x' (for the root)
|
|
||||||
// !! CHECK ME: is it applicable to directories too?
|
|
||||||
return (item.item_content.privileges & 01111) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HasAccess(item, 5); // r+x
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,6 @@ private:
|
||||||
std::vector<Item*> root_follow_dir_tab;
|
std::vector<Item*> root_follow_dir_tab;
|
||||||
Item temp_follow_item;
|
Item temp_follow_item;
|
||||||
|
|
||||||
bool HasAccess(const Item & item, int mask);
|
|
||||||
int NewPrivileges(int creation_mask);
|
int NewPrivileges(int creation_mask);
|
||||||
|
|
||||||
bool CreateNewFileSimpleFs(Item & item);
|
bool CreateNewFileSimpleFs(Item & item);
|
||||||
|
|
|
@ -183,25 +183,25 @@ void TextStream<StringType>::Reserve(size_t len)
|
||||||
|
|
||||||
|
|
||||||
template<class StringType>
|
template<class StringType>
|
||||||
TextStream<StringType>::iterator TextStream<StringType>::begin()
|
typename TextStream<StringType>::iterator TextStream<StringType>::begin()
|
||||||
{
|
{
|
||||||
return buffer.begin();
|
return buffer.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class StringType>
|
template<class StringType>
|
||||||
TextStream<StringType>::iterator TextStream<StringType>::end()
|
typename TextStream<StringType>::iterator TextStream<StringType>::end()
|
||||||
{
|
{
|
||||||
return buffer.end();
|
return buffer.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class StringType>
|
template<class StringType>
|
||||||
TextStream<StringType>::const_iterator TextStream<StringType>::begin() const
|
typename TextStream<StringType>::const_iterator TextStream<StringType>::begin() const
|
||||||
{
|
{
|
||||||
return buffer.begin();
|
return buffer.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class StringType>
|
template<class StringType>
|
||||||
TextStream<StringType>::const_iterator TextStream<StringType>::end() const
|
typename TextStream<StringType>::const_iterator TextStream<StringType>::end() const
|
||||||
{
|
{
|
||||||
return buffer.end();
|
return buffer.end();
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@ void ThreadManager::Add(BaseThread * pbase, const wchar_t * thread_name)
|
||||||
data.model_connector.set_winix_users(nullptr);
|
data.model_connector.set_winix_users(nullptr);
|
||||||
data.model_connector.set_winix_groups(nullptr);
|
data.model_connector.set_winix_groups(nullptr);
|
||||||
data.model_connector.set_winix_session_logger(nullptr);
|
data.model_connector.set_winix_session_logger(nullptr);
|
||||||
|
data.model_connector.set_winix_session(nullptr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,12 @@ void Cat::MakeGet()
|
||||||
}
|
}
|
||||||
|
|
||||||
cur->request->send_as_attachment = cur->request->IsParam(L"attachment");
|
cur->request->send_as_attachment = cur->request->IsParam(L"attachment");
|
||||||
|
|
||||||
|
|
||||||
|
// IMPROVEME this will be put by a generic method from winix
|
||||||
|
// if output is html
|
||||||
cur->request->models.Add(L"item", cur->request->item);
|
cur->request->models.Add(L"item", cur->request->item);
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -101,11 +101,17 @@ void Ls::MakeGet()
|
||||||
|
|
||||||
cur->request->models.Add(L"items", item_tab);
|
cur->request->models.Add(L"items", item_tab);
|
||||||
cur->request->models.Add(L"child_dirs", dir_tab);
|
cur->request->models.Add(L"child_dirs", dir_tab);
|
||||||
|
|
||||||
// IMPROVEME this will be put by a generic method from winix
|
|
||||||
// if output is html
|
|
||||||
cur->request->models.Add(L"request", cur->request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IMPROVEME this will be put by a generic method from winix
|
||||||
|
// if output is html
|
||||||
|
cur->request->models.Add(L"request", cur->request);
|
||||||
|
|
||||||
|
if( cur->request->is_item )
|
||||||
|
{
|
||||||
|
cur->request->models.Add(L"item", cur->request->item);
|
||||||
|
}
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<div class="winix"[if winix_function_param_is "ckeditor_browse"] style="padding: 1.5em;"[end]>
|
<div class="winix"[if winix_function_param_is "ckeditor_browse"] style="padding: 1.5em;"[end]>
|
||||||
|
|
||||||
|
[# we can add a winix function called 'image_browser' or similar]
|
||||||
|
[# such a function can be used for ckeditor and for ordinary browsing]
|
||||||
|
|
||||||
|
|
||||||
[# !! IMPROVE ME: move this html code to a ckeditor template]
|
[# !! IMPROVE ME: move this html code to a ckeditor template]
|
||||||
[if winix_function_param_is "ckeditor_browse"]
|
[if winix_function_param_is "ckeditor_browse"]
|
||||||
|
@ -9,9 +12,9 @@
|
||||||
<ul class="uk-breadcrumb">
|
<ul class="uk-breadcrumb">
|
||||||
[for request.dirs]
|
[for request.dirs]
|
||||||
<li>
|
<li>
|
||||||
<a href="[doc_base_url][request.dirs.link]ls/ckeditor_browse/CKEditor:itemcontent/CKEditorFuncNum:[ls_ckeditor_funnum_browse]">
|
<a href="[request.dirs.link]/ls/ckeditor_browse/CKEditor:itemcontent/CKEditorFuncNum:[ls_ckeditor_funnum_browse]">
|
||||||
[if cmp request.dirs.url ""]
|
[if request.dirs.is_root_dir]
|
||||||
[# !! IMPROVE ME it would be better to have a flag of some kind to indicate that this is a root dir]
|
[# rename ls_root_dir_name to root_dir_name as it can be used by other functions]
|
||||||
{ls_root_dir_name}
|
{ls_root_dir_name}
|
||||||
[else]
|
[else]
|
||||||
[request.dirs.url]
|
[request.dirs.url]
|
||||||
|
@ -23,7 +26,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="uk-flex uk-margin-medium">
|
<div class="uk-flex uk-margin-medium">
|
||||||
<div class="uk-width-1-4">
|
<div class="" style="margin-right: 40px;"> [# workaround: margin from first item from child_dirs overflows here]
|
||||||
|
|
||||||
[if child_dirs]
|
[if child_dirs]
|
||||||
<ul class="uk-list uk-list-disc uk-list-collapse">
|
<ul class="uk-list uk-list-disc uk-list-collapse">
|
||||||
|
@ -65,7 +68,7 @@
|
||||||
<h1>{ls_header}</h1>
|
<h1>{ls_header}</h1>
|
||||||
|
|
||||||
[# !! improve me: we need a 'l' flag to a file too, now it's working for dirs only]
|
[# !! improve me: we need a 'l' flag to a file too, now it's working for dirs only]
|
||||||
[if not item_is]
|
[if not request.is_item]
|
||||||
|
|
||||||
[if winix_function_param_is "l"]
|
[if winix_function_param_is "l"]
|
||||||
|
|
||||||
|
@ -83,9 +86,9 @@
|
||||||
[for child_dirs]
|
[for child_dirs]
|
||||||
<tr>
|
<tr>
|
||||||
<td>d</td>
|
<td>d</td>
|
||||||
<td>[child_dirs_privileges]</td>
|
<td>[child_dirs.content.privileges_octal]</td>
|
||||||
<td>[child_dirs_user]</td>
|
<td>[child_dirs.content.user_name]</td>
|
||||||
<td>[child_dirs_group]</td>
|
<td>[child_dirs.content.group_name]</td>
|
||||||
<td>
|
<td>
|
||||||
[if child_dirs.is_parent_for_current_dir]
|
[if child_dirs.is_parent_for_current_dir]
|
||||||
<a href="[doc_base_url][dir_parent_without_slash][if winix_function_param_is "dirls"]/ls/l/dirls[end]">../</a>
|
<a href="[doc_base_url][dir_parent_without_slash][if winix_function_param_is "dirls"]/ls/l/dirls[end]">../</a>
|
||||||
|
@ -98,11 +101,11 @@
|
||||||
|
|
||||||
[for items]
|
[for items]
|
||||||
<tr>
|
<tr>
|
||||||
<td>[if items_type_is_symlink]l[else][if items_has_static_file]s[else]-[end][end]</td>
|
<td>[if items.type_is_symlink]l[else][if items.has_static_file]s[else]-[end][end]</td>
|
||||||
<td>[items_privileges]</td>
|
<td>[items.content.privileges_octal]</td>
|
||||||
<td>[items_user]</td>
|
<td>[items.content.user_name]</td>
|
||||||
<td>[items_group]</td>
|
<td>[items.content.group_name]</td>
|
||||||
<td><a href="[doc_base_url][dir][items.url]">[items.url]</a>[if items_type_is_symlink] -> [items_link_to][end]</td>
|
<td><a href="[doc_base_url][dir][items.url]">[items.url]</a>[if items.type_is_symlink] -> [items.content.link_to][end]</td>
|
||||||
</tr>
|
</tr>
|
||||||
[end]
|
[end]
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
#include "finder.h"
|
#include "finder.h"
|
||||||
#include "core/request.h"
|
#include "core/request.h"
|
||||||
#include "templates/templates.h"
|
#include "templates/templates.h"
|
||||||
|
#include "core/session.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Winix
|
namespace Winix
|
||||||
|
@ -58,21 +60,32 @@ void Item::fields()
|
||||||
|
|
||||||
int type_helper = static_cast<int>(type);
|
int type_helper = static_cast<int>(type);
|
||||||
|
|
||||||
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"parent_id", parent_id);
|
field(L"parent_id", parent_id);
|
||||||
field(L"type", type_helper);
|
field(L"type", type_helper);
|
||||||
field(L"url", url);
|
field(L"url", url);
|
||||||
field(L"subject", subject);
|
field(L"subject", subject);
|
||||||
field(L"template", html_template);
|
field(L"template", html_template);
|
||||||
field(L"sort_index", sort_index);
|
field(L"sort_index", sort_index);
|
||||||
field(L"content_id", L"content", item_content, morm::FT::foreign_key);
|
field(L"content_id", L"content", item_content, morm::FT::foreign_key);
|
||||||
|
|
||||||
field(L"is", &Item::is);
|
field(L"dir_link", &Item::dir_link);
|
||||||
field(L"dir_link", &Item::dir_link);
|
field(L"link", &Item::link);
|
||||||
field(L"link", &Item::link);
|
|
||||||
field(L"is_parent_for_current_dir", &Item::is_parent_for_current_dir);
|
field(L"is_parent_for_current_dir", &Item::is_parent_for_current_dir);
|
||||||
field(L"is_current_dir", &Item::is_current_dir);
|
field(L"is_current_dir", &Item::is_current_dir);
|
||||||
field(L"is_root", &Item::is_root);
|
field(L"is_root_dir", &Item::is_root_dir);
|
||||||
|
|
||||||
|
field(L"type_is_symlink", &Item::type_is_symlink);
|
||||||
|
field(L"type_is_file", &Item::type_is_file);
|
||||||
|
field(L"type_is_dir", &Item::type_is_dir);
|
||||||
|
field(L"type_is_none", &Item::type_is_none);
|
||||||
|
|
||||||
|
field(L"url_is", &Item::url_is);
|
||||||
|
|
||||||
|
field(L"can_be_removed", &Item::can_be_removed);
|
||||||
|
field(L"has_read_access", &Item::has_read_access);
|
||||||
|
field(L"has_write_access", &Item::has_write_access);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// may we should add a method setTypeFromInt(int t)?
|
// may we should add a method setTypeFromInt(int t)?
|
||||||
|
@ -156,8 +169,6 @@ bool Item::update(morm::ModelData * model_data, bool update_whole_tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Item::Clear()
|
void Item::Clear()
|
||||||
{
|
{
|
||||||
id = -1;
|
id = -1;
|
||||||
|
@ -171,199 +182,6 @@ void Item::Clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CalcItemsHelper Item::calc_items_by_url(long parent_id, const std::wstring & url)
|
|
||||||
{
|
|
||||||
morm::Finder<CalcItemsHelper> finder(model_connector);
|
|
||||||
|
|
||||||
CalcItemsHelper helper = finder.
|
|
||||||
prepare_to_select().
|
|
||||||
raw("select count(id) as size, min(id) as item_id from core.item").
|
|
||||||
where().
|
|
||||||
eq(L"parent_id", parent_id).
|
|
||||||
eq(L"url", url).
|
|
||||||
get();
|
|
||||||
|
|
||||||
return helper;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* may we should check for '.' and '..' here too?
|
|
||||||
*/
|
|
||||||
bool Item::prepare_url()
|
|
||||||
{
|
|
||||||
std::wstring temp_url;
|
|
||||||
bool is_that_url;
|
|
||||||
const int max_index = 99;
|
|
||||||
size_t index = 1;
|
|
||||||
std::wstring postfix;
|
|
||||||
|
|
||||||
// only root dir may not have the url
|
|
||||||
if( parent_id != -1 && url.empty() )
|
|
||||||
url = L"_";
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if( index > 1 )
|
|
||||||
{
|
|
||||||
postfix = L"_(";
|
|
||||||
pt::Toa(index, postfix, false);
|
|
||||||
postfix += L")";
|
|
||||||
}
|
|
||||||
|
|
||||||
PrepareNewFileName(url, postfix, temp_url);
|
|
||||||
|
|
||||||
CalcItemsHelper helper = calc_items_by_url(parent_id, temp_url);
|
|
||||||
|
|
||||||
if( helper.size > 0 )
|
|
||||||
{
|
|
||||||
is_that_url = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
url = temp_url;
|
|
||||||
is_that_url = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
index += 1;
|
|
||||||
}
|
|
||||||
while( is_that_url && index <= max_index );
|
|
||||||
|
|
||||||
return !is_that_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Item::propagate_connector()
|
|
||||||
{
|
|
||||||
item_content.set_connector(model_connector);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// IMPROVEME move me to a better place
|
|
||||||
void Item::print_dir(Ezc::FunInfo<HtmlTextStream> & env)
|
|
||||||
{
|
|
||||||
Request * req = get_request();
|
|
||||||
|
|
||||||
if( req )
|
|
||||||
{
|
|
||||||
for(size_t a=0 ; a < req->dir_tab.size() ; ++a)
|
|
||||||
env.out << req->dir_tab[a]->url << '/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// IMPROVEME move me to a better place
|
|
||||||
void Item::print_dir_without_slash(Ezc::FunInfo<HtmlTextStream> & env)
|
|
||||||
{
|
|
||||||
Request * req = get_request();
|
|
||||||
|
|
||||||
if( req )
|
|
||||||
{
|
|
||||||
for(size_t a=0 ; a < req->dir_tab.size() ; ++a)
|
|
||||||
{
|
|
||||||
env.out << req->dir_tab[a]->url;
|
|
||||||
|
|
||||||
if( a < req->dir_tab.size()-1 )
|
|
||||||
env.out << '/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Item::is(Ezc::FunInfo<HtmlTextStream> & env)
|
|
||||||
{
|
|
||||||
Request * req = get_request();
|
|
||||||
|
|
||||||
if( req )
|
|
||||||
{
|
|
||||||
env.res = req->is_item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Item::dir_link(Ezc::FunInfo<HtmlTextStream> & env)
|
|
||||||
{
|
|
||||||
Dirs * dirs = get_dirs();
|
|
||||||
std::vector<Item*> dir_tab;
|
|
||||||
|
|
||||||
if( dirs && dirs->CreateDirTab(parent_id, dir_tab) )
|
|
||||||
{
|
|
||||||
for(Item * pitem : dir_tab)
|
|
||||||
{
|
|
||||||
env.out << pitem->url << '/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Item::link(Ezc::FunInfo<HtmlTextStream> & env)
|
|
||||||
{
|
|
||||||
Config * config = get_config();
|
|
||||||
Request * req = get_request();
|
|
||||||
|
|
||||||
if( config && req )
|
|
||||||
{
|
|
||||||
TemplatesFunctions::doc_proto(env);
|
|
||||||
|
|
||||||
if( !req->subdomain.empty() )
|
|
||||||
env.out << req->subdomain << '.';
|
|
||||||
|
|
||||||
env.out << config->base_url;
|
|
||||||
|
|
||||||
if( parent_id == req->dir_tab.back()->id )
|
|
||||||
{
|
|
||||||
print_dir(env);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dir_link(env);
|
|
||||||
}
|
|
||||||
|
|
||||||
env.out << url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Item::is_parent_for_current_dir(Ezc::FunInfo<HtmlTextStream> & env)
|
|
||||||
{
|
|
||||||
Request * req = get_request();
|
|
||||||
|
|
||||||
if( req )
|
|
||||||
{
|
|
||||||
if( req->dir_tab.size() > 1 )
|
|
||||||
{
|
|
||||||
env.res = (id == req->dir_tab[req->dir_tab.size() - 2]->id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Item::is_current_dir(Ezc::FunInfo<HtmlTextStream> & env)
|
|
||||||
{
|
|
||||||
Request * req = get_request();
|
|
||||||
|
|
||||||
if( req )
|
|
||||||
{
|
|
||||||
env.res = (id == req->dir_tab.back()->id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rename to is_root_dir
|
|
||||||
void Item::is_root(Ezc::FunInfo<HtmlTextStream> & env)
|
|
||||||
{
|
|
||||||
Request * req = get_request();
|
|
||||||
|
|
||||||
if( req )
|
|
||||||
{
|
|
||||||
// add a test whether this is a directory (not a file or a symlink)
|
|
||||||
env.res = (parent_id == -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -499,5 +317,295 @@ bool Item::do_migration_to_4()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool Item::can_remove_child(const User * current_user, long child_user_id) const
|
||||||
|
{
|
||||||
|
bool res = false;
|
||||||
|
|
||||||
|
if( type == Type::dir )
|
||||||
|
{
|
||||||
|
if( current_user && current_user->super_user )
|
||||||
|
{
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res = item_content.has_write_access(current_user);
|
||||||
|
|
||||||
|
if( res && item_content.is_sticky_bit_set() )
|
||||||
|
{
|
||||||
|
// IMPROVEME what about if child_user_id is -1 (guest)
|
||||||
|
res = (item_content.user_id == child_user_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Item::can_be_removed(const User * current_user) const
|
||||||
|
{
|
||||||
|
bool res = false;
|
||||||
|
const Dirs * dirs = get_dirs();
|
||||||
|
|
||||||
|
if( dirs && parent_id != -1 )
|
||||||
|
{
|
||||||
|
const Item * parent_dir = dirs->GetDir(parent_id);
|
||||||
|
|
||||||
|
if( parent_dir )
|
||||||
|
{
|
||||||
|
res = parent_dir->can_remove_child(current_user, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Item::can_remove_child(long child_user_id) const
|
||||||
|
{
|
||||||
|
return can_remove_child(get_current_user(), child_user_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Item::can_be_removed() const
|
||||||
|
{
|
||||||
|
return can_be_removed(get_current_user());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Item::has_read_access()
|
||||||
|
{
|
||||||
|
return item_content.has_read_access();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Item::has_write_access()
|
||||||
|
{
|
||||||
|
return item_content.has_write_access();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Item::type_is_symlink() const
|
||||||
|
{
|
||||||
|
return (type == Type::symlink);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Item::type_is_file() const
|
||||||
|
{
|
||||||
|
return (type == Type::file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Item::type_is_dir() const
|
||||||
|
{
|
||||||
|
return (type == Type::dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Item::type_is_none() const
|
||||||
|
{
|
||||||
|
return (type == Type::none);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Item::is_root_dir() const
|
||||||
|
{
|
||||||
|
return (type == Type::dir && parent_id == -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CalcItemsHelper Item::calc_items_by_url(long parent_id, const std::wstring & url)
|
||||||
|
{
|
||||||
|
morm::Finder<CalcItemsHelper> finder(model_connector);
|
||||||
|
|
||||||
|
CalcItemsHelper helper = finder.
|
||||||
|
prepare_to_select().
|
||||||
|
raw("select count(id) as size, min(id) as item_id from core.item").
|
||||||
|
where().
|
||||||
|
eq(L"parent_id", parent_id).
|
||||||
|
eq(L"url", url).
|
||||||
|
get();
|
||||||
|
|
||||||
|
return helper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* may we should check for '.' and '..' here too?
|
||||||
|
*/
|
||||||
|
bool Item::prepare_url()
|
||||||
|
{
|
||||||
|
std::wstring temp_url;
|
||||||
|
bool is_that_url;
|
||||||
|
const int max_index = 99;
|
||||||
|
size_t index = 1;
|
||||||
|
std::wstring postfix;
|
||||||
|
|
||||||
|
// only root dir may not have the url
|
||||||
|
if( parent_id != -1 && url.empty() )
|
||||||
|
url = L"_";
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if( index > 1 )
|
||||||
|
{
|
||||||
|
postfix = L"_(";
|
||||||
|
pt::Toa(index, postfix, false);
|
||||||
|
postfix += L")";
|
||||||
|
}
|
||||||
|
|
||||||
|
PrepareNewFileName(url, postfix, temp_url);
|
||||||
|
|
||||||
|
CalcItemsHelper helper = calc_items_by_url(parent_id, temp_url);
|
||||||
|
|
||||||
|
if( helper.size > 0 )
|
||||||
|
{
|
||||||
|
is_that_url = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
url = temp_url;
|
||||||
|
is_that_url = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
|
while( is_that_url && index <= max_index );
|
||||||
|
|
||||||
|
return !is_that_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Item::propagate_connector()
|
||||||
|
{
|
||||||
|
item_content.set_connector(model_connector);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// IMPROVEME move me to a better place
|
||||||
|
void Item::print_dir(EzcEnv & env)
|
||||||
|
{
|
||||||
|
Request * req = get_request();
|
||||||
|
|
||||||
|
if( req )
|
||||||
|
{
|
||||||
|
for(size_t a=0 ; a < req->dir_tab.size() ; ++a)
|
||||||
|
env.out << req->dir_tab[a]->url << '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// IMPROVEME move me to a better place
|
||||||
|
void Item::print_dir_without_slash(EzcEnv & env)
|
||||||
|
{
|
||||||
|
Request * req = get_request();
|
||||||
|
|
||||||
|
if( req )
|
||||||
|
{
|
||||||
|
for(size_t a=0 ; a < req->dir_tab.size() ; ++a)
|
||||||
|
{
|
||||||
|
env.out << req->dir_tab[a]->url;
|
||||||
|
|
||||||
|
if( a < req->dir_tab.size()-1 )
|
||||||
|
env.out << '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Item::dir_link(EzcEnv & env)
|
||||||
|
{
|
||||||
|
Dirs * dirs = get_dirs();
|
||||||
|
std::vector<Item*> dir_tab;
|
||||||
|
|
||||||
|
if( dirs && dirs->CreateDirTab(parent_id, dir_tab) )
|
||||||
|
{
|
||||||
|
for(Item * pitem : dir_tab)
|
||||||
|
{
|
||||||
|
env.out << pitem->url << '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Item::link(EzcEnv & env)
|
||||||
|
{
|
||||||
|
Config * config = get_config();
|
||||||
|
Request * req = get_request();
|
||||||
|
|
||||||
|
if( config && req )
|
||||||
|
{
|
||||||
|
TemplatesFunctions::doc_proto(env);
|
||||||
|
|
||||||
|
if( !req->subdomain.empty() )
|
||||||
|
env.out << req->subdomain << '.';
|
||||||
|
|
||||||
|
env.out << config->base_url;
|
||||||
|
|
||||||
|
if( parent_id == req->dir_tab.back()->id )
|
||||||
|
{
|
||||||
|
print_dir(env);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dir_link(env);
|
||||||
|
}
|
||||||
|
|
||||||
|
env.out << url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Item::is_parent_for_current_dir() const
|
||||||
|
{
|
||||||
|
bool res = false;
|
||||||
|
const Request * req = get_request();
|
||||||
|
|
||||||
|
if( req )
|
||||||
|
{
|
||||||
|
if( req->dir_tab.size() > 1 )
|
||||||
|
{
|
||||||
|
res = (id == req->dir_tab[req->dir_tab.size() - 2]->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Item::is_current_dir() const
|
||||||
|
{
|
||||||
|
bool res = false;
|
||||||
|
const Request * req = get_request();
|
||||||
|
|
||||||
|
if( req )
|
||||||
|
{
|
||||||
|
res = (id == req->dir_tab.back()->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Item::url_is(EzcEnv & env)
|
||||||
|
{
|
||||||
|
env.res = (url == env.par);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace Winix
|
} // namespace Winix
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
|
|
||||||
#include "funinfo.h"
|
#include "funinfo.h"
|
||||||
#include "templates/htmltextstream.h"
|
#include "templates/htmltextstream.h"
|
||||||
|
#include "templates/misc.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,16 +184,23 @@ public:
|
||||||
|
|
||||||
void propagate_connector();
|
void propagate_connector();
|
||||||
|
|
||||||
|
bool can_remove_child(const User * current_user, long child_user_id) const;
|
||||||
|
bool can_be_removed(const User * current_user) const;
|
||||||
|
bool can_remove_child(long child_user_id) const;
|
||||||
|
bool can_be_removed() const;
|
||||||
|
|
||||||
void print_dir(Ezc::FunInfo<HtmlTextStream> & env);
|
bool has_read_access();
|
||||||
void print_dir_without_slash(Ezc::FunInfo<HtmlTextStream> & env);
|
bool has_write_access();
|
||||||
|
|
||||||
|
bool type_is_symlink() const;
|
||||||
|
bool type_is_file() const;
|
||||||
|
bool type_is_dir() const;
|
||||||
|
bool type_is_none() const;
|
||||||
|
|
||||||
|
bool is_root_dir() const;
|
||||||
|
bool is_parent_for_current_dir() const;
|
||||||
|
bool is_current_dir() const;
|
||||||
|
|
||||||
void is(Ezc::FunInfo<HtmlTextStream> & env);
|
|
||||||
void dir_link(Ezc::FunInfo<HtmlTextStream> & env);
|
|
||||||
void link(Ezc::FunInfo<HtmlTextStream> & env);
|
|
||||||
void is_parent_for_current_dir(Ezc::FunInfo<HtmlTextStream> & env);
|
|
||||||
void is_current_dir(Ezc::FunInfo<HtmlTextStream> & env);
|
|
||||||
void is_root(Ezc::FunInfo<HtmlTextStream> & env);
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -204,7 +212,17 @@ protected:
|
||||||
bool do_migration_to_3();
|
bool do_migration_to_3();
|
||||||
bool do_migration_to_4();
|
bool do_migration_to_4();
|
||||||
|
|
||||||
|
void print_dir(EzcEnv & env);
|
||||||
|
void print_dir_without_slash(EzcEnv & env);
|
||||||
|
void dir_link(EzcEnv & env);
|
||||||
|
void link(EzcEnv & env);
|
||||||
|
|
||||||
|
void url_is(EzcEnv & env);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MORM_MEMBER_FIELD(Item)
|
MORM_MEMBER_FIELD(Item)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,9 @@
|
||||||
#include "core/misc.h"
|
#include "core/misc.h"
|
||||||
#include "templates/misc.h"
|
#include "templates/misc.h"
|
||||||
#include "core/bbcodeparser.h"
|
#include "core/bbcodeparser.h"
|
||||||
|
#include "core/request.h"
|
||||||
|
#include "core/users.h"
|
||||||
|
#include "core/groups.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Winix
|
namespace Winix
|
||||||
|
@ -83,7 +86,23 @@ void ItemContent::fields()
|
||||||
field(L"meta_admin", meta_admin);
|
field(L"meta_admin", meta_admin);
|
||||||
|
|
||||||
field(L"print_content", &ItemContent::print_content);
|
field(L"print_content", &ItemContent::print_content);
|
||||||
|
field(L"has_static_file", &ItemContent::has_static_file);
|
||||||
|
field(L"privileges_octal", &ItemContent::privileges_octal);
|
||||||
|
field(L"user_name", &ItemContent::user_name);
|
||||||
|
field(L"group_name", &ItemContent::group_name);
|
||||||
|
field(L"type_is", &ItemContent::type_is);
|
||||||
|
field(L"is_empty", &ItemContent::is_empty);
|
||||||
|
|
||||||
|
field(L"file_type_is_none", &ItemContent::file_type_is_none);
|
||||||
|
field(L"file_type_is_image", &ItemContent::file_type_is_image);
|
||||||
|
field(L"file_type_is_video", &ItemContent::file_type_is_video);
|
||||||
|
field(L"file_type_is_sound", &ItemContent::file_type_is_sound);
|
||||||
|
|
||||||
|
field(L"has_thumb", &ItemContent::has_thumb);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 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);
|
||||||
content_parsed_type = static_cast<ContentType>(content_parsed_type_helper);
|
content_parsed_type = static_cast<ContentType>(content_parsed_type_helper);
|
||||||
}
|
}
|
||||||
|
@ -153,66 +172,6 @@ void ItemContent::Clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* we're using the HtmlFilter only for those contents
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
bool ItemContent::CanContentBeHtmlFiltered(ItemContent::ContentType ct)
|
|
||||||
{
|
|
||||||
return ct == ct_text || ct == ct_formatted_text || ct == ct_html || ct == ct_bbcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ItemContent::CanContentBeHtmlFiltered()
|
|
||||||
{
|
|
||||||
return CanContentBeHtmlFiltered(content_raw_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ItemContent::print_content(HtmlTextStream & out, const std::wstring & content, ItemContent::ContentType content_type, bool is_html_filter_on)
|
|
||||||
{
|
|
||||||
using TemplatesFunctions::R;
|
|
||||||
|
|
||||||
if( is_html_filter_on && !ItemContent::CanContentBeHtmlFiltered(content_type) )
|
|
||||||
out << R("<nofilter>");
|
|
||||||
|
|
||||||
if( content_type == ItemContent::ct_text )
|
|
||||||
{
|
|
||||||
out << content;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( content_type == ItemContent::ct_formatted_text )
|
|
||||||
{
|
|
||||||
TemplatesFunctions::HtmlEscapeFormTxt(out, content);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( content_type == ItemContent::ct_bbcode )
|
|
||||||
{
|
|
||||||
static std::wstring out_temp;
|
|
||||||
out_temp.clear();
|
|
||||||
out_temp.reserve(content.size()*2);
|
|
||||||
|
|
||||||
BBCODEParser bbcode_parser; // IMPROVE ME move me to a better place
|
|
||||||
bbcode_parser.Filter(content.c_str(), out_temp);
|
|
||||||
out << R(out_temp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// ct_html, ct_other
|
|
||||||
out << R(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( is_html_filter_on && !ItemContent::CanContentBeHtmlFiltered(content_type) )
|
|
||||||
out << R("</nofilter>");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ItemContent::print_content(Ezc::FunInfo<HtmlTextStream> & env)
|
|
||||||
{
|
|
||||||
print_content(env.out, content_raw, content_raw_type, true); // IMPROVE ME get the 'true' from the config (config->html_filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool ItemContent::do_migration(int & current_table_version)
|
bool ItemContent::do_migration(int & current_table_version)
|
||||||
{
|
{
|
||||||
|
@ -305,6 +264,268 @@ bool ItemContent::do_migration_to_3()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ItemContent::has_access(const User * current_user, int mask) const
|
||||||
|
{
|
||||||
|
if( current_user )
|
||||||
|
{
|
||||||
|
if( current_user->super_user )
|
||||||
|
{
|
||||||
|
// super user is allowed everything
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( user_id != -1 && current_user->id == user_id )
|
||||||
|
{
|
||||||
|
// the owner
|
||||||
|
return ((privileges >> 9) & mask) == mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( group_id != -1 && current_user->IsMemberOf(group_id) )
|
||||||
|
{
|
||||||
|
// group
|
||||||
|
return ((privileges >> 6) & mask) == mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
// others -- others logged users
|
||||||
|
return ((privileges >> 3) & mask) == mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
// guests -- not logged users
|
||||||
|
return (privileges & mask) == mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ItemContent::has_read_access(const User * current_user) const
|
||||||
|
{
|
||||||
|
return has_access(current_user, 4); // r
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ItemContent::has_write_access(const User * current_user) const
|
||||||
|
{
|
||||||
|
return has_access(current_user, 2); // w
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ItemContent::has_read_write_access(const User * current_user) const
|
||||||
|
{
|
||||||
|
return has_access(current_user, 6); // r+w
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ItemContent::has_read_exec_access(const User * current_user) const
|
||||||
|
{
|
||||||
|
if( current_user && current_user->super_user )
|
||||||
|
{
|
||||||
|
// there must be at least one 'x' (for the root)
|
||||||
|
// !! CHECK ME: is it applicable to directories too?
|
||||||
|
return (privileges & 01111) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return has_access(current_user, 5); // r+x
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ItemContent::has_read_access() const
|
||||||
|
{
|
||||||
|
return has_read_access(get_current_user());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ItemContent::has_write_access() const
|
||||||
|
{
|
||||||
|
return has_write_access(get_current_user());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ItemContent::has_read_write_access() const
|
||||||
|
{
|
||||||
|
return has_read_write_access(get_current_user());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ItemContent::has_read_exec_access() const
|
||||||
|
{
|
||||||
|
return has_read_exec_access(get_current_user());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ItemContent::is_sticky_bit_set() const
|
||||||
|
{
|
||||||
|
int mask = 010000;
|
||||||
|
return (privileges & mask) == mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* we're using the HtmlFilter only for those contents
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bool ItemContent::CanContentBeHtmlFiltered(ItemContent::ContentType ct)
|
||||||
|
{
|
||||||
|
return ct == ct_text || ct == ct_formatted_text || ct == ct_html || ct == ct_bbcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ItemContent::CanContentBeHtmlFiltered()
|
||||||
|
{
|
||||||
|
return CanContentBeHtmlFiltered(content_raw_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ItemContent::print_content(HtmlTextStream & out, const std::wstring & content, ItemContent::ContentType content_type, bool is_html_filter_on)
|
||||||
|
{
|
||||||
|
using TemplatesFunctions::R;
|
||||||
|
|
||||||
|
if( is_html_filter_on && !ItemContent::CanContentBeHtmlFiltered(content_type) )
|
||||||
|
out << R("<nofilter>");
|
||||||
|
|
||||||
|
if( content_type == ItemContent::ct_text )
|
||||||
|
{
|
||||||
|
out << content;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( content_type == ItemContent::ct_formatted_text )
|
||||||
|
{
|
||||||
|
TemplatesFunctions::HtmlEscapeFormTxt(out, content);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( content_type == ItemContent::ct_bbcode )
|
||||||
|
{
|
||||||
|
static std::wstring out_temp;
|
||||||
|
out_temp.clear();
|
||||||
|
out_temp.reserve(content.size()*2);
|
||||||
|
|
||||||
|
BBCODEParser bbcode_parser; // IMPROVE ME move me to a better place
|
||||||
|
bbcode_parser.Filter(content.c_str(), out_temp);
|
||||||
|
out << R(out_temp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ct_html, ct_other
|
||||||
|
out << R(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( is_html_filter_on && !ItemContent::CanContentBeHtmlFiltered(content_type) )
|
||||||
|
out << R("</nofilter>");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ItemContent::print_content(EzcEnv & env)
|
||||||
|
{
|
||||||
|
print_content(env.out, content_raw, content_raw_type, true); // IMPROVE ME get the 'true' from the config (config->html_filter)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ItemContent::has_static_file(EzcEnv & env)
|
||||||
|
{
|
||||||
|
env.res = file_type != WINIX_ITEM_FILETYPE_NONE && !file_path.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ItemContent::privileges_octal(EzcEnv & env)
|
||||||
|
{
|
||||||
|
env.out << Toa(privileges, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ItemContent::user_name(EzcEnv & env)
|
||||||
|
{
|
||||||
|
Users * users = get_users();
|
||||||
|
|
||||||
|
if( users )
|
||||||
|
{
|
||||||
|
User * puser = users->GetUser(user_id);
|
||||||
|
TemplatesFunctions::print_user_name(env, puser, guest_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ItemContent::group_name(EzcEnv & env)
|
||||||
|
{
|
||||||
|
Groups * groups = get_groups();
|
||||||
|
|
||||||
|
if( groups )
|
||||||
|
{
|
||||||
|
Group * pgroup = groups->GetGroup(group_id);
|
||||||
|
|
||||||
|
if( pgroup )
|
||||||
|
env.out << pgroup->name;
|
||||||
|
else
|
||||||
|
env.out << group_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ItemContent::type_is(EzcEnv & env)
|
||||||
|
{
|
||||||
|
if( content_raw_type == ItemContent::ct_text && env.par == L"text" )
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ItemContent::is_empty(EzcEnv & env)
|
||||||
|
{
|
||||||
|
env.res = content_raw.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ItemContent::file_type_is_none(EzcEnv & env)
|
||||||
|
{
|
||||||
|
env.res = file_type == WINIX_ITEM_FILETYPE_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* when we change file_type to string the we can return true only for
|
||||||
|
* those images which can be able to show by a webbrowser
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void ItemContent::file_type_is_image(EzcEnv & env)
|
||||||
|
{
|
||||||
|
env.res = file_type == WINIX_ITEM_FILETYPE_IMAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* similar we can return true only for those videos which can be rendered by a webbrowser
|
||||||
|
*/
|
||||||
|
void ItemContent::file_type_is_video(EzcEnv & env)
|
||||||
|
{
|
||||||
|
env.res = file_type == WINIX_ITEM_FILETYPE_VIDEO;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ItemContent::file_type_is_sound(EzcEnv & env)
|
||||||
|
{
|
||||||
|
//env.res = file_type == WINIX_ITEM_FILETYPE_;
|
||||||
|
env.res = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ItemContent::has_thumb(EzcEnv & env)
|
||||||
|
{
|
||||||
|
env.res = file_has_thumb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace Winix
|
} // namespace Winix
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,12 @@
|
||||||
#define headerfile_winix_models_itemcontent
|
#define headerfile_winix_models_itemcontent
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "winixmodel.h"
|
||||||
#include "space/space.h"
|
#include "space/space.h"
|
||||||
#include "date/date.h"
|
#include "date/date.h"
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
#include "templates/htmltextstream.h"
|
#include "templates/htmltextstream.h"
|
||||||
|
#include "templates/misc.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Winix
|
namespace Winix
|
||||||
|
@ -55,10 +57,33 @@ namespace Winix
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ItemContent : public morm::Model
|
class ItemContent : public WinixModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IMPROVEME
|
||||||
|
*
|
||||||
|
* the kind of content type would be better to be a string
|
||||||
|
* so instead of 'ContentType content_raw_type' we would have 'std::wstring content_raw_type'
|
||||||
|
* this allows us to use plugin system to define its own types such as markdown
|
||||||
|
*
|
||||||
|
* if we show an editor (such as emacs) then we call plugins with a specified message
|
||||||
|
* and each plugin will put a string if it provides a content type mechanism
|
||||||
|
* (we can have pt::Space as a parameter in plugins - this can be a table of strings)
|
||||||
|
*
|
||||||
|
* after user clicks 'save' button we send another message with content_raw and content_raw_type
|
||||||
|
* and we expect content_raw_parsed to be made by a plugin
|
||||||
|
*
|
||||||
|
* or we have two content_type strings, one for internal use and the other for locale files (to show to a user)
|
||||||
|
* or even three, the last one used as a description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* file_type should be a string, we can use libmagick library to get the correct type
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* may we should add ct_none? and this will be default (set in Clear method)
|
* may we should add ct_none? and this will be default (set in Clear method)
|
||||||
*/
|
*/
|
||||||
|
@ -124,7 +149,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* name of a link in the case when type is a symlink or a directory
|
* name of a link in the case whct_texten type is a symlink or a directory
|
||||||
*/
|
*/
|
||||||
std::wstring link_to;
|
std::wstring link_to;
|
||||||
|
|
||||||
|
@ -226,16 +251,24 @@ public:
|
||||||
* what about clear() from Model?
|
* what about clear() from Model?
|
||||||
*/
|
*/
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
static bool CanContentBeHtmlFiltered(ItemContent::ContentType ct);
|
|
||||||
bool CanContentBeHtmlFiltered();
|
|
||||||
|
|
||||||
|
|
||||||
static void print_content(HtmlTextStream & out, const std::wstring & content, ItemContent::ContentType content_type, bool is_html_filter_on);
|
|
||||||
void print_content(Ezc::FunInfo<HtmlTextStream> & env);
|
|
||||||
|
|
||||||
bool do_migration(int & current_table_version);
|
bool do_migration(int & current_table_version);
|
||||||
|
|
||||||
|
static bool CanContentBeHtmlFiltered(ItemContent::ContentType ct);
|
||||||
|
static void print_content(HtmlTextStream & out, const std::wstring & content, ItemContent::ContentType content_type, bool is_html_filter_on);
|
||||||
|
|
||||||
|
bool CanContentBeHtmlFiltered();
|
||||||
|
|
||||||
|
bool has_read_access(const User * current_user) const;
|
||||||
|
bool has_write_access(const User * current_user) const;
|
||||||
|
bool has_read_write_access(const User * current_user) const;
|
||||||
|
bool has_read_exec_access(const User * current_user) const;
|
||||||
|
|
||||||
|
bool has_read_access() const;
|
||||||
|
bool has_write_access() const;
|
||||||
|
bool has_read_write_access() const;
|
||||||
|
bool has_read_exec_access() const;
|
||||||
|
|
||||||
|
bool is_sticky_bit_set() const;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -244,6 +277,22 @@ protected:
|
||||||
bool do_migration_to_2();
|
bool do_migration_to_2();
|
||||||
bool do_migration_to_3();
|
bool do_migration_to_3();
|
||||||
|
|
||||||
|
bool has_access(const User * current_user, int mask) const;
|
||||||
|
|
||||||
|
void print_content(EzcEnv & env);
|
||||||
|
void has_static_file(EzcEnv & env);
|
||||||
|
void privileges_octal(EzcEnv & env);
|
||||||
|
void user_name(EzcEnv & env);
|
||||||
|
void group_name(EzcEnv & env);
|
||||||
|
void type_is(EzcEnv & env);
|
||||||
|
void is_empty(EzcEnv & env);
|
||||||
|
void file_type_is_none(EzcEnv & env);
|
||||||
|
void file_type_is_image(EzcEnv & env);
|
||||||
|
void file_type_is_video(EzcEnv & env);
|
||||||
|
void file_type_is_sound(EzcEnv & env);
|
||||||
|
void has_thumb(EzcEnv & env);
|
||||||
|
|
||||||
|
|
||||||
MORM_MEMBER_FIELD(ItemContent)
|
MORM_MEMBER_FIELD(ItemContent)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -125,11 +125,11 @@ void User::clear_passwords()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool User::IsMemberOf(long group)
|
bool User::IsMemberOf(long group) const
|
||||||
{
|
{
|
||||||
std::vector<long>::iterator i;
|
std::vector<long>::const_iterator i;
|
||||||
|
|
||||||
for(i=groups.begin() ; i!=groups.end() ; ++i)
|
for(i=groups.cbegin() ; i!=groups.cend() ; ++i)
|
||||||
if( *i == group )
|
if( *i == group )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ public:
|
||||||
void after_select();
|
void after_select();
|
||||||
|
|
||||||
void Clear(); // IMPROVEME what about clear() from Model?
|
void Clear(); // IMPROVEME what about clear() from Model?
|
||||||
bool IsMemberOf(long group);
|
bool IsMemberOf(long group) const;
|
||||||
bool ReadMonthDayTime(pt::Date & date, const wchar_t * str);
|
bool ReadMonthDayTime(pt::Date & date, const wchar_t * str);
|
||||||
bool SetTzFromEnv();
|
bool SetTzFromEnv();
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "winixmodel.h"
|
#include "winixmodel.h"
|
||||||
|
#include "core/session.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Winix
|
namespace Winix
|
||||||
{
|
{
|
||||||
|
@ -141,6 +144,162 @@ SLog * WinixModel::get_session_logger()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Session * WinixModel::get_session()
|
||||||
|
{
|
||||||
|
WinixModelConnector * connector = get_winix_model_connector();
|
||||||
|
|
||||||
|
if( connector )
|
||||||
|
{
|
||||||
|
return connector->get_winix_session();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
User * WinixModel::get_current_user()
|
||||||
|
{
|
||||||
|
Session * session = get_session();
|
||||||
|
|
||||||
|
if( session )
|
||||||
|
{
|
||||||
|
return session->puser;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const Config * WinixModel::get_config() const
|
||||||
|
{
|
||||||
|
const WinixModelConnector * connector = get_winix_model_connector();
|
||||||
|
|
||||||
|
if( connector )
|
||||||
|
{
|
||||||
|
return connector->get_winix_config();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Request * WinixModel::get_request() const
|
||||||
|
{
|
||||||
|
const WinixModelConnector * connector = get_winix_model_connector();
|
||||||
|
|
||||||
|
if( connector )
|
||||||
|
{
|
||||||
|
return connector->get_winix_request();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Log * WinixModel::get_logger() const
|
||||||
|
{
|
||||||
|
const WinixModelConnector * connector = get_winix_model_connector();
|
||||||
|
|
||||||
|
if( connector )
|
||||||
|
{
|
||||||
|
return connector->get_winix_logger();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Dirs * WinixModel::get_dirs() const
|
||||||
|
{
|
||||||
|
const WinixModelConnector * connector = get_winix_model_connector();
|
||||||
|
|
||||||
|
if( connector )
|
||||||
|
{
|
||||||
|
return connector->get_winix_dirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Mounts * WinixModel::get_mounts() const
|
||||||
|
{
|
||||||
|
const WinixModelConnector * connector = get_winix_model_connector();
|
||||||
|
|
||||||
|
if( connector )
|
||||||
|
{
|
||||||
|
return connector->get_winix_mounts();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Users * WinixModel::get_users() const
|
||||||
|
{
|
||||||
|
const WinixModelConnector * connector = get_winix_model_connector();
|
||||||
|
|
||||||
|
if( connector )
|
||||||
|
{
|
||||||
|
return connector->get_winix_users();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Groups * WinixModel::get_groups() const
|
||||||
|
{
|
||||||
|
const WinixModelConnector * connector = get_winix_model_connector();
|
||||||
|
|
||||||
|
if( connector )
|
||||||
|
{
|
||||||
|
return connector->get_winix_groups();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const SLog * WinixModel::get_session_logger() const
|
||||||
|
{
|
||||||
|
const WinixModelConnector * connector = get_winix_model_connector();
|
||||||
|
|
||||||
|
if( connector )
|
||||||
|
{
|
||||||
|
return connector->get_winix_session_logger();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Session * WinixModel::get_session() const
|
||||||
|
{
|
||||||
|
const WinixModelConnector * connector = get_winix_model_connector();
|
||||||
|
|
||||||
|
if( connector )
|
||||||
|
{
|
||||||
|
return connector->get_winix_session();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const User * WinixModel::get_current_user() const
|
||||||
|
{
|
||||||
|
const Session * session = get_session();
|
||||||
|
|
||||||
|
if( session )
|
||||||
|
{
|
||||||
|
return session->puser;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,6 +314,16 @@ WinixModelConnector * WinixModel::get_winix_model_connector()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const WinixModelConnector * WinixModel::get_winix_model_connector() const
|
||||||
|
{
|
||||||
|
if( model_connector )
|
||||||
|
{
|
||||||
|
return dynamic_cast<const WinixModelConnector*>(model_connector);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,9 @@ class Mounts;
|
||||||
class Users;
|
class Users;
|
||||||
class Groups;
|
class Groups;
|
||||||
class SLog;
|
class SLog;
|
||||||
|
class Session;
|
||||||
|
class User;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class WinixModel : public morm::Model
|
class WinixModel : public morm::Model
|
||||||
|
@ -64,10 +67,24 @@ public:
|
||||||
Users * get_users();
|
Users * get_users();
|
||||||
Groups * get_groups();
|
Groups * get_groups();
|
||||||
SLog * get_session_logger(); // FIXME always return null at the moment, should be set when a new request is created and clear at the end of a request
|
SLog * get_session_logger(); // FIXME always return null at the moment, should be set when a new request is created and clear at the end of a request
|
||||||
|
Session * get_session();
|
||||||
|
User * get_current_user();
|
||||||
|
|
||||||
|
const Config * get_config() const;
|
||||||
|
const Request * get_request() const;
|
||||||
|
const Log * get_logger() const; // there is no need for logger to be const, we can do nothing with such a logger
|
||||||
|
const Dirs * get_dirs() const;
|
||||||
|
const Mounts * get_mounts() const;
|
||||||
|
const Users * get_users() const;
|
||||||
|
const Groups * get_groups() const;
|
||||||
|
const SLog * get_session_logger() const; // FIXME always return null at the moment, should be set when a new request is created and clear at the end of a request
|
||||||
|
const Session * get_session() const;
|
||||||
|
const User * get_current_user() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
WinixModelConnector * get_winix_model_connector();
|
WinixModelConnector * get_winix_model_connector();
|
||||||
|
const WinixModelConnector * get_winix_model_connector() const;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,6 +49,7 @@ WinixModelConnector::WinixModelConnector()
|
||||||
users = nullptr;
|
users = nullptr;
|
||||||
groups = nullptr;
|
groups = nullptr;
|
||||||
slog = nullptr;
|
slog = nullptr;
|
||||||
|
session = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,12 +94,74 @@ Groups * WinixModelConnector::get_winix_groups()
|
||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SLog * WinixModelConnector::get_winix_session_logger()
|
SLog * WinixModelConnector::get_winix_session_logger()
|
||||||
{
|
{
|
||||||
return slog;
|
return slog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Session * WinixModelConnector::get_winix_session()
|
||||||
|
{
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Config * WinixModelConnector::get_winix_config() const
|
||||||
|
{
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Request * WinixModelConnector::get_winix_request() const
|
||||||
|
{
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Log * WinixModelConnector::get_winix_logger() const
|
||||||
|
{
|
||||||
|
return log;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Dirs * WinixModelConnector::get_winix_dirs() const
|
||||||
|
{
|
||||||
|
return dirs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Mounts * WinixModelConnector::get_winix_mounts() const
|
||||||
|
{
|
||||||
|
return mounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Users * WinixModelConnector::get_winix_users() const
|
||||||
|
{
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Groups * WinixModelConnector::get_winix_groups() const
|
||||||
|
{
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const SLog * WinixModelConnector::get_winix_session_logger() const
|
||||||
|
{
|
||||||
|
return slog;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Session * WinixModelConnector::get_winix_session() const
|
||||||
|
{
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WinixModelConnector::set_winix_config(Config * config)
|
void WinixModelConnector::set_winix_config(Config * config)
|
||||||
{
|
{
|
||||||
this->config = config;
|
this->config = config;
|
||||||
|
@ -140,11 +203,18 @@ void WinixModelConnector::set_winix_groups(Groups * groups)
|
||||||
this->groups = groups;
|
this->groups = groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WinixModelConnector::set_winix_session_logger(SLog * slog)
|
void WinixModelConnector::set_winix_session_logger(SLog * slog)
|
||||||
{
|
{
|
||||||
this->slog = slog;
|
this->slog = slog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WinixModelConnector::set_winix_session(Session * session)
|
||||||
|
{
|
||||||
|
this->session = session;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ class Mounts;
|
||||||
class Users;
|
class Users;
|
||||||
class Groups;
|
class Groups;
|
||||||
class SLog;
|
class SLog;
|
||||||
|
class Session;
|
||||||
|
|
||||||
|
|
||||||
class WinixModelConnector : public morm::ModelConnector
|
class WinixModelConnector : public morm::ModelConnector
|
||||||
|
@ -64,6 +65,17 @@ public:
|
||||||
Users * get_winix_users();
|
Users * get_winix_users();
|
||||||
Groups * get_winix_groups();
|
Groups * get_winix_groups();
|
||||||
SLog * get_winix_session_logger();
|
SLog * get_winix_session_logger();
|
||||||
|
Session * get_winix_session();
|
||||||
|
|
||||||
|
const Config * get_winix_config() const;
|
||||||
|
const Request * get_winix_request() const;
|
||||||
|
const Log * get_winix_logger() const;
|
||||||
|
const Dirs * get_winix_dirs() const;
|
||||||
|
const Mounts * get_winix_mounts() const;
|
||||||
|
const Users * get_winix_users() const;
|
||||||
|
const Groups * get_winix_groups() const;
|
||||||
|
const SLog * get_winix_session_logger() const;
|
||||||
|
const Session * get_winix_session() const;
|
||||||
|
|
||||||
void set_winix_config(Config * config);
|
void set_winix_config(Config * config);
|
||||||
void set_winix_request(Request * request);
|
void set_winix_request(Request * request);
|
||||||
|
@ -73,6 +85,7 @@ public:
|
||||||
void set_winix_users(Users * users);
|
void set_winix_users(Users * users);
|
||||||
void set_winix_groups(Groups * groups);
|
void set_winix_groups(Groups * groups);
|
||||||
void set_winix_session_logger(SLog * slog);
|
void set_winix_session_logger(SLog * slog);
|
||||||
|
void set_winix_session(Session * session);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -85,6 +98,7 @@ protected:
|
||||||
Users * users;
|
Users * users;
|
||||||
Groups * groups;
|
Groups * groups;
|
||||||
SLog * slog;
|
SLog * slog;
|
||||||
|
Session * session;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace Winix
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
struct Request;
|
class Request;
|
||||||
class Config;
|
class Config;
|
||||||
class Users;
|
class Users;
|
||||||
class Dirs;
|
class Dirs;
|
||||||
|
|
|
@ -53,151 +53,152 @@ static EzcGen ezc_generator;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void item_is(Info & i)
|
//void item_is(Info & i)
|
||||||
{
|
//{
|
||||||
i.res = cur->request->is_item;
|
// i.res = cur->request->is_item;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_no_is(Info & i)
|
//void item_no_is(Info & i)
|
||||||
{
|
//{
|
||||||
i.res = !cur->request->is_item;
|
// i.res = !cur->request->is_item;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_id(Info & i)
|
//void item_id(Info & i)
|
||||||
{
|
//{
|
||||||
i.out << cur->request->last_item->id;
|
// i.out << cur->request->last_item->id;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void item_subject(Info & i)
|
//void item_subject(Info & i)
|
||||||
{
|
//{
|
||||||
i.out << cur->request->last_item->subject;
|
// i.out << cur->request->last_item->subject;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_subject_noescape(Info & i)
|
//void item_subject_noescape(Info & i)
|
||||||
{
|
//{
|
||||||
i.out << R(cur->request->last_item->subject);
|
// i.out << R(cur->request->last_item->subject);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void item_content(Info & i)
|
//void item_content(Info & i)
|
||||||
{
|
//{
|
||||||
i.out << cur->request->last_item->item_content.content_raw;
|
// i.out << cur->request->last_item->item_content.content_raw;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void item_content_noescape(Info & i)
|
//void item_content_noescape(Info & i)
|
||||||
{
|
//{
|
||||||
i.out << R(cur->request->last_item->item_content.content_raw);
|
// i.out << R(cur->request->last_item->item_content.content_raw);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_content_type_is(Item & item, Info & i)
|
//void item_content_type_is(Item & item, Info & i)
|
||||||
{
|
//{
|
||||||
i.res = false;
|
// i.res = false;
|
||||||
|
//
|
||||||
if( item.item_content.content_raw_type == ItemContent::ct_text && i.par == L"text" )
|
// if( item.item_content.content_raw_type == ItemContent::ct_text && i.par == L"text" )
|
||||||
i.res = true;
|
// i.res = true;
|
||||||
else
|
// else
|
||||||
if( item.item_content.content_raw_type == ItemContent::ct_formatted_text && i.par == L"formatted text" )
|
// if( item.item_content.content_raw_type == ItemContent::ct_formatted_text && i.par == L"formatted text" )
|
||||||
i.res = true;
|
// i.res = true;
|
||||||
else
|
// else
|
||||||
if( item.item_content.content_raw_type == ItemContent::ct_html && i.par == L"html" )
|
// if( item.item_content.content_raw_type == ItemContent::ct_html && i.par == L"html" )
|
||||||
i.res = true;
|
// i.res = true;
|
||||||
else
|
// else
|
||||||
if( item.item_content.content_raw_type == ItemContent::ct_bbcode && i.par == L"bbcode" )
|
// if( item.item_content.content_raw_type == ItemContent::ct_bbcode && i.par == L"bbcode" )
|
||||||
i.res = true;
|
// i.res = true;
|
||||||
else
|
// else
|
||||||
if( item.item_content.content_raw_type == ItemContent::ct_other && i.par == L"other" )
|
// if( item.item_content.content_raw_type == ItemContent::ct_other && i.par == L"other" )
|
||||||
i.res = true;
|
// i.res = true;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//void item_content_type_is(Info & i)
|
||||||
|
//{
|
||||||
|
// item_content_type_is(*cur->request->last_item, i);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_content_type_is(Info & i)
|
//void item_content_is_empty(Info & i)
|
||||||
{
|
//{
|
||||||
item_content_type_is(*cur->request->last_item, i);
|
// i.res = cur->request->last_item->item_content.content_raw.empty();
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_content_is_empty(Info & i)
|
//void item_privileges(Info & i)
|
||||||
{
|
//{
|
||||||
i.res = cur->request->last_item->item_content.content_raw.empty();
|
// i.out << Toa(cur->request->last_item->item_content.privileges, 8);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_privileges(Info & i)
|
// RENAMED TO item.dir_link
|
||||||
{
|
//void item_dir(Info & i)
|
||||||
i.out << Toa(cur->request->last_item->item_content.privileges, 8);
|
//{
|
||||||
}
|
// dir(i);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_dir(Info & i)
|
//void item_url(Info & i)
|
||||||
{
|
//{
|
||||||
dir(i);
|
// i.out << cur->request->last_item->url;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_url(Info & i)
|
//void item_url_is(Info & i)
|
||||||
{
|
//{
|
||||||
i.out << cur->request->last_item->url;
|
// i.res = (cur->request->last_item->url == i.par);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_url_is(Info & i)
|
//void item_url_is_no(Info & i)
|
||||||
{
|
//{
|
||||||
i.res = (cur->request->last_item->url == i.par);
|
// i.res = (cur->request->last_item->url != i.par);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_url_is_no(Info & i)
|
//void item_link(Info & i)
|
||||||
{
|
//{
|
||||||
i.res = (cur->request->last_item->url != i.par);
|
// doc_proto(i);
|
||||||
}
|
//
|
||||||
|
// if( !cur->request->subdomain.empty() )
|
||||||
|
// i.out << cur->request->subdomain << '.';
|
||||||
void item_link(Info & i)
|
//
|
||||||
{
|
// i.out << config->base_url;
|
||||||
doc_proto(i);
|
// item_dir(i);
|
||||||
|
// item_url(i);
|
||||||
if( !cur->request->subdomain.empty() )
|
//}
|
||||||
i.out << cur->request->subdomain << '.';
|
|
||||||
|
|
||||||
i.out << config->base_url;
|
|
||||||
item_dir(i);
|
|
||||||
item_url(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void item_filetype_is_none(Info & i)
|
//void item_filetype_is_none(Info & i)
|
||||||
{
|
//{
|
||||||
i.res = cur->request->last_item->item_content.file_type == WINIX_ITEM_FILETYPE_NONE;
|
// i.res = cur->request->last_item->item_content.file_type == WINIX_ITEM_FILETYPE_NONE;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//void item_filetype_is_image(Info & i)
|
||||||
|
//{
|
||||||
|
// i.res = cur->request->last_item->item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_filetype_is_image(Info & i)
|
//void item_has_static_file(Info & i)
|
||||||
{
|
//{
|
||||||
i.res = cur->request->last_item->item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE;
|
// i.res = cur->request->last_item->item_content.file_type != WINIX_ITEM_FILETYPE_NONE && !cur->request->last_item->item_content.file_path.empty();
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_has_static_file(Info & i)
|
//void item_has_thumb(Info & i)
|
||||||
{
|
//{
|
||||||
i.res = cur->request->last_item->item_content.file_type != WINIX_ITEM_FILETYPE_NONE && !cur->request->last_item->item_content.file_path.empty();
|
// i.res = cur->request->last_item->item_content.file_has_thumb;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_has_thumb(Info & i)
|
|
||||||
{
|
|
||||||
i.res = cur->request->last_item->item_content.file_has_thumb;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void item_can_read(Info & i)
|
void item_can_read(Info & i)
|
||||||
|
@ -220,11 +221,11 @@ void item_can_remove(Info & i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void item_user(Info & i)
|
//void item_user(Info & i)
|
||||||
{
|
//{
|
||||||
User * puser = system->users.GetUser(cur->request->last_item->item_content.user_id);
|
// User * puser = system->users.GetUser(cur->request->last_item->item_content.user_id);
|
||||||
print_user_name(i, puser, cur->request->last_item->item_content.guest_name);
|
// print_user_name(i, puser, cur->request->last_item->item_content.guest_name);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -325,22 +326,22 @@ void item_has_html_template(Info & i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void item_type_is_dir(Info & i)
|
//void item_type_is_dir(Info & i)
|
||||||
{
|
//{
|
||||||
i.res = cur->request->last_item->type == Item::dir;
|
// i.res = cur->request->last_item->type == Item::dir;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
void item_type_is_file(Info & i)
|
//void item_type_is_file(Info & i)
|
||||||
{
|
//{
|
||||||
i.res = cur->request->last_item->type == Item::file;
|
// i.res = cur->request->last_item->type == Item::file;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
void item_type_is_symlink(Info & i)
|
//void item_type_is_symlink(Info & i)
|
||||||
{
|
//{
|
||||||
i.res = cur->request->last_item->type == Item::symlink;
|
// i.res = cur->request->last_item->type == Item::symlink;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void item_is_link_to(Info & i)
|
void item_is_link_to(Info & i)
|
||||||
|
|
|
@ -155,6 +155,7 @@ void print_user_name(Info & i, User & user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// IMPROVEME move me to User class
|
||||||
void print_user_name(Info & i, User * puser, const std::wstring & guest_name)
|
void print_user_name(Info & i, User * puser, const std::wstring & guest_name)
|
||||||
{
|
{
|
||||||
if( puser )
|
if( puser )
|
||||||
|
|
|
@ -47,6 +47,9 @@ namespace Winix
|
||||||
|
|
||||||
class User;
|
class User;
|
||||||
|
|
||||||
|
// Ezc::FunInfo<> will be renamed to Ezc::Env<> in the future
|
||||||
|
typedef Ezc::FunInfo<HtmlTextStream> EzcEnv;
|
||||||
|
|
||||||
|
|
||||||
namespace TemplatesFunctions
|
namespace TemplatesFunctions
|
||||||
{
|
{
|
||||||
|
@ -54,7 +57,7 @@ namespace TemplatesFunctions
|
||||||
|
|
||||||
typedef Ezc::Functions<HtmlTextStream> EzcFun;
|
typedef Ezc::Functions<HtmlTextStream> EzcFun;
|
||||||
typedef Ezc::Generator<HtmlTextStream> EzcGen;
|
typedef Ezc::Generator<HtmlTextStream> EzcGen;
|
||||||
typedef Ezc::FunInfo<HtmlTextStream> Info;
|
typedef Ezc::FunInfo<HtmlTextStream> Info; // deprecated
|
||||||
|
|
||||||
template<class RawType>
|
template<class RawType>
|
||||||
HtmlTextStream::RawText<RawType> R(const RawType & par)
|
HtmlTextStream::RawText<RawType> R(const RawType & par)
|
||||||
|
|
|
@ -432,30 +432,30 @@ void Templates::CreateFunctions()
|
||||||
/*
|
/*
|
||||||
item
|
item
|
||||||
*/
|
*/
|
||||||
ezc_functions.Insert("item_is", item_is);
|
//ezc_functions.Insert("item_is", item_is);
|
||||||
ezc_functions.Insert("item_no_is", item_no_is);
|
//ezc_functions.Insert("item_no_is", item_no_is);
|
||||||
ezc_functions.Insert("item_id", item_id);
|
// ezc_functions.Insert("item_id", item_id);
|
||||||
ezc_functions.Insert("item_subject", item_subject);
|
// ezc_functions.Insert("item_subject", item_subject);
|
||||||
ezc_functions.Insert("item_subject_noescape", item_subject_noescape);
|
// ezc_functions.Insert("item_subject_noescape", item_subject_noescape);
|
||||||
ezc_functions.Insert("item_content_is_empty", item_content_is_empty);
|
// ezc_functions.Insert("item_content_is_empty", item_content_is_empty);
|
||||||
ezc_functions.Insert("item_content", item_content);
|
// ezc_functions.Insert("item_content", item_content);
|
||||||
ezc_functions.Insert("item_content_noescape", item_content_noescape);
|
// ezc_functions.Insert("item_content_noescape", item_content_noescape);
|
||||||
ezc_functions.Insert("item_content_type_is", item_content_type_is);
|
// ezc_functions.Insert("item_content_type_is", item_content_type_is);
|
||||||
ezc_functions.Insert("item_privileges", item_privileges);
|
//ezc_functions.Insert("item_privileges", item_privileges);
|
||||||
ezc_functions.Insert("item_dir", item_dir);
|
// ezc_functions.Insert("item_dir", item_dir);
|
||||||
ezc_functions.Insert("item_url", item_url);
|
// ezc_functions.Insert("item_url", item_url);
|
||||||
ezc_functions.Insert("item_url_is", item_url_is);
|
// ezc_functions.Insert("item_url_is", item_url_is);
|
||||||
ezc_functions.Insert("item_url_is_no", item_url_is_no);
|
// ezc_functions.Insert("item_url_is_no", item_url_is_no);
|
||||||
ezc_functions.Insert("item_link", item_link);
|
// ezc_functions.Insert("item_link", item_link);
|
||||||
ezc_functions.Insert("item_filetype_is_none", item_filetype_is_none);
|
// ezc_functions.Insert("item_filetype_is_none", item_filetype_is_none);
|
||||||
ezc_functions.Insert("item_filetype_is_image", item_filetype_is_image);
|
// ezc_functions.Insert("item_filetype_is_image", item_filetype_is_image);
|
||||||
ezc_functions.Insert("item_has_static_file", item_has_static_file);
|
//ezc_functions.Insert("item_has_static_file", item_has_static_file);
|
||||||
ezc_functions.Insert("item_has_thumb", item_has_thumb);
|
// ezc_functions.Insert("item_has_thumb", item_has_thumb);
|
||||||
|
|
||||||
ezc_functions.Insert("item_can_read", item_can_read);
|
ezc_functions.Insert("item_can_read", item_can_read);
|
||||||
ezc_functions.Insert("item_can_write", item_can_write);
|
ezc_functions.Insert("item_can_write", item_can_write);
|
||||||
ezc_functions.Insert("item_can_remove", item_can_remove);
|
ezc_functions.Insert("item_can_remove", item_can_remove);
|
||||||
ezc_functions.Insert("item_user", item_user);
|
//ezc_functions.Insert("item_user", item_user);
|
||||||
ezc_functions.Insert("item_modification_user", item_modification_user);
|
ezc_functions.Insert("item_modification_user", item_modification_user);
|
||||||
ezc_functions.Insert("item_users_different", item_users_different);
|
ezc_functions.Insert("item_users_different", item_users_different);
|
||||||
ezc_functions.Insert("item_date_creation", item_date_creation);
|
ezc_functions.Insert("item_date_creation", item_date_creation);
|
||||||
|
@ -467,9 +467,9 @@ void Templates::CreateFunctions()
|
||||||
ezc_functions.Insert("item_guest_name", item_guest_name);
|
ezc_functions.Insert("item_guest_name", item_guest_name);
|
||||||
ezc_functions.Insert("item_html_template", item_html_template);
|
ezc_functions.Insert("item_html_template", item_html_template);
|
||||||
ezc_functions.Insert("item_has_html_template", item_has_html_template);
|
ezc_functions.Insert("item_has_html_template", item_has_html_template);
|
||||||
ezc_functions.Insert("item_type_is_dir", item_type_is_dir);
|
// ezc_functions.Insert("item_type_is_dir", item_type_is_dir);
|
||||||
ezc_functions.Insert("item_type_is_file", item_type_is_file);
|
// ezc_functions.Insert("item_type_is_file", item_type_is_file);
|
||||||
ezc_functions.Insert("item_type_is_symlink", item_type_is_symlink);
|
// ezc_functions.Insert("item_type_is_symlink", item_type_is_symlink);
|
||||||
ezc_functions.Insert("item_is_link_to", item_is_link_to);
|
ezc_functions.Insert("item_is_link_to", item_is_link_to);
|
||||||
ezc_functions.Insert("item_link_to", item_link_to);
|
ezc_functions.Insert("item_link_to", item_link_to);
|
||||||
ezc_functions.Insert("item_is_link_redirect", item_is_link_redirect);
|
ezc_functions.Insert("item_is_link_redirect", item_is_link_redirect);
|
||||||
|
|
|
@ -322,30 +322,30 @@ namespace TemplatesFunctions
|
||||||
/*
|
/*
|
||||||
item
|
item
|
||||||
*/
|
*/
|
||||||
void item_is(Info & i);
|
//void item_is(Info & i);
|
||||||
void item_no_is(Info & i);
|
//void item_no_is(Info & i);
|
||||||
void item_id(Info & i);
|
//void item_id(Info & i);
|
||||||
void item_subject(Info & i);
|
//void item_subject(Info & i);
|
||||||
void item_subject_noescape(Info & i);
|
//void item_subject_noescape(Info & i);
|
||||||
void item_content(Info & i);
|
//void item_content(Info & i);
|
||||||
void item_content_noescape(Info & i);
|
//void item_content_noescape(Info & i);
|
||||||
void item_content_type_is(Item & item, Info & i);
|
//void item_content_type_is(Item & item, Info & i);
|
||||||
void item_content_type_is(Info & i);
|
//void item_content_type_is(Info & i);
|
||||||
void item_content_is_empty(Info & i);
|
//void item_content_is_empty(Info & i);
|
||||||
void item_privileges(Info & i);
|
//void item_privileges(Info & i);
|
||||||
void item_dir(Info & i);
|
//void item_dir(Info & i); // RENAMED TO item.dir_link
|
||||||
void item_url(Info & i);
|
//void item_url(Info & i);
|
||||||
void item_url_is(Info & i);
|
//void item_url_is(Info & i);
|
||||||
void item_url_is_no(Info & i);
|
//void item_url_is_no(Info & i);
|
||||||
void item_link(Info & i);
|
//void item_link(Info & i);
|
||||||
void item_filetype_is_none(Info & i);
|
//void item_filetype_is_none(Info & i);
|
||||||
void item_filetype_is_image(Info & i);
|
//void item_filetype_is_image(Info & i);
|
||||||
void item_has_static_file(Info & i);
|
//void item_has_static_file(Info & i);
|
||||||
void item_has_thumb(Info & i);
|
//void item_has_thumb(Info & i);
|
||||||
void item_can_read(Info & i);
|
void item_can_read(Info & i);
|
||||||
void item_can_write(Info & i);
|
void item_can_write(Info & i);
|
||||||
void item_can_remove(Info & i);
|
void item_can_remove(Info & i);
|
||||||
void item_user(Info & i);
|
//void item_user(Info & i);
|
||||||
void item_modification_user(Info & i);
|
void item_modification_user(Info & i);
|
||||||
void item_users_different(Info & i);
|
void item_users_different(Info & i);
|
||||||
void item_date_creation(Info & i);
|
void item_date_creation(Info & i);
|
||||||
|
@ -357,9 +357,9 @@ namespace TemplatesFunctions
|
||||||
void item_guest_name(Info & i);
|
void item_guest_name(Info & i);
|
||||||
void item_html_template(Info & i);
|
void item_html_template(Info & i);
|
||||||
void item_has_html_template(Info & i);
|
void item_has_html_template(Info & i);
|
||||||
void item_type_is_dir(Info & i);
|
//void item_type_is_dir(Info & i);
|
||||||
void item_type_is_file(Info & i);
|
//void item_type_is_file(Info & i);
|
||||||
void item_type_is_symlink(Info & i);
|
//void item_type_is_symlink(Info & i);
|
||||||
void item_is_link_to(Info & i);
|
void item_is_link_to(Info & i);
|
||||||
void item_link_to(Info & i);
|
void item_link_to(Info & i);
|
||||||
void item_is_link_redirect(Info & i);
|
void item_is_link_redirect(Info & i);
|
||||||
|
|
Loading…
Reference in New Issue