/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, org.opencms.workplace.explorer.CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { return !OpenCms.getRoleManager().hasRole(cms, CmsRole.WORKPLACE_USER); }
/** * Initializes this subscription manager with the OpenCms system configuration.<p> * * @param cms an OpenCms context object that must have been initialized with "Admin" permissions * * @throws CmsRoleViolationException in case the given opencms object does not have <code>{@link CmsRole#ROOT_ADMIN}</code> permissions */ public void initialize(CmsObject cms) throws CmsRoleViolationException { OpenCms.getRoleManager().checkRole(cms, CmsRole.ROOT_ADMIN); m_frozen = true; }
/** * Returns all users of organizational units for which the current user has * the {@link CmsRole#ACCOUNT_MANAGER} role.<p> * * @param cms the current cms context * @param ouFqn the fully qualified name of the organizational unit * @param includeSubOus if sub organizational units should be included in the search * * @return a list of {@link org.opencms.file.CmsUser} objects * * @throws CmsException if something goes wrong */ public List<CmsUser> getManageableUsers(CmsObject cms, String ouFqn, boolean includeSubOus) throws CmsException { return getManageableUsers(cms, ouFqn, includeSubOus, false); }
if (OpenCms.getRoleManager().hasRole(getCms(), CmsRole.VFS_MANAGER)) { CmsUser user = new CmsUser( CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID, principals.addAll(OpenCms.getRoleManager().getManageableUsers(getCms(), "", true)); if (OpenCms.getRoleManager().hasRole(getCms(), CmsRole.VFS_MANAGER)) { principals.add( new CmsGroup( principals.addAll(OpenCms.getRoleManager().getManageableGroups(getCms(), "", true));
return !OpenCms.getRoleManager().hasRole(cms, CmsRole.ADMINISTRATOR.forOrgUnit(parentOu)); return (OpenCms.getRoleManager().hasRole(cms, CmsRole.ADMINISTRATOR) && OpenCms.getRoleManager().hasRole(cms, CmsRole.ADMINISTRATOR.forOrgUnit(parentOu))); } else { return false; return OpenCms.getRoleManager().hasRole(cms, CmsRole.ADMINISTRATOR); } else if (getLink().equals(getPath(PARENT_FILE))) { if (parentOu != null) { return OpenCms.getRoleManager().hasRole(cms, CmsRole.ACCOUNT_MANAGER.forOrgUnit(parentOu)); } else { return false; return (OpenCms.getRoleManager().hasRole(cms, CmsRole.ADMINISTRATOR) && OpenCms.getRoleManager().hasRole(cms, CmsRole.ADMINISTRATOR.forOrgUnit(parentOu))); } else { return false; List<CmsOrganizationalUnit> orgUnits = OpenCms.getRoleManager().getOrgUnitsForRole( cms, CmsRole.ACCOUNT_MANAGER.forOrgUnit(""), try { CmsUser user = cms.readUser(userId); visible = OpenCms.getRoleManager().hasRole(cms, CmsRole.ADMINISTRATOR.forOrgUnit(user.getOuFqn())); visible &= OpenCms.getRoleManager().hasRole(cms, user.getName(), CmsRole.ELEMENT_AUTHOR); } catch (CmsException e) {
CmsGroup group = getCms().readGroup((String)listItem.get(LIST_COLUMN_GROUP_NAME)); CmsRole role = CmsRole.valueOf(group); if (!OpenCms.getRoleManager().hasRole(getCms(), user.getName(), role)) { OpenCms.getRoleManager().addUserToRole(getCms(), role, user.getName()); getCms().writeUser(user); CmsGroup group = getCms().readGroup((String)listItem.get(LIST_COLUMN_GROUP_NAME)); CmsRole role = CmsRole.valueOf(group); if (OpenCms.getRoleManager().hasRole(getCms(), user.getName(), role)) { OpenCms.getRoleManager().removeUserFromRole(getCms(), role, user.getName()); getCms().writeUser(user);
/** * Returns a list of those organizational units whose members can be managed by the current user.<p> * * @param cms the current CMS context * @param ouFqn the fully qualified name of the organizational unit * @param includeSubOus if sub organizational units should be included in the search * @param includeWebusers if webuser organizational units should be included in the search * * @return a list of organizational units * * @throws CmsException if something goes wrong */ public List<CmsOrganizationalUnit> getManageableOrgUnits( CmsObject cms, String ouFqn, boolean includeSubOus, boolean includeWebusers) throws CmsException { List<CmsOrganizationalUnit> result = Lists.newArrayList(); List<CmsOrganizationalUnit> ous = getOrgUnitsForRole( cms, CmsRole.ACCOUNT_MANAGER.forOrgUnit(ouFqn), includeSubOus); for (CmsOrganizationalUnit ou : ous) { if (includeWebusers || !ou.hasFlagWebuser()) { result.add(ou); } } return result; }
/** * Add the user to the given role.<p> * * @param user name of the user * @param role name of the role, for example 'EDITOR' * * @throws CmsException if something goes wrong */ public void addUserToRole(String user, String role) throws CmsException { OpenCms.getRoleManager().addUserToRole(m_cms, CmsRole.valueOfRoleName(role), user); }
/** * Returns all users of organizational units for which the current user has * the {@link CmsRole#ACCOUNT_MANAGER} role.<p> * * @param cms the current cms context * @param ouFqn the fully qualified name of the organizational unit * @param includeSubOus if sub organizational units should be included in the search * @param includeWebusers if webuser organizational units should be included in the search * * @return a list of {@link org.opencms.file.CmsUser} objects * * @throws CmsException if something goes wrong */ public List<CmsUser> getManageableUsers(CmsObject cms, String ouFqn, boolean includeSubOus, boolean includeWebusers) throws CmsException { List<CmsOrganizationalUnit> ous = getManageableOrgUnits(cms, ouFqn, includeSubOus, includeWebusers); List<CmsUser> users = new ArrayList<CmsUser>(); Iterator<CmsOrganizationalUnit> it = ous.iterator(); while (it.hasNext()) { CmsOrganizationalUnit orgUnit = it.next(); users.addAll(OpenCms.getOrgUnitManager().getUsers(cms, orgUnit.getName(), false)); } return users; }
/** * @see org.opencms.workplace.tools.accounts.A_CmsRoleUsersList#getUsers(boolean) */ @Override protected List<CmsUser> getUsers(boolean withOtherOus) throws CmsException { List<CmsUser> roleUsers = OpenCms.getRoleManager().getUsersOfRole( getCms(), CmsRole.valueOf(getCms().readGroup(getParamRole())), withOtherOus, false); List<CmsUser> users; if (withOtherOus) { users = OpenCms.getRoleManager().getManageableUsers(getCms(), "", true); } else { users = OpenCms.getRoleManager().getManageableUsers(getCms(), getParamOufqn(), false); } users.removeAll(roleUsers); return users; }
OpenCms.getRoleManager().addUserToRole(getCms(), role, user.getName()); getCms().writeUser(user); } catch (CmsException e) { if (!OpenCms.getRoleManager().getRolesOfUser(getCms(), user.getName(), "", true, true, true).contains( role)) { throw new CmsRuntimeException( OpenCms.getRoleManager().removeUserFromRole(getCms(), role, user.getName()); getCms().writeUser(user); } catch (CmsException e) {
if (isShowingUsers()) { if (OpenCms.getRoleManager().hasRole(getCms(), CmsRole.VFS_MANAGER)) { CmsUser user = new CmsUser( CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID, if (includeOtherOus) { principals.addAll(OpenCms.getRoleManager().getManageableUsers(getCms(), "", true)); if (OpenCms.getRoleManager().hasRole(getCms(), CmsRole.VFS_MANAGER)) { principals.add(new CmsGroup( CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID, if (includeOtherOus) { principals.addAll(OpenCms.getRoleManager().getManageableGroups(getCms(), "", true));
/** * Returns all groups of organizational units for which the current user * has the {@link CmsRole#ACCOUNT_MANAGER} role.<p> * * @param cms the current cms context * @param ouFqn the fully qualified name of the organizational unit * @param includeSubOus if sub organizational units should be included in the search * * @return a list of {@link org.opencms.file.CmsGroup} objects * * @throws CmsException if something goes wrong */ public List getManageableGroups(CmsObject cms, String ouFqn, boolean includeSubOus) throws CmsException { List groups = new ArrayList(); Iterator it = getOrgUnitsForRole(cms, CmsRole.ACCOUNT_MANAGER.forOrgUnit(ouFqn), includeSubOus).iterator(); while (it.hasNext()) { CmsOrganizationalUnit orgUnit = (CmsOrganizationalUnit)it.next(); groups.addAll(OpenCms.getOrgUnitManager().getGroups(cms, orgUnit.getName(), false)); } return groups; }
try { OpenCms.getRoleManager().addUserToRole(getCms(), role, userName); return; } catch (Throwable e) {
/** * Gets the search parameters.<p> * * @return the search parameters * * @throws CmsException if something goes wrong */ protected CmsUserSearchParameters getSearchParams() throws CmsException { CmsListState state = getListState(); List<CmsOrganizationalUnit> ous = OpenCms.getRoleManager().getManageableOrgUnits(getCms(), "", true, false); CmsUserSearchParameters params = new CmsUserSearchParameters(); params.setAllowedOus(ous); String searchFilter = state.getFilter(); params.addSearch(SearchKey.email); params.addSearch(SearchKey.orgUnit); params.setSearchFilter(searchFilter); params.setFilterCore(true); params.setPaging(getList().getMaxItemsPerPage(), state.getPage()); params.setSorting(getSortKey(state.getColumn()), state.getOrder().equals(CmsListOrderEnum.ORDER_ASCENDING)); return params; }
/** * @see org.opencms.workplace.tools.A_CmsToolHandler#isEnabled(org.opencms.file.CmsObject) */ @Override public boolean isEnabled(CmsObject cms) { return OpenCms.getRoleManager().hasRole(cms, CmsRole.WORKPLACE_MANAGER); }
/** * Checks that the current user is a workplace user.<p> * * @throws CmsRoleViolationException if the user does not have the required role */ protected void checkRole() throws CmsRoleViolationException { OpenCms.getRoleManager().checkRole(m_cms, CmsRole.WORKPLACE_USER); }
/** * Returns all groups of organizational units for which the current user * has the {@link CmsRole#ACCOUNT_MANAGER} role.<p> * * @param cms the current cms context * @param ouFqn the fully qualified name of the organizational unit * @param includeSubOus if sub organizational units should be included in the search * * @return a list of {@link org.opencms.file.CmsGroup} objects * * @throws CmsException if something goes wrong */ public List<CmsGroup> getManageableGroups(CmsObject cms, String ouFqn, boolean includeSubOus) throws CmsException { List<CmsGroup> groups = new ArrayList<CmsGroup>(); Iterator<CmsOrganizationalUnit> it = getOrgUnitsForRole( cms, CmsRole.ACCOUNT_MANAGER.forOrgUnit(ouFqn), includeSubOus).iterator(); while (it.hasNext()) { CmsOrganizationalUnit orgUnit = it.next(); groups.addAll(OpenCms.getOrgUnitManager().getGroups(cms, orgUnit.getName(), false)); } return groups; }
/** * Returns all users of organizational units for which the current user has * the {@link CmsRole#ACCOUNT_MANAGER} role.<p> * * @param cms the current cms context * @param ouFqn the fully qualified name of the organizational unit * @param includeSubOus if sub organizational units should be included in the search * * @return a list of {@link org.opencms.file.CmsUser} objects * * @throws CmsException if something goes wrong */ public List getManageableUsers(CmsObject cms, String ouFqn, boolean includeSubOus) throws CmsException { return getManageableUsers(cms, ouFqn, includeSubOus, false); }
try { OpenCms.getRoleManager().addUserToRole(getCms(), role, userName); return; } catch (Throwable e) {