GroupProvider
Summary
Defines a GroupProvider to get and save content groups.
Constructor
GroupProvider
Syntax
GroupProvider
-
database
Summary
Parameters:
-
database
DatabaseThe database to interact with
Item Index
Methods
add
Syntax
add
-
groups
-
[callback]
Summary
Adds content groups.
This will execute core hook "GROUPS_ADDED" after adding groups with:
- Array The list of added groups
Parameters:
-
groups
ArrayThe list of groups to store with for each group:
- String [id] The group id, generated if not specified
- String name The group name
- String description The group description
-
[callback]
Function optionalThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Number The total amount of groups inserted
- Array The list of added groups
createGroupPermissions
Syntax
Summary
Creates permissions for a group.
Returns:
The group permissions
createIndexes
Syntax
createIndexes
-
callback
Summary
Creates groups indexes.
Parameters:
-
callback
FunctionFunction to call when it's done with :
- Error An error if something went wrong, null otherwise
generateGroupPermissions
Syntax
generateGroupPermissions
-
callback
Summary
Generates permissions using groups.
Permission's translation keys for name and description are generated using the formats "GROUP_{OPERATION}NAME" and "{GROUP}{OPERATION}_DESCRIPTION".
Parameters:
-
callback
FunctionFunction to call when it's done with:
- Error An error if something went wrong, null otherwise
- Array The list of group permissions
Example:
// Example of generated groups
// [
// {
// label: 'My group name',
// permissions: [
// {
// id : 'get-group-groupID',
// name : 'CORE.PERMISSIONS.GROUP_GET_NAME',
// description : 'CORE.PERMISSIONS.GROUP_GET_DESCRIPTION'
// },
// {
// id : 'update-group-groupID',
// name : 'CORE.PERMISSIONS.GROUP_UPDATE_NAME',
// description : 'CORE.PERMISSIONS.GROUP_UPDATE_DESCRIPTION'
// },
// {
// id : 'delete-group-groupID',
// name : 'CORE.PERMISSIONS.GROUP_DELETE_NAME',
// description : 'CORE.PERMISSIONS.GROUP_DELETE_DESCRIPTION'
// }
// ]
// }
// ]
});
remove
Syntax
remove
-
[filter]
-
[callback]
Summary
Removes groups.
This will execute core hook "GROUPS_DELETED" after deleting groups with:
- Array ids The list of deleted group ids
Parameters:
-
[filter]
ResourceFilter optionalRules to filter groups to remove
-
[callback]
Function optionalThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Number The number of removed groups
updateOne
Syntax
updateOne
-
[filter]
-
data
-
[callback]
Summary
Updates a group.
This will execute core hook "GROUP_UPDATED" after updating group with:
- Object The hook data with:
- String id The id of updated group
- Object modifications The list of modifications applied