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
userPermissionType
string- The type of the user permission
userPermissionTypeID
string- 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
userPermissionType
string- The type of the user permission
userPermissionTypeId
string- The id of the user permission
userId
int- 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
userPermissionType
string- The type of the user permission
userPermissionTypeId
string- The id of the user permission
userId
int- The id of the user
forceReload
boolTrue
to 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
userPermissionType
string- The type of the user permission
userPermissionTypeId
string- The id of the user permission
userId
int- The id of the user
forceReload
boolTrue
to force reload the data from the databaseisAdmin
boolTrue
if 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
permission
UserPermissionRights- 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
True
if the database is ready
DeleteGroupRights(string)
Deletes all permissions for the group
public static void DeleteGroupRights(string groupId)
Parameters
groupId
string- The id of the group
DeleteRights(int)
Deletes all permissions defined for a specific user
public static void DeleteRights(int userId)
Parameters
userId
int- 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
userPermissionType
string- The type of the user permission
userPermissionTypeId
string- The id of the user permission
get_Granted(UserPermissionRights)
Gets permission
[Obsolete("Use indexer instead")]
public bool get_Granted(UserPermissionRights permission)
Parameters
permission
UserPermissionRights- 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
permission
UserPermissionRights- 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
permission
UserPermissionRights- An instance of the UserPermissionRights
usageContext
string- 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
userPermissionTypeGuid
Guid- 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
userPermissionType
string- The type of the user permission
userPermissionTypeId
string- 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
userPermissionType
string- The type of the user permission
userPermissionTypeId
string- 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
permission
UserPermissionRights- An instance of the UserPermissionRights
Returns
GetTranslationOf(UserPermissionRights, string)
Gets the translation for the permission
public static string GetTranslationOf(UserPermissionRights permission, string usageContext)
Parameters
permission
UserPermissionRights- An instance of the UserPermissionRights
usageContext
string- 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
predefinedType
PredefinedType- 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
userPermissionTypeGuid
Guid- 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
userPermissionType
string- The type of the user permission
userPermissionTypeId
string- 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
permission
UserPermissionRights- A UserPermissionRights enumeration member
value
bool- The value
SetDefinedRights(Guid, List<DefinedRight>, bool)
Sets new permissions
public static bool SetDefinedRights(Guid userPermissionTypeGuid, List<DefinedRight> newRights, bool deleteExistingRights)
Parameters
userPermissionTypeGuid
Guid- The GUID of the user permission type
newRights
List<DefinedRight>- The list of the new permissions
deleteExistingRights
boolTrue
if 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
userPermissionType
string- The type of the user permission
userPermissionTypeId
string- The id of the user permission
newRights
List<DefinedRight>- The list of the new permissions
deleteExistingRights
boolTrue
if 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
userPermissionType
string- The type of the user permission
userPermissionTypeId
string- The id of the user permission
newRights
List<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
userPermissionType
string- The type of the user permission
userPermissionTypeId
string- The id of the user permission
languageId
stringnewRights
List<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
userPermissionType
string- The type of the user permission
Returns
- bool
True
if 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
message
string- The text of the message