Item class has been moved to a new directory 'models', a new class has been added: ItemContent
and same fields from Item were moved to ItemContent Item - id - parent_id - type (file, dir, symlink) - url - subject - template (html template) - sort_index - content_id ItemContent - id - ref -> references (renamed) - user_id - modification_user_id - group_id - privileges - date_creation - date_modification - guest_name - link_to - link_redirect - file_path - file_fs - file_type - file_size - has_thumb -> file_has_thumb (renamed) - hash -> file_hash (renamed) - hash_type -> file_hash_type (renamed) - content -> content_raw (renamed) - content_type -> content_raw_type (renamed) - content_parsed - content_parsed_type - meta - ameta -> meta_admin (renamed) - modify_index (removed) WIP: #4
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -80,7 +80,7 @@ bool Rm::HasAccessToDir(const Item & dir, bool only_content)
|
||||
// ops, there is no a parent dir
|
||||
return false;
|
||||
|
||||
if( !system->CanRemoveRenameChild(*last_but_one_dir, dir.user_id) )
|
||||
if( !system->CanRemoveRenameChild(*last_but_one_dir, dir.item_content.user_id) )
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ bool res = false;
|
||||
|
||||
if( cur->request->is_item )
|
||||
{
|
||||
res = system->CanRemoveRenameChild(*cur->request->dir_tab.back(), cur->request->item.user_id);
|
||||
res = system->CanRemoveRenameChild(*cur->request->dir_tab.back(), cur->request->item.item_content.user_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -131,16 +131,16 @@ return res;
|
||||
void Rm::Prepare()
|
||||
{
|
||||
// selecting files and symlinks (without directories)
|
||||
content_dir_iq.SetAll(false, false);
|
||||
content_dir_iq.sel_parent_id = true;
|
||||
content_dir_iq.sel_type = true;
|
||||
content_dir_iq.sel_url = true;
|
||||
content_dir_iq.sel_file = true;
|
||||
content_dir_iq.sel_user_id = true;
|
||||
content_dir_iq.sel_group_id = true;
|
||||
content_dir_iq.sel_privileges = true;
|
||||
content_dir_iq.sel_meta = true;
|
||||
content_dir_iq.WhereType(Item::dir, false);
|
||||
// content_dir_iq.SetAll(false, false);
|
||||
// content_dir_iq.sel_parent_id = true;
|
||||
// content_dir_iq.sel_type = true;
|
||||
// content_dir_iq.sel_url = true;
|
||||
// content_dir_iq.sel_file = true;
|
||||
// content_dir_iq.sel_user_id = true;
|
||||
// content_dir_iq.sel_group_id = true;
|
||||
// content_dir_iq.sel_privileges = true;
|
||||
// content_dir_iq.sel_meta = true;
|
||||
// content_dir_iq.WhereType(Item::dir, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ void Rm::RemoveStaticFile(const Item & item)
|
||||
{
|
||||
RemoveStaticFile(path);
|
||||
|
||||
if( item.has_thumb && system->MakeFilePath(item, path, true) )
|
||||
if( item.item_content.file_has_thumb && system->MakeFilePath(item, path, true) )
|
||||
RemoveStaticFile(path);
|
||||
}
|
||||
else
|
||||
@@ -190,7 +190,8 @@ bool Rm::RemoveFile(Item & item)
|
||||
{
|
||||
plugin->Call(WINIX_FILE_PREPARE_TO_REMOVE, &item);
|
||||
|
||||
if( db->DelItem(item) == WINIX_ERR_OK )
|
||||
//if( db->DelItem(item) == WINIX_ERR_OK )
|
||||
if( item.remove() )
|
||||
{
|
||||
if( item.type == Item::file )
|
||||
log << log2 << "Rm: deleted file: ";
|
||||
@@ -201,7 +202,7 @@ bool Rm::RemoveFile(Item & item)
|
||||
|
||||
TemplatesFunctions::pattern_cacher.DeletePattern(item);
|
||||
|
||||
if( item.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
if( item.item_content.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
RemoveStaticFile(item);
|
||||
|
||||
plugin->Call(WINIX_FILE_REMOVED, &item);
|
||||
@@ -230,7 +231,7 @@ bool Rm::RemoveFileOrSymlink(Item & item, bool check_access)
|
||||
// if there is not 'dir' directory then we can simply remove 'item'
|
||||
if( dir )
|
||||
{
|
||||
if( !system->CanRemoveRenameChild(*dir, item.user_id) )
|
||||
if( !system->CanRemoveRenameChild(*dir, item.item_content.user_id) )
|
||||
{
|
||||
log << log1 << "Rm: permission denied to remove: " << item.url << ", id: " << item.id << logend;
|
||||
slog << logerror << T("rm_permission_denied_to") << ": " << item.url << logend;
|
||||
@@ -248,18 +249,27 @@ bool Rm::RemoveFileOrSymlink(long item_id, bool check_access)
|
||||
bool result = false;
|
||||
|
||||
// selecting files, symlinks and directories
|
||||
rm_by_id_iq.SetAll(false, false);
|
||||
rm_by_id_iq.sel_parent_id = true;
|
||||
rm_by_id_iq.sel_type = true;
|
||||
rm_by_id_iq.sel_url = true;
|
||||
rm_by_id_iq.sel_file = true;
|
||||
rm_by_id_iq.sel_user_id = true;
|
||||
rm_by_id_iq.sel_group_id = true;
|
||||
rm_by_id_iq.sel_privileges = true;
|
||||
rm_by_id_iq.sel_meta = true;
|
||||
rm_by_id_iq.WhereId(item_id);
|
||||
// rm_by_id_iq.SetAll(false, false);
|
||||
// rm_by_id_iq.sel_parent_id = true;
|
||||
// rm_by_id_iq.sel_type = true;
|
||||
// rm_by_id_iq.sel_url = true;
|
||||
// rm_by_id_iq.sel_file = true;
|
||||
// rm_by_id_iq.sel_user_id = true;
|
||||
// rm_by_id_iq.sel_group_id = true;
|
||||
// rm_by_id_iq.sel_privileges = true;
|
||||
// rm_by_id_iq.sel_meta = true;
|
||||
// rm_by_id_iq.WhereId(item_id);
|
||||
|
||||
if( db->GetItem(rm_by_id_item, rm_by_id_iq) == WINIX_ERR_OK )
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
rm_by_id_item = finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"id", item_id).
|
||||
get();
|
||||
|
||||
//if( db->GetItem(rm_by_id_item, rm_by_id_iq) == WINIX_ERR_OK )
|
||||
if( rm_by_id_item.found() )
|
||||
{
|
||||
if( rm_by_id_item.type == Item::file || rm_by_id_item.type == Item::symlink )
|
||||
{
|
||||
@@ -282,18 +292,27 @@ bool Rm::RemoveItemById(long item_id, bool check_access)
|
||||
bool result = false;
|
||||
|
||||
// selecting files, symlinks and directories
|
||||
rm_by_id_iq.SetAll(false, false);
|
||||
rm_by_id_iq.sel_parent_id = true;
|
||||
rm_by_id_iq.sel_type = true;
|
||||
rm_by_id_iq.sel_url = true;
|
||||
rm_by_id_iq.sel_file = true;
|
||||
rm_by_id_iq.sel_user_id = true;
|
||||
rm_by_id_iq.sel_group_id = true;
|
||||
rm_by_id_iq.sel_privileges = true;
|
||||
rm_by_id_iq.sel_meta = true;
|
||||
rm_by_id_iq.WhereId(item_id);
|
||||
// rm_by_id_iq.SetAll(false, false);
|
||||
// rm_by_id_iq.sel_parent_id = true;
|
||||
// rm_by_id_iq.sel_type = true;
|
||||
// rm_by_id_iq.sel_url = true;
|
||||
// rm_by_id_iq.sel_file = true;
|
||||
// rm_by_id_iq.sel_user_id = true;
|
||||
// rm_by_id_iq.sel_group_id = true;
|
||||
// rm_by_id_iq.sel_privileges = true;
|
||||
// rm_by_id_iq.sel_meta = true;
|
||||
// rm_by_id_iq.WhereId(item_id);
|
||||
|
||||
if( db->GetItem(rm_by_id_item, rm_by_id_iq) == WINIX_ERR_OK )
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
rm_by_id_item = finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"id", item_id).
|
||||
get();
|
||||
|
||||
//if( db->GetItem(rm_by_id_item, rm_by_id_iq) == WINIX_ERR_OK )
|
||||
if( rm_by_id_item.found() )
|
||||
{
|
||||
if( rm_by_id_item.type == Item::dir )
|
||||
{
|
||||
@@ -341,8 +360,16 @@ return result;
|
||||
|
||||
bool Rm::RemoveDirFiles(long dir_id, bool check_access)
|
||||
{
|
||||
content_dir_iq.WhereParentId(dir_id);
|
||||
db->GetItems(content_item_tab, content_dir_iq);
|
||||
// content_dir_iq.WhereParentId(dir_id);
|
||||
// db->GetItems(content_item_tab, content_dir_iq);
|
||||
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"parent_id", dir_id).
|
||||
get_vector(content_item_tab);
|
||||
|
||||
size_t removed = 0;
|
||||
|
||||
@@ -362,7 +389,7 @@ void Rm::RemoveCurrentDir(Item * parent_dir, Item * current_dir, bool check_acce
|
||||
{
|
||||
if( check_access )
|
||||
{
|
||||
if( !parent_dir || !system->CanRemoveRenameChild(*parent_dir, current_dir->user_id) )
|
||||
if( !parent_dir || !system->CanRemoveRenameChild(*parent_dir, current_dir->item_content.user_id) )
|
||||
{
|
||||
log << log1 << "Rm: permission denied to directory: " << current_dir->url << logend;
|
||||
slog << logerror << T("rm_permission_denied_to") << ": " << current_dir->url << logend;
|
||||
@@ -372,7 +399,8 @@ void Rm::RemoveCurrentDir(Item * parent_dir, Item * current_dir, bool check_acce
|
||||
|
||||
plugin->Call(WINIX_DIR_PREPARE_TO_REMOVE, current_dir);
|
||||
|
||||
if( db->DelDirById(current_dir->id) == WINIX_ERR_OK )
|
||||
//if( db->DelDirById(current_dir->id) == WINIX_ERR_OK )
|
||||
if( current_dir->remove() )
|
||||
{
|
||||
long dir_id = current_dir->id;
|
||||
old_url = current_dir->url;
|
||||
|
Reference in New Issue
Block a user