Class XWikiUser


  • public class XWikiUser
    extends Object
    • Field Detail

      • ACTIVE_PROPERTY

        public static final String ACTIVE_PROPERTY
        The name of the property that store the active status of the user.
        Since:
        11.8RC1
        See Also:
        Constant Field Values
      • EMAIL_CHECKED_PROPERTY

        public static final String EMAIL_CHECKED_PROPERTY
        The name of the property that store the information if an email was checked for the user.
        Since:
        11.8RC1
        See Also:
        Constant Field Values
      • ACCOUNT_VALIDATION_DOCUMENT_REFERENCE

        public static final LocalDocumentReference ACCOUNT_VALIDATION_DOCUMENT_REFERENCE
    • Constructor Detail

      • XWikiUser

        public XWikiUser​(DocumentReference userReference)
        Create a XWikiUser from its document reference and infer if the user is global or not based on the wiki part of this reference. See isMain() for more information.
        Parameters:
        userReference - the document reference of the user.
        Since:
        11.6RC1
      • XWikiUser

        public XWikiUser​(DocumentReference userReference,
                         boolean main)
        Create a XWikiUser from its document reference and set the main flag. (see isMain()).
        Parameters:
        userReference - the document reference of the user.
        main - true if the user is global (i.e. registered in the main wiki)
        Since:
        11.6RC1
      • XWikiUser

        @Deprecated
        public XWikiUser​(String user)
        Deprecated.
        since 11.6RC1 use XWikiUser(DocumentReference).
        Create a XWikiUser for the given user.
        Parameters:
        user - the full name of the user on the form XWiki.Foo.
      • XWikiUser

        @Deprecated
        public XWikiUser​(String user,
                         boolean main)
        Deprecated.
        Create a XWikiUser for the given user.
        Parameters:
        user - the full name of the user on the form XWiki.Foo.
        main - true if the user is global (i.e. registered in the main wiki)
    • Method Detail

      • getFullName

        public String getFullName()
        Returns:
        the fullname of the user like XWiki.Foo.
      • isEmailChecked

        public boolean isEmailChecked​(XWikiContext context)
        Parameters:
        context - used to retrieve the user document.
        Returns:
        true if the user is email have been checked before. This always returns true if the user is the guest or superadmin user.
        Since:
        11.8RC1
      • setEmailChecked

        public void setEmailChecked​(boolean checked,
                                    XWikiContext context)
        Parameters:
        checked - true if the email address was checked for the user. False if it wasn't checked.
        context - used to retrieve the user document.
        Since:
        11.8RC1
      • isDisabled

        public boolean isDisabled​(XWikiContext context)
        Parameters:
        context - used to retrieve the user document.
        Returns:
        true if the user is disabled (i.e. its active property is set to 0). This always returns false if the user is the guest or superadmin user.
        Since:
        11.6RC1
      • setDisabled

        public void setDisabled​(boolean disable,
                                XWikiContext context)
        Parameters:
        disable - true if the user disabled the account. False to enable the account.
        context - used to retrieve the user document.
        Since:
        11.6RC1
      • exists

        public boolean exists​(XWikiContext context)
        Parameters:
        context - used to retrieve the user document.
        Returns:
        true if the user exists.
        Since:
        11.6RC1
      • setUser

        public void setUser​(String user)
      • isUserInGroup

        public boolean isUserInGroup​(String groupName,
                                     XWikiContext context)
                              throws XWikiException
        Check if the user belongs to a group or not. This method only check direct membership (no recursive checking) in the current wiki.
        Parameters:
        groupName - The group to check.
        context - The current context.
        Returns:
        true if the user does belong to the specified group, false otherwise or if an exception occurs.
        Throws:
        XWikiException - If an error occurs when checking the groups.
        Since:
        1.3
      • isMain

        public boolean isMain()
        See if the user is global (i.e. registered in the main wiki) or local to a virtual wiki.
        Returns:
        true if the user is global, false otherwise or if an exception occurs.
      • setMain

        public void setMain​(boolean main)