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
|
||||
@@ -135,15 +135,15 @@ bool Cp::CopyStaticFile(const std::wstring & from, const std::wstring & to)
|
||||
|
||||
void Cp::CopyStaticFile(Item & item)
|
||||
{
|
||||
bool res1, res2, res3, res4, res5;
|
||||
bool ok = true;
|
||||
|
||||
res1 = system->MakeFilePath(item, old_path, false);
|
||||
res2 = !item.has_thumb || system->MakeFilePath(item, old_path_thumb, true);
|
||||
res3 = system->CreateNewFile(item);
|
||||
res4 = system->MakeFilePath(item, new_path, false, true, config->upload_dirs_chmod);
|
||||
res5 = !item.has_thumb || system->MakeFilePath(item, new_path_thumb, true, true, config->upload_dirs_chmod);
|
||||
ok = ok && system->MakeFilePath(item, old_path, false);
|
||||
ok = ok && (!item.item_content.file_has_thumb || system->MakeFilePath(item, old_path_thumb, true));
|
||||
ok = ok && system->CreateNewFile(item);
|
||||
ok = ok && system->MakeFilePath(item, new_path, false, true, config->upload_dirs_chmod);
|
||||
ok = ok && (!item.item_content.file_has_thumb || system->MakeFilePath(item, new_path_thumb, true, true, config->upload_dirs_chmod));
|
||||
|
||||
if( !res1 || !res2 || !res3 || !res4 || !res5 )
|
||||
if( !ok )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
@@ -151,9 +151,14 @@ bool res1, res2, res3, res4, res5;
|
||||
|
||||
if( CopyStaticFile(old_path, new_path) )
|
||||
{
|
||||
cur->request->status = db->EditFileById(item, item.id);
|
||||
//cur->request->status = db->EditFileById(item, item.id);
|
||||
if( !item.update(false, true) )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
if( item.has_thumb )
|
||||
|
||||
if( item.item_content.file_has_thumb )
|
||||
CopyStaticFile(old_path_thumb, new_path_thumb);
|
||||
}
|
||||
}
|
||||
@@ -162,9 +167,9 @@ bool res1, res2, res3, res4, res5;
|
||||
|
||||
void Cp::SetNewAttributes(Item & item)
|
||||
{
|
||||
item.user_id = new_user;
|
||||
item.group_id = new_group;
|
||||
item.SetDateModifyToNow();
|
||||
item.item_content.user_id = new_user;
|
||||
item.item_content.group_id = new_group;
|
||||
item.item_content.SetDateModifyToNow();
|
||||
}
|
||||
|
||||
|
||||
@@ -174,11 +179,12 @@ void Cp::CopyFile(Item & item, long dst_dir_id)
|
||||
SetNewAttributes(item);
|
||||
|
||||
item.parent_id = dst_dir_id;
|
||||
cur->request->status = db->AddItem(item);
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
// cur->request->status = db->AddItem(item);
|
||||
// if( cur->request->status == WINIX_ERR_OK )
|
||||
if( item.insert() )
|
||||
{
|
||||
if( item.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
if( item.item_content.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
CopyStaticFile(item);
|
||||
|
||||
plugin->Call(WINIX_FILE_COPIED, &item);
|
||||
@@ -195,7 +201,7 @@ void Cp::CopyFileOrSymlink(Item & item, long dst_dir_id)
|
||||
{
|
||||
if( system->dirs.CreateDirTab(item.parent_id, symlink_dir_tab) )
|
||||
{
|
||||
int res = system->FollowAllLinks(symlink_dir_tab, item.link_to, symlink_dir_tab, item);
|
||||
int res = system->FollowAllLinks(symlink_dir_tab, item.item_content.link_to, symlink_dir_tab, item);
|
||||
|
||||
if( res == 0 )
|
||||
CopyDirTree(*symlink_dir_tab.back(), dst_dir_id);
|
||||
@@ -215,11 +221,11 @@ void Cp::CopyFileOrSymlink(Item & item, long dst_dir_id)
|
||||
|
||||
void Cp::Prepare()
|
||||
{
|
||||
iq.SetAll(true, false);
|
||||
iq.WhereType(Item::dir, false);
|
||||
// iq.SetAll(true, false);
|
||||
// iq.WhereType(Item::dir, false);
|
||||
|
||||
new_user = -1;
|
||||
new_group = dir_tab.back()->group_id;
|
||||
new_group = dir_tab.back()->item_content.group_id;
|
||||
|
||||
if( cur->session->puser )
|
||||
new_user = cur->session->puser->id;
|
||||
@@ -232,8 +238,17 @@ void Cp::Prepare()
|
||||
|
||||
void Cp::CopyFilesInDir(const Item & dir, long dst_dir_id)
|
||||
{
|
||||
iq.WhereParentId(dir.id);
|
||||
db->GetItems(item_tab, iq);
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
item_tab = finder.
|
||||
select().
|
||||
where().
|
||||
neq(L"type", static_cast<int>(Item::dir)).
|
||||
eq(L"parent_id", dir.id).
|
||||
get_vector();
|
||||
|
||||
//iq.WhereParentId(dir.id);
|
||||
//db->GetItems(item_tab, iq);
|
||||
|
||||
for(size_t i=0 ; i<item_tab.size() ; ++i)
|
||||
CopyFileOrSymlink(item_tab[i], dst_dir_id);
|
||||
@@ -291,8 +306,8 @@ long Cp::CopyDirTree(const Item & dir, long dst_dir_id)
|
||||
|
||||
if( remove_defaults )
|
||||
{
|
||||
temp.link_to.clear();
|
||||
temp.link_redirect = 0;
|
||||
temp.item_content.link_to.clear();
|
||||
temp.item_content.link_redirect = 0;
|
||||
}
|
||||
|
||||
cur->request->status = system->dirs.AddDirectory(temp);
|
||||
|
Reference in New Issue
Block a user