I'm checking a user's usergroup id and displaying additional options
if they are in a particular usergroup. (followed the 2 part ACL
tutorial in the 2.0 book)
Here's an example I have in one of my views, to display different
content if you have the permissions:
<?php
$user = $this->Session->read('Auth.User');
if(isset($user)){
if($user['group_id'] == 1){
//Display Admin Options
}elseif($user['group_id'] == 2){
//Display Manager Options
}elseif($user['group_id'] == 3){
//Display User options
}
}
?>
It works - but it doesn't seem very efficient. I would have to put
that chunk of code into EVERY view that I create. Just looking for a
little guidance on how I can use this code more efficiently and
accomplish the same thing easier and more to standards.
Thanks
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment