私はhttp://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-managed-application/part-two.htmlチュートリアルに従っていますが、少し異なるグループ (グループ 4 と 5 ) 4 は訪問者、5 は管理者
function initDB() {
10 $group = $this->User->Group;
11 //Allow admins to everything
12 $group->id = 5;
13 $this->Acl->allow($group, 'controllers');
14 //^doesnt work
15 //$this->Acl->allow(array( 'model' => 'Group', 'foreign_key' => 5), 'controllers');
16
17
18 $group->id = 4;
19 $this->Acl->deny($group, 'controllers');
20 $this->Acl->allow($group, 'controllers/User/login');
21 $this->Acl->allow($group, 'controllers/User/logout');
22 /*
23 $this->Acl->deny(array( 'model' => 'Group', 'foreign_key' => 4), 'controllers');
24 $this->Acl->allow(array( 'model' => 'Group', 'foreign_key' => 4), 'controllers/User/login');
25 $this->Acl->allow(array( 'model' => 'Group', 'foreign_key' => 4), 'controllers/User/logout');
26 */
27
28
29 echo "all done";
30 exit();
31 }
しかし、この関数を実行すると、次のエラーが発生します
Warning (512): DbAcl::allow() - Invalid node [CORE/Cake/Controller/Component/AclComponent.php, line 387]
Warning (512): DbAcl::allow() - Invalid node [CORE/Cake/Controller/Component/AclComponent.php, line 387]all done
何が得られる?!
編集 - 私のApp Controllerは次のようになります
<?php
class AppController extends Controller {
public $components = array(
'Acl',
'Auth' => array(
'authorize' => array(
'Actions' => array('actionPath' => 'controllers')
)
),
'Session'
);
public $helpers = array('Html', 'Form', 'Session');
public function beforeFilter() {
$this->Auth->actionPath = 'controllers/';
//Configure AuthComponent
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'images', 'action' => 'index');
$this->Auth->allow('display');
}
}
?>
EDIT 2:完全な警告は次のようになります
Warning (512): DbAcl::allow() - Invalid node [CORE/Cake/Controller/Component/AclComponent.php, line 387]
Code Context
DbAcl::allow() - CORE/Cake/Controller/Component/AclComponent.php, line 387
AclComponent::allow() - CORE/Cake/Controller/Component/AclComponent.php, line 128
UsersController::initDB() - APP/Controller/UsersController.php, line 20
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 473
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 107
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 89
[main] - APP/webroot/index.php, line 96
他のコードを投稿してほしい場合はお知らせください。