001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/projects/CmsProjectsToolHandler.java,v $
003: * Date : $Date: 2008-02-27 12:05:51 $
004: * Version: $Revision: 1.8 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.workplace.tools.projects;
033:
034: import org.opencms.file.CmsObject;
035: import org.opencms.main.OpenCms;
036: import org.opencms.security.CmsRole;
037: import org.opencms.workplace.CmsWorkplace;
038: import org.opencms.workplace.administration.CmsAdminDialog;
039: import org.opencms.workplace.list.A_CmsListExplorerDialog;
040: import org.opencms.workplace.tools.A_CmsToolHandler;
041:
042: import java.util.HashMap;
043: import java.util.Map;
044:
045: /**
046: * Users management tool handler that hides the tool if the current user
047: * has not the needed privileges.<p>
048: *
049: * @author Michael Moossen
050: *
051: * @version $Revision: 1.8 $
052: *
053: * @since 6.0.0
054: */
055: public class CmsProjectsToolHandler extends A_CmsToolHandler {
056:
057: private static final String PROJECT_ID = "projectid";
058: private static final String PROJECT_NAME = "projectname";
059: private static final String PROJECT_OVERVIEW_FILE = "/system/workplace/admin/projects/project_overview.jsp";
060:
061: /**
062: * @see org.opencms.workplace.tools.A_CmsToolHandler#getParameters(org.opencms.workplace.CmsWorkplace)
063: */
064: public Map getParameters(CmsWorkplace wp) {
065:
066: if (OpenCms.getRoleManager().hasRole(wp.getCms(),
067: CmsRole.PROJECT_MANAGER)) {
068: return super .getParameters(wp);
069: } else {
070: Map argMap = new HashMap();
071: argMap.put(PROJECT_ID, wp.getCms().getRequestContext()
072: .currentProject().getUuid().toString());
073: argMap.put(PROJECT_NAME, wp.getCms().getRequestContext()
074: .currentProject().getName());
075: if (wp instanceof CmsProjectFilesDialog) {
076: argMap.put(A_CmsListExplorerDialog.PARAM_SHOW_EXPLORER,
077: "false");
078: }
079: if (wp instanceof CmsAdminDialog) {
080: argMap.put(A_CmsListExplorerDialog.PARAM_SHOW_EXPLORER,
081: "true");
082: }
083: return argMap;
084: }
085: }
086:
087: /**
088: * @see org.opencms.workplace.tools.I_CmsToolHandler#isEnabled(org.opencms.file.CmsObject)
089: */
090: public boolean isEnabled(CmsObject cms) {
091:
092: return !cms.getRequestContext().currentProject()
093: .isOnlineProject();
094: }
095:
096: /**
097: * @see org.opencms.workplace.tools.A_CmsToolHandler#isVisible(org.opencms.file.CmsObject)
098: */
099: public boolean isVisible(CmsObject cms) {
100:
101: if (OpenCms.getRoleManager().hasRole(cms,
102: CmsRole.PROJECT_MANAGER)) {
103: return !getLink().equals(PROJECT_OVERVIEW_FILE);
104: } else {
105: return getLink().equals(PROJECT_OVERVIEW_FILE);
106: }
107: }
108: }
|