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:
2021-02-24 01:19:47 +01:00
parent 3d7ece15f8
commit 32e93a04c5
118 changed files with 5795 additions and 4514 deletions

View File

@@ -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
@@ -76,7 +76,7 @@ void Dirs::Clear()
bool Dirs::HasReadExecAccessForRoot(const Item & item)
{
// there must be at least one 'x' (for the root)
return (item.privileges & 01111) != 0;
return (item.item_content.privileges & 01111) != 0;
}
@@ -88,28 +88,33 @@ void Dirs::CheckRootDir()
{
if( !HasReadExecAccessForRoot(*i) )
{
i->privileges = 07555;
i->item_content.privileges = 07555;
log << log1 << "Dirs: there is no access for a root (admin) to the root dir, setting 07555 for the root directory" << logend;
db->EditPrivById(*i, i->id);
i->update(false, false);
//db->EditPrivById(*i, i->id);
}
return;
}
log << log1 << "Dirs: there is no a root directory in the database (creating one)" << logend;
Item root;
root.set_connector(model_connector);
root.type = Item::dir;
root.parent_id = -1;
root.user_id = -1;
root.group_id = -1;
root.privileges = 07555;
root.item_content.user_id = -1;
root.item_content.group_id = -1;
root.item_content.privileges = 07555;
// !! upewnic sie ze baza nie zmieni url (gdyby wczesniej juz byl w bazie pusty url)
// !! zrobic jakis wyjatek do wprowadzania roota?
if( db->AddItem(root) == WINIX_ERR_OK )
// if( db->AddItem(root) == WINIX_ERR_OK )
// {
// dir_tab.PushBack(root);
// }
if( root.insert() )
{
dir_tab.PushBack(root);
}
@@ -122,7 +127,15 @@ void Dirs::ReadDirs()
{
Clear();
db->GetDirs(dir_tab);
//db->GetDirs(dir_tab);
morm::Finder<Item> finder(model_connector);
std::list<Item> all_dirs = finder.select().where().eq(L"type", static_cast<int>(Item::Type::dir)).get_list();
for(Item & item : all_dirs)
{
dir_tab.PushBack(item);
}
CheckRootDir();
dir_tab.FindSpecialFolders();
}
@@ -723,7 +736,7 @@ bool Dirs::DelDir(long dir_id)
}
Error Dirs::AddDirectory(Item & item, bool add_to_dir_tab, Item ** pdir, int notify_code)
bool Dirs::AddDirectory(Item & item, bool add_to_dir_tab, Item ** pdir, int notify_code)
{
if( pdir )
*pdir = 0;
@@ -731,9 +744,11 @@ Error Dirs::AddDirectory(Item & item, bool add_to_dir_tab, Item ** pdir, int not
if( item.type != Item::dir )
return WINIX_ERR_DIR_EXPECTED;
Error status = db->AddItem(item);
//Error status = db->AddItem(item);
//item.set_connector(model_connector);
bool status = item.insert();
if( status == WINIX_ERR_OK )
if( status )
{
Item * d = AddDir(item);
@@ -764,10 +779,11 @@ Item * Dirs::CreateVarDir()
if( root )
{
v.set_connector(root->get_connector());
v.parent_id = root->id;
v.user_id = root->user_id;
v.group_id = root->group_id;
v.privileges = root->privileges;
v.item_content.user_id = root->item_content.user_id;
v.item_content.group_id = root->item_content.group_id;
v.item_content.privileges = root->item_content.privileges;
v.subject = L"var";
v.url = L"var";
v.type = Item::dir;