I'm setting a few variables in my UserController that I want to access
in my AppController (in the beforeFilter). But I'm getting this error:
Notice: Undefined property: PagesController::$accessExceptions in
C:\websites\klickfile.com\app\app_controller.php on line 67
I get the same error with the $this->category variable as well.
In the app_controller's beforeFilter, are the variables in the child
class not available yet? How can I access them? (If I can, this will be
a really slick way to do user-managed ACL).
class UsersController extends AppController
{
var $uses = array('User');
var $category = 'Users'; // The category this controller belongs to
/**
* Exceptions for access_rights other that view,index,add,edit,delete.
Maps the exceptions to one of the default access_rights
*/
var $accessExceptions = array(
'dashboard'=>'view',
'login'=>'view',
'email'=>'add',
);
}
class AppController extends Controller {
var $beforeFilter = array('_checkAccess');
var $uses = array('UsergroupRight', 'AccessCategory');
/**
* Default actions (bit values)
*/
var $defaults = array(
'view'=>1,
'index'=>2,
'add'=>4,
'edit'=>8,
'delete'=>16
);
/**
* Checks to see whether a usegroup has permission to perform the
requested
* action on the requested controller.
*/
function _checkAccess()
{
// Check for accessExceptions
$checkAction = in_array($this->action, $this->defaults) ?
$this->action : $this->accessExceptions[$this->action];
$hasAccess =
$this->UsergroupRight->find(array('AccessCatetegory.name'=>$this->category,
'UsergroupRight.usergroup_id'=>$this->Session->read('usergroup_id'),
'UsergroupRight.access_rights_value & '.$checkAction.' > 0'));
echo 'hasAccess?: '.$hasAccess;
exit();
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---