In the portal_normal.vm file, present in the theme, we have to modify the below lines. Right now, dockbar is visible to anybody who signs in. We need to change it so that it is visible to users with a specific role.
#if ($is_signed_in) #dockbar() #endThis makes the com.liferay.portal.service.UserService available in the Velocity Template. It is assigned to the $userService variable.
#set($userService = $serviceLocator.findService("com.liferay.portal.service.UserService"))This line Calls the hasRoleUser method, to check if the user has the Role Dockbar assigned to him.
#set($docbarVisible = $userService.hasRoleUser($company_id, "Dockbar", $user_id, true))The below line checks if the user is Signed In AND has the role Dockbar OR if the User is the Company Admin.
#if ($is_signed_in && ($docbarVisible || $permissionChecker.isCompanyAdmin()))Final Code
#set($userService = $serviceLocator.findService("com.liferay.portal.service.UserService")) #set($docbarVisible = $userService.hasRoleUser($company_id, "Dockbar", $user_id, true)) #if ($is_signed_in && ($docbarVisible || $permissionChecker.isCompanyAdmin())) #dockbar() #endNow all that is left out is to assign few users the Dockbar role to verify that the Users will have access to the Dockbar. Hope the entire thing makes sense.
Feel free to post your comments.
No comments :
Post a Comment