Module admin link for configuring a module

Module admin link for configuring a module

by Mad Alex -
Number of replies: 5
Some modules may have configuration settings which are system wide. In this case there is currently no nice way to provide a user interface for chaning them.

It would be nice to have the option of a link on the module list page which would link to an admin page. This could be implemented by having the script that generates the module table call a function in the module's lib.php to get the address to be used (empty meaning do not include a link).

I am happy to work on this if the idea is liked.

One small question: Where would it be best to store configuration data?
I see that moodle stores its config in the 'prefix'_config table in the database. Is it intended that modules should use this or should they add their own config tables?
Seperate tables would be easier to clean up if the module is deleted.
Average of ratings: -
In reply to Mad Alex

Re: Module admin link for configuring a module

by Gustav W Delius -
If I understand correctly, then you are proposing to add an extra column to the table on the "Manage Modules" page (admin/modules.php). So in addition to the "Delete" column it would also have a "Settings" column. I like the idea. I think even the existing Moodle modules could profit from having a settings page where the administrator can set the default behaviour of the modules.

To decide whether a particular module should get a "Settings" link in that table, why not simply check whether the corresponding module directory has a file called "settings.php"? If it does, there will be a link pointing to this page, if it doesn't, there won't.
In reply to Gustav W Delius

Re: Module admin link for configuring a module

by Mad Alex -
Yes, that is a better way of doing things. I will add this to my TODO for this coming week.
In reply to Mad Alex

Re: Module admin link for configuring a module

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
settings.php could store the config data in the main configuration table, using names starting with modulename_ ... eg:

forum_manydiscussions or quiz_defaultgrade

All you need do is call set_config(), eg:

set_config("forum_manydiscussions", 100);

There's no need for a get_config() because you will find all these variables in the global $CFG
In reply to Mad Alex

Re: Module admin link for configuring a module

by Mad Alex -
Here is a modified admin/modules.php. As suggested it checks for the presence of a settings.php file in the module directory and adds a link to it if found.

The individual settings.php files are then free to do what they like.
In reply to Mad Alex

Re: Module admin link for configuring a module

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Thanks, Mad Alex. smile

I've checked this file into CVS, except I changed the name from settings.php to config.php (for consistency with the other ones).