using System; using System.Collections.Generic; using System.Linq; using Umbraco.Core.Models; using Umbraco.Core.Models.Membership; using Umbraco.Core.Persistence.DatabaseModelDefinitions; using Umbraco.Core.Persistence.Querying; namespace Umbraco.Core.Services { /// /// Defines the UserService, which is an easy access to operations involving and eventually Users. /// public interface IUserService : IMembershipUserService { /// /// Creates a database entry for starting a new login session for a user /// /// /// /// Guid CreateLoginSession(int userId, string requestingIpAddress); /// /// Validates that a user login session is valid/current and hasn't been closed /// /// /// /// bool ValidateLoginSession(int userId, Guid sessionId); /// /// Removes the session's validity /// /// void ClearLoginSession(Guid sessionId); /// /// Removes all valid sessions for the user /// /// int ClearLoginSessions(int userId); /// /// This is basically facets of UserStates key = state, value = count /// IDictionary GetUserStates(); /// /// Get paged users /// /// /// /// /// /// /// /// /// A filter to only include user that belong to these user groups /// /// /// A filter to only include users that do not belong to these user groups /// /// /// IEnumerable GetAll(long pageIndex, int pageSize, out long totalRecords, string orderBy, Direction orderDirection, UserState[] userState = null, string[] includeUserGroups = null, string[] excludeUserGroups = null, IQuery filter = null); /// /// Get paged users /// /// /// /// /// /// /// /// /// A filter to only include user that belong to these user groups /// /// /// IEnumerable GetAll(long pageIndex, int pageSize, out long totalRecords, string orderBy, Direction orderDirection, UserState[] userState = null, string[] userGroups = null, string filter = null); /// /// Deletes or disables a User /// /// to delete /// True to permanently delete the user, False to disable the user void Delete(IUser user, bool deletePermanently); /// /// Gets an IProfile by User Id. /// /// Id of the User to retrieve /// IProfile GetProfileById(int id); /// /// Gets a profile by username /// /// Username /// IProfile GetProfileByUserName(string username); /// /// Gets a user by Id /// /// Id of the user to retrieve /// IUser GetUserById(int id); /// /// Gets a users by Id /// /// Ids of the users to retrieve /// IEnumerable GetUsersById(params int[] ids); /// /// Removes a specific section from all user groups /// /// This is useful when an entire section is removed from config /// Alias of the section to remove void DeleteSectionFromAllUserGroups(string sectionAlias); /// /// Get explicitly assigned permissions for a user and optional node ids /// /// If no permissions are found for a particular entity then the user's default permissions will be applied /// User to retrieve permissions for /// Specifying nothing will return all user permissions for all nodes that have explicit permissions defined /// An enumerable list of /// /// This will return the default permissions for the user's groups for node ids that don't have explicitly defined permissions /// EntityPermissionCollection GetPermissions(IUser user, params int[] nodeIds); /// /// Get explicitly assigned permissions for groups and optional node Ids /// /// /// /// Flag indicating if we want to include the default group permissions for each result if there are not explicit permissions set /// /// Specifying nothing will return all permissions for all nodes /// An enumerable list of EntityPermissionCollection GetPermissions(IUserGroup[] groups, bool fallbackToDefaultPermissions, params int[] nodeIds); /// /// Gets the implicit/inherited permissions for the user for the given path /// /// User to check permissions for /// Path to check permissions for EntityPermissionSet GetPermissionsForPath(IUser user, string path); /// /// Gets the permissions for the provided groups and path /// /// /// Path to check permissions for /// /// Flag indicating if we want to include the default group permissions for each result if there are not explicit permissions set /// EntityPermissionSet GetPermissionsForPath(IUserGroup[] groups, string path, bool fallbackToDefaultPermissions = false); /// /// Replaces the same permission set for a single group to any number of entities /// /// Id of the group /// /// Permissions as enumerable list of , /// if no permissions are specified then all permissions for this node are removed for this group /// /// Specify the nodes to replace permissions for. If nothing is specified all permissions are removed. /// If no 'entityIds' are specified all permissions will be removed for the specified group. void ReplaceUserGroupPermissions(int groupId, IEnumerable permissions, params int[] entityIds); /// /// Assigns the same permission set for a single user group to any number of entities /// /// Id of the group /// /// Specify the nodes to replace permissions for void AssignUserGroupPermission(int groupId, char permission, params int[] entityIds); /// /// Gets a list of objects associated with a given group /// /// Id of group /// IEnumerable GetAllInGroup(int groupId); /// /// Gets a list of objects not associated with a given group /// /// Id of group /// IEnumerable GetAllNotInGroup(int groupId); #region User groups /// /// Gets all UserGroups or those specified as parameters /// /// Optional Ids of UserGroups to retrieve /// An enumerable list of IEnumerable GetAllUserGroups(params int[] ids); /// /// Gets a UserGroup by its Alias /// /// Alias of the UserGroup to retrieve /// IEnumerable GetUserGroupsByAlias(params string[] alias); /// /// Gets a UserGroup by its Alias /// /// Name of the UserGroup to retrieve /// IUserGroup GetUserGroupByAlias(string name); /// /// Gets a UserGroup by its Id /// /// Id of the UserGroup to retrieve /// IUserGroup GetUserGroupById(int id); /// /// Saves a UserGroup /// /// UserGroup to save /// /// If null than no changes are made to the users who are assigned to this group, however if a value is passed in /// than all users will be removed from this group and only these users will be added /// /// Optional parameter to raise events. /// Default is True otherwise set to False to not raise events void Save(IUserGroup userGroup, int[] userIds = null, bool raiseEvents = true); /// /// Deletes a UserGroup /// /// UserGroup to delete void DeleteUserGroup(IUserGroup userGroup); #endregion } }