role: Create a role

View source: R/databases.R

roleR Documentation

Create a role

Description

Returns a role that can be added to a database and assigned to users.

Usage

role(
  id,
  label,
  parameters = list(),
  grants,
  permissions = databasePermissions()
)

Arguments

id

the id of the role, must start with a lower case letter and may contain up to 32 lower case letters and numbers

label

the label or name of the role, e.g. "Viewer" or "Administrator"

parameters

a list of parameter items defining role parameters

grants

a list of grant items for each resource and their respective permissions

permissions

databasePermissions under this role

Details

A role contains one or more grant items that define access to resources (database, folder, forms).

Some administrative permissions are defined at the level of the role rather than within grants. See databasePermissions.

Examples

## Not run: 

# Create a Reporting Partner role that may view, and edit their own records 
in the form with id "cq9xyz1552" and optional access to view and add records
to a form with id "cz55555555". They are also allowed to discover these 
forms.

grantBasedRole <- 
  role(id = "rp",
      label = "Reporting Partner",
      parameters = list(
        parameter(id = "partner", label = "Partner", range = "ck5dxt1712")),
      grants = list(
        grant(resourceId = "cq9xyz1552",
          permissions = resourcePermissions(
            view = "ck5dxt1712 == @user.partner",
            edit_record = "ck5dxt1712 == @user.partner",
            discover = TRUE,
            export_records = TRUE)),
        grant(resourceId = "cz55555555",
          permissions = resourcePermissions(
            view = TRUE,
            discover = TRUE,
            add_record = TRUE),
          optional = TRUE))
      )
      

## End(Not run)

bedatadriven/activityinfo-R documentation built on Dec. 21, 2024, 8:23 a.m.