Added functions to get link from menu or link composite.
Improved management menu, but using sub menu.
This commit is contained in:
@@ -103,7 +103,7 @@ feature -- Security
|
||||
-- List of permission ids, used by this module, and declared.
|
||||
do
|
||||
Result := Precursor
|
||||
Result.force ("manage admin")
|
||||
Result.force ("access admin")
|
||||
Result.force ("admin users")
|
||||
Result.force ("admin roles")
|
||||
Result.force ("admin modules")
|
||||
@@ -132,29 +132,34 @@ feature -- Hooks
|
||||
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
|
||||
local
|
||||
lnk: CMS_LOCAL_LINK
|
||||
admin_lnk: CMS_LINK_COMPOSITE
|
||||
do
|
||||
if a_response.api.user_is_authenticated then
|
||||
if
|
||||
a_response.has_permission ("manage " + {CMS_ADMIN_MODULE}.name) -- Note: admin user has all permissions enabled by default.
|
||||
then
|
||||
-- TODO: we should probably use more side menu and less primary_menu.
|
||||
create lnk.make ("Admin", "admin")
|
||||
lnk.set_permission_arguments (<<"manage " + {CMS_ADMIN_MODULE}.name>>)
|
||||
a_menu_system.management_menu.extend (lnk)
|
||||
|
||||
end
|
||||
admin_lnk := a_menu_system.management_menu.new_composite_item ("Admin", "admin")
|
||||
|
||||
create lnk.make ("Module", "admin/modules")
|
||||
lnk.set_permission_arguments (<<"manage module">>)
|
||||
a_menu_system.management_menu.extend (lnk)
|
||||
admin_lnk.extend (lnk)
|
||||
|
||||
-- Per module cache permission!
|
||||
create lnk.make ("Cache", "admin/cache")
|
||||
a_menu_system.management_menu.extend (lnk)
|
||||
admin_lnk.extend (lnk)
|
||||
|
||||
-- Per module export permission!
|
||||
create lnk.make ("Export", "admin/export")
|
||||
a_menu_system.management_menu.extend (lnk)
|
||||
admin_lnk.extend (lnk)
|
||||
|
||||
-- if
|
||||
-- a_response.has_permission ("access " + {CMS_ADMIN_MODULE}.name) -- Note: admin user has all permissions enabled by default.
|
||||
-- then
|
||||
-- lnk := admin_lnk
|
||||
-- lnk.set_title ("Admin")
|
||||
|
||||
-- a_menu_system.management_menu.extend (lnk)
|
||||
-- elseif admin_lnk.has_children then
|
||||
-- a_menu_system.management_menu.extend (admin_lnk)
|
||||
-- end
|
||||
-- admin_lnk.set_permission_arguments (<<"access " + {CMS_ADMIN_MODULE}.name>>)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -17,22 +17,58 @@ feature -- Process
|
||||
process
|
||||
local
|
||||
b: STRING
|
||||
l_admin_links: ARRAYED_LIST [TUPLE [package: READABLE_STRING_8; permissions: ARRAY [READABLE_STRING_GENERAL]; link: CMS_LINK; help: READABLE_STRING_GENERAL]]
|
||||
lst: detachable ARRAYED_LIST [TUPLE [permissions: ARRAY [READABLE_STRING_GENERAL]; link: CMS_LINK; help: READABLE_STRING_GENERAL]]
|
||||
categories: STRING_TABLE [ARRAYED_LIST [TUPLE [permissions: ARRAY [READABLE_STRING_GENERAL]; link: CMS_LINK; help: READABLE_STRING_GENERAL]]]
|
||||
l_package: READABLE_STRING_8
|
||||
do
|
||||
create l_admin_links.make (5)
|
||||
l_admin_links.force (["core", <<"admin users">>, local_link ("Users", "admin/users"), "View/Edit/Add Users"])
|
||||
l_admin_links.force (["core", <<"admin roles">>, local_link ("Roles", "admin/roles"), "View/Edit/Add Roles"])
|
||||
l_admin_links.force (["core", <<"admin modules">>, local_link ("Modules", "admin/modules"), "(un)Install modules"])
|
||||
l_admin_links.force (["support", <<"admin cache">>, local_link ("Cache", "admin/cache"), "Clear caches"])
|
||||
l_admin_links.force (["support", <<"admin export">>, local_link ("Export", "admin/export"), "Export CMS contents, and modules contents."])
|
||||
create categories.make_caseless (3)
|
||||
across
|
||||
l_admin_links as ic
|
||||
loop
|
||||
l_package := ic.item.package
|
||||
lst := categories.item (l_package)
|
||||
if lst = Void then
|
||||
create lst.make (1)
|
||||
categories.force (lst, l_package)
|
||||
end
|
||||
lst.force ([ic.item.permissions, ic.item.link, ic.item.help])
|
||||
end
|
||||
|
||||
create b.make_empty
|
||||
set_title (translation ("Admin Page", Void))
|
||||
b.append ("<ul id=%"content-types%">")
|
||||
fixme ("Check how to make it configurable")
|
||||
if has_permissions (<< "admin users">>) then
|
||||
b.append ("<li>" + link ("Users", "admin/users", Void))
|
||||
b.append ("<div class=%"description%">View/Edit/Add Users</div>")
|
||||
b.append ("</li>")
|
||||
across
|
||||
categories as cats_ic
|
||||
loop
|
||||
lst := cats_ic.item
|
||||
b.append ("<h3>")
|
||||
b.append (html_encoded (cats_ic.key))
|
||||
b.append ("</h3>")
|
||||
b.append ("<ul>")
|
||||
across
|
||||
lst as ic
|
||||
loop
|
||||
if has_permissions (ic.item.permissions) then
|
||||
b.append ("<li>")
|
||||
if attached ic.item.link as lnk then
|
||||
b.append (link (lnk.title, lnk.location, Void))
|
||||
end
|
||||
b.append ("<div class=%"description%">")
|
||||
b.append (html_encoded (ic.item.help))
|
||||
b.append ("</div>")
|
||||
b.append ("</li>")
|
||||
end
|
||||
end
|
||||
b.append ("</ul>")
|
||||
end
|
||||
if has_permissions (<< "admin roles">>) then
|
||||
b.append ("<li>" + link ("Roles", "admin/roles", Void))
|
||||
b.append ("<div class=%"description%">View/Edit/Add Roles</div>")
|
||||
b.append ("</li>")
|
||||
end
|
||||
b.append ("</ul>")
|
||||
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@ feature -- Hooks configuration
|
||||
-- Add the link to the taxonomy to the main menu
|
||||
if a_response.has_permission ("admin registration") then
|
||||
create lnk.make ("Registration", "admin/pending-registrations/")
|
||||
a_menu_system.management_menu.extend (lnk)
|
||||
a_menu_system.management_menu.extend_into (lnk, "Admin", "admin")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ feature -- Hook
|
||||
if a_response.is_authenticated then
|
||||
a_menu_system.navigation_menu.extend (create {CMS_LOCAL_LINK}.make ("Feeds", "feed_aggregation/"))
|
||||
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/"))
|
||||
a_menu_system.management_menu.extend_into (create {CMS_LOCAL_LINK}.make ("Feeds (admin)", "admin/feed_aggregator/"), "Admin", "admin")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -187,7 +187,7 @@ feature -- Hooks
|
||||
-- Add the link to the taxonomy to the main menu
|
||||
if a_response.has_permission ("admin taxonomy") then
|
||||
create lnk.make ("Taxonomy", "admin/taxonomy/")
|
||||
a_menu_system.management_menu.extend (lnk)
|
||||
a_menu_system.management_menu.extend_into (lnk, "Admin", "admin")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user