如何动态组合管理菜单?

发布于 2024-09-08 17:30:16 字数 742 浏览 0 评论 0原文

我正在尝试根据浏览每个页面上每个对象的结果,找出动态组装管理应用程序导航菜单的最佳方法,以便仅包含用户可用的对象的页面都显示在菜单中!

举一个简单的例子,假设我有两种用户类型;秘书兼经理。我有一个简单的管理页面来管理员工,其中有两个可以更新的字段; “地址”和“出生日期”。通常,这两个字段都有一个访问级别,允许 SECRETARY 执行我们正常的 CRUD 操作。有一天,我们的管理员出现并决定“出生日期”需要管理员级别的访问权限 - 它足够简单,可以在页面上隐藏该字段或将其设置为只读。现在,管理员突然决定“地址”字段也需要管理员级别的访问权限。鉴于现在此页面上没有可供 SECRETARY 用户使用的字段,我的菜单如何知道是否显示它(无需为菜单选项创建单独的规则)?

Zend 中的 ACL 和导航之类的东西似乎只能使菜单选项成为访问控制对象。这个:http://www. tonymarston.net/php-mysql/role-based-access-control.html#menu-system 似乎符合我的要求,但我找不到任何讨论此特定问题的演示或代码块话题。

下一个问题是,如果我必须在数据库中维护页面上所有对象的列表,为什么不在数据库中也包含 HTML,并让应用程序动态组装页面而不是使用视图+ 模板? (当然可以缓存)

有什么建议吗?

I'm trying to work out the best way to assemble the navigation menu of my admin application dynamically, based on the result of going through each of the objects on each of the pages, such that only pages with objects that are available to the user are displayed in the menu!

As a simple example, say I have two user types; SECRETARY and MANAGER. I have a simple admin page to manage staff with two fields that I can update; "address" and "date of birth". Normally, both fields have an access level which allows SECRETARY to do our normal CRUD operations. Our administrator comes along one day and decides that "date of birth" needs MANAGER level access - it's straight-forward enough to hide that field on the page or make it read-only. Now, all of a sudden, the administrator decides that the "address" field needs MANAGER level access too. Given there are no fields on this page available to the SECRETARY user now, how does my menu know to display it or not (without creating a separate rule for the menu option)?

Things like ACL and Navigation in Zend only seem to go as far as making a menu option an access control object. This: http://www.tonymarston.net/php-mysql/role-based-access-control.html#menu-system seems to do what I'm asking, but I can't find any demos or code chunks which talk about this particular topic.

The next question is, if I have to go as far as maintaining a list of all the objects on a page in the db, why not include the HTML in the db too, and have the application dynamically assemble the page instead of using a View + template? (could be cached of course)

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

早茶月光 2024-09-15 17:30:16

粗略地说,在检查各个页面对象的权限后,我可以计算有多少对象是有效的。如果该计数 = 0,那么我将忽略该页面。

没有适合您的代码,但这是我采取的方法的理论基础。

Speaking in rough and general terms, after checking permissions for individual page objects, I could count how many objects are valid. If that count = 0, then I would omit the page.

No code for you, but that's the theoretical basis of the approach I'd take.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文