001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.servlet.taglib.ui;
016    
017    import com.liferay.portal.kernel.servlet.taglib.ui.FormNavigatorConstants;
018    import com.liferay.portal.kernel.spring.osgi.OSGiBeanProperties;
019    import com.liferay.portal.model.User;
020    import com.liferay.portal.service.ServiceContext;
021    import com.liferay.portal.service.ServiceContextThreadLocal;
022    import com.liferay.portal.theme.PortletDisplay;
023    import com.liferay.portal.theme.ThemeDisplay;
024    import com.liferay.portal.util.PortletKeys;
025    
026    /**
027     * @author Pei-Jung Lan
028     */
029    @OSGiBeanProperties(property = {"service.ranking:Integer=20"})
030    public class UserPersonalSiteFormNavigatorEntry
031            extends BaseUserFormNavigatorEntry {
032    
033            @Override
034            public String getCategoryKey() {
035                    return FormNavigatorConstants.CATEGORY_KEY_USER_USER_INFORMATION;
036            }
037    
038            @Override
039            public String getKey() {
040                    return "personal-site";
041            }
042    
043            @Override
044            public boolean isVisible(User user, User selUser) {
045                    ServiceContext serviceContext =
046                            ServiceContextThreadLocal.getServiceContext();
047    
048                    ThemeDisplay themeDisplay = serviceContext.getThemeDisplay();
049    
050                    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
051    
052                    String portletName = portletDisplay.getPortletName();
053    
054                    if ((selUser != null) && portletName.equals(PortletKeys.MY_ACCOUNT)) {
055                            return false;
056                    }
057    
058                    return true;
059            }
060    
061            @Override
062            protected String getJspPath() {
063                    return "/html/portlet/users_admin/user/personal_site.jsp";
064            }
065    
066    }