1 31 32 package org.opencms.workplace.tools.accounts; 33 34 import org.opencms.file.CmsObject; 35 import org.opencms.main.OpenCms; 36 import org.opencms.module.CmsModule; 37 import org.opencms.security.CmsRole; 38 import org.opencms.workplace.tools.A_CmsToolHandler; 39 40 50 public class CmsAccountsToolHandler extends A_CmsToolHandler { 51 52 53 private static final String PARAM_VISIBILITY_FLAG = "visibility"; 54 55 56 private static final String VISIBILITY_ALL = "all"; 57 58 59 private static final String VISIBILITY_NONE = "none"; 60 61 62 private static final String VISIBILITY_WEBUSERSONLY = "webusersonly"; 63 64 67 public boolean isEnabled(CmsObject cms) { 68 69 return cms.hasRole(CmsRole.ACCOUNT_MANAGER); 70 } 71 72 75 public boolean isVisible(CmsObject cms) { 76 77 if (getVisibilityFlag().equals(VISIBILITY_NONE)) { 78 return false; 79 } 80 if (getVisibilityFlag().equals(VISIBILITY_ALL)) { 81 return cms.hasRole(CmsRole.ACCOUNT_MANAGER); 82 } 83 if (getVisibilityFlag().equals(VISIBILITY_WEBUSERSONLY)) { 84 boolean visible = cms.hasRole(CmsRole.ACCOUNT_MANAGER); 85 visible = visible 86 && (getPath().equals("/accounts") || getPath().indexOf("/webusers") > 0 || getPath().indexOf("/groups") > 0); 87 return visible; 88 } 89 return true; 90 } 91 92 97 private String getVisibilityFlag() { 98 99 CmsModule module = OpenCms.getModuleManager().getModule(this.getClass().getPackage().getName()); 100 if (module == null) { 101 return VISIBILITY_ALL; 102 } 103 return module.getParameter(PARAM_VISIBILITY_FLAG, VISIBILITY_ALL); 104 } 105 } 106 | Popular Tags |