2012-09-11 2 views
1

이 시스템, 관리자 및 슈퍼 관리자 2 개 사용자 수준이,있다, 내 탐색 XML 형식입니다 젠드 탐색 렌더링 문제

로그인 관리자로 모든 메뉴 항목이 표시되어야하며 슈퍼 위해, 잘 작동하는 경우 관리자는 대시 보드 및 통계 만 표시해야합니다.

슈퍼 관리자의 경우 대시 보드 및 통계와 함께 다른 메뉴 항목의 레이블 (관리자 만 표시해야 함)이 표시됩니다. 레이블을 숨기는 데 문제가 있습니까? 내 경우에는 대시 보드를 제외한 최상위 메뉴 항목에 대한 작업이 없습니다.

메뉴는 젠드 ACL과 연결

<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); 
} 

은}

+1

ACL 코드도 표시해야합니다. – PatrikAkerstrand

+0

admin 및 superAdmin은 거의 동일한 ACL 규칙을 사용합니까? – akond

+0

@akond - 그것을 고쳤습니다. – Shaolin

답변

1

이 문제가 발생하는 이유는 여기

놓여있다

당신만큼 당신이이 사람에게 사용할 수 있습니다 자원의 액세스 매개 변수를 정의하지 않는 한

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

을 가지고해야합니다 동안.

+0

예, 그게 내 문제입니다. 컨트롤러와 액션을 정의하지 않고도이를 극복 할 수있는 방법이 있습니다. – Shaolin

+0

Nope. 다른 방법은 없습니다. ZF가 이러한 매개 변수가 무엇인지 추측 할 것이라고 기대하지 않습니까? – akond