2013-03-11 56 views
0

我有一个多步旅行请求应用程序。用户被引导到第一步,例如localhost/intraweb/travel_requests/step/1,直到他们到达最后一步localhost/intraweb/travel_requests/step/5。我现在遇到的问题是只有管理员可以访问步骤和普通用户不能。在我的情况下,用户在我的组表中有一个ID = 10ACL允许在CakePHP 2.x中不起作用的动作

这是怎么了我在我的UsersController使用ACL

//allow users to do a travel request 
public function initDB() { 
$group = $this->User->Group; 
$group->id = 10; 
$this->Acl->allow($group, 'controllers/TravelRequests/step($stepNumber'); 
} 

这里是我为我的TravelRequestsController代码

public function beforeRender() { 
parent::beforeRender(); 
$params = $this->Session->read('form.params'); 
$this->Auth->allow('step($stepNumber)'); 
$this->set('params', $params); 
} 

public function setup() { 
$steps = 5; 
$this->Session->write('form.params.steps', $steps); 
$this->Session->write('form.params.maxProgress', 0); 
$this->redirect(array('action' => 'step', 1)); 
} 

public function step($stepNumber) { 
if($this->Session->read('form.params.steps') != 5) { 
$this->redirect(array('action'=>'index')); 
} 

if (!file_exists(APP.'View'.DS.'TravelRequests'.DS.'step_'.$stepNumber.'.ctp')) { 
$this->redirect('/travel_requests/index'); 
} 

$maxAllowed = $this->Session->read('form.params.maxProgress') + 1; 
if ($stepNumber > $maxAllowed) { 
$this->redirect('/travel_requests/step/'.$maxAllowed); 
} else { 
$this->Session->write('form.params.currentStep', $stepNumber); 
} 
} 

做一些有一个想法,我错过了我的代码?

预先感谢您

回答

0

您正在试图让$this->Acl->allow($group, 'controllers/TravelRequests/step($stepNumber');其中step($stepNumber不是现有的操作。

您应该改用$this->Acl->allow($group, 'controllers/TravelRequests/step')

+0

感谢@noslone它的工作 – 2013-03-12 13:09:46