Showing posts with label check user for user group in theme in liferay. Show all posts
Showing posts with label check user for user group in theme in liferay. Show all posts

Friday, 18 May 2012

Show the dock bar to the Particular group of user in theme in liferay

In the init-custom.vm
To access the UserLocalServicewrite the following line
#set ($userLocalService = $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))


to access the UserGroupLocalServiceUtil added the following line.
#set ($userGroupLocalService = $serviceLocator.findService("com.liferay.portal.service.UserGroupLocalService"))



Get the user group with the name web content moderator
#set ($userGroup = $userGroupLocalService.getUserGroup($user.getCompanyId(),$propsUtil.get("WebContentModerator)))


If the ser group exist and if the user is part of that user group then returns value true.


#if($userGroup)
    #set ($hasUserGroupRole = $userLocalService.hasUserGroupUser($userGroup.getUserGroupId(),$user.getUserId()))
#end

in the portal_normal.vm

#if ($is_signed_in && $hasUserGroupRole))
    #dockbar()
#end