
Personal Community
Table of Contents [-]
This wiki page is dedicated to the Personal Community feature in Liferay Enterprise Portal. The Personal Community has evolved over the different versions of Liferay, but none as big a change as in version 5.1.
Other Names (aka)#
- My Community
- Private Community (not to be confused with private pages)
- Set of Personal Pages
- Personal Zone
What is Personal Community?#
Pre 5.1#
A dynamic feature of Liferay portal is the Personal Community, where specified users can have a set of public and private pages for themselves to manage. Historically, you could give a Personal Community to a user by assigning them the Power User role. The maximum number of members to one Personal Community is one. A user with a Personal Zone cannot make anyone else a member of his community. If you own a Personal Community, you have administrative rights over the pages within the community.
5.1#
5.1 takes the Power User role and throws it out the window. By default, the Personal Community is a portal wide setting, so the setting will affect all users. Coincidentally, a the settings are divided between private and public pages for greater versatility. Here are the settings in portal.properties:
layout.user.private.layouts.enabled=true //activate Personal Community with *private* pages layout.user.public.layouts.enabled=false //deactivate Personal Community with *public* pages
Customizations to Personal Community Pages#
One of the most asked questions about Personal Communities is how to administrate or manage the pages that belong to other users. How does one overcome the challenge that you cannot update something in Liferay that you don't have permissions to? How do you give a user a Personal Community that you have prepackaged with a set of predefined portlets and pages?
Pre 4.0#
If you search for "##Default User" in portal.properties, you will get the following:
//defines the name of the first page default.user.layout.name=Home //define the default layout template by specifying the layout template ID default.user.layout.template.id=2_columns_ii //define which portlets go on which column of the page default.user.layout.column-1=71_INSTANCE_OY0d,82,23,61,65,
The major drawbacks here are that you are limited to predefining one page and you don't have control over public pages.
4.x to 5.0.1#
Version 4.0 gave more flexibility in terms of private and public pages through the use of LARs (Liferay archives):
//specify the LAR that will be used to autogenerate a Private Community's private default.user.private.layouts.lar=${resource.repositories.root}/deploy/default_user_private.lar //and public pages. default.user.public.layouts.lar=${resource.repositories.root}/deploy/default_user_public.lar
5.1#
Version 5.1 introduces a whole slew of new settings. Once again some portal wide settings from the past are now multiplied in two between private and public pages for a personal community. To save space, I'm just going to paste the private page settings here:
//specify the default theme (used to be a portal wide setting) default.user.private.layout.regular.theme.id=classic //speficy default color scheme default.user.private.layout.regular.color.scheme.id=01 //define whether a user can update the page you set up for them layout.user.private.layouts.modifiable=true //pages are auto generated if true; if set to false, the user gets a Personal Community without predefined pages. //he can create the pages himself. layout.user.private.layouts.auto.create=true
Scenarios and Settings (feel free to add your own combinations here)#
I want to give users a Personal Community, but I don't want to prebuild it for them. I want them to have the freedom to do it themselves.
layout.user.private.layouts.enabled=true layout.user.private.layouts.modifiable=true layout.user.private.layouts.auto.create=false
I want to give users a Personal Community with predefined pages, but I don't want them to update the pages.
layout.user.private.layouts.enabled=true layout.user.private.layouts.modifiable=false layout.user.private.layouts.auto.create=true
I want to start out my users with a Personal Community with some default portlets, but they should be able to change it however they want.
layout.user.private.layouts.enabled=true layout.user.private.layouts.modifiable=true layout.user.private.layouts.auto.create=true
I only want Power Users to get a Personal Community in 5.1#
Let's say you don't want every user to get their own set of personal pages; you want to selectively give certain users this power. You would put your logic in ServicePreAction.java. Search for " Layouts" inside ServicePreAction. Notice how the portal checks if you are signed in first, if you are, it checks to see whether layout.user.private.layouts.enabled is true. If layout.user.private.layouts.enabled=true, then it executes addDefaultUserPrivateLayouts(). Let's try putting in some logic that will also check if the user has the Power User role:if (signedIn) { if (PropsValues.LAYOUT_USER_PRIVATE_LAYOUTS_ENABLED && UserLocalServiceUtil.hasRoleUser(RoleLocalServiceUtil.getRole(companyId, "Power User").getRoleId(), user.getUserId())) {
addDefaultUserPrivateLayouts(user); } else { deleteDefaultUserPrivateLayouts(user, companyId); }
if (PropsValues.LAYOUT_USER_PUBLIC_LAYOUTS_ENABLED) { addDefaultUserPublicLayouts(user); } else { deleteDefaultUserPublicLayouts(user); } } }}}
Also make sure to modify the logic for deleteDefaultUserPrivateLayouts() to be consistent with the portal's default behavior!
protected void deleteDefaultUserPrivateLayouts(User user, long companyId) throws PortalException, SystemException { if (!PropsValues.LAYOUT_USER_PRIVATE_LAYOUTS_ENABLED && user.hasPrivateLayouts() || /* if user does not have Power User role, and has a Private Community with private pages, delete the private pages */ !UserLocalServiceUtil.hasRoleUser(RoleLocalServiceUtil.getRole(companyId, "Power User").getRoleId(), user.getUserId()) && user.hasPrivateLayouts()*/) { Group userGroup = user.getGroup(); LayoutLocalServiceUtil.deleteLayouts(userGroup.getGroupId(), true); } }
Developer notes#
Remember to use this setting to overwrite or extend ServicePreAction:
servlet.service.events.pre=com.liferay.portal.events.ServicePreAction
Improvements#
Perhaps there could be a setting that will revert back to the old Power User logic.
Potential Upgrade Complications (please contribute to this area)#
Will the old Power User logic be broken when upgrading to 5.1? How will upgrading to 5.1 affect my system that depends on only Power Users getting a Personal Community?