001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.workflow;
016    
017    import com.liferay.portal.kernel.workflow.WorkflowTaskManagerUtil;
018    import com.liferay.portal.model.Portlet;
019    import com.liferay.portal.security.permission.PermissionChecker;
020    
021    /**
022     * @author Miguel Pastor
023     */
024    public class MyWorkflowTasksControlPanelEntry
025            extends WorkflowControlPanelEntry {
026    
027            @Override
028            public boolean isVisible(
029                            PermissionChecker permissionChecker, Portlet portlet)
030                    throws Exception {
031    
032                    long companyId = permissionChecker.getCompanyId();
033                    long userId = permissionChecker.getUserId();
034    
035                    if (WorkflowTaskManagerUtil.getWorkflowTaskCountByUser(
036                                    companyId, userId, Boolean.FALSE) > 0) {
037    
038                            return true;
039                    }
040    
041                    if (WorkflowTaskManagerUtil.getWorkflowTaskCountByUser(
042                                    companyId, userId, Boolean.TRUE) > 0) {
043    
044                            return true;
045                    }
046    
047                    if (WorkflowTaskManagerUtil.getWorkflowTaskCountByUserRoles(
048                                    companyId, userId, Boolean.FALSE) > 0) {
049    
050                            return true;
051                    }
052    
053                    if (WorkflowTaskManagerUtil.getWorkflowTaskCountByUserRoles(
054                                    companyId, userId, Boolean.TRUE) > 0) {
055    
056                            return true;
057                    }
058    
059                    return false;
060            }
061    
062    }