tags:

views:

51

answers:

1

I am using Symfony 1.2.9 (with Propel ORM) on a website I am building. I have installed the sfGuard plugin and have created groups and permissions.

Assume the credential in this case is 'foobar'. I am thinking of assigning the permission 'foobar' to a group 'foobarGrp', and then making new users, members of the group 'foobarGrp'. The assumption is that users will then 'inherit' the permission (credential) from the foobarGrp (by dint of the fact that they are members of the group foobarGrp). Is my assumption correct?.

+2  A: 

yes, that's correct.

If you create a credential and a group, and assign that credential to that group, then all the users that belong to that group get the credential permission as well.

Groups and credentials are useful when handling multiple credentials and multiple users, that way you can add / remove permissions to certain groups instead of add / remove permissions per user basis making it faster to manage them.

Roberto
Thanks Roberto. So the code to do that would be something like the code here: http://pastebin.com/d54fd4bec Is there a more effecient way of doing this? (as you can see, I am hitting the db quite a few times.)
Stick it to THE MAN
It should be `$user->addGroupByName('groupname')`
develop7
Yeah, he is correct, you can find more information regarding addGroupByName and addPermissionsByName methods here: http://www.symfonylab.com/extra-questions-and-solutions-for-sfguardplugin/
Roberto