/** * Returns the current user.<p> * * @return the current user */ public CmsUser currentUser() { return m_requestContext.getCurrentUser(); }
/** * Returns the current user object.<p> * * @return the current user object * * @deprecated use {@link #getCurrentUser()} instead */ @Deprecated public CmsUser currentUser() { return getCurrentUser(); }
/** * Creates a user settings object with initialized settings of the current user.<p> * * @param cms the OpenCms context */ public CmsUserSettings(CmsObject cms) { this(cms.getRequestContext().getCurrentUser()); }
/** * Returns the current user from the context.<p> * * Usage example on a JSP with the EL:<pre> * The current user name is: ${cms:vfs(pageContext).currentUser.name} * </pre> * * @return the current user */ public CmsUser getCurrentUser() { return m_cms.getRequestContext().getCurrentUser(); }
/** * Returns the user.<p> * * @return the user */ public String getUser() { return m_context.getCurrentUser().getName(); } }
/** * Returns the current user.<p> * * @return the current user */ public CmsUser whoami() { return m_cms.getRequestContext().getCurrentUser(); }
/** * @see org.opencms.ui.contextmenu.I_CmsHasMenuItemVisibility#getVisibility(org.opencms.file.CmsObject, java.util.List) */ public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, List<CmsResource> resources) { return cms.getRequestContext().getCurrentUser().isManaged() ? CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE : CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE; } }
/** * Returns the current users name.<p> * * @return the current users name */ public String userName() { return m_cms.getRequestContext().getCurrentUser().getName(); }
/** * Returns the set of permissions of the current user for a given resource.<p> * * @param resourceName the name of the resource * * @return the bit set of the permissions of the current user * * @throws CmsException if something goes wrong */ public CmsPermissionSet getPermissions(String resourceName) throws CmsException { return getPermissions(resourceName, m_context.getCurrentUser().getName()); }
/** * Sets the show editor help flag.<p> * * @param cms the cms context * @param showHelp the show help flag * @throws CmsException if writing the user info fails */ public void setShowEditorHelp(CmsObject cms, boolean showHelp) throws CmsException { CmsUser user = cms.getRequestContext().getCurrentUser(); user.setAdditionalInfo(ADDINFO_ADE_SHOW_EDITOR_HELP, String.valueOf(showHelp)); cms.writeUser(user); }
/** * Returns the show editor help flag.<p> * * @param cms the cms context * * @return the show editor help flag */ public boolean isShowEditorHelp(CmsObject cms) { CmsUser user = cms.getRequestContext().getCurrentUser(); String showHelp = (String)user.getAdditionalInfo(ADDINFO_ADE_SHOW_EDITOR_HELP); return CmsStringUtil.isEmptyOrWhitespaceOnly(showHelp) || Boolean.parseBoolean(showHelp); }
/** * Returns the id of the last used workflow for the current user.<p> * * @return the workflow id */ private String getLastWorkflowForUser() { CmsUser user = getCmsObject().getRequestContext().getCurrentUser(); return (String)user.getAdditionalInfo(PARAM_WORKFLOW_ID); }
/** * Checks if the given context user has the given role in the given organizational unit.<p> * * @param cms the opencms context * @param role the role to check * * @return <code>true</code> if the given context user has the given role in the given organizational unit */ public boolean hasRole(CmsObject cms, CmsRole role) { return m_securityManager.hasRole(cms.getRequestContext(), cms.getRequestContext().getCurrentUser(), role); }
/** * Perform a security check against OpenCms. * * @param cms The OpenCms object. * * @throws CmsPermissionViolationException in case of the anonymous guest user */ private void performPermissionCheck(CmsObject cms) throws CmsPermissionViolationException { if (cms.getRequestContext().getCurrentUser().isGuestUser()) { throw new CmsPermissionViolationException(null); } }
/** * Reads the result view type from the current user.<p> * * @return the result view type */ private String readResultViewType() { return (String)getCmsObject().getRequestContext().getCurrentUser().getAdditionalInfo( RESULT_VIEW_TYPE_ADD_INFO_KEY); }
/** * Returns whether the login dialog should be shown.<p> * * @return <code>true</code> if the login dialog should be shown */ static boolean shouldShowLogin() { return ((CmsUIServlet)getCurrent()).getCmsObject().getRequestContext().getCurrentUser().isGuestUser(); }
/** * @see org.opencms.ade.galleries.shared.rpc.I_CmsGalleryService#saveResultViewType(java.lang.String) */ public void saveResultViewType(String resultViewType) { CmsUser user = getCmsObject().getRequestContext().getCurrentUser(); user.setAdditionalInfo(RESULT_VIEW_TYPE_ADD_INFO_KEY, resultViewType); try { getCmsObject().writeUser(user); } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); } }
/** * Make sure that this resource is locked.<p> * * @throws CmsException if something goes wrong */ protected void ensureLock() throws CmsException { CmsLock lock = m_cms.getLock(m_resource); if (lock.isUnlocked() || !lock.isLockableBy(m_cms.getRequestContext().getCurrentUser())) { m_cms.lockResourceTemporary(m_cms.getSitePath(m_resource)); } }
/** * Checks that the resource is not locked by another user.<p> * * @param resource the resource * @return true if the resource is not locked by another user * * @throws CmsException if something goes wrong */ private boolean checkLock(CmsResource resource) throws CmsException { CmsLock lock = m_cms.getLock(resource); return lock.isUnlocked() || lock.getUserId().equals(m_cms.getRequestContext().getCurrentUser().getId()); }
/** * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isEnabled() */ @Override public boolean isEnabled() { return (OpenCms.getRoleManager().hasRole(getWp().getCms(), CmsRole.ROOT_ADMIN) || getWp().getCms().getRequestContext().getCurrentUser().getName().equals( getItem().get(LIST_COLUMN_USER))); }