I have problem with Acl in cakePhp 2.5.x . I have done everything cakephp cookbook told me, but i still have a problem.
So I set up my application to have 3 groups. Administrator, Manager, and User, just like in cookbook. At this time my app only has 1 user and this user belong to Administrator. Administrator can do anything.
this is my AppController code :
class AppController extends Controller {
public $components = array(
'Acl',
'Session',
'Auth' => array(
'loginRedirect' => array(
'controller' => 'users',
'action' => 'index'
),
'logoutRedirect' => array(
'controller' => 'users',
'action' => 'login'
),
'authenticate' => array(
'Form' => array(
'passwordHasher' => 'Blowfish'
)
),
'authorize' => array(
'Actions' => array('actionPath'=>'controllers'),
),
)
);
public function beforeFilter(){
//not thinked yet
parent::beforeFilter();
//$this->initDB();
}
public function initDB(){
$group = $this->User->MemberOf;
// Allow admins to everything
$group->id = 1;
$this->Acl->allow($group, 'controllers');
}
}
and UsersController
class UsersController extends AppController{
public $helpers = array('Html','Form');
public $uses = array("User","Group");
// callbacks
public function beforeFilter(){
parent::beforeFilter();
The problem is when i(Administrator, and i've logged in) want to call 'add' action of UsersController cakephp give me this error :
Database Error
Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Aro0.foreignKey' in 'where clause'
SQL Query: SELECT Aro
.id
, Aro
.parent_id
, Aro
.model
, Aro
.foreign_key
, Aro
.alias
FROM dotcore
.aros
AS Aro
INNER JOIN dotcore
.aros
AS Aro0
ON (Aro
.lft
<= Aro0
.lft
AND Aro
.rght
>= Aro0
.rght
) WHERE Aro0
.model
= 'Group' AND Aro0
.foreignKey
= '1' ORDER BY Aro
.lft
DESC
Notice: If you want to customize this error message, create app\View\Errors\pdo_error.ctp
I know that in aros table there's no foreignKey field, but foreign_key, but why cakephp use foreignKey in where clause?
Please help me to solve this problem, i can't find any post/question about this problem, so i ask this problem here. I really appreciate your response. Thank you