2011-07-19 78 views
0

我想提出以下基於Zend_Acl裏 Zend_Navigation導航是我的一塊navigation.xml文件位於/應用/ CONFIGS DIRZend的導航和遞歸的Zend的Acl

<?xml version="1.0" encoding="UTF-8"?> 
<config> 
    <nav> 
     <menu1> 
      <label>solidData</label> 
      <uri>#</uri> 
      <pages> 
       <service> 
        <label>menuLabel1</label> 
        <controller>service</controller> 
        <action>index</action> 
        <resource>service</resource> 
        <privilege>index</privilege> 
       </service> 
       <attendance> 
        <label>menuLabel2</label> 
        <controller>attendance</controller> 
        <action>index</action> 
        <resource>attendance</resource> 
        <privilege>index</privilege> 
       </attendance> 
      </pages> 
     </menu1> 
     <menu2> 
      <label>systemData</label> 
      <uri>#</uri> 
      <pages> 
       <users> 
        <label>users</label> 
        <controller>users</controller> 
        <action>index</action> 
        <resource>users</resource> 
        <privilege>index</privilege> 
       </users> 
       <profile> 
        <label>profiles</label> 
        <controller>profile</controller> 
        <action>index</action> 
        <resource>profile</resource> 
        <privilege>index</privilege> 
       </profile> 
       <dictionary> 
        <label>dictionary</label> 
        <controller>dictionary</controller> 
        <action>index</action> 
        <resource>dictionary</resource> 
        <privilege>index</privilege> 
       </dictionary> 
       <language> 
        <label>languages</label> 
        <controller>language</controller> 
        <action>index</action> 
        <resource>language</resource> 
        <privilege>index</privilege> 
       </language> 
      </pages> 
     </menu2> 
    </nav> 
</config> 

我不想展示所有頁面在ACL中被拒絕的部分。

例如如果其在ACL中的<menu1>所有網頁資源和特權我不想創建和TYPE_DENY用戶顯示標籤「solidData」

主要的問題是我的菜單結構,因爲當你看到我在一個菜單部分有各種資源。

我已經嘗試用功能ISVISIBLE()「和」 isActive()延長Zend_Navigation我自己的導航類「但我不能找到解決辦法。

我會任何幫助

感激

[編輯]看看我的菜單的這個片段的結構:

<menu2> 
    <label>systemData</label> 
    <uri>#</uri> 
    <pages> 
     <users> 
      <label>users</label> 
      <controller>users</controller> 
      <action>index</action> 
      <resource>users</resource> 
      <privilege>index</privilege> 
     </users> 
     <profile> 
      <label>profiles</label> 
      <controller>profile</controller> 
      <action>index</action> 
      <resource>profile</resource> 
      <privilege>index</privilege> 
     </profile> 
    </pages> 
</menu2> 

我不能<resource><menu2>因爲<menu2>包括具有不同資源f.e.的頁面。 '用戶'和'個人資料'。 也許有一些可能性添加許多資源到一個菜單。我嘗試類似的東西:

<menu2> 
    <label>systemData</label> 
    <uri>#</uri> 
    <resource>users</resource> 
    <resource>profile</resource> 
    <pages> 
     ... 
    </pages> 
</menu2> 

,但我得到

Invalid argument: $resource must be null, a string, or an instance of Zend_Acl_Resource_Interface 

編輯

好了,但如果我改變菜單的結構我也有改變ACL。 在我的ACL資源中,控制器的權限是控制器中的操作。

回答

1

我不確定自己的理解是否正確,但您爲什麼沒有<menu1>中的資源並拒絕這些用戶訪問該資源,而是拒絕其他人訪問該資源?您可能必須對ACL模式進行更改才能捕獲此類事件,但不能導航。

UPDATE 試試這個關於第二個問題:

<menu2> 
    <label>systemData</label> 
    <uri>#</uri> 
    <resource>systemData</resource> 
    <pages> 
     ... 
    </pages> 
</menu2> 

資源是一個標識符,所以你不應該(也不能)添加兩個資源,一個對象。您不必擔心導航中的訪問邏輯,但可以提供ACL的使用信息。在您的ACL中,您當然需要添加更多邏輯,以便您可以將權限分配給正確的資源。

+1

我同意,增加資源和特權''和限制訪問的ACL –

+0

頁女巫的導航項目屬於有差異的資源,所以我不能任何資源添加到這不是一個解決方案 –

+0

好的,但如果我改變菜單的結構,我還必須更改ACL。在我的ACL資源中,控制器的權限是控制器中的操作 –

0

即標記特權?也許?

 $this->allow($guest, array('login', 'register'), array('view', 'guest:login', 'guest:register')); 
    $this->allow('user', array('logout', new Zfcms_Acl_Resource_News, 'content'), array('view', 'browse', 'latest', 'submit', 'save', 'editown', 'deleteown')); 
    $this->allow('admin', array('admin:area'), array('admin:view', 'admin:edit', 'admin:delete', 'admin:summary')); 
    $this->allow('admin'); 
    $this->deny($guest, new Zfcms_Acl_Resource_News, array('save')); 
    /** 
    * The below prevents logged users from seeing the login/register tabs 
    */ 
    $this->deny(new Zfcms_Acl_Role_User(), null, array('guest:login', 'guest:register'));