daledavies / moodle-tool_registrationrules

GNU General Public License v3.0
2 stars 1 forks source link

Instance config as json #54

Open daledavies opened 1 month ago

daledavies commented 1 month ago

To allow provisioning of sites with tool_registrationrules preconfigured, could we have a way to provide rule instances config as something like json? This could be provided in config.php via $CFG->forced_plugin_settings and would override UI config, stopping admins from using the rule instance management page.

Something like this would allow us to provision sites without needing to manually configure them.

phager-at commented 1 month ago

For this to be accomplished in the "Moodle way", we may consider converting our external Instances management page to a proper Moodle admin setting class? Then the Moodle magic could take over in case of configuration via config.php. Or is it feasable to considdr the case of configuration via config.php manually? I've never developed it for an external admin page.

daledavies commented 1 month ago

To move away from using an external admin page would we need to stop saving instances to our own DB table, then we'd need to think of a format (like json) for them to get saved using set_config() or something?

phager-at commented 1 month ago

Not necessarily, we'd have to define our own setting class and can overwrite the read and write methods... https://github.com/moodle/moodle/blob/main/lib/adminlib.php#L1960 I'm on my mobile right now, so looking for examples is a bit cumbersome, but werden be able to pull it of... Also we can decide on our own format for pre-defined settings, even enforce them via config.php.

phager-at commented 1 month ago

Or maybe the abstract read_setting() and write_setting() methods... need to take a Look at the big screen. https://github.com/moodle/moodle/blob/main/lib/adminlib.php#L2026

phager-at commented 1 month ago

admin_setting_sitesetselect uses a DB table to store its settings. https://github.com/moodle/moodle/blob/main/lib/adminlib.php#L2026

admin_setting_bloglevel and others too...

daledavies commented 12 hours ago

Just thinking a bit about this again. tool_log_setting_managestores implements the entire management table as a setting class, but this doesn't have any custom write_setting method.