From 746aa411117544af3c150a98fb6c8de9a3d4f0af Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Sat, 3 Jul 2021 01:18:28 +0200 Subject: [PATCH] renamed: ItemContent::meta_admin -> ItemContent::admin_meta --- winixd/functions/meta.cpp | 2 +- winixd/html/fun_meta.html | 12 ++---- winixd/html/fun_sort.html | 12 +++--- winixd/locale/en | 1 + winixd/locale/pl | 1 + winixd/models/item.cpp | 60 ++++++++++++---------------- winixd/models/itemcontent.cpp | 28 ++++++++++++- winixd/models/itemcontent.h | 7 +++- winixd/plugins/thread/reply.cpp | 2 +- winixd/plugins/ticket/editticket.cpp | 4 +- winixd/plugins/ticket/templates.cpp | 4 +- 11 files changed, 76 insertions(+), 57 deletions(-) diff --git a/winixd/functions/meta.cpp b/winixd/functions/meta.cpp index fa1dbce..a975d6e 100644 --- a/winixd/functions/meta.cpp +++ b/winixd/functions/meta.cpp @@ -73,7 +73,7 @@ bool Meta::EditAdminMeta(Item & item, const std::wstring & meta_str, bool use_se if( Parse(meta_str) ) { item.propagate_connector(); - item.item_content.meta_admin = space; + item.item_content.admin_meta = space; //if( db->EditAdminMetaById(space, item_id) == WINIX_ERR_OK ) if( item.item_content.update() ) diff --git a/winixd/html/fun_meta.html b/winixd/html/fun_meta.html index 422fa46..5d6c80a 100644 --- a/winixd/html/fun_meta.html +++ b/winixd/html/fun_meta.html @@ -35,16 +35,12 @@
diff --git a/winixd/html/fun_sort.html b/winixd/html/fun_sort.html index 3d8f38d..2f9edbd 100644 --- a/winixd/html/fun_sort.html +++ b/winixd/html/fun_sort.html @@ -10,7 +10,7 @@
- +
@@ -38,13 +38,13 @@
    [for item_tab] -
  • - +
  • + [# is it correct? may give this 'if' only to /-/thumb param? ] - [if item_tab_has_thumb][item_tab_subject][end] + [if item_tab.content.file_has_thumb][item_tab.subject][end] - [item_tab_url][if item_tab_type_is_dir]/[end] [if not [is item_tab_subject ""]]({sort_item.subject}: [item_tab_subject])[end] + [item_tab.url][if item_tab.type_is_dir]/[end] [if not [is item_tab.subject ""]]({sort_item.subject}: [item_tab.subject])[end]
  • [end]
@@ -55,7 +55,7 @@ [if winix_function_param_is "index"]
- +
[end] diff --git a/winixd/locale/en b/winixd/locale/en index 7580324..8daa28d 100644 --- a/winixd/locale/en +++ b/winixd/locale/en @@ -476,6 +476,7 @@ sort_current_sortindex = Current sort index sort_info_multi = Set an order of items by using the mouse. sort_info_multi_index = Set an order of items by providing an index number. You can also set an order of items by using the mouse and then clicking the renumerate button. sort_item_subject = Subject: +sort_item_renumber = Renumber stat_header = Stat stat_item_type = type diff --git a/winixd/locale/pl b/winixd/locale/pl index 20fb533..bf38782 100644 --- a/winixd/locale/pl +++ b/winixd/locale/pl @@ -493,6 +493,7 @@ sort_current_sortindex = Bieżący indeks sortowania sort_info_multi = Ustaw kolejność elementów przeciągając je przy pomocy myszki. sort_info_multi_index = Ustaw kolejność elementów podająć ich indeks. Możesz także ustawić kolejność elementów przeciągając je przy pomocy myszki i następnie kliknąć przycisk Renumeruj. sort_item_subject = Tytuł: +sort_item_renumber = Renumeruj stat_header = Stat stat_item_type = typ diff --git a/winixd/models/item.cpp b/winixd/models/item.cpp index 0c70be2..5615705 100644 --- a/winixd/models/item.cpp +++ b/winixd/models/item.cpp @@ -61,35 +61,36 @@ void Item::fields() int type_helper = static_cast(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); } diff --git a/winixd/models/itemcontent.cpp b/winixd/models/itemcontent.cpp index 8fdaf8d..a7e4f1c 100644 --- a/winixd/models/itemcontent.cpp +++ b/winixd/models/itemcontent.cpp @@ -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(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 diff --git a/winixd/models/itemcontent.h b/winixd/models/itemcontent.h index 4d5b31a..1f257ff 100644 --- a/winixd/models/itemcontent.h +++ b/winixd/models/itemcontent.h @@ -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); diff --git a/winixd/plugins/thread/reply.cpp b/winixd/plugins/thread/reply.cpp index b3ab761..44e9a82 100644 --- a/winixd/plugins/thread/reply.cpp +++ b/winixd/plugins/thread/reply.cpp @@ -80,7 +80,7 @@ bool Reply::HasAccess() return false; - pt::Space * thread_space = cur->request->item.item_content.meta_admin.get_space(L"thread"); + pt::Space * thread_space = cur->request->item.item_content.admin_meta.get_space(L"thread"); if( thread_space ) { diff --git a/winixd/plugins/ticket/editticket.cpp b/winixd/plugins/ticket/editticket.cpp index c17c1d0..4d95826 100644 --- a/winixd/plugins/ticket/editticket.cpp +++ b/winixd/plugins/ticket/editticket.cpp @@ -203,10 +203,10 @@ bool EditTicket::CloseTicket() { cur->request->item.propagate_connector(); - pt::Space & ticket_space = cur->request->item.item_content.meta_admin.get_add_space(L"ticket"); //CHECKME it was find_add_child_space(L"ticket"); + pt::Space & ticket_space = cur->request->item.item_content.admin_meta.get_add_space(L"ticket"); //CHECKME it was find_add_child_space(L"ticket"); ticket_space.add(L"closed", true); - pt::Space & thread_space = cur->request->item.item_content.meta_admin.get_add_space(L"thread"); //CHECKME it was find_add_child_space(L"thread"); + pt::Space & thread_space = cur->request->item.item_content.admin_meta.get_add_space(L"thread"); //CHECKME it was find_add_child_space(L"thread"); thread_space.add(L"closed", true); //if( db->EditAdminMetaById(cur->request->item.ameta, cur->request->item.id) == WINIX_ERR_OK ) diff --git a/winixd/plugins/ticket/templates.cpp b/winixd/plugins/ticket/templates.cpp index 8c93ef4..932cdde 100644 --- a/winixd/plugins/ticket/templates.cpp +++ b/winixd/plugins/ticket/templates.cpp @@ -318,7 +318,7 @@ void ticket_is_creating_new(Info & i) void ticket_is_closed(Info & i) { - pt::Space * ticket_space = ticket_info.item->item_content.meta_admin.get_space(L"ticket"); + pt::Space * ticket_space = ticket_info.item->item_content.admin_meta.get_space(L"ticket"); if( ticket_space ) i.res = ticket_space->to_bool(L"closed", false); @@ -552,7 +552,7 @@ void tickets_tab_is_closed(Info & i) if( tickets_value.is_item ) { - pt::Space * ticket_space = tickets_value.item->item_content.meta_admin.get_space(L"ticket"); + pt::Space * ticket_space = tickets_value.item->item_content.admin_meta.get_space(L"ticket"); if( ticket_space ) i.res = ticket_space->to_bool(L"closed", false);