Foros de discusión

Theme and Groups

Simone Puviani, modificado hace 14 años.

Theme and Groups

New Member Mensajes: 6 Fecha de incorporación: 30/10/09 Mensajes recientes
Hi,

i'm using liferay 5.0.1.
Is there any possibility to find the groups of an user in the template using Velocity?
I don't want the community or the organizzation, because i need to check a sort of permission.
I need the groups to show to certain users a different menu

Thanks
Simone
thumbnail
Amos Fong, modificado hace 14 años.

RE: Theme and Groups

Liferay Legend Mensajes: 2047 Fecha de incorporación: 7/10/08 Mensajes recientes
Hi Simone,

Do you mean usergroups? I'm not sure what groups you are referring to.

You can access all the liferay services in the template:
http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Access+to+Liferay+services+in+Velocity
thumbnail
Felix Joseph Christy, modificado hace 14 años.

RE: Theme and Groups

Regular Member Mensajes: 111 Fecha de incorporación: 26/08/09 Mensajes recientes
Hi,

You can search for init.vm in portal source. This vm includes all the variables which are available in templates. There is one variable set here

#set ($user_group = $user.getGroup())

You can use the same.


Thanks,
Felix
Simone Puviani, modificado hace 14 años.

RE: Theme and Groups

New Member Mensajes: 6 Fecha de incorporación: 30/10/09 Mensajes recientes
Thanks for the answer.

Felix Joseph Christy:
Hi,

You can search for init.vm in portal source. This vm includes all the variables which are available in templates. There is one variable set here

#set ($user_group = $user.getGroup())

You can use the same.


I've already tried that method but i didn't found anything good for my needs.
Everything i found is related to the community or the organizzation, and it's not what i'm looking for


Amos Fong:
Hi Simone,

Do you mean usergroups? I'm not sure what groups you are referring to.

You can access all the liferay services in the template:
http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Access+to+Liferay+services+in+Velocity


Yes, I mean user groups.
I have already read that article, and probably is the only solution (now I'll try it).

what I have to do is for example to show the deck only to the user group "administrator".
If someone has a simpler idea i can try to figure out if it is good for my purpose.
Simone Puviani, modificado hace 14 años.

RE: Theme and Groups

New Member Mensajes: 6 Fecha de incorporación: 30/10/09 Mensajes recientes
I've found the solution.
I've accessed the liferay services com.liferay.portal.service.UserGroupService from the template and then used it.


#set ($GroupAdministratorName = "Administrators")

#set($userGroupService = $serviceLocator.findService("com.liferay.portal.service.UserGroupService"))
#set($userGroups = $userGroupService.getUserUserGroups($user_id))
#set ($isAdministrator = false)
#foreach ($group in $userGroups)
	#if ($GroupAdministratorName == $group.getName())
		#set ($isAdministrator = true)
	#end
#end


After this, i just use an if on isAdministrator variable to show what i want.
If someone have a simpler idea i'm here.

Thanks.