I want to show or hide some elements in a scene based on ACL. For example, if a user is considering his user / index view, then I do not have permission to delete the user, so I do not want to show the 'Delete User' element. If he does have permission to edit users, then I want to show a 'edit user' link to do .
I can hack it together, but new to the cake I'm hoping that is a great solution. The best I have done is to keep logic in two places, so hell to maintain it.
Thank you!
I know this is an old question, but the way I was ...
In AppController :: beforeFilter, you can specify the ACL component in a viewable variable and then use it in your view:
$ this-> Set ('user', $ this-> AUTH- & gt; user ()); $ This- & gt; Set ('acl', $ this- & gt; ACL); And after that you can see it just like juice:
if ($ acl-> check (array ('user' = & Gt; $ It is not necessary that this is the best way to do it but it works well / html>
Comments
Post a Comment