renamed: ItemContent::meta_admin -> ItemContent::admin_meta

This commit is contained in:
2021-07-03 01:18:28 +02:00
parent 175dd17416
commit 746aa41111
11 changed files with 76 additions and 57 deletions

View File

@@ -61,35 +61,36 @@ void Item::fields()
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"parent_id", parent_id);
field(L"type", type_helper);
field(L"url", url);
field(L"subject", subject);
field(L"template", html_template);
field(L"sort_index", sort_index);
field(L"content_id", L"content", item_content, morm::FT::foreign_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"type", type_helper);
field(L"url", url);
field(L"subject", subject);
field(L"template", html_template);
field(L"sort_index", sort_index);
field(L"content_id", L"content", item_content, morm::FT::foreign_key);
field(L"dir_link", &Item::dir_link);
field(L"link", &Item::link);
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_root_dir", &Item::is_root_dir);
field(L"dir_link", &Item::dir_link);
field(L"link", &Item::link);
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"is_parent_for_current_dir", &Item::is_parent_for_current_dir);
field(L"is_current_dir", &Item::is_current_dir);
field(L"is_root_dir", &Item::is_root_dir);
field(L"url_is", &Item::url_is);
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"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);
field(L"has_read_write_access", &Item::has_read_write_access);
field(L"has_read_exec_access", &Item::has_read_exec_access);
field(L"url_is", &Item::url_is);
field(L"execute", &Item::execute);
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);
field(L"has_read_write_access", &Item::has_read_write_access);
field(L"has_read_exec_access", &Item::has_read_exec_access);
field(L"execute", &Item::execute);
// may we should add a method setTypeFromInt(int t)?
@@ -285,16 +286,7 @@ bool Item::do_migration_to_3()
};
size_t len = sizeof(str) / sizeof(const char*);
for(size_t i=0 ; i < len ; ++i)
{
if( !db_query(str[i]) )
{
return false;
}
}
return true;
return db_query(str, len);
}

View File

@@ -83,7 +83,7 @@ void ItemContent::fields()
field(L"content_parsed", content_parsed);
field(L"content_parsed_type", content_parsed_type_helper);
field(L"meta", meta);
field(L"meta_admin", meta_admin);
field(L"admin_meta", admin_meta);
field(L"print_content", &ItemContent::print_content);
field(L"has_static_file", &ItemContent::has_static_file);
@@ -103,6 +103,8 @@ void ItemContent::fields()
field(L"has_thumb", &ItemContent::has_thumb);
field(L"display_user_name", &ItemContent::display_user_name);
field(L"is_meta_object", &ItemContent::is_meta_object);
field(L"is_admin_meta_object", &ItemContent::is_admin_meta_object);
// 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);
@@ -168,7 +170,7 @@ void ItemContent::Clear()
content_parsed_type = ct_formatted_text;
meta.clear();
meta_admin.clear();
admin_meta.clear();
SetDateToNow();
}
@@ -182,6 +184,7 @@ bool ItemContent::do_migration(int & current_table_version)
ok = ok && morm::Model::do_migration(current_table_version, 1, this, &ItemContent::do_migration_to_1);
ok = ok && morm::Model::do_migration(current_table_version, 2, this, &ItemContent::do_migration_to_2);
ok = ok && morm::Model::do_migration(current_table_version, 3, this, &ItemContent::do_migration_to_3);
ok = ok && morm::Model::do_migration(current_table_version, 4, this, &ItemContent::do_migration_to_4);
return ok;
}
@@ -257,6 +260,17 @@ bool ItemContent::do_migration_to_3()
}
bool ItemContent::do_migration_to_4()
{
const char * str[] = {
"alter table core.content rename column meta_admin to admin_meta;",
};
size_t len = sizeof(str) / sizeof(const char*);
return db_query(str, len);
}
bool ItemContent::has_access(const User * current_user, int mask) const
{
if( current_user )
@@ -586,6 +600,16 @@ void ItemContent::display_user_name(EzcEnv & env)
}
bool ItemContent::is_meta_object()
{
return meta.is_object();
}
bool ItemContent::is_admin_meta_object()
{
return admin_meta.is_object();
}
} // namespace Winix

View File

@@ -233,7 +233,7 @@ public:
* admin meta information
* additional information available to edit only by an admin
*/
pt::Space meta_admin;
pt::Space admin_meta;
ItemContent();
@@ -273,11 +273,16 @@ public:
bool has_user() const;
bool has_group() const;
bool is_meta_object();
bool is_admin_meta_object();
protected:
bool do_migration_to_1();
bool do_migration_to_2();
bool do_migration_to_3();
bool do_migration_to_4();
bool has_access(const User * current_user, int mask) const;
bool content_type_is(const std::wstring & type);