2
votes

I'm using the CakePHP ACL CRUD system in my webapplications and i'm trying to generate some menu's based on the permissions for the user currently logged in.

I'm facing a problem which is not documented in the CakePHP manual (at least I couldn't find it). I would like to check the permissions based on the following URL-format:

$url = '/admin/users/add';
$this->Acl->check(array('User' => array('id' => 2)), $url);

I've tried to parse the URL to a array-format with Router::parse() but check() is not able to handle this format.

The second parameter of Acl->check() expects a "Array with 'model' and 'foreign_key', model object, or string value"..

What is the best way to transform my $url to a format that checks() accepts?

1
Store the url in session data ..give it a try - Bhuvan Rikka
Unless you have the URL itself stored as an access control object (ACO) in your database, I think you're using the ACL incorrectly. I suggest reading and re-reading the ACL section of Cake's manual as this is probably the hardest section to fully understand. - Hoff

1 Answers

0
votes

urls map to controllers and actions, so use ActionsAuthorize for this