diff --git a/modules/admin/cms_admin_module.e b/modules/admin/cms_admin_module.e index 3477c31..8e5d724 100644 --- a/modules/admin/cms_admin_module.e +++ b/modules/admin/cms_admin_module.e @@ -99,6 +99,8 @@ feature -- Security Result.force ("admin roles") Result.force ("admin modules") Result.force ("install modules") + Result.force ("admin core caches") + Result.force ("clear blocks cache") end feature -- Hooks @@ -128,13 +130,9 @@ feature -- Hooks lnk.set_permission_arguments (<<"manage " + {CMS_ADMIN_MODULE}.name>>) a_menu_system.management_menu.extend (lnk) end - if - a_response.has_permission ("admin cache") -- Note: admin user has all permissions enabled by default. - then - create lnk.make ("Cache", "admin/cache") - lnk.set_permission_arguments (<<"admin cache">>) - a_menu_system.management_menu.extend (lnk) - end + -- Per module cache permission! + create lnk.make ("Cache", "admin/cache") + a_menu_system.management_menu.extend (lnk) end note diff --git a/modules/admin/handler/cms_admin_cache_handler.e b/modules/admin/handler/cms_admin_cache_handler.e index 09aef60..9cd9f34 100644 --- a/modules/admin/handler/cms_admin_cache_handler.e +++ b/modules/admin/handler/cms_admin_cache_handler.e @@ -42,14 +42,10 @@ feature -- Execution f: CMS_FORM do create {GENERIC_VIEW_CMS_RESPONSE} l_response.make (req, res, api) - if l_response.has_permission ("admin cache") then - f := clear_cache_web_form (l_response) - create s.make_empty - f.append_to_html (create {CMS_TO_WSF_THEME}.make (l_response, l_response.theme), s) - l_response.set_main_content (s) - else - create {FORBIDDEN_ERROR_CMS_RESPONSE} l_response.make (req, res, api) - end + f := clear_cache_web_form (l_response) + create s.make_empty + f.append_to_html (create {CMS_TO_WSF_THEME}.make (l_response, l_response.theme), s) + l_response.set_main_content (s) l_response.execute end @@ -60,26 +56,22 @@ feature -- Execution f: CMS_FORM do create {GENERIC_VIEW_CMS_RESPONSE} l_response.make (req, res, api) - if l_response.has_permission ("admin cache") then - f := clear_cache_web_form (l_response) - f.process (l_response) - if - attached f.last_data as fd and then - fd.is_valid - then - if attached fd.string_item ("op") as l_op and then l_op.same_string (text_clear_all_caches) then - l_response.hooks.invoke_clear_cache (Void, l_response) - l_response.add_notice_message ("Cache cleared!") - else - fd.report_error ("Invalid form data!") - end + f := clear_cache_web_form (l_response) + f.process (l_response) + if + attached f.last_data as fd and then + fd.is_valid + then + if attached fd.string_item ("op") as l_op and then l_op.same_string (text_clear_all_caches) then + l_response.hooks.invoke_clear_cache (Void, l_response) + l_response.add_notice_message ("Caches cleared (if allowed)!") + else + fd.report_error ("Invalid form data!") end - create s.make_empty - f.append_to_html (create {CMS_TO_WSF_THEME}.make (l_response, l_response.theme), s) - l_response.set_main_content (s) - else - create {FORBIDDEN_ERROR_CMS_RESPONSE} l_response.make (req, res, api) end + create s.make_empty + f.append_to_html (create {CMS_TO_WSF_THEME}.make (l_response, l_response.theme), s) + l_response.set_main_content (s) l_response.execute end diff --git a/modules/feed_aggregator/feed_aggregator_module.e b/modules/feed_aggregator/feed_aggregator_module.e index e0a4aee..308f332 100644 --- a/modules/feed_aggregator/feed_aggregator_module.e +++ b/modules/feed_aggregator/feed_aggregator_module.e @@ -46,9 +46,13 @@ feature -- Access -- List of permission ids, used by this module, and declared. do Result := Precursor - Result.force ("manage feed aggregator") + Result.force (permission__manage_feed_aggregator) + Result.force (permission__clear_feed_cache) end + permission__manage_feed_aggregator: STRING = "manage feed aggregator" + permission__clear_feed_cache: STRING = "clear feed cache" + feature {CMS_API} -- Module Initialization initialize (api: CMS_API) @@ -194,12 +198,14 @@ feature -- Hook p: PATH dir: DIRECTORY do - if a_cache_id_list = Void then - -- Clear all cache. - p := a_response.api.files_location.extended (".cache").extended (name) - create dir.make_with_path (p) - if dir.exists then - dir.recursive_delete + if a_response.has_permissions (<>) then + if a_cache_id_list = Void then + -- Clear all cache. + p := a_response.api.files_location.extended (".cache").extended (name) + create dir.make_with_path (p) + if dir.exists then + dir.recursive_delete + end end end end @@ -341,7 +347,7 @@ feature -- Hook -- for related response `a_response'. do a_menu_system.navigation_menu.extend (create {CMS_LOCAL_LINK}.make ("Feeds", "feed_aggregation/")) - if a_response.has_permission ("manage feed aggregator") then + if a_response.has_permission (permission__manage_feed_aggregator) then a_menu_system.management_menu.extend (create {CMS_LOCAL_LINK}.make ("Feeds (admin)", "admin/feed_aggregator/")) end end diff --git a/src/hooks/cms_hook_core_manager.e b/src/hooks/cms_hook_core_manager.e index 2198897..0ce47aa 100644 --- a/src/hooks/cms_hook_core_manager.e +++ b/src/hooks/cms_hook_core_manager.e @@ -219,7 +219,7 @@ feature -- Hook: cache end end - a_response.clear_block_caches (a_cache_id_list) + a_response.clear_cache (a_cache_id_list) end end diff --git a/src/service/response/cms_response.e b/src/service/response/cms_response.e index fbb3156..b06b689 100644 --- a/src/service/response/cms_response.e +++ b/src/service/response/cms_response.e @@ -997,6 +997,17 @@ feature -- Element Change status_code_set: status_code = a_status end +feature -- Cache managment + + clear_cache (a_cache_id_list: detachable ITERABLE [READABLE_STRING_GENERAL]) + -- Clear caches identified by `a_cache_id_list', + -- or clear all caches if `a_cache_id_list' is Void. + do + if has_permissions (<<"clear blocks cache", "admin core caches">>) then + clear_block_caches (a_cache_id_list) + end + end + feature -- Generation prepare (page: CMS_HTML_PAGE)