Click or drag to resize

TOPICA Basic Class ProfileCollection

[This is preliminary documentation and is subject to change.]

The ProfileCollection class is a collection of Profile objects.

ProfileCollection properties

Property

Type

Description

ToString

String

Returns a string representation for debugging etc.

ToLines

String

Returns a string representation of the Profile objects in the collection, each line containing the string representation of one Profile object. The lines are separated by Newline.

Count

Integer

Number of objects in the collection.

ProfileCollection indexing

Index type

Description

Integer

Zero-based:

EmployeeUser.Profiles[0] returns the first Profile related to the Employee user.

String

Look-up by profile name.

May be used to test whether the logged in Employee user has a Profile with a given name.

Example

Description

EmployeeUser.Profiles["SystemAdministrator"]

Returns a Profile named "SystemAdministrator", if the logged in Employee user has a profile by that name - null if the user does not have this permission.

IsNotNull(EmployeeUser.Profiles["SystemAdministrator"])

Returns true iff the Employee user has the Profile named "SystemAdministrator".

Note Note

Profiles and their names are NOT hardcoded in TOPICA - number and name of profiles are fully configurable, and may thus vary from application to application - it might even vary over time inside the same application.

New databases are created with som default profiles (e.g. "SystemAdministrator", "Debugger", etc.), but there is NO guarantee, that these default profiles still exist in the database.

Permission names, on the other hand, ARE hardcoded. Therefore, whenever possible, it is better to check whether the user has a permission with a given name. See PermissionCollection. The above example SHOULD have been written: IsNotNull(EmployeeUser.Permissions["Everything"]). This would also work as, if the Everything permission was added to some other profiles beside "SystemAdministrator".

The ProfileCollection class should be reserved to those situations, where an application needs to define some "custom" access rights. Because permission names are hardcoded, it is impossible to create an application-specific permission. AS a workaround, create an application-specific profile (it does not need to have any permissions) - then the application may check for this custom profile in this way: IsNotNull(EmployeeUser.Permissions["CustomProfile"]).