开发者

Cake php menu generation

开发者 https://www.devze.com 2022-12-26 14:05 出处:网络
I am trying 开发者_Python百科to generate dynamic menu according to the user permission given with ACL component in cake php..

I am trying 开发者_Python百科to generate dynamic menu according to the user permission given with ACL component in cake php..

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


Try PoundCake Control Panel. 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. There is a controller to semi-automatically fill menus table with data from your acos table.


I have an AdminMenu model that defines my admin system navigation hierarchy. 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. 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, e.g. only display the link to delete a post if they have permission to delete it.

0

精彩评论

暂无评论...
验证码 换一张
取 消