質問

I'd like to know if there is a way to active the option "Merge Liferay public pages" by default for all the portal's user.

This option can be set here (have a look at the screenshot) : Control panel > Personal site > Site Pages > Public Pages > Advanced.

enter image description here

I searched the portal properties options but didn't find anything.

If there is a way to set it through a hook, I'm also interested.

役に立ちましたか?

解決

I found a solution.

I added a bit of code to my AutoLogin hook (see Liferay auto.login.hook property which can be set in the portail.properties file).

It's easy to set the "merge public page" option with the GroupServiceUtil class :

GroupServiceUtil.updateGroup(user.getGroupId(), "mergeGuestPublicPages=true");

If a "com.liferay.portal.security.auth.PrincipalException: PermissionChecker not initi alized" error is raised. It's necessary to first initialize the permission checker. Here is a way to do it:

Company company = PortalUtil.getCompany(request);
Role adminRole =  RoleLocalServiceUtil.getRole(company.getCompanyId(),"Administrator");
List<User> adminUsers = UserLocalServiceUtil.getRoleUsers(adminRole.getRoleId());

PrincipalThreadLocal.setName(adminUsers.get(0).getUserId());
try {
    PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(adminUsers.get(0));
    PermissionThreadLocal.setPermissionChecker(permissionChecker);
} catch (Exception e) {
    e.printStackTrace();
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top