简体   繁体   English

蛋糕PHP菜单生成

[英]Cake php menu generation

I am trying to generate dynamic menu according to the user permission given with ACL component in cake php.. 我试图根据蛋糕php中ACL组件给定的用户权限生成动态菜单。

ie., if a user logins, i need to check which all actions are permitted for that specific user and according that list of actions i need to generate menu 即,如果用户登录,我需要检查允许该特定用户执行哪些操作,并根据该操作列表生成菜单

can any one help me to get all the permitted actions from the acos,aros,acos_aros tables 谁能帮我从acos,aros,acos_aros表中获取所有允许的操作

I have an AdminMenu model that defines my admin system navigation hierarchy. 我有一个AdminMenu模型,用于定义我的管理系统导航层次结构。 This is the same for all users. 所有用户都一样。 The structure is cached after every save to it. 每次保存后都会缓存该结构。 When a user logs into the Admin system, I fetch the menu data from the cache and also fetch all permissions that logged in user has been granted access to. 当用户登录到Admin系统时,我从缓存中获取菜单数据,还获取已授予登录用户访问权限的所有权限。 I do this in a single query. 我在单个查询中执行此操作。 The details are posted here . 详细信息在这里发布

I then recursively iterate through the menu data, checking each node against the permissions for that user, and build up a menu structure and store it in the session. 然后,我递归地遍历菜单数据,对照该用户的权限检查每个节点,并建立菜单结构并将其存储在会话中。 This menu structure only contains the nodes the logged in user has permission to access, and it's only generated once, when they log in. This menu structure is then rendered with a helper. 此菜单结构仅包含已登录用户有权访问的节点,并且仅在登录时才生成一次。然后使用帮助程序呈现此菜单结构。

In addition, the permissions are available in the session, so you can check whether to display links in your views or not, eg only display the link to delete a post if they have permission to delete it. 此外,该权限在会话中可用,因此您可以检查是否在视图中显示链接,例如,只有在他们有权删除帖子的情况下,才显示链接以删除帖子。

Try PoundCake Control Panel . 尝试PoundCake控制面板 Dynamic menu generation is implemented there. 在那里实现了动态菜单生成。 It generates only those menu items that user has access to based on acos, aros, acos_aros and menus tables. 它仅基于acos,aros,acos_aros和菜单表生成用户有权访问的那些菜单项。 There is a controller to semi-automatically fill menus table with data from your acos table. 有一个控制器可以用acos表中的数据半自动填充菜单表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM