2010-06-03 28 views
1

我有四個動作時間表控制器:拒絕訪問與Zend ACL動作導致導航鏈接消失

class ScheduleController extends Zend_Controller_Action { 

    public function indexAction(){ ... } 

    public function viewAction(){ ... } 

    public function addAction(){ ... } 

    public function deleteAction(){ ... } 

} 

所以我已經設置了Zend_Navigation一個數組,像這樣:

array(

    ...other links here... 

    array(
     'controller'=> 'schedule', 
     'action' => 'index', 
     'label' => 'Schedule', 
     'resource' => 'schedule', 
     'privilege' => 'index', 
     'privilege' => 'view',  
     'privilege' => 'add', 
     'privilege' => 'edit', 
    ) 
); 

我還在ACL中創建了兩個組:用戶&管理員。我想設置它,以便用戶可以訪問'索引'和'查看',而管理員可以訪問所有內容。於是我開始用這樣的:現在

class My_AccessControlList extends Zend_Acl { 
    $this->addRole(new Zend_Acl_Role('user')); 
    $this->addRole(new Zend_Acl_Role('admin'), 'user'); 
    ... 
    $this->addResource(new Zend_Acl_Resource('schedule')); 
    $this->deny(); 
    ... 

,看來除非我加入這一行:

$this->allow('user', 'schedule'); 

的鏈接不會在導航顯示。然後,如果我添加此:

$this->deny('user', 'schedule', 'add'); 

用戶被阻止'添加'行動,迄今爲止好。但是,如果我接着添加:

$this->deny('user', 'schedule', 'edit'); 
    --or change it to this-- 
    $this->deny('user', 'schedule', array('add', 'edit')); 

用戶被適當阻擋,但鏈接從導航對象中消失。有誰知道我做錯了什麼?謝謝。

回答

1
array(
    'controller'=> 'schedule', 
    'action' => 'index', 
    'label' => 'Schedule', 
    'resource' => 'schedule', 
    'privilege' => 'index', 
    'privilege' => 'view',  
    'privilege' => 'add', 
    'privilege' => 'edit', 
) 

...您將三次覆蓋'特權'鍵,這將導致數組中包含最後一個值'edit'的'特權'。 '特權'鍵應該包含四個值的數組