如何将一个模型数据扩展到cakephp中的另一个控制器来检查条件?
,
class UsersController extends AppController
{
public function beforeFilter()
{
$this->loadModel('Apages');
$usr=$this->Apages->find('all');
$this->loadModel('Pagepermissions');
$pre=$this->Pagepermissions->find('all',array('conditions'=>array('user_id'=>'1')));
if($pre->request->data['Pagepermissions']['_add']==1)
{
$this->redirect(array('controller'=>'users','action'=>'add'));
}
else
{
throw new NotFoundException(__("Don't have access this Page"));
}
}
}
$pre->request->data['Pagepermissions']['_add']
显示错误。请告诉我该怎么做
Thanks in Advance
$ preis数组,执行如下操作
$pre=$this->Pagepermissions->find('all',array('conditions'=>array('user_id'=>'1')));
if(!empty($pre)){
foreach($pre as $v){
if($v['Pagepermissions']['_add']==1){
$this->redirect(array('controller'=>'users','action'=>'add'));
return;
}else{
throw new NotFoundException(__("Don't have access this Page"));
}
}
}else{
throw new NotFoundException(__("user not find"));
}