Capabilities on new plugin - help to organize

Capabilities on new plugin - help to organize

by Lawrence Lagerlof -
Number of replies: 2

I need help identifying the best way to organize the necessary capabilities to use a plugin.

I created a plugin that allows user1 to register and enrol other users on Moodle on the same course as user1.  To use this plugin, user1 must have all of the following capabilities:

  • enrol/manual:enrol
  • moodle/role:assign
  • moodle/course:enrolreview
  • moodle/user:create

I want to know if this is the best approach. Maybe should I create a custom capability in db/access.php and test for it instead of all four capabilities above?

I appreciate any help you can give me.

Thank you.

Average of ratings: -
In reply to Lawrence Lagerlof

Re: Capabilities on new plugin - help to organize

by Dominique Palumbo -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi,

I think that testing the four capabilities it's the best. Specially if you want to share the plugin after.
At least it's the most flexible and the most secure.

They had other ways with less code and check (role in course or the right to use your plugin) but more vulnerability and/or problem later.

Have a nice day.

Dominique.
Average of ratings: Useful (1)
In reply to Dominique Palumbo

Re: Capabilities on new plugin - help to organize

by Luis Britland -
Outstanding!! Just what I was looking for. There is this myth/hyperbole that you should only have a handful of plugins or your site will grind to a crawl. Valid but exaggerated. This helps to organize which plugins are backend admin related, frontend related, performance related, etc.