1

これは私のナビゲーションXML形式です。システムには、管理者とスーパー管理者の2つのユーザーレベルがあります。

管理者としてログインすると、すべてのメニュー項目が表示され、正常に機能します。スーパー管理者の場合、ダッシュボードと統計のみが表示されます。

私の問題は、スーパー管理者の場合、ダッシュボードと統計とともに、他のメニュー項目のラベル(管理者のみに表示される必要があります)が表示されていることです。ラベルを非表示にする回避策はありますか。私の場合、ダッシュボードを除いて、トップレベルのメニュー項目に対するアクションはありません。

メニューはZendACLに接続されています

<configdata>

<nav>

    <dashboard>
        <label>Dashboard</label>
        <class>nav-top-item no-submenu</class>
        <controller>index</controller>
        <action>index</action>
        <resource>index</resource>
        <privilege>index</privilege>
    </dashboard>

    <app>
        <label>Apps</label>  
        <class>nav-top-item no-submenu</class>
        <uri>#</uri>

        <pages>
            <managefeaturedapps>
                <label>Manage Apps</label>                    
                <controller>app</controller>
                <action>index</action>
                <resource>app</resource>
                <privilege>index</privilege>
            </managefeaturedapps>             
            <managepage>
                <label>Filter Apps</label>                    
                <controller>app</controller>
                <action>filter-apps</action>
                <resource>app</resource>
                <privilege>filter-apps</privilege>
            </managepage>
         </pages> 
    </app>

    <user>
        <label>Users</label>  
        <class>nav-top-item no-submenu</class>
        <uri>#</uri>

        <pages>
            <allusers>
                <label>Registered Users / Developers</label>                    
                <controller>user</controller>
                <action>index</action>
                <resource>user</resource>
                <privilege>index</privilege>
            </allusers>
         </pages>
    </user>        

    <page>
        <label>Pages</label> 
        <class>nav-top-item no-submenu</class>
        <uri>#</uri>

        <pages>
            <addpage>
                <label>Add New Page</label>                    
                <controller>page</controller>
                <action>add-page</action>
                <resource>page</resource>
                <privilege>add-page</privilege>
            </addpage>         

         </pages> 
    </page>


    <statistics>
        <label>Statistics</label> 
        <class>nav-top-item no-submenu</class>
        <uri>#</uri>

        <pages>
            <viewstats>
                <label>Statistics</label>                    
                <controller>statistic</controller>
                <action>index</action>
                <resource>statistic</resource>
                <privilege>index</privilege>
            </viewstats>
         </pages>              
    </statistics>

</nav>

ACLコード

class XXX_Controller_Action_Helper_AclPbo {

public $acl;

//Instatntiate Zend ACL
public function __construct() 
{
    $this->acl = new Zend_Acl();
}

//Set User Rolse
public function setRoles() 
{
    $this->acl->addRole(new Zend_Acl_Role('superAdmin'));       
    $this->acl->addRole(new Zend_Acl_Role('admin'));
}

//Set Resources - controller, models, etc...
public function setResources() 
{
    $this->acl->add(new Zend_Acl_Resource('app'));
    $this->acl->add(new Zend_Acl_Resource('index'));
    $this->acl->add(new Zend_Acl_Resource('user'));     
    $this->acl->add(new Zend_Acl_Resource('page'));
    $this->acl->add(new Zend_Acl_Resource('statistic'));
}

//Set privileges
public function setPrivilages() 
{
    $this->acl->allow('superAdmin', 'user', array('login','logout'));
    $this->acl->allow('superAdmin', 'index', 'index');
    $this->acl->allow('superAdmin', 'app', 'index');   
    $this->acl->allow('superAdmin', 'statistic', array('index'));

    $this->acl->allow('admin', 'user', array('index','login','logout'));      
    $this->acl->allow('admin', 'index', 'index');
    $this->acl->allow('admin', 'app', array('index'));
    $this->acl->allow('admin', 'page', array('index', 'add-page', 'edit-page'));
    $this->acl->allow('admin', 'statistic', array('index'));
}

//Set ACL to registry - store ACL object in the registry
public function setAcl() 
{
    Zend_Registry::set('acl', $this->acl);
}

}

4

1 に答える 1

1

この動作を経験している理由はここにあります

<statistics>
    <label>Statistics</label>
    <class>nav-top-item no-submenu</class>
            <uri>#</uri>

あなたが持っている必要がある間

<statistics>
    <label>Statistics</label>
    <class>nav-top-item no-submenu</class>
    <controller>statistic</controller>
    <action>index</action>
    <resource>statistic</resource>
    <privilege>index</privilege>

リソースのアクセス パラメータを定義しない限り、誰でも使用できます。

于 2012-09-12T11:39:38.337 に答える