이 시스템, 관리자 및 슈퍼 관리자 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);
}
은}
ACL 코드도 표시해야합니다. – PatrikAkerstrand
admin 및 superAdmin은 거의 동일한 ACL 규칙을 사용합니까? – akond
@akond - 그것을 고쳤습니다. – Shaolin