5.1 Overhaul of Personal Communities

One of the most widely used features of Liferay is the Personal Community, aka My Community, aka Personal Space. It's a feature that allows users to have their own set of web pages, both private and public, to manage and update as they please. It's also a feature that has been challenging for developers to deal with. For example, you would like to grant certain users a Personal Community, but you want to be able to customize how it looks and what it does before you give it to them. These are the issues that were taken into consideration when version 5.1 was created!

One major update has to do with who gets a Personal Community. 5.1 jump kicks the Power User role out the window, so by default ALL users get a Personal Community. What if I want to be restrictive about who gets a Personal Space? I'm a control freak, how do I regain control over who gets a Personal Community!

Here is one quick way to do it in ServicePreAction.java.
First I have decided to overwrite the ServicePreAction class, so I've put this in my portal-ext.properties:

servlet.service.events.pre=com.ext.portal.events.CustomServicePreAction

I basically copied over the original ServicePreAction to my EXT environment and renamed it. Search for "// Layouts" inside ServicePreAction. Notice how the portal checks if you are signed in first, if you are then 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 && 
               /* check if user has Power User role */
               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);
         }
    }


Please refer here for more information on Personal Communities: http://wiki.liferay.com/index.php/Personal_Community

Blogs
Great Ivan! Not just for the power users anymore! Liferay.com has been in this state since May around the time WOL was introduced.
I think instead of simply throwing away the Power User, this should have been a configurable setting in the properties file. If you consider enterprise scenarios where the portal is being used for publishing and distributing content, a lot of times there will be no need to give each user a private space. Of course, as you specified, it is not very difficult to change this but then the overall out-of-the-box experience is broken.
Just my 2 cents.
I hope that it doesn't take coding to disable personal community pages in version 5.1!! Did Liferay servey thier customer base about this? My guess is that most of the commercial customers will want to have a means of easily disabling personal pages.