This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » plugins » User management plugins » sfGuard permission extra value
sfGuard permission extra value [message #56424] Thu, 17 July 2008 22:48 Go to next message
colnector
Messages: 162
Registered: July 2008
Senior Member
Real-world scenario: my site is translated by users on the site. Most users do not have translation permissions and some have permissions for a specific language (or two). In my currently running non-symfony website (with 25 languages), I implement these permissions using a permissions string (such as translate=es or translate=de or translate=es,de).
It seems sfGuard some not provide a good solution for this situation unless I'm missing something.
Creating 25 different permissions may seem possible but for other things I would have to create thousands of different permissions which doesn't seem very logical or effective.

How would you suggest to solve this?
Do you think a solution should be provided in the plugin?
(I'm actually using sfGuardDoctrinePlugin).

A possible solution for me (without touching the plugin) would be to add another table sf_guard_user_permission_extra(user_id, permission_id, extra_data) with extended permission data.


Colnect Collectors Club Community
http://colnect.com

http://i.colnect.net/images/colnect_logo_255.png
Re: sfGuard permission extra value [message #56431 is a reply to message #56424 ] Fri, 18 July 2008 00:20 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
I've solved this issue in the general case by having a property table that relates to user ids (1:many - one user can have many property table rows). A "property" is simply a name-value pair, and in my system is read into the user session at logon time.

It seems to me that your system could use something similar. Rather than creating a specific table just for translation permissions, you could just allocate name-value pairs in a general properties table. You could do something like this:

language_allowed -> en
language_allowed -> de
language_allowed -> es

Or, since you are dealing with relatively small strings, you could just have one property and explode it when you need to:

languages_allowed -> en,de,es

To retrieve values, you can modify your user class to contain a getProperty($name) method.


Remember Palestine
Re: sfGuard permission extra value [message #56438 is a reply to message #56431 ] Fri, 18 July 2008 02:57 Go to previous messageGo to next message
colnector
Messages: 162
Registered: July 2008
Senior Member
Thank you for your reply.

I've been trying to present a solution for the general case that would fit into the sfGuard plugin as well but I guess you can't have all the functionality you want in plugins Smile

Cheers


Colnect Collectors Club Community
http://colnect.com

http://i.colnect.net/images/colnect_logo_255.png
Re: sfGuard permission extra value [message #57812 is a reply to message #56424 ] Mon, 04 August 2008 15:51 Go to previous message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
There's no need to edit the plugin here. Just have a profile table - allowed by sfGuard - that includes a getProperty() method.

Edit: sorry, that's not very clear. The getProperty() method would go in your sfUser/sfSecurityUser extending class, but then would do a lookup based on the id of your user and the name of the property requested. The user mgmt stuff confuses even me sometimes, and I've been working for some time with it! Rolling Eyes

[Updated on: Mon, 04 August 2008 15:53]


Remember Palestine
Previous Topic:How to enable sfGuard to keep sessions between apps
Next Topic:[sfGuardDoctrine] Integrity Exception
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software