Forums / Developer / Fetch current usergroup?

Fetch current usergroup?

Author Message

Nicklas Lundgren

Monday 08 June 2009 2:35:14 pm

Hi all,

I have some trouble finding a way to list the users of the usergroup that has access to a certain content object.

It´s an intranet application, all users with access rights to a certain content object are placed in one of many user groups. From the template of a node I want to list all users with access to the contentobject.

It could be as easy as:

{def $user=fetch( 'user', 'current_user' )}

{def $users=fetch(content,list,hash(parent_node_id,$user.contentobject.main_parent_node_id, limitation, array()))}

{foreach $users as $oneuser}
 <h2>Name of user :{$oneuser.name}</h2>
 {/foreach}
 {undef}

BUT ... what if the current user has additional placements in other usergroups... how can I then know which of these user groups that has access to this content object?

I imagine I would need to do some check for reverse related objects from the content object to the usergroup, but so far, I haven´t found any solution.

So.... all suggestions on how to accomplish this are welcome.

Best regards,
/Nicklas

Nicklas Lundgren, Managing Director
Novitell AB, Sweden