Forums / Developer / Custom userclass cannot be assigned roles!?

Custom userclass cannot be assigned roles!?

Author Message

Werner Klausen

Sunday 17 July 2005 5:47:07 am

I have a custom class called "Person" which contains the user-attribute. However, I am not able to add a role to instances of this calss, the radiobuttons are all greyed out.

If I make an instance of the premade "User" class, all is well.

So, the question is: How can I make a custom class, that I can assign roles? Is this maybe a bug?

I've treided this on both my upgraded eZ 3.6 version and e freshinstall of 3.6 (just to check there was nothing wrong with the upgrade).

Thanks =)

Because I can!

Bruce Morrison

Sunday 17 July 2005 9:03:50 pm

Hi Werner

Does the new class reside in the 'Users' Class group?
(i.e. /class/classlist/2 )

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Werner Klausen

Monday 18 July 2005 2:41:44 pm

Hi Bruce!

Yes, the class resides in both the User and content classgroups. So I am able to make an instance of the class from both the "Content structure" and the "User accounts" screen.

The calss is assigned a small green man-icon, so I guess it's interpeded by the system as a user-class. (However, the testclasses I make do NOT get this icon, but only has the common "sheet"-icon)

Because I can!

Bruce Morrison

Monday 18 July 2005 5:02:23 pm

Hi Werner

Not sure. The only other thing to check is if the new users you are creating are assigned the "Users" Section: (/section/view/2)

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Daniel Beyer

Tuesday 19 July 2005 2:28:37 am

Hi Werner,

by default eZ publish is configured to assign roles only to users (a class with the identifier "user") and to usergroups (a class with the identifier "user_group").

This behavior can be changed or extended by other class identifiers. Take a look into the file /settings/browse.ini. In it you will find a Section called "[AssignRole]", which looks like this:

# Action used when assigning a role to a user or user group
[AssignRole]
StartNode=users
SelectionType=single
ReturnType=ObjectID
Class[]
Class[]=user
Class[]=user_group
TopLevelNodes[]
TopLevelNodes[]=users

This defines that you can choose in browse mode only objects where the class identifier is either "user" or "user_group" and where the objects placed on the TopLevelNode "users".

If you want to assign roles to other classes you have to extend this section in browse.ini or an override of it. For example create a file /settings/override/browse.ini.append and write something like this into it:

[AssignRole]
Class[]=my_custom_user
Class[]=an_alternate_user_group

Of course you have to replace "my_custom_user" and "an_alternate_user_group" with the identifiers of the classes you created.

If you don't care about assigning roles only to specific classes you can either just delete the "Class[]" entries of section "[AssignRole]" from /settings/browse.ini or add something like this into an e.g. /settings/override/browse.ini:

[AssignRole]
Class[]

Now it is possible to assign roles to any object (folder, images, articles, ...) placed on TopLevelNode "users". But I really <b>don't</b> recommend this! Take the time and configure your system to assign roles only to specific classes (as in my first example).

Daniel Beyer
_________________________________
YMC AG
Kreuzlingen, Switzerland
web: www.ymc.ch
____________________________________

Werner Klausen

Wednesday 20 July 2005 6:11:28 am

Thanks all for helping out :)

I'm on vacation right now, so I'll get to it when I get back! Have a nice summer =)

Because I can!

Raymond Williams

Friday 29 September 2006 11:07:22 am

Just like to add a note that this post was /very/ useful to me. Addressed and solved my specific need, worked like a charm. Thank you Daniel!!

Marco Zinn

Saturday 30 September 2006 1:59:07 am

Just a quick "this saved my life, too". Thx.

Marco
http://www.hyperroad-design.com