Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
toggle
Simone Puviani
Theme and Groups
11 de noviembre de 2009 15:18
Respuesta

Simone Puviani

Ranking: New Member

Mensajes: 6

Fecha de incorporación: 30 de octubre de 2009

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
Amos Fong
RE: Theme and Groups
11 de noviembre de 2009 16:58
Respuesta

Amos Fong

LIFERAY STAFF

Ranking: Liferay Legend

Mensajes: 1898

Fecha de incorporación: 7 de octubre de 2008

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
Felix J Christy
RE: Theme and Groups
11 de noviembre de 2009 20:34
Respuesta

Felix J Christy

Ranking: Regular Member

Mensajes: 111

Fecha de incorporación: 25 de agosto de 2009

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
RE: Theme and Groups
12 de noviembre de 2009 2:53
Respuesta

Simone Puviani

Ranking: New Member

Mensajes: 6

Fecha de incorporación: 30 de octubre de 2009

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
RE: Theme and Groups
12 de noviembre de 2009 3:45
Respuesta

Simone Puviani

Ranking: New Member

Mensajes: 6

Fecha de incorporación: 30 de octubre de 2009

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.

 1
 2#set ($GroupAdministratorName = "Administrators")
 3
 4#set($userGroupService = $serviceLocator.findService("com.liferay.portal.service.UserGroupService"))
 5#set($userGroups = $userGroupService.getUserUserGroups($user_id))
 6#set ($isAdministrator = false)
 7#foreach ($group in $userGroups)
 8    #if ($GroupAdministratorName == $group.getName())
 9        #set ($isAdministrator = true)
10    #end
11#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.