doukezi4576 2013-04-02 20:28
浏览 24
已采纳

没有Zend ACL的Zend Navigation权限

Ok, I have a code that generates a xml file like the following:

<?xml version="1.0" encoding="UTF-8"?>
<configdata>
    <nav>
        <main>
            <label>Home</label>
            <alias>main</alias>
            <uri>/</uri>
            <privilege>
                <super_admin>super_admin</super_admin>
                <reg_user>reg_user</reg_user>
            </privilege>
            <status>active</status>
            <sprite>sprite.png</sprite>
            <pages>
                <article>
                    <label>Article</label>
                    <alias>article</alias>
                    <uri>/article</uri>
                    <privilege>
                        <super_admin>super_admin</super_admin>
                        <reg_user>reg_user</reg_user>
                    </privilege>
                    <status>active</status>
                    <pages>
                        <insert>
                            <label>Insert</label>
                            <alias>insert</alias>
                            <uri>/article/insert</uri>
                            <privilege>
                                <super_admin>super_admin</super_admin>
                            </privilege>
                            <status>active</status>
                        </insert>
                        [...]
                    </pages>
                </article>
                [...]
            </pages>
        </main>
    </nav>
</configdata>

My problem is that my URI's are not in the form of a Zend Acl because I followed this link that helped me getting all my URI's, manage the privileges of each group (named as super_admin and reg_user on the code above) and save them on the Database.

The problem is that now, I want to render a menu with only the specific items that are accessable to a specific group. This means that, using the above XML, if I enter with a super_admin, I would have a menu like this:

- Home
    - Article
        - Insert

And if I enter with a reg_user, my menu should be:

- Home
    - Article

How can I do this?

I'm using Zend Framework 1.11.x

  • 写回答

1条回答 默认 最新

  • dongsheng6056 2013-04-02 21:58
    关注

    If you want to do it without Zend ACL I suggest to write own partial for menu. Then you check current user role (stored maybe in Zend_Registry) with menu item privilege from xml file.

    Here you can see how to use custom menu partial https://stackoverflow.com/a/1255289/760866

    You read custom xml properties like this:

    $properties = new Zend_Config($page->GetCustomProperties());
    $privilege = $properties->privilege;
    

    Hope that helps!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题