Class UserPermission
- Namespace
- Dynamicweb.Ecommerce.UserPermissions
- Assembly
- Dynamicweb.Ecommerce.dll
This class contains functions for manage user permissions
[Serializable]
public class UserPermission
- Inheritance
-
UserPermission
- Inherited Members
Constructors
UserPermission(string, string)
Initializes a new instance of the UserPermission class
public UserPermission(string userPermissionType, string userPermissionTypeID)
Parameters
userPermissionTypestring- The type of the user permission
userPermissionTypeIDstring- The id of the user permission
UserPermission(string, string, int)
Initializes a new instance of the UserPermission class
public UserPermission(string userPermissionType, string userPermissionTypeId, int userId)
Parameters
userPermissionTypestring- The type of the user permission
userPermissionTypeIdstring- The id of the user permission
userIdint- The id of the user
UserPermission(string, string, int, bool)
Initializes a new instance of the UserPermission class
public UserPermission(string userPermissionType, string userPermissionTypeId, int userId, bool forceReload)
Parameters
userPermissionTypestring- The type of the user permission
userPermissionTypeIdstring- The id of the user permission
userIdint- The id of the user
forceReloadboolTrueto force reload the data from the database
UserPermission(string, string, int, bool, bool)
Initializes a new instance of the UserPermission class
public UserPermission(string userPermissionType, string userPermissionTypeId, int userId, bool forceReload, bool isAdmin)
Parameters
userPermissionTypestring- The type of the user permission
userPermissionTypeIdstring- The id of the user permission
userIdint- The id of the user
forceReloadboolTrueto force reload the data from the databaseisAdminboolTrueif user is administrator
Fields
AdminUserId
Id for administrative user
public const int AdminUserId = 2
Field Value
AngelUserId
Id for Angel user
public const int AngelUserId = 1
Field Value
EveryoneUserId
Id for non-administrative user
public const int EveryoneUserId = -2
Field Value
Properties
DataPresence
Gets the data presence
public DataPresenceType DataPresence { get; }
Property Value
this[UserPermissionRights]
Gets or sets permission
public bool this[UserPermissionRights permission] { get; set; }
Parameters
permissionUserPermissionRights- A UserPermissionRights enumeration member
Property Value
SpecificPermissionsDefined
Return
True if specific permissions are defined on a given objectpublic bool SpecificPermissionsDefined { get; }
Property Value
UserId
Gets the user id
public int UserId { get; }
Property Value
UserPermissionType
Gets the type of user permission
public string UserPermissionType { get; }
Property Value
UserPermissionTypeGuid
Gets the GUID of the user permission type
public Guid UserPermissionTypeGuid { get; }
Property Value
UserPermissionTypeId
Gets the id of the user permission type
public string UserPermissionTypeId { get; }
Property Value
Value
Gets the value of the current permissions
public int Value { get; }
Property Value
Methods
DatabasePrepared()
Checks if the database is ready to work with permissions
public static bool DatabasePrepared()
Returns
- bool
Trueif the database is ready
DeleteGroupRights(string)
Deletes all permissions for the group
public static void DeleteGroupRights(string groupId)
Parameters
groupIdstring- The id of the group
DeleteRights(int)
Deletes all permissions defined for a specific user
public static void DeleteRights(int userId)
Parameters
userIdint- The id of the user
DeleteRights(string, string)
Deletes all permissions defined on a given object
public static void DeleteRights(string userPermissionType, string userPermissionTypeId)
Parameters
userPermissionTypestring- The type of the user permission
userPermissionTypeIdstring- The id of the user permission
get_Granted(UserPermissionRights)
Gets permission
[Obsolete("Use indexer instead")]
public bool get_Granted(UserPermissionRights permission)
Parameters
permissionUserPermissionRights- A UserPermissionRights enumeration member
Returns
get_TranslationOf(UserPermissionRights)
Gets the translation for the permission
[Obsolete("Use GetTranslationOf instead")]
public static string get_TranslationOf(UserPermissionRights permission)
Parameters
permissionUserPermissionRights- An instance of the UserPermissionRights
Returns
get_TranslationOf(UserPermissionRights, string)
Gets the translation for the permission
[Obsolete("Use GetTranslationOf instead")]
public static string get_TranslationOf(UserPermissionRights permission, string usageContext)
Parameters
permissionUserPermissionRights- An instance of the UserPermissionRights
usageContextstring- The usage context
Returns
GetDefinedRights(Guid)
Return all permissions defined for the requested object based on guid
public static List<DefinedRight> GetDefinedRights(Guid userPermissionTypeGuid)
Parameters
userPermissionTypeGuidGuid- The GUID of the user permission type
Returns
- List<DefinedRight>
- The list of the DefinedRight
GetDefinedRights(string, string)
Return all permissions defined for the requested object based on type and id
public static List<DefinedRight> GetDefinedRights(string userPermissionType, string userPermissionTypeId)
Parameters
userPermissionTypestring- The type of the user permission
userPermissionTypeIdstring- The id of the user permission
Returns
- List<DefinedRight>
- The list of the DefinedRight
GetRightsGuid(string, string)
Gets GUID for the permission
public static Guid GetRightsGuid(string userPermissionType, string userPermissionTypeId)
Parameters
userPermissionTypestring- The type of the user permission
userPermissionTypeIdstring- The id of the user permission
Returns
- Guid
- The Guid
GetTranslationOf(UserPermissionRights)
Gets the translation for the permission
public static string GetTranslationOf(UserPermissionRights permission)
Parameters
permissionUserPermissionRights- An instance of the UserPermissionRights
Returns
GetTranslationOf(UserPermissionRights, string)
Gets the translation for the permission
public static string GetTranslationOf(UserPermissionRights permission, string usageContext)
Parameters
permissionUserPermissionRights- An instance of the UserPermissionRights
usageContextstring- The usage context
Returns
GrantAll()
Provides all rights
public void GrantAll()
GrantNone()
Provides no rights
public void GrantNone()
ObjectType(PredefinedType)
Returns name of the predefined permission type
public static string ObjectType(PredefinedType predefinedType)
Parameters
predefinedTypePredefinedType- An instance of the PredefinedType
Returns
- string
- Name of the predefined permission type
Exceptions
RefreshXmlCache(Guid)
Refreshes the cache of the user permissions
public static void RefreshXmlCache(Guid userPermissionTypeGuid)
Parameters
userPermissionTypeGuidGuid- The GUID of the user permission type
RefreshXmlCache(string, string)
Refreshes the cache of the user permissions
public static void RefreshXmlCache(string userPermissionType, string userPermissionTypeId)
Parameters
userPermissionTypestring- The type of the user permission
userPermissionTypeIdstring- The id of the user permission
Save()
Save changes to the database
public void Save()
set_Granted(UserPermissionRights, bool)
Sets permission
[Obsolete("Use indexer instead")]
public void set_Granted(UserPermissionRights permission, bool value)
Parameters
permissionUserPermissionRights- A UserPermissionRights enumeration member
valuebool- The value
SetDefinedRights(Guid, List<DefinedRight>, bool)
Sets new permissions
public static bool SetDefinedRights(Guid userPermissionTypeGuid, List<DefinedRight> newRights, bool deleteExistingRights)
Parameters
userPermissionTypeGuidGuid- The GUID of the user permission type
newRightsList<DefinedRight>- The list of the new permissions
deleteExistingRightsboolTrueif need to delete existing permissions
Returns
SetDefinedRights(string, string, List<DefinedRight>, bool)
Setting defined permissions
public static bool SetDefinedRights(string userPermissionType, string userPermissionTypeId, List<DefinedRight> newRights, bool deleteExistingRights)
Parameters
userPermissionTypestring- The type of the user permission
userPermissionTypeIdstring- The id of the user permission
newRightsList<DefinedRight>- The list of the new permissions
deleteExistingRightsboolTrueif need to delete existing permissions
Returns
SetDefinedRightsOnChildren(string, string, List<DefinedRight>)
Setting defined permissions on children
[Obsolete("Use SetDefinedRightsOnChildren(userPermissionType, userPermissionTypeId, languageId, newRights) instead.")]
public static bool SetDefinedRightsOnChildren(string userPermissionType, string userPermissionTypeId, List<DefinedRight> newRights)
Parameters
userPermissionTypestring- The type of the user permission
userPermissionTypeIdstring- The id of the user permission
newRightsList<DefinedRight>- The list of the new permissions
Returns
SetDefinedRightsOnChildren(string, string, string, List<DefinedRight>)
Setting defined permissions on children
public static bool SetDefinedRightsOnChildren(string userPermissionType, string userPermissionTypeId, string languageId, List<DefinedRight> newRights)
Parameters
userPermissionTypestring- The type of the user permission
userPermissionTypeIdstring- The id of the user permission
languageIdstringnewRightsList<DefinedRight>- The list of the new permissions
Returns
UsePermissionTypeId(string)
Determines whether the user has access to the specified object
public static bool UsePermissionTypeId(string userPermissionType)
Parameters
userPermissionTypestring- The type of the user permission
Returns
- bool
Trueif user has access
WriteDenyMessage()
Shows "Access denied" message
[Obsolete("UI/request stuff is not allowed here.", true)]
public static void WriteDenyMessage()
WriteDenyMessage(string)
Shows "Access denied" message with the custom text
[Obsolete("UI/request stuff is not allowed here.", true)]
public static void WriteDenyMessage(string message)
Parameters
messagestring- The text of the message