Custom roles: Extended general attributes
Problem to solve
Currently none new role / role types can be added with special rights/feature like permissons to edit, moderate discussion, notify all, appoint other roles or that is visible in the filter etc.
At the moment, the functionality of the roles is statically defined in the code. So no new roles can be added and no existing ones can be changed via the data model.
Intended users
Openki Admins
Further details
Proposal
Move the static functionality/permissions configuration into the model and configurate the current roles as before.
-
subscribe.allways
The role is allways shown and anybody can subscribe -
subscribe.ifNone
If there are no subscribing for this role, anybody can subscribe (subscription.js, Line: 132) -
notifications.onJoin
Get an notification if a user subscribe to the course (notification.join.js, Line: 43) -
enlist.overFilter
It is visible in the filter -
permissions.edit
On subscribing the user is automatic added to editors list (courses.js, Line: 168) -
permissions.moderateDiscussion
Delete others user posts (course-discussion-utils.js, Line: 10) -
permissions.notifyAll
Send a message to all members of a course (methods.js 'courseDiscussion.postComment', Line: 64) -
permissions.appoint
The listed roles are restricted and members of this role can take-on other people (subscription.js, Line: 138)
Proposed model and data
This model defines existing permissions and features via flags. I have added a hint in the brackets to places in the code that have to be modified.
/**
* @typedef {Object} RoleEntity
* @property {string} id id of role
* @property {string} icon ex: "fa fa-bullhorn"
* @property {boolean} preset When a course is created, the role is automatically added to the course
* @property {object} subscribe
* @property {boolean} subscribe.allways The role is allways shown and anybody can subscribe
* @property {boolean} [subscribe.ifNone] If there are no subscribing for this role, anybody can subscribe (subscription.js, Line: 132)
* @property {object} notifications
* @property {boolean} notifications.onJoin Get an notification if a user subscribe to the course (notification.join.js, Line: 43)
* @property {object} enlist
* @property {boolean} enlist.overFilter It is visible in the filter
* @property {object} permissions
* @property {boolean} permissions.edit On subscribing the user is automatic added to editors list (courses.js, Line: 168)
* @property {boolean} permissions.moderateDiscussion Delete others user posts (course-discussion-utils.js, Line: 10)
* @property {boolean} permissions.notifyAll Send a message to all members of a course (methods.js 'courseDiscussion.postComment', Line: 64)
* @property {string[]} permissions.appoint The listed roles are restricted and members of this role can take-on other people (subscription.js, Line: 138)
*/
/** @type {RoleEntity[]} */
const Roles = [
{
type: 'participant',
icon: 'fa fa-user',
preset: true,
subscribe: { allways: true },
notifications: { onJoin: false },
enlist: { overFilter: false }
},
{
type: 'mentor',
icon: 'fa fa-graduation-cap',
preset: false,
subscribe: { allways: true },
notifications: { onJoin: false },
enlist: { overFilter: true }
},
{
type: 'host',
icon: 'fa fa-home',
preset: false,
subscribe: { allways: true },
notifications: { onJoin: false },
enlist: { overFilter: true }
},
{
type: 'team',
icon: 'fa fa-bullhorn',
preset: true,
subscribe: { allways: false, ifNone: true },
notifications: { onJoin: true },
enlist: { overFilter: true },
rights: {
edit: true,
moderateDiscussion: true,
notifyAll: true,
appoint: ['team']
},
},
];
Current model and data
/**
* @typedef {Object} RoleEntity
* @property {string} type name/id of role, current: 'participant', 'mentor', 'host', 'team'
* @property {string} icon ex: 'fa fa-bullhorn'
* @property {boolean} [preset=false] When a course is created, the role is automatically added to the course
*/
/** @type {RoleEntity[]} */
const Roles = [
{
type: 'participant',
icon: 'fa fa-user',
preset: true,
},
{
type: 'mentor',
icon: 'fa fa-graduation-cap',
},
{
type: 'host',
icon: 'fa fa-home',
},
{
type: 'team',
icon: 'fa fa-bullhorn',
preset: true,
},
];
Permissions and Security
Links / references
Edited by Markus